support visual block mode

This commit is contained in:
Daniel Micay 2012-07-06 22:46:00 -04:00
parent 7443b8fb8b
commit 115e466615
2 changed files with 53 additions and 17 deletions

View File

@ -1,6 +1,6 @@
diff -aur vte-0.32.2-old/src/vteaccess.c vte-0.32.2/src/vteaccess.c
--- vte-0.32.2-old/src/vteaccess.c 2012-07-06 19:26:00.615978048 -0400
+++ vte-0.32.2/src/vteaccess.c 2012-07-06 19:26:52.543297289 -0400
--- vte-0.32.2-old/src/vteaccess.c 2012-07-06 22:23:20.937715584 -0400
+++ vte-0.32.2/src/vteaccess.c 2012-07-06 22:23:26.521119667 -0400
@@ -1666,7 +1666,7 @@
VTE_TERMINAL_ACCESSIBLE_PRIVATE_DATA);
xy_from_offset (priv, start_offset, &start_x, &start_y);
@ -11,8 +11,8 @@ diff -aur vte-0.32.2-old/src/vteaccess.c vte-0.32.2/src/vteaccess.c
}
diff -aur vte-0.32.2-old/src/vte.c vte-0.32.2/src/vte.c
--- vte-0.32.2-old/src/vte.c 2012-07-06 19:26:00.612644674 -0400
+++ vte-0.32.2/src/vte.c 2012-07-06 19:26:52.479963159 -0400
--- vte-0.32.2-old/src/vte.c 2012-07-06 22:23:20.934382208 -0400
+++ vte-0.32.2/src/vte.c 2012-07-06 22:31:02.140287012 -0400
@@ -14568,7 +14568,7 @@
}
@ -22,7 +22,24 @@ diff -aur vte-0.32.2-old/src/vte.c vte-0.32.2/src/vte.c
long start_col, long start_row,
long end_col, long end_row,
int start_offset, int end_offset)
@@ -14603,7 +14603,7 @@
@@ -14593,6 +14593,16 @@
}
+gboolean
+vte_terminal_get_selection_block_mode(VteTerminal *terminal) {
+ return terminal->pvt->selection_block_mode;
+}
+
+void
+vte_terminal_set_selection_block_mode(VteTerminal *terminal, gboolean block_mode) {
+ return terminal->pvt->selection_block_mode = block_mode;
+}
+
void
_vte_terminal_remove_selection(VteTerminal *terminal)
{
@@ -14603,7 +14613,7 @@
_vte_terminal_select_empty_at(VteTerminal *terminal,
long col, long row)
{
@ -31,7 +48,7 @@ diff -aur vte-0.32.2-old/src/vte.c vte-0.32.2/src/vte.c
}
static void
@@ -15293,7 +15293,7 @@
@@ -15293,7 +15303,7 @@
g_free (row_text);
g_match_info_free (match_info);
@ -40,18 +57,20 @@ diff -aur vte-0.32.2-old/src/vte.c vte-0.32.2/src/vte.c
/* Quite possibly the math here should not access adjustment directly... */
value = gtk_adjustment_get_value(terminal->adjustment);
page_size = gtk_adjustment_get_page_size(terminal->adjustment);
Only in vte-0.32.2/src: vte.gresource.xml
diff -aur vte-0.32.2-old/src/vte.h vte-0.32.2/src/vte.h
--- vte-0.32.2-old/src/vte.h 2012-07-06 19:26:00.612644674 -0400
+++ vte-0.32.2/src/vte.h 2012-07-06 19:28:06.264224798 -0400
@@ -485,6 +485,11 @@
char *vte_get_user_shell (void);
--- vte-0.32.2-old/src/vte.h 2012-07-06 22:23:20.934382208 -0400
+++ vte-0.32.2/src/vte.h 2012-07-06 22:28:20.071533871 -0400
@@ -296,6 +296,12 @@
/* simple manipulation of selection */
void vte_terminal_select_all(VteTerminal *terminal);
void vte_terminal_select_none(VteTerminal *terminal);
+void vte_terminal_select_text(VteTerminal *terminal,
+ long start_col, long start_row,
+ long end_col, long end_row,
+ int start_offset, int end_offset);
+
/* Accessors for bindings. */
#if !GTK_CHECK_VERSION (2, 91, 2)
GtkAdjustment *vte_terminal_get_adjustment(VteTerminal *terminal);
+gboolean vte_terminal_get_selection_block_mode(VteTerminal *terminal);
+void vte_terminal_set_selection_block_mode(VteTerminal *terminal, gboolean block_mode);
/* Set the terminal's size. */
void vte_terminal_set_size(VteTerminal *terminal,

View File

@ -26,7 +26,8 @@ typedef enum select_mode {
SELECT_OFF = 0,
SELECT_ON,
SELECT_VISUAL,
SELECT_VISUAL_LINE
SELECT_VISUAL_LINE,
SELECT_VISUAL_BLOCK
} select_mode;
typedef struct select_info {
@ -91,6 +92,8 @@ static void cursor_moved_cb(VteTerminal *vte, select_info *select) {
long begin = select->begin_row * n_columns + select->begin_col;
long end = end_row * n_columns + end_col;
vte_terminal_set_selection_block_mode(vte, select->mode == SELECT_VISUAL_BLOCK);
if (select->mode == SELECT_VISUAL) {
if (begin < end) {
vte_terminal_select_text(vte, select->begin_col, select->begin_row,
@ -107,6 +110,14 @@ static void cursor_moved_cb(VteTerminal *vte, select_info *select) {
vte_terminal_select_text(vte, 0, end_row,
n_columns - 1, select->begin_row, 0, 0);
}
} else if (select->mode == SELECT_VISUAL_BLOCK) {
if (begin < end) {
vte_terminal_select_text(vte, MIN(select->begin_col, end_col), select->begin_row,
MAX(select->begin_col, end_col), end_row, 0, 0);
} else {
vte_terminal_select_text(vte, MIN(select->begin_col, end_col), end_row,
MAX(select->begin_col, end_col), select->begin_row, 0, 0);
}
}
vte_terminal_copy_primary(vte);
@ -136,6 +147,12 @@ gboolean key_press_cb(VteTerminal *vte, GdkEventKey *event, search_panel_info *i
const guint modifiers = event->state & gtk_accelerator_get_default_mod_mask();
gboolean dynamic_title = FALSE, urgent_on_bell = FALSE, clickable_url = FALSE;
if (info->select.mode) {
if (modifiers == GDK_CONTROL_MASK) {
if (gdk_keyval_to_lower(event->keyval) == GDK_KEY_v) {
toggle_visual(vte, &info->select, SELECT_VISUAL_BLOCK);
}
return TRUE;
}
switch (event->keyval) {
case GDK_KEY_Left:
case GDK_KEY_h: