Documentation
¶
Overview ¶
Package termsetup makes shift+Enter and ctrl+Enter work in the terminal interface.
A terminal sends the same byte for Enter, shift+Enter and ctrl+Enter, so the program cannot tell them apart; ctrl+j is the one newline key every terminal delivers. Terminals that support a keyboard protocol (kitty, WezTerm, Ghostty, recent Alacritty, iTerm2...) report the modifiers by themselves. Windows Terminal and the VS Code terminal do not, but they can be told to send the sequences the protocol uses for these two keys (ESC [ 13 ; 2 u and ESC [ 13 ; 5 u), which the interface already decodes. This package writes that setting.
Both files it edits are JSON with comments, so they are patched as text: what the user wrote is kept as it is, a backup is made first, and nothing is written unless the result still parses.
Index ¶
Constants ¶
const ( // ShiftEnterSequence and CtrlEnterSequence are what the terminal is told to send. ShiftEnterSequence = "\x1b[13;2u" CtrlEnterSequence = "\x1b[13;5u" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result struct {
Target string // "Windows Terminal", "VS Code"
Path string
Status Status
Backup string // path of the backup, when one was made
Detail string
}
Result describes one target file.
type Status ¶
type Status string
Status is what happened to one file.
const ( Added Status = "added" // the keys were written Already Status = "already" // the keys were already there Conflict Status = "conflict" // shift+enter is bound to something else: left alone WouldAdd Status = "would-add" // dry run: the keys would be written NotFound Status = "not-found" // no such terminal on this machine Failed Status = "failed" Unchanged Status = "unchanged" )