mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
osc: add support for OSC 133;A (prompt markers)
This patch adds support for the OSC-133;A sequence, introduced by FinalTerm and implemented by iTerm2, Kitty and more. See https://iterm2.com/documentation-one-page.html#documentation-escape-codes.html. The shell emits the OSC just before printing the prompt. This lets the terminal know where, in the scrollback, there are prompts. We implement this using a simple boolean in the row struct ("this row has a prompt"). The prompt marker must be reflowed along with the text on window resizes. In an ideal world, erasing, or overwriting the cell where the OSC was emitted, would remove the prompt mark. Since we don't store this information in the cell struct, we can't do that. The best we can do is reset it in erase_line(). This works well enough in the "normal" screen, when used with a "normal" shell. It doesn't really work in fullscreen apps, on the alt screen. But that doesn't matter since we don't support jumping between prompts on the alt screen anyway. To be able to jump between prompts, two new key bindings have been added: prompt-prev and prompt-next, bound to ctrl+shift+z and ctrl+shift+x respectively. prompt-prev will jump to the previous, not currently visible, prompt, by moving the viewport, ensuring the prompt is at the top of the screen. prompt-next jumps to the next prompt, visible or not. Again, by moving the viewport to ensure the prompt is at the top of the screen. If we're at the bottom of the scrollback, the viewport is instead moved as far down as possible. Closes #30
This commit is contained in:
parent
96f23b4c64
commit
bdb79e8b9f
15 changed files with 285 additions and 18 deletions
|
|
@ -205,6 +205,13 @@ default) available; see *foot.ini*(5).
|
|||
*ctrl*+*shift*+*u*
|
||||
Activate URL mode, allowing you to "launch" URLs.
|
||||
|
||||
*ctrl*+*shift*+*z*
|
||||
Jump to the previous, currently not visible, prompt. Requires
|
||||
shell integration.
|
||||
|
||||
*ctrl*+*shift*+*x*
|
||||
Jump to the next prompt. Requires shell integration.
|
||||
|
||||
## SCROLLBACK SEARCH
|
||||
|
||||
*ctrl*+*r*
|
||||
|
|
@ -370,6 +377,38 @@ commented out will usually be installed to */etc/xdg/foot/foot.ini*.
|
|||
|
||||
For more information, see *foot.ini*(5).
|
||||
|
||||
# SHELL INTEGRATION
|
||||
|
||||
## Current working directory
|
||||
|
||||
New foot terminal instances (bound to *ctrl*+*shift*+*n* by default)
|
||||
will open in the current working directory, if the shell in the
|
||||
“parent” terminal reports directory changes.
|
||||
|
||||
This is done with the OSC-7 escape sequence. Most shells can be
|
||||
scripted to do this, if they do not support it natively. See the wiki
|
||||
(https://codeberg.org/dnkl/foot/wiki#user-content-spawning-new-terminal-instances-in-the-current-working-directory)
|
||||
for details.
|
||||
|
||||
|
||||
## Jumping between prompts
|
||||
|
||||
Foot can move the current viewport to focus prompts of already
|
||||
executed commands (bound to *ctrl*+*shift*+*z*/*x* by default).
|
||||
|
||||
For this to work, the shell needs to emit an OSC-133;A
|
||||
(*\\E]133;A\\E\\\\*) sequence before each prompt.
|
||||
|
||||
In zsh, one way to do this is to add a _precmd_ hook:
|
||||
|
||||
*precmd() {
|
||||
print -Pn "\\e]133;A\\e\\\\"
|
||||
}*
|
||||
|
||||
See the wiki
|
||||
(https://codeberg.org/dnkl/foot/wiki#user-content-jumping-between-prompts)
|
||||
for details, and examples for other shells.
|
||||
|
||||
# TERMINFO
|
||||
|
||||
Client applications use the terminfo identifier specified by the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue