Documentation ¶
Index ¶
- Variables
- func Extension(in string, def string) string
- func Filename(in string) string
- func FillFiletypes(dst map[string]Filetype, src []Filetype) error
- func FocusedWinAddr() string
- func FocusedWinID(addr string) (int, error)
- func FontSize(font *draw.Font) (int, error)
- func IsHiDPI(font *draw.Font) bool
- func Namespace() string
- func Nums(s string) (nums []int, err error)
- func Tab(width int, expand bool) []byte
- func Windows() (map[int]*Win, error)
- type Acme
- type Action
- type Buf
- type Command
- type Condition
- type Event
- type Filetype
- type Flag
- type Formatter
- type Handler
- type Hook
- type Origin
- type TabwidthFunc
- type Text
- type Win
- func (w *Win) Addr() (q0, q1 int, err error)
- func (w *Win) AddrFromSelection() error
- func (w *Win) AppendBody(data []byte) error
- func (w *Win) AppendTag(text string) error
- func (w *Win) Body() ([]byte, error)
- func (w *Win) Char(q0 int) (c byte, err error)
- func (w *Win) Clean() error
- func (w *Win) ClearBody() error
- func (w *Win) ClearTag() error
- func (w *Win) Close()
- func (w *Win) CurrentAddr() (q0, q1 int, err error)
- func (w *Win) Data(q0, q1 int) ([]byte, error)
- func (w *Win) Del() error
- func (w *Win) Dirty() error
- func (w *Win) DisableNoMark() error
- func (w *Win) Dump(file string) error
- func (w *Win) Dumpdir(dir string) error
- func (w *Win) EventChan(id int, filename string, stop <-chan struct{}) (<-chan Event, <-chan error)
- func (w *Win) Exec(exec string, args ...string) error
- func (w *Win) Font() (tab int, font *draw.Font, err error)
- func (w *Win) Get() error
- func (w *Win) LimitSearchToAddr() error
- func (w *Win) Name(format string, args ...interface{}) error
- func (w *Win) NoMark() error
- func (w *Win) Put() error
- func (w *Win) SelectionFromAddr() error
- func (w *Win) SetAddr(fmtstr string, args ...interface{}) error
- func (w *Win) SetData(data []byte) error
- func (w *Win) SetFont(font string) error
- func (w *Win) Show() error
- func (w *Win) Tag() ([]byte, error)
- func (w *Win) WriteEvent(e Event) error
- type WinFunc
- type WinHandler
Constants ¶
This section is empty.
Variables ¶
var AcmeDeps = []string{
"plumber",
"fontsrv",
}
AcmeDeps are programs that will be executed before acme can launch
var AcmeHelpers = []string{
"acme-lsp",
"acmefocused",
"skhd",
}
AcmeHelpers are programs that will be executed in an acme subprocess by nstart
var Config = func() map[string]Filetype { c := make(map[string]Filetype) err := FillFiletypes(c, Filetypes) if err != nil { panic(err) } return c }()
Config maps file extensions to their formatting specification
var Filetypes = []Filetype{ { Name: "cpp", Extensions: []string{".cc", ".cpp", ".hpp", ".cxx", ".hxx"}, Tabwidth: 2, Tabexpand: true, Comment: "// ", Commands: []Command{}, }, { Name: "java", Extensions: []string{".java"}, Tabwidth: 2, Tabexpand: true, Comment: "// ", Commands: []Command{}, }, { Name: "javascript", Extensions: []string{".js", ".ts"}, Tabwidth: 2, Tabexpand: true, Comment: "// ", Commands: []Command{ { Exec: "prettier", Args: []string{ "$NAME", "--write", "--loglevel", "error", }, PrintsToStdout: false, }, }, }, { Name: "json", Extensions: []string{".json"}, Tabwidth: 2, Tabexpand: true, Comment: "", Commands: []Command{}, }, { Name: "makefile", Extensions: []string{"Makefile"}, Tabwidth: 8, Tabexpand: false, Comment: "# ", Commands: []Command{}, }, { Name: "text", Extensions: []string{".txt"}, Tabwidth: 8, Tabexpand: false, Comment: "# ", Commands: []Command{}, }, { Name: "shell", Extensions: []string{".rc", ".sh"}, Tabwidth: 8, Tabexpand: false, Comment: "# ", Commands: []Command{}, }, { Name: "c", Extensions: []string{".c", ".h"}, Tabwidth: 8, Tabexpand: false, Comment: "/* */", Commands: []Command{}, }, { Name: "html", Extensions: []string{".html"}, Tabwidth: 2, Tabexpand: true, Comment: "<!-- -->", Commands: []Command{}, }, { Name: "markdown", Extensions: []string{".md"}, Tabwidth: 2, Tabexpand: true, Comment: "", Commands: []Command{}, }, { Name: "terraform", Extensions: []string{".tf"}, Tabwidth: 2, Tabexpand: true, Comment: "# ", Commands: []Command{ { Exec: "terraform", Args: []string{ "fmt", "$NAME", }, PrintsToStdout: false, }, }, }, { Name: "toml", Extensions: []string{".toml"}, Tabwidth: 8, Tabexpand: false, Comment: "# ", Commands: []Command{}, }, { Name: "yaml", Extensions: []string{".yml", ".yaml"}, Tabwidth: 2, Tabexpand: true, Comment: "# ", Commands: []Command{}, }, { Name: "go", Extensions: []string{".go", "go.mod", "go.sum"}, Tabwidth: 8, Tabexpand: false, Comment: "// ", Commands: []Command{}, }, }
Filetypes define file formatting rules that will be applied
var Menu = []string{
" Put ", "Undo ", "Redo ", "win", "\n",
"|com ", "|a- ", "|a+ ", "Ldef ", "Lrefs ", "Lcomp",
}
Menu contains the menu options that should be written to the tag
Functions ¶
func FillFiletypes ¶
FillFiletypes updates the filetypes in the given map
func FocusedWinAddr ¶
func FocusedWinAddr() string
FocusedWinAddr returns the address of the active window using acmefocused
func FocusedWinID ¶
FocusedWinID returns the $winid if present, otherwise it connects to the given addr to find the ID
Derived from https://github.com/fhs/acme-lsp/blob/623cb39c2e31bddda0ad7c216c2f3c2fcfcf237f/cmd/L/main.go#L256
func IsHiDPI ¶
IsHiDPI returns whether the font is being displayed in a HiDPI context. This is absolutely a hack and should not be trusted.
Types ¶
type Acme ¶
type Acme struct { EventHooks map[Text][]Handler WinHooks map[Text][]WinHandler KeyHooks map[rune]Handler // contains filtered or unexported fields }
Acme implements the Listener interface for acme events
type Action ¶
type Action rune
Action describes what kind of action was taken
const ( // BodyDelete is a deletion in the window body BodyDelete Action = 'D' // TagDelete is a deletion in the window tag TagDelete Action = 'd' // BodyInsert is an insertion into the window body BodyInsert Action = 'I' // TagInsert is an insert into the window tag TagInsert Action = 'i' // B3Body is a right click event in the window body B3Body Action = 'L' // B3Tag is a right click event in the window tag B3Tag Action = 'l' // B2Body is a middle click event in the window body B2Body Action = 'X' // B2Tag is a middle click event in the window tag B2Tag Action = 'x' // DelAction represents a delete event DelAction Action = 0x0 )
type Buf ¶
type Buf struct { EventHooks map[Text][]Handler WinHooks map[Text][]WinHandler KeyHooks map[rune]Handler // contains filtered or unexported fields }
Buf implements the BufListener interface and runs on opened acme buffers
type Event ¶
type Event struct { // Log ID int File string Origin Origin Action Action Text Text Flag Flag SelBegin, SelEnd int OrigSelBegin, OrigSelEnd int NumBytes int NumRunes int ChordArg []byte ChordLoc []byte // Hooks WriteHooks []Hook }
Event contains metadata for each Acme event
The message includes the text if it is less than 256 chars. If it is longer than that, the fourth number is 0 and the body must be read through the data file
type Filetype ¶
type Filetype struct { Name string Extensions []string Tabwidth int Tabexpand bool Comment string Commands []Command }
Filetype contains the formatting specification for a given file extension
func FindFiletype ¶
FindFiletype returns the filetype in the nyne config if present
type Flag ¶
type Flag int
Flag contains the flag for the event. For BodyDelete, TagDelete, BodyInsert, and TagInsert the flag is always zero. For messages with the 1 bit on in the flag, writing the message back to the event file, but with the flag, count, and text omitted, will cause the action to be applied to the file exactly as it would have been if the event file had not been open.
const ( // IsBuiltin represents a built-in command IsBuiltin Flag = iota // IsNull represents if the text is a null string that has a // non-null expansion; if so, another complete message will // follow describing the expansion exactly as if it had been // indicated explicitly (its flag will always be 0) IsNull // HasChordedArg says if the command has an extra (chorded) // argument; if so, two more complete messages will follow // reporting the argument (with all numbers 0 except the // character count) and where it originated, in the form of a // fully-qualified button 3 style address. HasChordedArg // NoReloadNeeded says if acme can interpret the action without // loading a new file NoReloadNeeded // PostExpandFollows says if a second (post-expansion) message // follows, analogous to that with X messages PostExpandFollows // IsFileOrWindow says If the text is a file or window name // (perhaps with address) rather than plain literal text. IsFileOrWindow )
type Formatter ¶
type Formatter struct {
// contains filtered or unexported fields
}
Formatter formats acme windows and buffers
func NewFormatter ¶
NewFormatter constructs a Formatter
type Origin ¶
type Origin rune
Origin is the entity that originated the action
const ( // BodyOrTag represents an action received in the body or tag BodyOrTag Origin = 'E' // WindowFiles represents an action taken in the file WindowFiles Origin = 'F' // Keyboard represents an action taken by the keyboard Keyboard Origin = 'K' // Mouse represents an action taken by the mouse Mouse Origin = 'M' // DelOrigin represents a delete event DelOrigin Origin = 0x0 )
type TabwidthFunc ¶
TabwidthFunc returns the tabwidth based on properties of the Event
type Text ¶
type Text string
Text contains the default acme event types
const ( // New represents window creation New Text = "New" // Zerox reprents window creation via zerox Zerox Text = "Zerox" // Get loads/reloads the file in the window Get Text = "Get" // Put writes window to the named file Put Text = "Put" // Del deletes the window Del Text = "Del" // Focus is received when the window focused Focus Text = "Focus" )
type Win ¶
Win represents the active Acme window
func (*Win) Addr ¶
Addr returns the current address of the window
Derived from https://github.com/fhs/acme-lsp/blob/623cb39c2e31bddda0ad7c216c2f3c2fcfcf237f/internal/acme/acme.go#L366
func (*Win) AddrFromSelection ¶
AddrFromSelection sets the addr address to that of the user’s selected text in the window.
func (*Win) AppendBody ¶
AppendBody appends the given text to the body
func (*Win) CurrentAddr ¶
CurrentAddr sets the addr to dot and reads the addr
func (*Win) Data ¶
Data reads the data in the body between q0 and q1. It is assumed that CurrentAddr() or similar has been called to properly set the addr and retrieve valid q0 and q1 points.
func (*Win) DisableNoMark ¶
DisableNoMark cancels nomark, returning the window to the usual state wherein each modification to the body must be undone individually.
func (*Win) Dumpdir ¶
Dumpdir sets the directory in which to run the command to recreate the window from a dump file.
func (*Win) Get ¶
Get is the equivalent to the Get interactive command with no arguments; accepts no arguments.
func (*Win) LimitSearchToAddr ¶
LimitSearchToAddr restricts subsequent searches to the current addr address.
func (*Win) NoMark ¶
NoMark turns off automatic ‘marking’ of changes, so a set of related changes may be undone in a single Undo interactive command.
func (*Win) Put ¶
Put is the equivalent to the Put interactive command with no arguments; accepts no arguments.
func (*Win) SelectionFromAddr ¶
SelectionFromAddr sets the user’s selected text in the window to the text addressed by the addr address.
func (*Win) SetAddr ¶
SetAddr takes an addr which may be written with any textual address in the format understood by button 3 but without the initial colon
func (*Win) SetData ¶
SetData is used in conjunction with addr for random access to the contents of the body. The file offset is ignored when writing the data file; instead the location of the data to be read or written is determined by the state of the addr file. Text, which must contain only whole characters (no ‘partial runes’), written to data replaces the characters addressed by the addr file and sets the address to the null string at the end of the written text. A read from data returns as many whole characters as the read count will permit starting at the beginning of the addr address (the end of the address has no effect) and sets the address to the null string at the end of the returned characters.
func (*Win) WriteEvent ¶
WriteEvent writes the acme event to the log
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
a+
Indents selected source code.
|
Indents selected source code. |
a-
Unindents selected source code.
|
Unindents selected source code. |
aspell
A spell checker for acme Usage of aspell: aspell [spell options]
|
A spell checker for acme Usage of aspell: aspell [spell options] |
com
Comments/uncomments piped text Usage of com: |com `com` uses the `commentstyle` you've configured a given file extension to comment or uncomment a given selection in acme.
|
Comments/uncomments piped text Usage of com: |com `com` uses the `commentstyle` you've configured a given file extension to comment or uncomment a given selection in acme. |
f+
Increase font size Usage of f+: Execute f+ with B2
|
Increase font size Usage of f+: Execute f+ with B2 |
f-
Decrease font size Usage of f-: Execute f- with B2
|
Decrease font size Usage of f-: Execute f- with B2 |
font
Wrapper around f+ or f- intended to be invoked from a tool like skhd Usage of font: -op string font operation to execute: inc, dec (default "inc")
|
Wrapper around f+ or f- intended to be invoked from a tool like skhd Usage of font: -op string font operation to execute: inc, dec (default "inc") |
md
Shortcuts for working with markdown Usage of md: -op string the operation to perform: link, bold, italic, preview
|
Shortcuts for working with markdown Usage of md: -op string the operation to perform: link, bold, italic, preview |
move
Shortcuts for moving the cursor Usage of move: -d string the direction to move: up, down, left, right, start, end -p move by paragraph (only valid for left and right) -s select text while moving -w move by word (only valid for left and right)
|
Shortcuts for moving the cursor Usage of move: -d string the direction to move: up, down, left, right, start, end -p move by paragraph (only valid for left and right) -s select text while moving -w move by word (only valid for left and right) |
nstart
nstart is used for launching acme along with all of its dependencies and helpers.
|
nstart is used for launching acme along with all of its dependencies and helpers. |
nyne
The core autoformatting engine that is run from within acme.
|
The core autoformatting engine that is run from within acme. |
nynetab
Implements tab expansion and indentation.
|
Implements tab expansion and indentation. |
save
Utility to execute Put via keyboard bindings Usage of save: Execute save from the shell
|
Utility to execute Put via keyboard bindings Usage of save: Execute save from the shell |
xcom
Wrapper around `com` intended to be invoked from a tool like skhd Usage of xcom: Execute xcom from the shell
|
Wrapper around `com` intended to be invoked from a tool like skhd Usage of xcom: Execute xcom from the shell |
xec
Execute a command in the focused window as if it had been clicked with B2 Usage of xec: xec [command]
|
Execute a command in the focused window as if it had been clicked with B2 Usage of xec: xec [command] |