Compare commits

..

3 Commits

Author SHA1 Message Date
sammyette 6edf1c7733
Merge f312cc2cac into 9d5f5abef4 2023-12-24 17:23:31 -05:00
sammyette f312cc2cac
docs: improve docs for signals 2023-12-24 18:23:10 -04:00
sammyette 9d5f5abef4
feat: add pprof 2023-12-18 21:31:04 -04:00
4 changed files with 131 additions and 21 deletions

View File

@ -7,15 +7,61 @@ menu:
parent: "Signals" parent: "Signals"
--- ---
- `command.preexec` -> input, cmdStr > Thrown before a command ## command.preexec
is executed. The `input` is the user written command, while `cmdStr` Thrown right before a command is executed.
is what will be executed (`input` will have aliases while `cmdStr`
will have alias resolved input).
- `command.exit` -> code, cmdStr > Thrown when a command exits. #### Variables
`code` is the exit code of the command, and `cmdStr` is the command that was run. `string` **`input`**
The raw string that the user typed. This will include the text
without changes applied to it (argument substitution, alias expansion,
etc.)
- `command.not-found` -> cmdStr > Thrown when a command is not found. `string` **`cmdStr`**
The command that will be directly executed by the current runner.
- `command.not-executable` -> cmdStr > Thrown when Hilbish attempts to run a file <hr>
that is not executable.
## command.exit
Thrown after the user's ran command is finished.
#### Variables
`number` **`code`**
The exit code of what was executed.
`string` **`cmdStr`**
The command or code that was executed
<hr>
## command.not-found
Thrown if the command attempted to execute was not found.
This can be used to customize the text printed when a command is not found.
Example:
```lua
local bait = require 'bait'
-- Remove any present handlers on `command.not-found`
local notFoundHooks = bait.hooks 'command.not-found'
for _, hook in ipairs(notFoundHooks) do
bait.release('command.not-found', hook)
end
-- then assign custom
bait.catch('command.not-found', function(cmd)
print(string.format('The command "%s" was not found.', cmd))
end)
```
#### Variables
`string` **`cmdStr`**
The name of the command.
<hr>
## command.not-executable
Thrown when the user attempts to run a file that is not executable
(like a text file, or Unix binary without +x permission).
#### Variables
`string` **`cmdStr`**
The name of the command.

View File

@ -7,15 +7,41 @@ menu:
parent: "Signals" parent: "Signals"
--- ---
+ `hilbish.exit` > Sent when Hilbish is about to exit. ## hilbish.exit
Sent when Hilbish is going to exit.
+ `hilbish.vimMode` -> modeName > Sent when Hilbish's Vim mode is changed (example insert to normal mode), #### Variables
`modeName` is the name of the mode changed to (can be `insert`, `normal`, `delete` or `replace`). This signal returns no variables.
<hr>
## hilbish.vimMode
Sent when the Vim mode of Hilbish is changed (like from insert to normal mode).
This can be used to change the prompt and notify based on Vim mode.
#### Variables
`string` **`modeName`**
The mode that has been set.
Can be these values: `insert`, `normal`, `delete` or `replace`
<hr>
## hilbish.cancel
Sent when the user cancels their command input with Ctrl-C
#### Variables
This signal returns no variables.
<hr>
## hilbish.notification
Thrown when a [notification](../../features/notifications) is sent.
#### Variables
`table` **`notification`**
The notification. The properties are defined in the link above.
<hr>
+ `hilbish.vimAction` -> actionName, args > Sent when the user does a "vim action," being something + `hilbish.vimAction` -> actionName, args > Sent when the user does a "vim action," being something
like yanking or pasting text. See `doc vim-mode actions` for more info. like yanking or pasting text. See `doc vim-mode actions` for more info.
+ `hilbish.cancel` > Sent when the user cancels their input with Ctrl-C.
+ `hilbish.notification` -> message > Sent when a message is
sent.

View File

@ -7,10 +7,34 @@ menu:
parent: "Signals" parent: "Signals"
--- ---
+ `signal.sigint` > Sent when Hilbish receives SIGINT (on Ctrl-C). ## signal.sigint
Thrown when Hilbish receive the SIGINT signal,
aka when Ctrl-C is pressed.
+ `signal.resize` > Sent when the terminal is resized. #### Variables
This signal returns no variables.
+ `signal.sigusr1` <hr>
## signal.resize
Thrown when the terminal is resized.
#### Variables
This signal returns no variables.
<hr>
## signal.sigusr1
Thrown when SIGUSR1 is sent to Hilbish.
#### Variables
This signal returns no variables.
<hr>
## signal.sigusr2
Thrown when SIGUSR2 is sent to Hilbish.
#### Variables
This signal returns no variables.
+ `signal.sigusr2`

14
pprof.go 100644
View File

@ -0,0 +1,14 @@
// +build pprof
package main
import (
_ "net/http/pprof"
"net/http"
)
func init() {
go func() {
http.ListenAndServe("localhost:8080", nil)
}()
}