[vte] emulation: Support CSI 3J (clear scrollback)
- From: Egmont Koblinger <egmontkob src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] emulation: Support CSI 3J (clear scrollback)
- Date: Sun, 28 Dec 2014 22:54:58 +0000 (UTC)
commit 3111d44927ee755c07eb5c51656935770b0ce59b
Author: Egmont Koblinger <egmont gmail com>
Date: Sun Dec 28 23:53:22 2014 +0100
emulation: Support CSI 3J (clear scrollback)
https://bugzilla.gnome.org/show_bug.cgi?id=678042
src/caps.c | 8 ++++----
src/ring.c | 21 ++++++++++++++++++++-
src/ring.h | 1 +
src/vte-private.h | 1 +
src/vte.c | 14 ++++++++++++++
src/vteseq.c | 10 ++++++++--
6 files changed, 48 insertions(+), 7 deletions(-)
---
diff --git a/src/caps.c b/src/caps.c
index edeb97d..b51882f 100644
--- a/src/caps.c
+++ b/src/caps.c
@@ -136,13 +136,13 @@ const char _vte_xterm_capability_strings[] =
ENTRY(CSI "I", "cursor-forward-tabulation")
ENTRY(CSI "%dI", "cursor-forward-tabulation")
ENTRY(CSI "J", "erase-in-display")
- ENTRY(CSI "%dJ", "erase-in-display")
+ ENTRY(CSI "%mJ", "erase-in-display")
ENTRY(CSI "?J", "selective-erase-in-display")
- ENTRY(CSI "?%dJ", "selective-erase-in-display")
+ ENTRY(CSI "?%mJ", "selective-erase-in-display")
ENTRY(CSI "K", "erase-in-line")
- ENTRY(CSI "%dK", "erase-in-line")
+ ENTRY(CSI "%mK", "erase-in-line")
ENTRY(CSI "?K", "selective-erase-in-line")
- ENTRY(CSI "?%dK", "selective-erase-in-line")
+ ENTRY(CSI "?%mK", "selective-erase-in-line")
ENTRY(CSI "L", "insert-lines")
ENTRY(CSI "%dL", "insert-lines")
ENTRY(CSI "M", "delete-lines")
diff --git a/src/ring.c b/src/ring.c
index 5364aeb..f3fccc6 100644
--- a/src/ring.c
+++ b/src/ring.c
@@ -616,12 +616,31 @@ _vte_ring_append (VteRing * ring)
/**
+ * _vte_ring_drop_scrollback:
+ * @ring: a #VteRing
+ * @position: drop contents up to this point, which must be in the writable region.
+ *
+ * Drop the scrollback (offscreen contents).
+ *
+ * TODOegmont: We wouldn't need the position argument after addressing 708213#c29.
+ */
+void
+_vte_ring_drop_scrollback (VteRing * ring, gulong position)
+{
+ _vte_ring_ensure_writable (ring, position);
+
+ ring->start = ring->writable = position;
+ _vte_ring_reset_streams (ring, position);
+}
+
+
+/**
* _vte_ring_set_visible_rows:
* @ring: a #VteRing
*
* Set the number of visible rows.
* It's required to be set correctly for the alternate screen so that it
- * never hits the streams.
+ * never hits the streams. It's also required for clearing the scrollback.
*/
void
_vte_ring_set_visible_rows (VteRing *ring, gulong rows)
diff --git a/src/ring.h b/src/ring.h
index 7e6078a..58b8731 100644
--- a/src/ring.h
+++ b/src/ring.h
@@ -87,6 +87,7 @@ void _vte_ring_shrink (VteRing *ring, gulong max_len);
VteRowData *_vte_ring_insert (VteRing *ring, gulong position);
VteRowData *_vte_ring_append (VteRing *ring);
void _vte_ring_remove (VteRing *ring, gulong position);
+void _vte_ring_drop_scrollback (VteRing *ring, gulong position);
void _vte_ring_set_visible_rows (VteRing *ring, gulong rows);
void _vte_ring_rewrap (VteRing *ring, glong columns, VteVisualPosition **markers);
gboolean _vte_ring_write_contents (VteRing *ring,
diff --git a/src/vte-private.h b/src/vte-private.h
index dded036..3a40131 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -474,6 +474,7 @@ void _vte_terminal_queue_contents_changed(VteTerminal *terminal);
void _vte_terminal_emit_text_deleted(VteTerminal *terminal);
void _vte_terminal_emit_text_inserted(VteTerminal *terminal);
void _vte_terminal_cursor_down (VteTerminal *terminal);
+void _vte_terminal_drop_scrollback (VteTerminal *terminal);
void _vte_terminal_restore_cursor (VteTerminal *terminal, VteScreen *screen);
void _vte_terminal_save_cursor (VteTerminal *terminal, VteScreen *screen);
gboolean _vte_terminal_insert_char(VteTerminal *terminal, gunichar c,
diff --git a/src/vte.c b/src/vte.c
index 362aa3b..59eceec 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -3025,6 +3025,20 @@ _vte_terminal_cursor_down (VteTerminal *terminal)
}
}
+/* Drop the scrollback. */
+void
+_vte_terminal_drop_scrollback (VteTerminal *terminal)
+{
+ /* Only for normal screen; alternate screen doesn't have a scrollback. */
+ _vte_ring_drop_scrollback (terminal->pvt->normal_screen.row_data,
+ terminal->pvt->normal_screen.insert_delta);
+
+ if (terminal->pvt->screen == &terminal->pvt->normal_screen) {
+ vte_terminal_queue_adjustment_value_changed (terminal,
terminal->pvt->normal_screen.insert_delta);
+ _vte_terminal_adjust_adjustments_full (terminal);
+ }
+}
+
/* Restore cursor on a screen. */
void
_vte_terminal_restore_cursor (VteTerminal *terminal, VteScreen *screen)
diff --git a/src/vteseq.c b/src/vteseq.c
index 4d2b461..b2f4b7d 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -2470,13 +2470,14 @@ vte_sequence_handler_erase_in_display (VteTerminal *terminal, GValueArray *param
guint i;
/* The default parameter is 0. */
param = 0;
- /* Pull out a parameter. */
+ /* Pull out the first parameter. */
for (i = 0; (params != NULL) && (i < params->n_values); i++) {
value = g_value_array_get_nth(params, i);
if (!G_VALUE_HOLDS_LONG(value)) {
continue;
}
param = g_value_get_long(value);
+ break;
}
/* Clear the right area. */
switch (param) {
@@ -2495,6 +2496,10 @@ vte_sequence_handler_erase_in_display (VteTerminal *terminal, GValueArray *param
/* Clear the entire screen. */
_vte_terminal_clear_screen (terminal);
break;
+ case 3:
+ /* Drop the scrollback. */
+ _vte_terminal_drop_scrollback (terminal);
+ break;
default:
break;
}
@@ -2511,13 +2516,14 @@ vte_sequence_handler_erase_in_line (VteTerminal *terminal, GValueArray *params)
guint i;
/* The default parameter is 0. */
param = 0;
- /* Pull out a parameter. */
+ /* Pull out the first parameter. */
for (i = 0; (params != NULL) && (i < params->n_values); i++) {
value = g_value_array_get_nth(params, i);
if (!G_VALUE_HOLDS_LONG(value)) {
continue;
}
param = g_value_get_long(value);
+ break;
}
/* Clear the right area. */
switch (param) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]