mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-01 04:41:14 -03:00
ctrl-l to scroll content instead of erasing screen
On ctrl-l we send `\e[2J` (Erase in Display). Some terminals interpret this to scroll the screen content instead of clearing it. This happens on VTE-based terminals like gnome-terminal for example. The traditional behavior of ctrl-l erasing the screen (but not the rest of the scrollback) is weird because: 1. `ctrl-l` is the easiest and most portable way to push the prompt to the top (and repaint after glitches I guess). But it's also a destructive action, truncating scrollback. I use it for scrolling and am frequently surprised when my scroll back is missing information. 2. the amount of lines erased depends on the window size. It would be more intuitive to erase by prompts, or erase the text in the terminal selection. Let's use scrolling behavior on all terminals. The new command could also be named "push-to-scrollback", for consistency with others. But if we anticipate a want to add other scrollback-related commands, "scrollback-push" is better. This causes tests/checks/tmux-history-search.fish to fail; that test seems pretty broken; M-d (alt-d) is supposed to delete the current search match but there is a rogue "echo" that is supposed to invalidate the search match. I'm not sure how that ever worked. Also, pexepect doesn't seem to support cursor position reporting, so work around that. Ref: https://codeberg.org/dnkl/foot/wiki#how-do-i-make-ctrl-l-scroll-the-content-instead-of-erasing-it as of wiki commit b57489e298f95d037fdf34da00ea60a5e8eafd6d Closes #10934
This commit is contained in:
@@ -131,6 +131,7 @@ pub enum ReadlineCmd {
|
||||
EndUndoGroup,
|
||||
RepeatJump,
|
||||
ClearScreenAndRepaint,
|
||||
ScrollbackPush,
|
||||
// NOTE: This one has to be last.
|
||||
ReverseRepeatJump,
|
||||
}
|
||||
@@ -191,6 +192,8 @@ pub enum ImplicitEvent {
|
||||
DisableMouseTracking,
|
||||
/// Handle mouse left click.
|
||||
MouseLeftClickContinuation(ViewportPosition, ViewportPosition),
|
||||
/// Push prompt to top.
|
||||
ScrollbackPushContinuation(usize),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -590,6 +593,7 @@ pub fn function_set_status(&mut self, status: bool) {
|
||||
|
||||
pub enum WaitingForCursorPosition {
|
||||
MouseLeft(ViewportPosition),
|
||||
ScrollbackPush,
|
||||
}
|
||||
|
||||
/// A trait which knows how to produce a stream of input events.
|
||||
@@ -1025,6 +1029,9 @@ fn parse_csi(&mut self, buffer: &mut Vec<u8>) -> Option<Key> {
|
||||
*click_position,
|
||||
)
|
||||
}
|
||||
WaitingForCursorPosition::ScrollbackPush => {
|
||||
ImplicitEvent::ScrollbackPushContinuation(y)
|
||||
}
|
||||
};
|
||||
self.push_front(CharEvent::Implicit(continuation));
|
||||
return None;
|
||||
|
||||
Reference in New Issue
Block a user