vte r2240 - in trunk: . src
- From: behdad svn gnome org
- To: svn-commits-list gnome org
- Subject: vte r2240 - in trunk: . src
- Date: Mon, 1 Dec 2008 02:12:05 +0000 (UTC)
Author: behdad
Date: Mon Dec 1 02:12:05 2008
New Revision: 2240
URL: http://svn.gnome.org/viewvc/vte?rev=2240&view=rev
Log:
2008-11-30 Behdad Esfahbod <behdad gnome org>
* src/vte-private.h:
* src/vte.c (vte_insert_line_internal), (vte_remove_line_internal),
(_vte_terminal_cursor_down), (_vte_terminal_insert_char),
(_vte_terminal_audible_beep), (_vte_terminal_visible_beep),
(_vte_terminal_beep), (vte_terminal_key_press):
* src/vteseq.c (vte_insert_line_internal),
(vte_remove_line_internal), (vte_unichar_strlen),
(vte_sequence_handler_bl), (vte_sequence_handler_sf),
(vte_sequence_handler_SF), (vte_sequence_handler_vb):
* src/vteseq.h:
Some code reshuffling to remove vte.c calls to vteseq.c functions.
Modified:
trunk/ChangeLog
trunk/src/vte-private.h
trunk/src/vte.c
trunk/src/vteseq.c
trunk/src/vteseq.h
Modified: trunk/src/vte-private.h
==============================================================================
--- trunk/src/vte-private.h (original)
+++ trunk/src/vte-private.h Mon Dec 1 02:12:05 2008
@@ -435,6 +435,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);
gboolean _vte_terminal_insert_char(VteTerminal *terminal, gunichar c,
gboolean force_insert_mode,
gboolean invalidate_cells);
@@ -446,6 +447,9 @@
void _vte_terminal_set_tabstop(VteTerminal *terminal, int column);
void _vte_terminal_update_insert_delta(VteTerminal *terminal);
void _vte_terminal_cleanup_tab_fragments_at_cursor (VteTerminal *terminal);
+void _vte_terminal_audible_beep(VteTerminal *terminal);
+void _vte_terminal_visible_beep(VteTerminal *terminal);
+void _vte_terminal_beep(VteTerminal *terminal);
void _vte_terminal_inline_error_message(VteTerminal *terminal, const char *format, ...) G_GNUC_PRINTF(2,3);
Modified: trunk/src/vte.c
==============================================================================
--- trunk/src/vte.c (original)
+++ trunk/src/vte.c Mon Dec 1 02:12:05 2008
@@ -359,6 +359,52 @@
return row;
}
+/* Insert a blank line at an arbitrary position. */
+static void
+vte_insert_line_internal(VteTerminal *terminal, glong position)
+{
+ VteRowData *row, *old_row;
+ old_row = terminal->pvt->free_row;
+ /* Pad out the line data to the insertion point. */
+ while (_vte_ring_next(terminal->pvt->screen->row_data) < position) {
+ if (old_row) {
+ row = _vte_reset_row_data (terminal, old_row, TRUE);
+ } else {
+ row = _vte_new_row_data_sized(terminal, TRUE);
+ }
+ old_row = _vte_ring_append(terminal->pvt->screen->row_data, row);
+ }
+ /* If we haven't inserted a line yet, insert a new one. */
+ if (old_row) {
+ row = _vte_reset_row_data (terminal, old_row, TRUE);
+ } else {
+ row = _vte_new_row_data_sized(terminal, TRUE);
+ }
+ if (_vte_ring_next(terminal->pvt->screen->row_data) >= position) {
+ old_row = _vte_ring_insert(terminal->pvt->screen->row_data,
+ position, row);
+ } else {
+ old_row =_vte_ring_append(terminal->pvt->screen->row_data, row);
+ }
+ terminal->pvt->free_row = old_row;
+}
+
+/* Remove a line at an arbitrary position. */
+static void
+vte_remove_line_internal(VteTerminal *terminal, glong position)
+{
+ if (_vte_ring_next(terminal->pvt->screen->row_data) > position) {
+ if (terminal->pvt->free_row)
+ _vte_free_row_data (terminal->pvt->free_row);
+
+ terminal->pvt->free_row = _vte_ring_remove(
+ terminal->pvt->screen->row_data,
+ position,
+ FALSE);
+ }
+}
+
+
/* Reset defaults for character insertion. */
void
_vte_terminal_set_default_attributes(VteTerminal *terminal)
@@ -2930,6 +2976,94 @@
}
}
+/* Cursor down, with scrolling. */
+void
+_vte_terminal_cursor_down (VteTerminal *terminal)
+{
+ VteRowData *row;
+ long start, end;
+ 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;
+ }
+ if (screen->cursor_current.row == end) {
+ /* Match xterm and fill to the end of row when scrolling. */
+ if (screen->fill_defaults.attr.back != VTE_DEF_BG) {
+ VteRowData *rowdata;
+ rowdata = _vte_terminal_ensure_row (terminal);
+ vte_g_array_fill (rowdata->cells,
+ &screen->fill_defaults,
+ terminal->column_count);
+ }
+
+ if (screen->scrolling_restricted) {
+ if (start == screen->insert_delta) {
+ /* Scroll this line into the scrollback
+ * buffer by inserting a line at the next
+ * line and scrolling the area up. */
+ screen->insert_delta++;
+ screen->scroll_delta++;
+ screen->cursor_current.row++;
+ /* update start and end, as they are relative
+ * to insert_delta. */
+ start++;
+ end++;
+ if (terminal->pvt->free_row) {
+ row = _vte_reset_row_data (terminal,
+ terminal->pvt->free_row,
+ FALSE);
+ } else {
+ row = _vte_new_row_data_sized(terminal, FALSE);
+ }
+ terminal->pvt->free_row = _vte_ring_insert_preserve(terminal->pvt->screen->row_data,
+ screen->cursor_current.row,
+ row);
+ /* Force the areas below the region to be
+ * redrawn -- they've moved. */
+ _vte_terminal_scroll_region(terminal, start,
+ end - start + 1, 1);
+ /* Force scroll. */
+ _vte_terminal_adjust_adjustments(terminal);
+ } else {
+ /* If we're at the bottom of the scrolling
+ * region, add a line at the top to scroll the
+ * bottom off. */
+ vte_remove_line_internal(terminal, start);
+ vte_insert_line_internal(terminal, end);
+ /* Update the display. */
+ _vte_terminal_scroll_region(terminal, start,
+ end - start + 1, -1);
+ _vte_invalidate_cells(terminal,
+ 0, terminal->column_count,
+ end - 2, 2);
+ }
+ } else {
+ /* Scroll up with history. */
+ screen->cursor_current.row++;
+ _vte_terminal_update_insert_delta(terminal);
+ }
+
+ /* Match xterm and fill the new row when scrolling. */
+ if (screen->fill_defaults.attr.back != VTE_DEF_BG) {
+ VteRowData *rowdata;
+ rowdata = _vte_terminal_ensure_row (terminal);
+ vte_g_array_fill (rowdata->cells,
+ &screen->fill_defaults,
+ terminal->column_count);
+ }
+ } else {
+ /* Otherwise, just move the cursor down. */
+ screen->cursor_current.row++;
+ }
+}
+
/* Insert a single character into the stored data array. */
gboolean
_vte_terminal_insert_char(VteTerminal *terminal, gunichar c,
@@ -2983,7 +3117,7 @@
/* Mark this line as soft-wrapped. */
row = _vte_terminal_ensure_row(terminal);
row->soft_wrapped = 1;
- _vte_sequence_handler_sf(terminal, NULL, 0, NULL);
+ _vte_terminal_cursor_down (terminal);
} else {
/* Don't wrap, stay at the rightmost column. */
col = screen->cursor_current.col =
@@ -3084,7 +3218,7 @@
screen->cursor_current.col = 0;
/* Mark this line as soft-wrapped. */
row->soft_wrapped = 1;
- _vte_sequence_handler_sf(terminal, NULL, 0, NULL);
+ _vte_terminal_cursor_down (terminal);
}
}
@@ -4594,6 +4728,49 @@
terminal->pvt->cursor_blink_tag = VTE_INVALID_SOURCE;
}
+
+void
+_vte_terminal_audible_beep(VteTerminal *terminal)
+{
+ GdkDisplay *display;
+
+ g_assert(VTE_IS_TERMINAL(terminal));
+ display = gtk_widget_get_display(&terminal->widget);
+ gdk_display_beep(display);
+}
+
+void
+_vte_terminal_visible_beep(VteTerminal *terminal)
+{
+ GtkWidget *widget;
+
+ widget = &terminal->widget;
+ if (GTK_WIDGET_REALIZED(widget)) {
+ /* Fill the screen with the default foreground color, and then
+ * repaint everything, to provide visual bell. */
+ gdk_draw_rectangle(widget->window,
+ widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
+ TRUE,
+ 0, 0,
+ widget->allocation.width, widget->allocation.height);
+ gdk_flush();
+ /* Force the repaint. */
+ _vte_invalidate_all(terminal); /* max delay of UPDATE_REPEAT_TIMEOUT */
+ }
+}
+
+void
+_vte_terminal_beep(VteTerminal *terminal)
+{
+ if (terminal->pvt->audible_bell) {
+ _vte_terminal_audible_beep (terminal);
+ }
+ if (terminal->pvt->visible_bell) {
+ _vte_terminal_visible_beep (terminal);
+ }
+}
+
+
/*
* Translate national keys with Crtl|Alt modifier
* Refactored from http://bugzilla.gnome.org/show_bug.cgi?id=375112
@@ -4667,10 +4844,7 @@
if ((terminal->pvt->screen->cursor_current.col +
(glong) terminal->pvt->bell_margin) ==
terminal->column_count) {
- _vte_sequence_handler_bl(terminal,
- "bl",
- 0,
- NULL);
+ _vte_terminal_beep (terminal);
}
}
Modified: trunk/src/vteseq.c
==============================================================================
--- trunk/src/vteseq.c (original)
+++ trunk/src/vteseq.c Mon Dec 1 02:12:05 2008
@@ -43,20 +43,6 @@
#include "vteseq-list.h"
#undef VTE_SEQUENCE_HANDLER
-/* These two handlers are accessed from vte.c */
-gboolean
-_vte_sequence_handler_bl(VteTerminal *terminal, const char *match, GQuark match_quark, GValueArray *params)
-{
- return vte_sequence_handler_bl(terminal, match, match_quark, params);
-}
-gboolean
-_vte_sequence_handler_sf(VteTerminal *terminal, const char *match, GQuark match_quark, GValueArray *params)
-{
- return vte_sequence_handler_sf(terminal, match, match_quark, params);
-}
-
-
-
/* FUNCTIONS WE USE */
@@ -103,6 +89,60 @@
} while (--final_size);
}
+/* Insert a blank line at an arbitrary position. */
+static void
+vte_insert_line_internal(VteTerminal *terminal, glong position)
+{
+ VteRowData *row, *old_row;
+ old_row = terminal->pvt->free_row;
+ /* Pad out the line data to the insertion point. */
+ while (_vte_ring_next(terminal->pvt->screen->row_data) < position) {
+ if (old_row) {
+ row = _vte_reset_row_data (terminal, old_row, TRUE);
+ } else {
+ row = _vte_new_row_data_sized(terminal, TRUE);
+ }
+ old_row = _vte_ring_append(terminal->pvt->screen->row_data, row);
+ }
+ /* If we haven't inserted a line yet, insert a new one. */
+ if (old_row) {
+ row = _vte_reset_row_data (terminal, old_row, TRUE);
+ } else {
+ row = _vte_new_row_data_sized(terminal, TRUE);
+ }
+ if (_vte_ring_next(terminal->pvt->screen->row_data) >= position) {
+ old_row = _vte_ring_insert(terminal->pvt->screen->row_data,
+ position, row);
+ } else {
+ old_row =_vte_ring_append(terminal->pvt->screen->row_data, row);
+ }
+ terminal->pvt->free_row = old_row;
+}
+
+/* Remove a line at an arbitrary position. */
+static void
+vte_remove_line_internal(VteTerminal *terminal, glong position)
+{
+ if (_vte_ring_next(terminal->pvt->screen->row_data) > position) {
+ if (terminal->pvt->free_row)
+ _vte_free_row_data (terminal->pvt->free_row);
+
+ terminal->pvt->free_row = _vte_ring_remove(
+ terminal->pvt->screen->row_data,
+ position,
+ FALSE);
+ }
+}
+
+/* Check how long a string of unichars is. Slow version. */
+static gssize
+vte_unichar_strlen(gunichar *c)
+{
+ int i;
+ for (i = 0; c[i] != 0; i++) ;
+ return i;
+}
+
@@ -190,71 +230,8 @@
g_signal_emit_by_name(terminal, "resize-window", width, height);
}
-static void
-vte_terminal_beep(VteTerminal *terminal)
-{
- GdkDisplay *display;
-
- g_assert(VTE_IS_TERMINAL(terminal));
- display = gtk_widget_get_display(&terminal->widget);
- gdk_display_beep(display);
-}
-/* Insert a blank line at an arbitrary position. */
-static void
-vte_insert_line_internal(VteTerminal *terminal, glong position)
-{
- VteRowData *row, *old_row;
- old_row = terminal->pvt->free_row;
- /* Pad out the line data to the insertion point. */
- while (_vte_ring_next(terminal->pvt->screen->row_data) < position) {
- if (old_row) {
- row = _vte_reset_row_data (terminal, old_row, TRUE);
- } else {
- row = _vte_new_row_data_sized(terminal, TRUE);
- }
- old_row = _vte_ring_append(terminal->pvt->screen->row_data, row);
- }
- /* If we haven't inserted a line yet, insert a new one. */
- if (old_row) {
- row = _vte_reset_row_data (terminal, old_row, TRUE);
- } else {
- row = _vte_new_row_data_sized(terminal, TRUE);
- }
- if (_vte_ring_next(terminal->pvt->screen->row_data) >= position) {
- old_row = _vte_ring_insert(terminal->pvt->screen->row_data,
- position, row);
- } else {
- old_row =_vte_ring_append(terminal->pvt->screen->row_data, row);
- }
- terminal->pvt->free_row = old_row;
-}
-
-/* Remove a line at an arbitrary position. */
-static void
-vte_remove_line_internal(VteTerminal *terminal, glong position)
-{
- if (_vte_ring_next(terminal->pvt->screen->row_data) > position) {
- if (terminal->pvt->free_row)
- _vte_free_row_data (terminal->pvt->free_row);
-
- terminal->pvt->free_row = _vte_ring_remove(
- terminal->pvt->screen->row_data,
- position,
- FALSE);
- }
-}
-
-/* Check how long a string of unichars is. Slow version. */
-static gssize
-vte_unichar_strlen(gunichar *c)
-{
- int i;
- for (i = 0; c[i] != 0; i++) ;
- return i;
-}
-
/* Call another function, offsetting any long arguments by the given
* increment value. */
static gboolean
@@ -965,14 +942,7 @@
GQuark match_quark,
GValueArray *params)
{
- if (terminal->pvt->audible_bell) {
- /* Feep. */
- vte_terminal_beep(terminal);
- }
- if (terminal->pvt->visible_bell) {
- /* Visual bell. */
- vte_sequence_handler_vb(terminal, match, match_quark, params);
- }
+ _vte_terminal_beep (terminal);
g_signal_emit_by_name(terminal, "beep");
return FALSE;
@@ -2188,88 +2158,8 @@
GQuark match_quark,
GValueArray *params)
{
- VteRowData *row;
- long start, end;
- 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;
- }
- if (screen->cursor_current.row == end) {
- /* Match xterm and fill to the end of row when scrolling. */
- if (screen->fill_defaults.attr.back != VTE_DEF_BG) {
- VteRowData *rowdata;
- rowdata = _vte_terminal_ensure_row (terminal);
- vte_g_array_fill (rowdata->cells,
- &screen->fill_defaults,
- terminal->column_count);
- }
-
- if (screen->scrolling_restricted) {
- if (start == screen->insert_delta) {
- /* Scroll this line into the scrollback
- * buffer by inserting a line at the next
- * line and scrolling the area up. */
- screen->insert_delta++;
- screen->scroll_delta++;
- screen->cursor_current.row++;
- /* update start and end, as they are relative
- * to insert_delta. */
- start++;
- end++;
- if (terminal->pvt->free_row) {
- row = _vte_reset_row_data (terminal,
- terminal->pvt->free_row,
- FALSE);
- } else {
- row = _vte_new_row_data_sized(terminal, FALSE);
- }
- terminal->pvt->free_row = _vte_ring_insert_preserve(terminal->pvt->screen->row_data,
- screen->cursor_current.row,
- row);
- /* Force the areas below the region to be
- * redrawn -- they've moved. */
- _vte_terminal_scroll_region(terminal, start,
- end - start + 1, 1);
- /* Force scroll. */
- _vte_terminal_adjust_adjustments(terminal);
- } else {
- /* If we're at the bottom of the scrolling
- * region, add a line at the top to scroll the
- * bottom off. */
- vte_remove_line_internal(terminal, start);
- vte_insert_line_internal(terminal, end);
- /* Update the display. */
- _vte_terminal_scroll_region(terminal, start,
- end - start + 1, -1);
- _vte_invalidate_cells(terminal,
- 0, terminal->column_count,
- end - 2, 2);
- }
- } else {
- /* Scroll up with history. */
- screen->cursor_current.row++;
- _vte_terminal_update_insert_delta(terminal);
- }
+ _vte_terminal_cursor_down (terminal);
- /* Match xterm and fill the new row when scrolling. */
- if (screen->fill_defaults.attr.back != VTE_DEF_BG) {
- VteRowData *rowdata;
- rowdata = _vte_terminal_ensure_row (terminal);
- vte_g_array_fill (rowdata->cells,
- &screen->fill_defaults,
- terminal->column_count);
- }
- } else {
- /* Otherwise, just move the cursor down. */
- screen->cursor_current.row++;
- }
return FALSE;
}
@@ -2280,6 +2170,7 @@
GQuark match_quark,
GValueArray *params)
{
+ /* XXX implment this directly in _vte_terminal_cursor_down */
return vte_sequence_handler_multiple(terminal, match, match_quark,
params, vte_sequence_handler_sf);
}
@@ -2662,21 +2553,7 @@
GQuark match_quark,
GValueArray *params)
{
- GtkWidget *widget;
-
- widget = &terminal->widget;
- if (GTK_WIDGET_REALIZED(widget)) {
- /* Fill the screen with the default foreground color, and then
- * repaint everything, to provide visual bell. */
- gdk_draw_rectangle(widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- TRUE,
- 0, 0,
- widget->allocation.width, widget->allocation.height);
- gdk_flush();
- /* Force the repaint. */
- _vte_invalidate_all(terminal); /* max delay of UPDATE_REPEAT_TIMEOUT */
- }
+ _vte_terminal_visible_beep (terminal);
return FALSE;
}
Modified: trunk/src/vteseq.h
==============================================================================
--- trunk/src/vteseq.h (original)
+++ trunk/src/vteseq.h Mon Dec 1 02:12:05 2008
@@ -32,8 +32,4 @@
VteTerminalSequenceHandler _vte_sequence_get_handler (const char *code);
-
-gboolean _vte_sequence_handler_bl(VteTerminal *terminal, const char *match, GQuark match_quark, GValueArray *params);
-gboolean _vte_sequence_handler_sf(VteTerminal *terminal, const char *match, GQuark match_quark, GValueArray *params);
-
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]