acmetools

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Namespace

func Namespace() (string, error)

Namespace duplicates plan9port's getns behavior, returning the local namespace directory where plan9 services may be posted.

func Plumb

func Plumb(src, dest, wdir, data string) error

Plumb sends a plumbing message to the plumber, according to plumb(7). src: application/service generating message dst: destination `port' for message wdir: working directory (used if data is a file name) data: the data itself See: plumb(7) for details.

func PlumbCmd

func PlumbCmd(dir string, s string) error

PlumbCmd invokes the plumb command on s in the directory dir.

Types

type Acme

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

Acme represents a connection to an Acme/Edwood instance.

func NewAcme

func NewAcme() (*Acme, error)

NewAcme creates a connection to a running Acme/Edwood instance by looking for the service `acme` in the current namespace (See: Namespace()).

func (*Acme) GetWindow

func (a *Acme) GetWindow(id string) (*Window, error)

GetWindow returns a handle to an existing window by its numeric ID

func (*Acme) Log

func (a *Acme) Log(f string, args ...interface{}) error

Log accepts a format string and arguments, which will be formatted according to the fmt package. This will be written to a window labeled `+Errors`.

func (*Acme) NewWindow

func (a *Acme) NewWindow() (*Window, error)

NewWindow will open a new Window.

type EType

type EType int

EType is the type of an event.

const (
	ET_BodyDelete EType = iota
	ET_TagDelete
	ET_BodyInsert
	ET_TagInsert
	ET_BodyBtn3
	ET_TagBtn3
	ET_BodyBtn2
	ET_TagBtn2
)

func (EType) Char

func (t EType) Char() rune

Char returns the character associated with the event type. This character is specified by acme(4) under the event file description.

func (EType) String

func (t EType) String() string

String returns a human-readable string representing the EType. This is different from the character that represents the event type. For the acme(4) character that identifies the event type, see Char().

type Event

type Event struct {
	Origin    Origin
	Type      EType
	StartAddr int
	EndAddr   int
	Flag      int
	NChars    int
	S         string
}

Event is something that happens in a window. This includes insertions, deletions, keypresses, clicks, etc.

func (*Event) Chorded

func (e *Event) Chorded() bool

Chorded reports whether the event represents a chorded command. If so, 2 more events should follow reporting the argument: The first will contain only the character count, and the second will contain where it originated, in the form of a fully-qualified button 3 style address.

func (*Event) HasExpansion

func (e *Event) HasExpansion() bool

HasExpansion reports whether this event has an expansion, meaning there will be another message following that contains the expanded text.

For example, a single button-2 click on Look will send an event with S=="" and HasExpansion() == true followed by another event with S == "Look" and HasExpansion() == false.

func (*Event) IsBuiltin

func (e *Event) IsBuiltin() bool

IsBuiltin reports whether an event has a built-in implementation of the command. This can be used to determine if WriteBack() can be used to execute the event. This includes built-in commands like Del, Put, Get, etc. This is only true if acme can execute the event without loading a new file.

func (*Event) String

func (e *Event) String() string

String prints a human-readable representation of the event.

type EventStream

type EventStream struct {
	C chan *Event
	// contains filtered or unexported fields
}

EventStream represents a stream of events from a Window. These events are read from the window's `event` file. Events should be read from the chan C.

func (*EventStream) Close

func (e *EventStream) Close() error

Close closes the event stream, returning control of the window to Acme.

func (*EventStream) WriteBack

func (e *EventStream) WriteBack(ev *Event) error

This causes the event to be written back to the event file, according to acme(4).

For events where IsBuiltin() == true, writing the message back will cause the action to be applied to the file exactly as it would have been if the event file had not been open.

type Origin

type Origin int

Origin is used to identify the source of an Event.

const (
	// The event was caused by a write to the body or tag file.
	EV_Write Origin = iota
	// The event was caused by a write to one of the window's files other than body or tag.
	EV_File
	// The event was caused by the keyboard.
	EV_Keyboard
	// The event was caused by the mouse.
	EV_Mouse
)

func (Origin) Char

func (o Origin) Char() rune

Char returns the character associated with the event origin. This character is specified by acme(4) under the event file description.

func (Origin) String

func (o Origin) String() string

String returns a human-readable string representing the Origin. This is different from the character that represents the event origin. For the acme(4) character that identifies the origin, see Char().

type WinParams

type WinParams struct {
	ID        int  // The Window's ID
	TagChars  int  // The number of characters in the tag
	BodyChars int  // The number of characters in the body
	Dir       bool // True if the window is a directory
	Modified  bool // True if the window has been modified
}

WinParams represents the 5 parameters read from the Window's ctl file.

type Window

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

Window represents an Acme window

func (*Window) Addr

func (w *Window) Addr() (q0 int, q1 int, err error)

Addr reads the window's addr file and returns the value of the address that would next be read or written through the data file in the format of 2 character (not byte) offsets. (See: acme(4))

func (*Window) AppendTag

func (w *Window) AppendTag(s string) error

AppendTag adds a string to the end of the window's tag

func (*Window) Body

func (w *Window) Body() (io.ReadWriter, error)

Body returns the window's body file.

func (*Window) Close

func (w *Window) Close() error

Close will close the Window.

func (*Window) Ctl

func (w *Window) Ctl(msg string) error

Ctl writes a message to the Window's ctl file. Ctl will add a newline to the message. This can be used to control much of the window's state. See acme(4) for what messages can be written.

func (*Window) Events

func (w *Window) Events() (*EventStream, error)

Events returns an EventStream which can be used by applications to handle window events. Please see EventStream and acme(4) for more details.

func (*Window) LineNumber

func (w *Window) LineNumber() (l0 int, l1 int, err error)

LineNumber returns the start and end line numbers of the user's currently selected text.

func (*Window) ReadCtl

func (w *Window) ReadCtl() (WinParams, error)

ReadCtl reads the window's ctl file and returns the WinParams associated with the Window.

func (*Window) Selected

func (w *Window) Selected() (string, error)

Selected returns the currently selected text.

func (*Window) Tag

func (w *Window) Tag() (string, error)

Tag returns the window's tag.

func (*Window) WriteAddr

func (w *Window) WriteAddr(a string) error

WriteAddr will write an address to the Window's addr file. This can be any format understood by button 3 (but without the initial colon). This affects what data will be read from the Data() and XData() files.

func (*Window) XData

func (w *Window) XData() (io.ReadWriteCloser, error)

XData returns a new handle to the window's xdata file, which will return data according to the address set by WriteAddr.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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