go: 9fans.net/go/acme Index | Files | Directories

package acme

import "9fans.net/go/acme"

Package acme is a simple interface for interacting with acme windows.

Many of the functions in this package take a format string and optional parameters. In the documentation, the notation format, ... denotes the result of formatting the string and arguments using fmt.Sprintf.

Index

Package Files

acme.go

func AutoExit Uses

func AutoExit(exit bool)

AutoExit sets whether to call os.Exit the next time the last managed acme window is deleted. If there are no acme windows at the time of the call, the exit does not happen until one is created and then deleted.

func DeleteAll Uses

func DeleteAll()

DeleteAll deletes all windows.

func Err Uses

func Err(src, msg string)

Err finds or creates a window appropriate for showing errors related to a window titled src and then prints msg to that window. It adds a final newline to msg if needed.

func Errf Uses

func Errf(src, format string, args ...interface{})

Errf is like Err but accepts a printf-style formatting.

type Event Uses

type Event struct {
    // The two event characters, indicating origin and type of action
    C1, C2 rune

    // The character addresses of the action.
    // If the original event had an empty selection (OrigQ0=OrigQ1)
    // and was accompanied by an expansion (the 2 bit is set in Flag),
    // then Q0 and Q1 will indicate the expansion rather than the
    // original event.
    Q0, Q1 int

    // The Q0 and Q1 of the original event, even if it was expanded.
    // If there was no expansion, OrigQ0=Q0 and OrigQ1=Q1.
    OrigQ0, OrigQ1 int

    // The flag bits.
    Flag int

    // The number of bytes in the optional text.
    Nb  int

    // The number of characters (UTF-8 sequences) in the optional text.
    Nr  int

    // The optional text itself, encoded in UTF-8.
    Text []byte

    // The chorded argument, if present (the 8 bit is set in the flag).
    Arg []byte

    // The chorded location, if present (the 8 bit is set in the flag).
    Loc []byte
}

An Event represents an event originating in a particular window. The fields correspond to the fields in acme's event messages. See http://swtch.com/plan9port/man/man4/acme.html for details.

type EventHandler Uses

type EventHandler interface {
    Execute(cmd string) bool
    Look(arg string) bool
}

type LogEvent Uses

type LogEvent struct {
    ID   int
    Op   string
    Name string
}

A LogEvent is a single event in the acme log file.

type LogReader Uses

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

A LogReader provides read access to the acme log file.

func Log Uses

func Log() (*LogReader, error)

Log returns a reader reading the acme/log file.

func (*LogReader) Close Uses

func (r *LogReader) Close() error

func (*LogReader) Read Uses

func (r *LogReader) Read() (LogEvent, error)

Read reads an event from the acme log file.

type Win Uses

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

A Win represents a single acme window and its control files.

func New Uses

func New() (*Win, error)

New creates a new window.

func Open Uses

func Open(id int, ctl *client.Fid) (*Win, error)

Open connects to the existing window with the given id. If ctl is non-nil, Open uses it as the window's control file and takes ownership of it.

func Show Uses

func Show(name string) *Win

Show looks and causes acme to show the window with the given name, returning that window. If this process has not created a window with the given name (or if any such window has since been deleted), Show returns nil.

func (*Win) Addr Uses

func (w *Win) Addr(format string, args ...interface{}) error

Addr writes format, ... to the window's addr file.

func (w *Win) Blink() (stop func())

Blink starts the window tag blinking and returns a function that stops it. When stop returns, the blinking is over and the window state is clean.

func (*Win) Clear Uses

func (w *Win) Clear()

Clear clears the window body.

func (*Win) CloseFiles Uses

func (w *Win) CloseFiles()

CloseFiles closes all the open files associated with the window w. (These file descriptors are cached across calls to Ctl, etc.)

func (*Win) Ctl Uses

func (w *Win) Ctl(format string, args ...interface{}) error

Ctl writes the command format, ... to the window's ctl file.

func (*Win) Del Uses

func (w *Win) Del(sure bool) error

Winctl deletes the window, writing `del' (or, if sure is true, `delete') to the ctl file.

func (*Win) Err Uses

func (w *Win) Err(msg string)

Err finds or creates a window appropriate for showing errors related to w and then prints msg to that window. It adds a final newline to msg if needed.

func (*Win) Errf Uses

func (w *Win) Errf(format string, args ...interface{})

func (*Win) EventChan Uses

func (w *Win) EventChan() <-chan *Event

EventChan returns a channel on which events can be read. The first call to EventChan allocates a channel and starts a new goroutine that loops calling ReadEvent and sending the result into the channel. Subsequent calls return the same channel. Clients should not call ReadEvent after calling EventChan.

func (*Win) EventLoop Uses

func (w *Win) EventLoop(h EventHandler)

func (*Win) Font Uses

func (w *Win) Font() (tab int, font *draw.Font, err error)

Font returns the window's current tab width (in zeros) and font.

func (*Win) Fprintf Uses

func (w *Win) Fprintf(file, format string, args ...interface{}) error

func (*Win) ID Uses

func (w *Win) ID() int

func (*Win) Name Uses

func (w *Win) Name(format string, args ...interface{}) error

func (*Win) OpenEvent Uses

func (w *Win) OpenEvent() error

func (*Win) PrintTabbed Uses

func (w *Win) PrintTabbed(text string)

PrintTabbed prints tab-separated columnated text to body, replacing single tabs with runs of tabs as needed to align columns.

func (*Win) Read Uses

func (w *Win) Read(file string, b []byte) (n int, err error)

func (*Win) ReadAddr Uses

func (w *Win) ReadAddr() (q0, q1 int, err error)

func (*Win) ReadAll Uses

func (w *Win) ReadAll(file string) ([]byte, error)

ReadAll

func (*Win) ReadEvent Uses

func (w *Win) ReadEvent() (e *Event, err error)

ReadEvent reads the next event from the window's event file.

func (*Win) Seek Uses

func (w *Win) Seek(file string, offset int64, whence int) (int64, error)

func (*Win) Selection Uses

func (w *Win) Selection() string

func (*Win) SetErrorPrefix Uses

func (w *Win) SetErrorPrefix(p string)

func (*Win) Sort Uses

func (w *Win) Sort(less func(x, y string) bool) error

Sort sorts the lines in the current address range according to the comparison function.

func (*Win) Write Uses

func (w *Win) Write(file string, b []byte) (n int, err error)

func (*Win) WriteEvent Uses

func (w *Win) WriteEvent(e *Event) error

WriteEvent writes an event back to the window's event file, indicating to acme that the event should be handled internally.

type WinInfo Uses

type WinInfo struct {
    ID   int
    Name string
}

func Windows Uses

func Windows() ([]WinInfo, error)

Windows returns a list of the existing acme windows.

Directories

PathSynopsis
acmegoAcmego watches acme for .go files being written.
Dict
editinacmeEditinacme can be used as $EDITOR in a Unix environment.
WatchWatch runs a command each time files in the current directory change.

Package acme imports 17 packages (graph) and is imported by 60 packages. Updated 2019-06-27. Refresh now. Tools for package owners.