Makes Page-Up, Page-Down, Home, and End key behavior consistent
Submitted by Jon Steinhart
Link to original bug (#131597)
Description
In vte-0.11 a Shift key must be down in order for the Page-Up, Page-Down, Home, and End keys to manipulate the scroll bar. However, in other applications including mozilla and gthumb, the Shift is not required. Furthermore, a Shift is not required when running an application such as less or vim which fields the key codes and implements scrolling.
This inconsistency requires that the user know what application they're running in order to know how to operate these keys. Such inconsistency is bad user interface as the user cannot operate in the efficient pre-attentive state.
The patches below change vte so that the paging keys normally operate the scroll bar without requiring a Shift. But, it switches to requiring the Shift whenever a control sequence has put the terminal into alternate screen mode. All of the screen-oriented applications that I'm aware of use the alternate screen mode. So, this allows application such as less to field the key codes and implement scrolling themselves.
Functions are provided to enable/disable this behavior in case the old behavior is desired for some legacy reason.
diff -u -r vte-0.11.10/src/vte.c src/vte.c --- vte-0.11.10/src/vte.c 2003-06-16 14:15:09.000000000 -0700 +++ src/vte.c 2004-01-13 09:59:31.000000000 -0800 @@ -287,6 +287,8 @@ gboolean scroll_on_output; gboolean scroll_on_keystroke; long scrollback_lines;
-
gboolean shift_required_for_scroll_keys;
-
gboolean scroll_keys_auto_shift; /* Cursor blinking. */ int cursor_force_fg;
@@ -4640,6 +4642,19 @@ 0, NULL); } +
-
/* Set the Page-Up and Page-Down key operation to manipulate
-
* the scroll bar if reset. Set them to only operate the
-
* scroll bar when a Shift key is depressed if set. This
-
* allows "screen" applications to field the paging keys
-
* themselves, while normal scrolling applications like
-
* terminal emulators will scroll. Only do this behavior
-
* if enabled so that backwards compatibility is possible
-
* in case someone wants it.
-
*/
-
if (terminal->pvt->scroll_keys_auto_shift == TRUE)
vte_terminal_set_shift_required_for_scroll_keys(terminal, set); + /* Reset scrollbars and repaint everything. / vte_terminal_adjust_adjustments(terminal, TRUE); vte_invalidate_all(terminal); @@ -8021,7 +8036,7 @@ / Keypad/motion keys. */ case GDK_KP_Page_Up: case GDK_Page_Up:
-
if (terminal->pvt->modifiers & GDK_SHIFT_MASK) {
-
if (terminal->pvt->shift_required_for_scroll_keys
== FALSE || terminal->pvt->modifiers & GDK_SHIFT_MASK) { vte_terminal_scroll_pages(terminal, -1); scrolled = TRUE; handled = TRUE; @@ -8030,7 +8045,7 @@ break; case GDK_KP_Page_Down: case GDK_Page_Down:
-
if (terminal->pvt->modifiers & GDK_SHIFT_MASK) {
-
if (terminal->pvt->shift_required_for_scroll_keys
== FALSE || terminal->pvt->modifiers & GDK_SHIFT_MASK) { vte_terminal_scroll_pages(terminal, 1); scrolled = TRUE; handled = TRUE; @@ -8039,7 +8054,7 @@ break; case GDK_KP_Home: case GDK_Home:
-
if (terminal->pvt->modifiers & GDK_SHIFT_MASK) {
-
if (terminal->pvt->shift_required_for_scroll_keys
== FALSE || terminal->pvt->modifiers & GDK_SHIFT_MASK) { vte_terminal_maybe_scroll_to_top(terminal); scrolled = TRUE; handled = TRUE; @@ -8047,7 +8062,7 @@ break; case GDK_KP_End: case GDK_End:
-
if (terminal->pvt->modifiers & GDK_SHIFT_MASK) {
-
if (terminal->pvt->shift_required_for_scroll_keys
== FALSE || terminal->pvt->modifiers & GDK_SHIFT_MASK) { vte_terminal_maybe_scroll_to_bottom(terminal); scrolled = TRUE; handled = TRUE; @@ -10819,6 +10834,8 @@ pvt->scroll_on_output = FALSE; pvt->scroll_on_keystroke = TRUE; pvt->scrollback_lines = VTE_SCROLLBACK_MIN;
-
pvt->shift_required_for_scroll_keys = FALSE;
-
pvt->scroll_keys_auto_shift = TRUE; vte_terminal_set_scrollback_lines(terminal, terminal->pvt->scrollback_lines);
@@ -13798,6 +13815,51 @@ }
/**
-
- vte_terminal_set_shift_required_for_scroll_keys:
-
- @terminal: a #VteTerminal
-
- @scroll: TRUE if the shift key must be held down for the scroll keys to operate
-
-
- Controls the operation of the Home, End, Page-Up, and Page-Down keys. These
-
- keys only cause scrolling when a Shift key is down if set to TRUE. These
-
- keys always cause scrolling if set to FALSE, which is the default.
- */ +void +vte_terminal_set_shift_required_for_scroll_keys(VteTerminal *terminal, gboolean scroll) +{
-
g_return_if_fail(VTE_IS_TERMINAL(terminal));
-
terminal->pvt->shift_required_for_scroll_keys = scroll;
-
return;
+} + +/**
-
- vte_terminal_set_scroll_keys_auto_shift:
-
- @terminal: a #VteTerminal
-
- @auto_shift: TRUE to enable auto-shifting of the scroll keys.
-
-
- Controls the operation of the Home, End, Page-Up, and Page-Down keys. These
-
- keys can either control the scroll bar, or emit key codes to an application.
-
- There are two modes of operation. In the first, the Shift keys determine
-
- the operation; the scroll bar is controlled if a Shift key is down, otherwise
-
- key codes are emitted. In the second, they always control the scroll bar.
-
- The reason that the scroll bar is not always controlled is that some
-
- screen-oriented applications field the key codes and do their own scrolling.
-
- Auto-shifting, which is enabled by a value of TRUE and is the default,
-
- switches between these two modes. The keys normally control the scroll bar.
-
- Key codes are emitted if control sequence selects an alternate screen. Pretty
-
- much all screen-oriented applications do this, so it presents a consistent
-
- user behavior in which the keys always cause scrolling. Auto-shifting is
-
- disabled by a value of FALSE. When disabled, the key behavior is determined
-
- by the vte_terminal_set_shift_required_for_scroll_keys() function.
- */ +void +vte_terminal_set_scroll_keys_auto_shift(VteTerminal *terminal, gboolean auto_shift) +{
-
g_return_if_fail(VTE_IS_TERMINAL(terminal));
-
terminal->pvt->scroll_keys_auto_shift = auto_shift;
-
return;
+} + +/**
- vte_terminal_copy_clipboard:
- @terminal: a #VteTerminal
diff -u -r vte-0.11.10/src/vte.h src/vte.h --- vte-0.11.10/src/vte.h 2003-06-16 14:15:10.000000000 -0700 +++ src/vte.h 2004-01-13 09:16:52.000000000 -0800 @@ -184,6 +184,8 @@ void vte_terminal_set_scroll_on_output(VteTerminal *terminal, gboolean scroll); void vte_terminal_set_scroll_on_keystroke(VteTerminal *terminal, gboolean scroll); +void vte_terminal_set_shift_required_for_scroll_keys(VteTerminal *terminal, gboolean scroll); +void vte_terminal_set_scroll_keys_auto_shift(VteTerminal *terminal, gboolean auto_shift);
/* Set the color scheme. */ void vte_terminal_set_color_dim(VteTerminal *terminal,
Version: 0.11.x
Resolution: RESOLVED WONTFIX