diff options
author | Behdad Esfahbod <behdad@gnome.org> | 2008-12-01 02:55:00 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2008-12-01 02:55:00 +0000 |
commit | fbcaf9548ae6453387c9708a832844a47b7e1460 (patch) | |
tree | 6704d052a804e5f2d14e2740d3238080abde89e2 /src | |
parent | e37545fbe4c3a5bce280f4f7c34d38721a6bc2da (diff) |
Move vte_terminal_scroll to vte.c
2008-11-30 Behdad Esfahbod <behdad@gnome.org>
* src/vte-private.h:
* src/vte.c (_vte_terminal_scroll), (_vte_terminal_scroll_region):
* src/vteseq.c (vte_sequence_handler_scroll_down_one),
(vte_sequence_handler_scroll_up_one):
Move vte_terminal_scroll to vte.c
svn path=/trunk/; revision=2244
Diffstat (limited to 'src')
-rw-r--r-- | src/vte-private.h | 2 | ||||
-rw-r--r-- | src/vte.c | 57 | ||||
-rw-r--r-- | src/vteseq.c | 112 |
3 files changed, 93 insertions, 78 deletions
diff --git a/src/vte-private.h b/src/vte-private.h index e3d74a1..1283ed3 100644 --- a/src/vte-private.h +++ b/src/vte-private.h @@ -439,6 +439,8 @@ void _vte_terminal_cursor_down (VteTerminal *terminal); gboolean _vte_terminal_insert_char(VteTerminal *terminal, gunichar c, gboolean force_insert_mode, gboolean invalidate_cells); +void _vte_terminal_scroll (VteTerminal *terminal, + int scroll_amount); void _vte_terminal_scroll_region(VteTerminal *terminal, long row, glong count, glong delta); void _vte_terminal_set_default_attributes(VteTerminal *terminal); @@ -589,11 +589,64 @@ _vte_invalidate_all(VteTerminal *terminal) } } +/* Scroll the text, but don't move the cursor. Negative = up, positive = down. */ +void +_vte_terminal_scroll (VteTerminal *terminal, int scroll_amount) +{ + VteRowData *row, *old_row; + long start, end, i; + VteScreen *screen; + + screen = terminal->pvt->screen; + + if (screen->scrolling_restricted) { + start = screen->insert_delta + screen->scrolling_region.start; + end = screen->insert_delta + screen->scrolling_region.end; + } else { + start = screen->insert_delta; + end = start + terminal->row_count - 1; + } + + old_row = terminal->pvt->free_row; + while (_vte_ring_next(screen->row_data) <= end) { + if (old_row) { + row = _vte_reset_row_data (terminal, old_row, FALSE); + } else { + row = _vte_new_row_data_sized(terminal, FALSE); + } + old_row = _vte_ring_append(terminal->pvt->screen->row_data, row); + } + terminal->pvt->free_row = old_row; + if (scroll_amount > 0) { + for (i = 0; i < scroll_amount; i++) { + vte_remove_line_internal(terminal, end); + vte_insert_line_internal(terminal, start); + } + } else { + for (i = 0; i < -scroll_amount; i++) { + vte_remove_line_internal(terminal, start); + vte_insert_line_internal(terminal, end); + } + } + + /* Update the display. */ + _vte_terminal_scroll_region(terminal, start, end - start + 1, + scroll_amount); + + /* Adjust the scrollbars if necessary. */ + _vte_terminal_adjust_adjustments(terminal); + + /* We've modified the display. Make a note of it. */ + terminal->pvt->text_inserted_flag = TRUE; + terminal->pvt->text_deleted_flag = TRUE; +} + + /* Scroll a rectangular region up or down by a fixed number of lines, * negative = up, positive = down. */ void -_vte_terminal_scroll_region(VteTerminal *terminal, - long row, glong count, glong delta) +_vte_terminal_scroll_region (VteTerminal *terminal, + long row, glong count, glong delta) { if ((delta == 0) || (count == 0)) { /* Shenanigans! */ diff --git a/src/vteseq.c b/src/vteseq.c index 3e885c2..4b5309c 100644 --- a/src/vteseq.c +++ b/src/vteseq.c @@ -32,25 +32,6 @@ -/* A function which can handle a terminal control sequence. Returns TRUE only - * if something happened (usually a signal emission) to which the controlling - * application must have an immediate opportunity to respond. */ -typedef gboolean (*VteTerminalSequenceHandler)(VteTerminal *terminal, - const char *match, - GQuark match_quark, - GValueArray *params); - -/* Prototype all handlers... */ -#define VTE_SEQUENCE_HANDLER(name) \ - static gboolean name(VteTerminal *terminal, \ - const char *match, \ - GQuark match_quark, \ - GValueArray *params); -#include "vteseq-list.h" -#undef VTE_SEQUENCE_HANDLER - - - /* FUNCTIONS WE USE */ @@ -238,6 +219,38 @@ vte_terminal_emit_resize_window(VteTerminal *terminal, + + + + +/* + * Sequence handling boilerplate + */ + + + + + +/* A function which can handle a terminal control sequence. Returns TRUE only + * if something happened (usually a signal emission) to which the controlling + * application must have an immediate opportunity to respond. */ +typedef gboolean (*VteTerminalSequenceHandler)(VteTerminal *terminal, + const char *match, + GQuark match_quark, + GValueArray *params); + +/* Prototype all handlers... */ +#define VTE_SEQUENCE_HANDLER(name) \ + static gboolean name(VteTerminal *terminal, \ + const char *match, \ + GQuark match_quark, \ + GValueArray *params); +#include "vteseq-list.h" +#undef VTE_SEQUENCE_HANDLER + + + + /* Call another function, offsetting any long arguments by the given * increment value. */ static gboolean @@ -291,61 +304,6 @@ vte_sequence_handler_multiple(VteTerminal *terminal, return (again > 0); } -/* Scroll the text, but don't move the cursor. Negative = up, - * positive = down. */ -static gboolean -vte_sequence_handler_scroll_up_or_down(VteTerminal *terminal, int scroll_amount) -{ - VteRowData *row, *old_row; - long start, end, i; - VteScreen *screen; - - screen = terminal->pvt->screen; - - if (screen->scrolling_restricted) { - start = screen->insert_delta + screen->scrolling_region.start; - end = screen->insert_delta + screen->scrolling_region.end; - } else { - start = screen->insert_delta; - end = start + terminal->row_count - 1; - } - - old_row = terminal->pvt->free_row; - while (_vte_ring_next(screen->row_data) <= end) { - if (old_row) { - row = _vte_reset_row_data (terminal, old_row, FALSE); - } else { - row = _vte_new_row_data_sized(terminal, FALSE); - } - old_row = _vte_ring_append(terminal->pvt->screen->row_data, row); - } - terminal->pvt->free_row = old_row; - if (scroll_amount > 0) { - for (i = 0; i < scroll_amount; i++) { - vte_remove_line_internal(terminal, end); - vte_insert_line_internal(terminal, start); - } - } else { - for (i = 0; i < -scroll_amount; i++) { - vte_remove_line_internal(terminal, start); - vte_insert_line_internal(terminal, end); - } - } - - /* Update the display. */ - _vte_terminal_scroll_region(terminal, start, end - start + 1, - scroll_amount); - - /* Adjust the scrollbars if necessary. */ - _vte_terminal_adjust_adjustments(terminal); - - /* We've modified the display. Make a note of it. */ - terminal->pvt->text_inserted_flag = TRUE; - terminal->pvt->text_deleted_flag = TRUE; - - return FALSE; -} - /* Set icon/window titles. */ static gboolean vte_sequence_handler_set_title_internal(VteTerminal *terminal, @@ -2061,7 +2019,8 @@ vte_sequence_handler_scroll_down_one(VteTerminal *terminal, GQuark match_quark, GValueArray *params) { - return vte_sequence_handler_scroll_up_or_down(terminal, 1); + _vte_terminal_scroll (terminal, 1); + return FALSE; } /* Scroll the text down, but don't move the cursor. */ @@ -2082,7 +2041,8 @@ vte_sequence_handler_scroll_up_one(VteTerminal *terminal, GQuark match_quark, GValueArray *params) { - return vte_sequence_handler_scroll_up_or_down(terminal, -1); + _vte_terminal_scroll (terminal, -1); + return FALSE; } /* Scroll the text up, but don't move the cursor. */ |