util

package
v0.0.0-...-8ec759b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2024 License: BSD-3-Clause Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EO_BODYTAG = EventOrigin('E')
	EO_FILES   = EventOrigin('F')
	EO_KBD     = EventOrigin('K')
	EO_MOUSE   = EventOrigin('M')
)
View Source
const (
	ET_BODYDEL  = EventType('D')
	ET_TAGDEL   = EventType('d')
	ET_BODYINS  = EventType('I')
	ET_TAGINS   = EventType('i')
	ET_BODYLOAD = EventType('L')
	ET_TAGLOAD  = EventType('l')
	ET_BODYEXEC = EventType('X')
	ET_TAGEXEC  = EventType('x')
)
View Source
const (
	EFX_BUILTIN  = EventFlag(1)
	EFX_EXPANDED = EventFlag(2)
	EFX_EXTRAARG = EventFlag(8)

	EFL_EXPANDED = EventFlag(2)
)
View Source
const MAX_EVENT_TEXT_LENGTH = 256

original p9 value is 256

View Source
const SHORT_NAME_LEN = 40

Variables

This section is empty.

Functions

func Allergic

func Allergic(debug bool, err error)

func Allergic3

func Allergic3(debug bool, err error, silent bool)

func Dedup

func Dedup(v []string) []string

func FloatToFixed

func FloatToFixed(x float64) fixed.Int26_6

func Fmtevent2

func Fmtevent2(eventChan chan string, origin EventOrigin, istag, isbltin, hasextra bool, p, s, e int, arg string, onfail func())

Writes an execute event to eventChan. s and e are the boundaries of the selection, p is the point of the click that was expanded (-1 if the user made the selection directly)

func Fmtevent2extra

func Fmtevent2extra(eventChan chan string, origin EventOrigin, istag bool, s, e int, originPath, arg string, onfail func())

Writes messages to describe the extra argument for an execute message (ie you should call Fmtevent2 first with hasextra == true

func Fmtevent3

func Fmtevent3(eventChan chan string, origin EventOrigin, istag bool, p, s, e int, arg string, onfail func())

func FmteventBase

func FmteventBase(eventChan chan string, origin EventOrigin, istag bool, etype EventType, s, e int, arg string, onfail func())

func KeyEvent

func KeyEvent(e key.Event) string

control, alt, shift, super

func MeasureString

func MeasureString(face font.Face, in string) int

Mesures the length of the string

func MixColorHack

func MixColorHack(rs []rune, cs []uint8) []byte

func Must

func Must(err error, msg string)

func MustNewFont

func MustNewFont(dpi, size, lineSpacing float64, fullHinting, autoligatures bool, fontPath string) font.Face

func MustNewFontFromBytes

func MustNewFontFromBytes(dpi, size, lineSpacing float64, fullHinting, autoligatures bool, fontBytes [][]byte) font.Face

func NewFont

func NewFont(dpi, size, lineSpacing float64, fullHinting, autoligatures bool, fontPath string) (font.Face, error)

Reads a Font: fontPath is a ':' separated list of ttf or pcf font files (they will be used to search characters)

func NewFontFromBytes

func NewFontFromBytes(dpi, size, lineSpacing float64, fullHinting, autoligatures bool, fontBytes [][]byte) (font.Face, error)

func P9Copy

func P9Copy(dst *clnt.File, src io.Reader) (written int64, err error)

func QuotedSplit

func QuotedSplit(s string) []string

func ReadProps

func ReadProps(p9clnt *clnt.Clnt) (map[string]string, error)

func ResolvePath

func ResolvePath(rel2dir, path string) string

func SetTag

func SetTag(p9clnt *clnt.Clnt, outbufid string, tagstr string) error

func ShortPath

func ShortPath(ap string, canRelative bool) string

func SingleQuote

func SingleQuote(s string) string

func UnmixColorHack

func UnmixColorHack(data []byte) (text []rune, color []uint8)

func YaccoConnect

func YaccoConnect() (*clnt.Clnt, error)

Types

type AltingEntry

type AltingEntry struct {
	Seq   string
	Glyph rune
}

type BufferConn

type BufferConn struct {
	Id      string
	CtlFd   *clnt.File
	EventFd *clnt.File
	BodyFd  *clnt.File
	AddrFd  *clnt.File
	XDataFd *clnt.File
	PropFd  *clnt.File
	TagFd   *clnt.File
	ColorFd *clnt.File
	// contains filtered or unexported fields
}

func FindWin

func FindWin(name string, p9clnt *clnt.Clnt) (*BufferConn, bool, error)

func FindWinEx

func FindWinEx(name string, p9clnt *clnt.Clnt) (*BufferConn, bool, error)

func MakeBufferConn

func MakeBufferConn(p9clnt *clnt.Clnt, id string, ctlfd, eventfd *clnt.File) (*BufferConn, error)

func OpenBufferConn

func OpenBufferConn(p9clnt *clnt.Clnt, id string) (*BufferConn, error)

func (*BufferConn) Close

func (buf *BufferConn) Close()

func (*BufferConn) GetTag

func (buf *BufferConn) GetTag() (string, error)

func (*BufferConn) ReadAddr

func (buf *BufferConn) ReadAddr() ([]int, error)

func (*BufferConn) ReadXData

func (buf *BufferConn) ReadXData() ([]byte, error)

func (*BufferConn) SetTag

func (buf *BufferConn) SetTag(newtag string) error

type EventFlag

type EventFlag int

type EventOrRunnable

type EventOrRunnable struct {
	// contains filtered or unexported fields
}

func NewEvent

func NewEvent(e interface{}) EventOrRunnable

func NewRunnable

func NewRunnable(r func()) EventOrRunnable

func (*EventOrRunnable) EventOrRun

func (e *EventOrRunnable) EventOrRun() interface{}

type EventOrigin

type EventOrigin rune

type EventReader

type EventReader struct {
	// contains filtered or unexported fields
}

func (*EventReader) BuiltIn

func (er *EventReader) BuiltIn() bool

If the event is an execute event and the command is a builtin command then true is returned otherwise false is returned

func (*EventReader) Done

func (er *EventReader) Done() bool

The event is complete

func (*EventReader) ExtraArg

func (er *EventReader) ExtraArg() (path string, s, e int, txt string)

Returns the extra argument as: path of the buffer containing it, start and end points of the selection and text

func (*EventReader) Flags

func (er *EventReader) Flags() EventFlag

func (*EventReader) Insert

func (er *EventReader) Insert(msg string)

Adds an event message to the event reader

func (*EventReader) IsCompat

func (er *EventReader) IsCompat() bool

func (*EventReader) MissingExtraArg

func (er *EventReader) MissingExtraArg() bool

The extra argument (to an execute command) was too big to be included in the message

func (*EventReader) Origin

func (er *EventReader) Origin() EventOrigin

Origin of the read event

func (*EventReader) Points

func (er *EventReader) Points() (p, s, e int)

Pre-expanded point (if applicable), start point and end point of the event

func (*EventReader) ReadFrom

func (er *EventReader) ReadFrom(in io.Reader) error

func (*EventReader) Reset

func (er *EventReader) Reset()

Reset event reader

func (*EventReader) SendBack

func (er *EventReader) SendBack(fh io.Writer) error

Writes the event back to a file

func (*EventReader) SetExtraArg

func (er *EventReader) SetExtraArg(s string)

func (*EventReader) SetText

func (er *EventReader) SetText(s string)

func (*EventReader) ShouldFetchText

func (er *EventReader) ShouldFetchText() bool

The text was too big to be included in the message, we will need to fetch it using addr and data files

func (*EventReader) String

func (er *EventReader) String() string

func (*EventReader) Text

func (er *EventReader) Text(addrRead io.ReadSeeker, addrWrite io.Writer, xdata io.ReadSeeker) (txt string, err error)

Returns the text of the event, if the text was to long to be included in the message attempts to retrieve it using addr and data. If addr and data are nil an empty string is returned

func (*EventReader) Type

func (er *EventReader) Type() EventType

Type of the read event

func (*EventReader) Valid

func (er *EventReader) Valid() (bool, string)

Returns true if the event is valid. If the event is invalid false is returned along with a description of why parsing failed

type EventType

type EventType rune

type IndexEntry

type IndexEntry struct {
	Idx      int
	TagSize  int
	BodySize int
	IsDir    bool
	IsMod    bool
	Path     string
}

func ReadIndex

func ReadIndex(p9clnt *clnt.Clnt) ([]IndexEntry, error)

type LoadRule

type LoadRule struct {
	BufRe  string // only apply to buffers matching this regular expression
	Re     string // apply when this regular expression is matched
	Action string // action to execute
}

LoadRule describes a rule executed when right clicking on text.

Concerning Action: - If the first character is 'X' the rest of the string will be interpreted as a command (possibly external) and executed - if the first character is 'L' the rest of the string *up to the first semicolon* will be interpreted as a file name to open, the text after the semicolon will be interpreted as an address expression (like those understood by Edit) and used to calculate the initial position of the cursor

In either case expressions like $1, $2 etc... inside Action string will be replaced with the corrisponding matching group of Re.

An 'L' type action will only succeed if the specified file exists, is a UTF8 file and is less than 10MB. If any of this conditions isn't met the rule will be considered failed and other rules will be evaluated.

type MouseDownEvent

type MouseDownEvent struct {
	Where     image.Point
	Which     mouse.Button
	Modifiers key.Modifiers
	Count     int
}

type Multiface

type Multiface struct {
	Otatm *otat.Machine
	// contains filtered or unexported fields
}

func (*Multiface) Close

func (f *Multiface) Close() error

func (*Multiface) Glyph

func (f *Multiface) Glyph(dot fixed.Point26_6, r rune) (dr image.Rectangle, mask image.Image, maskp image.Point, advance fixed.Int26_6, ok bool)

func (*Multiface) GlyphAdvance

func (f *Multiface) GlyphAdvance(r rune) (advance fixed.Int26_6, ok bool)

func (*Multiface) GlyphBounds

func (f *Multiface) GlyphBounds(r rune) (bounds fixed.Rectangle26_6, advance fixed.Int26_6, ok bool)

func (*Multiface) Kern

func (f *Multiface) Kern(r0, r1 rune) fixed.Int26_6

func (*Multiface) Metrics

func (f *Multiface) Metrics() font.Metrics

type SaveRule

type SaveRule struct {
	Ext string
	Cmd string
}

type Sel

type Sel struct {
	S, E int
}

type WheelEvent

type WheelEvent struct {
	Where image.Point
	Count int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL