X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=runtime%2Fhelp%2Fplugins.md;h=2b29ca4b4becbeb5a2d7c31d5266acc83f769d8f;hb=aae0f4630e5d834f0b5f78c5b6a27212e69e5e3f;hp=4b11beeec8ae7efb4a18842f168b533201d3b85e;hpb=4f41881c102a2790b2917c1ff86f54571e96f4c7;p=micro.git diff --git a/runtime/help/plugins.md b/runtime/help/plugins.md index 4b11beee..2b29ca4b 100644 --- a/runtime/help/plugins.md +++ b/runtime/help/plugins.md @@ -65,6 +65,9 @@ functions are given using Go's type system): * `NewBuffer(text, path string) *Buffer`: creates a new buffer from a given reader with a given path +* `NewBufferFromFile(path string) *Buffer`: creates a new buffer from a given + path + * `GetLeadingWhitespace() bool`: returns the leading whitespace of the given string @@ -108,11 +111,33 @@ functions are given using Go's type system): * `HandleCommand(cmd string)`: runs the given command -* `HandleShellCommand(shellCmd string, interactive bool, waitToClose bool)`: - runs the given shell command. The `interactive` bool specifies whether the - command should run in the background. The `waitToClose` bool only applies if - `interactive` is true and means that it should wait before returning to the - editor. +* `ExecCommand(name string, args []string) (string, error)`: exec a (shell) command with the + given arguments. Returns the command's output and a possible error. + +* `RunShellCommand(cmd string) (string, error)`: Run a shell command. This uses `ExecCommand` + under the hood but also does some parsing for the arguments (i.e. quoted arguments). The + function returns the command's output and a possible error. + +* `RunBackgroundShell(cmd string)`: Run a shell command in the background. + +* `RunInteractiveShell(cmd string, wait bool, getOutput bool) (string, error)`: Run a shell command + by closing micro and running the command interactively. If `wait` is true, a prompt will be + used after the process exits to prevent the terminal from immediately returning to micro, allowing + the user to view the output of the process. If `getOutput` is true, the command's standard output + will be returned. Note that if `getOutput` is true, some interactive commands may not behave + normally because `isatty` will return false. + +* `RunTermEmulator(cmd string, wait bool, getOutput bool, callback string) error`: Same as + `RunInteractiveShell` except the command is run within the current split in a terminal emulator. + The `callback` input is a string callback to a lua function which will be called when the process + exits. The output of the process will be provided as the first and only argument to the callback + (it will be empty if `getOutput` is false). + Note that this functionality is only supported on some operating systems (linux, darwin, dragonfly, + openbsd, freebsd). Use the `TermEmuSupported` (see below) boolean to determine if the current + system is supported. + +* `TermEmuSupported`: Boolean specifying if the terminal emulator is supported on the version of + micro that is running. * `ToCharPos(loc Loc, buf *Buffer) int`: returns the character position of a given x, y location @@ -302,7 +327,7 @@ plugins that are stored in the official channel Micro also has a built in plugin manager which you can invoke with the `> plugin ...` command. -For the valid commands you can use, see the `command` help topic. +For the valid commands you can use, see the `commands` help topic. The manager fetches plugins from the channels (which is simply a list of plugin metadata) which it knows about. By default, micro only knows about the official