AtkText -> vte_terminal_select_text

vte requires a patch to expose this for now, but it's the only way to do
this since AtkText is completely broken
This commit is contained in:
Daniel Micay 2012-07-06 19:39:07 -04:00
parent 4ed94191a9
commit 8bb2c476df
3 changed files with 68 additions and 17 deletions

View File

@ -6,7 +6,8 @@ unset) and then falls back to ``$XDG_CONFIG_DIRS``.
DEPENDENCIES DEPENDENCIES
============ ============
A vte version >= 0.30. A vte version >= 0.30. A patch is currently required to expose the
``vte-terminal-select-text`` function which is used for keyboard selection.
KEYBINDINGS KEYBINDINGS
=========== ===========
@ -46,12 +47,7 @@ TODO
* scrollback search needs to be improved upstream [1]_ * scrollback search needs to be improved upstream [1]_
* expose keybindings in ``termite.cfg`` * expose keybindings in ``termite.cfg``
TEXT SELECTION * text selection needs to be extended to more than just the basic
-------------- ``h``/``j``/``k``/``l``
* _vte_terminal_select_text would be perfect for extending this, but it isn't
exposed in the API
* does not currently work in ncurses applications
* needs to be extended to more than just the basic ``h``/``j``/``k``/``l``
.. [1] https://bugzilla.gnome.org/show_bug.cgi?id=627886 .. [1] https://bugzilla.gnome.org/show_bug.cgi?id=627886

57
expose_select_text.patch Normal file
View File

@ -0,0 +1,57 @@
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
@@ -1666,7 +1666,7 @@
VTE_TERMINAL_ACCESSIBLE_PRIVATE_DATA);
xy_from_offset (priv, start_offset, &start_x, &start_y);
xy_from_offset (priv, end_offset, &end_x, &end_y);
- _vte_terminal_select_text (terminal, start_x, start_y, end_x, end_y, start_offset, end_offset);
+ vte_terminal_select_text (terminal, start_x, start_y, end_x, end_y, start_offset, end_offset);
return TRUE;
}
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
@@ -14568,7 +14568,7 @@
}
void
-_vte_terminal_select_text(VteTerminal *terminal,
+vte_terminal_select_text(VteTerminal *terminal,
long start_col, long start_row,
long end_col, long end_row,
int start_offset, int end_offset)
@@ -14603,7 +14603,7 @@
_vte_terminal_select_empty_at(VteTerminal *terminal,
long col, long row)
{
- _vte_terminal_select_text(terminal, col, row, col - 1, row, 0, 0);
+ vte_terminal_select_text(terminal, col, row, col - 1, row, 0, 0);
}
static void
@@ -15293,7 +15293,7 @@
g_free (row_text);
g_match_info_free (match_info);
- _vte_terminal_select_text (terminal, start_col, start_row, end_col, end_row, 0, 0);
+ vte_terminal_select_text (terminal, start_col, start_row, end_col, end_row, 0, 0);
/* 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);
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);
+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);

View File

@ -6,7 +6,6 @@
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <vte/vte.h> #include <vte/vte.h>
#include <vte/vteaccess.h>
#ifndef __GNUC__ #ifndef __GNUC__
# define __attribute__(x) # define __attribute__(x)
@ -30,9 +29,9 @@ typedef enum select_mode {
} select_mode; } select_mode;
typedef struct select_info { typedef struct select_info {
AtkText *text;
select_mode mode; select_mode mode;
int begin; long begin_col;
long begin_row;
} select_info; } select_info;
typedef struct search_panel_info { typedef struct search_panel_info {
@ -83,11 +82,10 @@ static void cursor_moved_cb(VteTerminal *vte, select_info *select) {
vte_terminal_select_none(vte); vte_terminal_select_none(vte);
int offset = atk_text_get_caret_offset(select->text); long end_row, end_col;
vte_terminal_get_cursor_position(vte, &end_col, &end_row);
atk_text_add_selection(select->text, vte_terminal_select_text(vte, select->begin_col, select->begin_row, end_col, end_row, 0, 0);
MIN(select->begin, offset),
MAX(select->begin, offset));
vte_terminal_copy_primary(vte); vte_terminal_copy_primary(vte);
} }
@ -108,7 +106,7 @@ static void toggle_visual(VteTerminal *vte, select_info *select) {
vte_terminal_select_none(vte); vte_terminal_select_none(vte);
} else { } else {
select->mode = SELECT_VISUAL; select->mode = SELECT_VISUAL;
select->begin = atk_text_get_caret_offset(select->text); vte_terminal_get_cursor_position(vte, &select->begin_col, &select->begin_row);
} }
} }
@ -641,7 +639,7 @@ int main(int argc, char **argv) {
gtk_container_add(GTK_CONTAINER(overlay), vte); gtk_container_add(GTK_CONTAINER(overlay), vte);
gtk_container_add(GTK_CONTAINER(window), overlay); gtk_container_add(GTK_CONTAINER(window), overlay);
select_info select = {ATK_TEXT(vte_terminal_accessible_new(VTE_TERMINAL(vte))), SELECT_OFF, 0}; select_info select = {SELECT_OFF, 0, 0};
search_panel_info info = {vte, entry, alignment, OVERLAY_HIDDEN, select}; search_panel_info info = {vte, entry, alignment, OVERLAY_HIDDEN, select};
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);