[vte/vte-next: 148/223] Move row and column count to VteBuffer
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/vte-next: 148/223] Move row and column count to VteBuffer
- Date: Wed, 22 Jun 2011 21:01:02 +0000 (UTC)
commit e2994a176b620db6917d972921802d3637563e8c
Author: Christian Persch <chpe gnome org>
Date: Sat Jun 11 16:25:52 2011 +0200
Move row and column count to VteBuffer
doc/reference/vte-sections.txt | 6 ++--
src/vte.c | 64 +++++++++++++++++++++------------------
src/vte.h | 6 ----
src/vteaccess.c | 10 ++++--
src/vteapp.c | 16 ++++++----
src/vtebuffer.h | 8 +++++
6 files changed, 61 insertions(+), 49 deletions(-)
---
diff --git a/doc/reference/vte-sections.txt b/doc/reference/vte-sections.txt
index ea4bfed..2cf4735 100644
--- a/doc/reference/vte-sections.txt
+++ b/doc/reference/vte-sections.txt
@@ -17,7 +17,6 @@ vte_terminal_copy_clipboard
vte_terminal_paste_clipboard
vte_terminal_copy_primary
vte_terminal_paste_primary
-vte_terminal_set_size
vte_terminal_set_font_scale
vte_terminal_get_font_scale
vte_terminal_set_audible_bell
@@ -85,8 +84,6 @@ VTE_TERMINAL_CLASS
<SUBSECTION Binding Accessors>
vte_terminal_get_char_height
vte_terminal_get_char_width
-vte_terminal_get_column_count
-vte_terminal_get_row_count
<SUBSECTION Private>
VteCharAttributes
@@ -114,6 +111,9 @@ vte_buffer_get_icon_title
vte_buffer_get_window_title
vte_buffer_get_status_line
vte_buffer_write_contents_sync
+vte_buffer_set_size
+vte_buffer_get_column_count
+vte_buffer_get_row_count
<SUBSECTION Standard>
VTE_TYPE_BUFFER
diff --git a/src/vte.c b/src/vte.c
index d503ae6..72004d3 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -7288,48 +7288,51 @@ vte_terminal_refresh_size(VteTerminal *terminal)
}
/**
- * vte_terminal_set_size:
- * @terminal: a #VteTerminal
+ * vte_buffer_set_size:
+ * @buffer: a #VteBuffer
* @columns: the desired number of columns
* @rows: the desired number of rows
*
- * Attempts to change the terminal's size in terms of rows and columns. If
+ * Attempts to change the buffer's size in terms of rows and columns. If
* the attempt succeeds, the widget will resize itself to the proper size.
*/
void
-vte_terminal_set_size(VteTerminal *terminal, glong columns, glong rows)
+vte_buffer_set_size(VteBuffer *buffer, glong columns, glong rows)
{
+ VteTerminal *terminal;
glong old_columns, old_rows;
- g_return_if_fail(VTE_IS_TERMINAL(terminal));
+ g_return_if_fail(VTE_IS_BUFFER(buffer));
+
+ terminal = buffer->pvt->terminal;
_vte_debug_print(VTE_DEBUG_MISC,
"Setting PTY size to %ldx%ld.\n",
columns, rows);
- old_rows = terminal->pvt->row_count;
- old_columns = terminal->pvt->column_count;
+ old_rows = buffer->pvt->row_count;
+ old_columns = buffer->pvt->column_count;
- if (terminal->pvt->pty != NULL) {
+ if (buffer->pvt->pty != NULL) {
GError *error = NULL;
- /* Try to set the terminal size, and read it back,
+ /* Try to set the buffer size, and read it back,
* in case something went awry.
*/
- if (!vte_pty_set_size(terminal->pvt->pty, rows, columns, &error)) {
+ if (!vte_pty_set_size(buffer->pvt->pty, rows, columns, &error)) {
g_warning("%s\n", error->message);
g_error_free(error);
}
vte_terminal_refresh_size(terminal);
} else {
- terminal->pvt->row_count = rows;
- terminal->pvt->column_count = columns;
+ buffer->pvt->row_count = rows;
+ buffer->pvt->column_count = columns;
}
- if (old_rows != terminal->pvt->row_count || old_columns != terminal->pvt->column_count) {
- VteScreen *screen = terminal->pvt->screen;
+ if (old_rows != buffer->pvt->row_count || old_columns != buffer->pvt->column_count) {
+ VteScreen *screen = buffer->pvt->screen;
glong visible_rows = MIN (old_rows, _vte_ring_length (screen->row_data));
- if (terminal->pvt->row_count < visible_rows) {
- glong delta = visible_rows - terminal->pvt->row_count;
+ if (buffer->pvt->row_count < visible_rows) {
+ glong delta = visible_rows - buffer->pvt->row_count;
screen->insert_delta += delta;
vte_terminal_queue_adjustment_value_changed (
terminal,
@@ -7709,7 +7712,7 @@ vte_terminal_init(VteTerminal *terminal)
* be set up properly first. */
pvt->pty = NULL;
vte_buffer_set_emulation(buffer, NULL);
- vte_terminal_set_size(terminal,
+ vte_buffer_set_size(buffer,
pvt->default_column_count,
pvt->default_row_count);
pvt->pty_input_source = 0;
@@ -7851,6 +7854,7 @@ static void
vte_terminal_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
VteTerminal *terminal;
+ VteBuffer *buffer;
glong width, height;
GtkAllocation current_allocation;
gboolean repaint, update_scrollback;
@@ -7859,6 +7863,7 @@ vte_terminal_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
"vte_terminal_size_allocate()\n");
terminal = VTE_TERMINAL(widget);
+ buffer = terminal->term_pvt->buffer;
width = (allocation->width - (terminal->pvt->padding.left + terminal->pvt->padding.right)) /
terminal->pvt->char_width;
@@ -7889,7 +7894,7 @@ vte_terminal_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
VteScreen *screen = terminal->pvt->screen;
/* Set the size of the pseudo-terminal. */
- vte_terminal_set_size(terminal, width, height);
+ vte_buffer_set_size(buffer, width, height);
/* Adjust scrolling area in case our boundaries have just been
* redefined to be invalid. */
@@ -12382,30 +12387,29 @@ vte_terminal_get_char_height(VteTerminal *terminal)
}
/**
- * vte_terminal_get_row_count:
- * @terminal: a #VteTerminal
- *
+ * vte_buffer_get_row_count:
+ * @buffer: a #VteBuffer
*
* Returns: the number of rows
*/
glong
-vte_terminal_get_row_count(VteTerminal *terminal)
+vte_buffer_get_row_count(VteBuffer *buffer)
{
- g_return_val_if_fail(VTE_IS_TERMINAL(terminal), -1);
- return terminal->pvt->row_count;
+ g_return_val_if_fail(VTE_IS_BUFFER(buffer), -1);
+ return buffer->pvt->row_count;
}
/**
- * vte_terminal_get_column_count:
- * @terminal: a #VteTerminal
+ * vte_buffer_get_column_count:
+ * @buffer: a #VteBuffer
*
* Returns: the number of columns
*/
glong
-vte_terminal_get_column_count(VteTerminal *terminal)
+vte_buffer_get_column_count(VteBuffer *buffer)
{
- g_return_val_if_fail(VTE_IS_TERMINAL(terminal), -1);
- return terminal->pvt->column_count;
+ g_return_val_if_fail(VTE_IS_BUFFER(buffer), -1);
+ return buffer->pvt->column_count;
}
/**
@@ -12513,7 +12517,7 @@ vte_terminal_set_pty(VteTerminal *terminal,
fcntl(pty_master, F_SETFL, flags | O_NONBLOCK);
}
- vte_terminal_set_size(terminal,
+ vte_buffer_set_size(terminal->term_pvt->buffer,
terminal->pvt->column_count,
terminal->pvt->row_count);
diff --git a/src/vte.h b/src/vte.h
index be5b1ac..be9bde1 100644
--- a/src/vte.h
+++ b/src/vte.h
@@ -174,10 +174,6 @@ void vte_terminal_paste_primary(VteTerminal *terminal);
void vte_terminal_select_all(VteTerminal *terminal);
void vte_terminal_select_none(VteTerminal *terminal);
-/* Set the terminal's size. */
-void vte_terminal_set_size(VteTerminal *terminal,
- glong columns, glong rows);
-
void vte_terminal_set_font_scale(VteTerminal *terminal,
gdouble scale);
gdouble vte_terminal_get_font_scale(VteTerminal *terminal);
@@ -269,8 +265,6 @@ char *vte_get_user_shell (void);
glong vte_terminal_get_char_width(VteTerminal *terminal);
glong vte_terminal_get_char_height(VteTerminal *terminal);
-glong vte_terminal_get_row_count(VteTerminal *terminal);
-glong vte_terminal_get_column_count(VteTerminal *terminal);
G_END_DECLS
diff --git a/src/vteaccess.c b/src/vteaccess.c
index 9c26a8f..b0cc790 100644
--- a/src/vteaccess.c
+++ b/src/vteaccess.c
@@ -546,7 +546,7 @@ vte_terminal_accessible_text_scrolled(VteTerminal *terminal,
VTE_TERMINAL_ACCESSIBLE_PRIVATE_DATA);
g_assert(priv != NULL);
- row_count = vte_terminal_get_row_count(terminal);
+ row_count = vte_buffer_get_row_count(vte_terminal_get_buffer(terminal));
if (((howmuch < 0) && (howmuch <= -row_count)) ||
((howmuch > 0) && (howmuch >= row_count))) {
/* All of the text was removed. */
@@ -1775,6 +1775,7 @@ vte_terminal_accessible_set_size(AtkComponent *component,
gint width, gint height)
{
VteTerminal *terminal;
+ VteBuffer *buffer;
long columns, rows;
GtkWidget *widget;
@@ -1783,15 +1784,16 @@ vte_terminal_accessible_set_size(AtkComponent *component,
return FALSE;
}
terminal = VTE_TERMINAL(widget);
+ buffer = vte_terminal_get_buffer(terminal);
/* If the size is an exact multiple of the cell size, use that,
* otherwise round down. */
if (!_vte_terminal_size_to_grid_size(terminal, width, height, &columns, &rows))
return FALSE;
- vte_terminal_set_size(terminal, columns, rows);
- return (vte_terminal_get_row_count (terminal) == rows) &&
- (vte_terminal_get_column_count (terminal) == columns);
+ vte_buffer_set_size(buffer, columns, rows);
+ return (vte_buffer_get_row_count (buffer) == rows) &&
+ (vte_buffer_get_column_count (buffer) == columns);
}
diff --git a/src/vteapp.c b/src/vteapp.c
index 6b2d9d7..fdc74df 100644
--- a/src/vteapp.c
+++ b/src/vteapp.c
@@ -300,20 +300,22 @@ static void
resize_window(GtkWidget *widget, guint width, guint height, gpointer data)
{
VteTerminal *terminal;
+ VteBuffer *buffer;
if ((GTK_IS_WINDOW(data)) && (width >= 2) && (height >= 2)) {
gint owidth, oheight, char_width, char_height, column_count, row_count;
GtkBorder padding;
terminal = VTE_TERMINAL(widget);
+ buffer = vte_terminal_get_buffer(terminal);
gtk_window_get_size(GTK_WINDOW(data), &owidth, &oheight);
/* Take into account border overhead. */
char_width = vte_terminal_get_char_width (terminal);
char_height = vte_terminal_get_char_height (terminal);
- column_count = vte_terminal_get_column_count (terminal);
- row_count = vte_terminal_get_row_count (terminal);
+ column_count = vte_buffer_get_column_count (buffer);
+ row_count = vte_buffer_get_row_count (buffer);
gtk_style_context_get_padding(gtk_widget_get_style_context(widget),
gtk_widget_get_state_flags(widget),
&padding);
@@ -342,14 +344,16 @@ static void
adjust_font_size(GtkWidget *widget, gpointer data, gdouble factor)
{
VteTerminal *terminal;
+ VteBuffer *buffer;
gdouble scale;
glong char_width, char_height;
gint columns, rows, owidth, oheight;
/* Read the screen dimensions in cells. */
terminal = VTE_TERMINAL(widget);
- columns = vte_terminal_get_column_count(terminal);
- rows = vte_terminal_get_row_count(terminal);
+ buffer = vte_terminal_get_buffer(terminal);
+ columns = vte_buffer_get_column_count(buffer);
+ rows = vte_buffer_get_row_count(buffer);
/* Take into account padding and border overhead. */
gtk_window_get_size(GTK_WINDOW(data), &owidth, &oheight);
@@ -1183,8 +1187,8 @@ main(int argc, char **argv)
* size not its natural size, so we need to set the right default size
* explicitly */
gtk_window_set_default_geometry (GTK_WINDOW (window),
- vte_terminal_get_column_count (terminal),
- vte_terminal_get_row_count (terminal));
+ vte_buffer_get_column_count (buffer),
+ vte_buffer_get_row_count (buffer));
}
gtk_widget_show_all(window);
diff --git a/src/vtebuffer.h b/src/vtebuffer.h
index 6e1789f..c28e464 100644
--- a/src/vtebuffer.h
+++ b/src/vtebuffer.h
@@ -107,6 +107,14 @@ const char *vte_buffer_get_icon_title (VteBuffer *buffer);
const char *vte_buffer_get_status_line (VteBuffer *buffer);
+void vte_buffer_set_size (VteBuffer *buffer,
+ glong columns,
+ glong rows);
+
+glong vte_buffer_get_row_count (VteBuffer *buffer);
+
+glong vte_buffer_get_column_count (VteBuffer *buffer);
+
gboolean vte_buffer_write_contents_sync (VteBuffer *buffer,
GOutputStream *stream,
VteWriteFlags flags,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]