]> git.pld-linux.org Git - packages/vte.git/blob - vte-atktextselection.patch
- R: ncurses-devel in -devel
[packages/vte.git] / vte-atktextselection.patch
1 diff -aurN vte-0.11.13.orig/src/vte.c vte-0.11.13/src/vte.c
2 --- vte-0.11.13.orig/src/vte.c  2005-03-14 15:43:47.000000000 +0100
3 +++ vte-0.11.13/src/vte.c       2005-04-15 21:18:40.000000000 +0200
4 @@ -15821,6 +15821,80 @@
5         terminal->pvt->accessible_emit = TRUE;
6  }
7  
8 +
9 +char *
10 +_vte_terminal_get_selection(VteTerminal *terminal)
11 +{
12 +       g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
13 +
14 +       return g_strdup (terminal->pvt->selection);
15 +}
16 +
17 +void 
18 +_vte_terminal_get_start_selection(VteTerminal *terminal, long *x, long *y)
19 +{
20 +       struct selection_cell_coords ss;
21 +
22 +       g_return_if_fail(VTE_IS_TERMINAL(terminal));
23 +
24 +       ss = terminal->pvt->selection_start;
25 +       
26 +       if (x) {
27 +               *x = ss.x;
28 +       }
29 +
30 +       if (y) {
31 +               *y = ss.y;
32 +       }
33 +}
34 +
35 +void 
36 +_vte_terminal_get_end_selection(VteTerminal *terminal, long *x, long *y)
37 +{
38 +       struct selection_cell_coords se;
39 +
40 +       g_return_if_fail(VTE_IS_TERMINAL(terminal));
41 +
42 +       se = terminal->pvt->selection_end;
43 +       
44 +       if (x) {
45 +               *x = se.x;
46 +       }
47 +
48 +       if (y) {
49 +               *y = se.y;
50 +       }
51 +}
52 +
53 +void 
54 +_vte_terminal_select_text(VteTerminal *terminal, long start_x, long start_y, long end_x, long end_y, int start_offset, int end_offset)
55 +{
56 +       g_return_if_fail(VTE_IS_TERMINAL(terminal));
57 +
58 +       terminal->pvt->selection_type = selection_type_char;
59 +       terminal->pvt->has_selection = TRUE;
60 +       terminal->pvt->selecting_had_delta = TRUE;
61 +       terminal->pvt->selection_start.x = start_x;
62 +       terminal->pvt->selection_start.y = start_y;
63 +       terminal->pvt->selection_end.x = end_x;
64 +       terminal->pvt->selection_end.y = end_y;
65 +       vte_terminal_copy(terminal,
66 +                         GDK_SELECTION_PRIMARY);
67 +       vte_invalidate_cells (terminal, 
68 +                             0,
69 +                             terminal->column_count,
70 +                             MIN (start_y, end_y),
71 +                             ABS (start_y - end_y) + 1);
72 +
73 +       vte_terminal_emit_selection_changed(terminal);
74 +}
75 +
76 +void 
77 +_vte_terminal_remove_selection(VteTerminal *terminal)
78 +{
79 +       vte_terminal_deselect_all (terminal);
80 +}
81 +
82  static gboolean display_timeout (gpointer data);
83  static gboolean coalesce_timeout (gpointer data);
84  
85 diff -aurN vte-0.11.13.orig/src/vteaccess.c vte-0.11.13/src/vteaccess.c
86 --- vte-0.11.13.orig/src/vteaccess.c    2005-03-09 12:24:56.000000000 +0100
87 +++ vte-0.11.13/src/vteaccess.c 2005-04-15 21:13:33.000000000 +0200
88 @@ -150,7 +150,7 @@
89                 }
90         }
91         if (i == priv->snapshot_linebreaks->len) {
92 -               if (offset < priv->snapshot_characters->len) {
93 +               if (offset <= priv->snapshot_characters->len) {
94                         cur_x = offset - cur_offset;
95                         cur_y = i - 1;
96                 }
97 @@ -735,6 +735,16 @@
98  }
99  
100  static void
101 +vte_terminal_accessible_selection_changed (VteTerminal *terminal,
102 +                                          gpointer data)
103 +{
104 +       g_return_if_fail(VTE_IS_TERMINAL_ACCESSIBLE(data));
105 +       g_return_if_fail(VTE_IS_TERMINAL(terminal));
106 +
107 +       g_signal_emit_by_name (data, "text_selection_changed");
108 +}
109 +
110 +static void
111  vte_terminal_initialize (AtkObject *obj, gpointer data)
112  {
113         VteTerminal *terminal;
114 @@ -777,6 +787,9 @@
115         g_signal_connect(G_OBJECT(terminal), "visibility-notify-event",
116                          GTK_SIGNAL_FUNC(vte_terminal_accessible_visibility_notify),
117                          obj);
118 +       g_signal_connect(G_OBJECT(terminal), "selection-changed",
119 +                        GTK_SIGNAL_FUNC(vte_terminal_accessible_selection_changed),
120 +                        obj);
121  
122         if (GTK_IS_WIDGET((GTK_WIDGET(terminal))->parent)) {
123                 parent = gtk_widget_get_accessible((GTK_WIDGET(terminal))->parent);
124 @@ -1382,55 +1395,136 @@
125  static gint
126  vte_terminal_accessible_get_n_selections(AtkText *text)
127  {
128 -       g_return_val_if_fail(VTE_IS_TERMINAL_ACCESSIBLE(text), 0);
129 +       GtkWidget *widget;
130 +       VteTerminal *terminal;
131 +
132 +       g_return_val_if_fail(VTE_IS_TERMINAL_ACCESSIBLE(text), -1);
133         vte_terminal_accessible_update_private_data_if_needed(ATK_OBJECT(text),
134                                                               NULL, NULL);
135 -       /* FIXME? */
136 -       return 0;
137 +
138 +       widget = GTK_ACCESSIBLE(text)->widget;
139 +       if (widget == NULL) {
140 +               /* State is defunct */
141 +               return -1;
142 +       }
143 +       g_return_val_if_fail (VTE_IS_TERMINAL (widget), -1);
144 +       terminal = VTE_TERMINAL (widget);
145 +       return (vte_terminal_get_has_selection (terminal)) ? 1 : 0;
146  }
147  
148  static gchar *
149  vte_terminal_accessible_get_selection(AtkText *text, gint selection_number,
150                                       gint *start_offset, gint *end_offset)
151  {
152 +       GtkWidget *widget;
153 +       VteTerminal *terminal;
154 +       VteTerminalAccessiblePrivate *priv;
155 +       long start_x, start_y, end_x, end_y;
156 +
157         g_return_val_if_fail(VTE_IS_TERMINAL_ACCESSIBLE(text), NULL);
158         vte_terminal_accessible_update_private_data_if_needed(ATK_OBJECT(text),
159                                                               NULL, NULL);
160 -       /* FIXME? */
161 -       return NULL;
162 +       widget = GTK_ACCESSIBLE(text)->widget;
163 +       if (widget == NULL) {
164 +               /* State is defunct */
165 +               return NULL;
166 +       }
167 +       g_return_val_if_fail (VTE_IS_TERMINAL (widget), NULL);
168 +       terminal = VTE_TERMINAL (widget);
169 +       if (!vte_terminal_get_has_selection (terminal)) {
170 +               return NULL;
171 +       }
172 +       if (selection_number != 0) {
173 +               return NULL;
174 +       }
175 +
176 +       priv = g_object_get_data(G_OBJECT(text),
177 +                                VTE_TERMINAL_ACCESSIBLE_PRIVATE_DATA);
178 +       _vte_terminal_get_start_selection (terminal, &start_x, &start_y);
179 +       *start_offset = offset_from_xy (priv, start_x, start_y);
180 +       _vte_terminal_get_end_selection (terminal, &end_x, &end_y);
181 +       *end_offset = offset_from_xy (priv, end_x, end_y);
182 +       return _vte_terminal_get_selection (terminal);
183  }
184  
185  static gboolean
186  vte_terminal_accessible_add_selection(AtkText *text,
187                                       gint start_offset, gint end_offset)
188  {
189 +       GtkWidget *widget;
190 +       VteTerminal *terminal;
191 +       VteTerminalAccessiblePrivate *priv;
192 +       gint start_x, start_y, end_x, end_y;
193 +
194         g_return_val_if_fail(VTE_IS_TERMINAL_ACCESSIBLE(text), FALSE);
195         vte_terminal_accessible_update_private_data_if_needed(ATK_OBJECT(text),
196                                                               NULL, NULL);
197 -       /* FIXME? */
198 -       return FALSE;
199 +       widget = GTK_ACCESSIBLE(text)->widget;
200 +       if (widget == NULL) {
201 +               /* State is defunct */
202 +               return FALSE;
203 +       }
204 +       g_return_val_if_fail (VTE_IS_TERMINAL (widget), FALSE);
205 +       terminal = VTE_TERMINAL (widget);
206 +       g_return_val_if_fail (!vte_terminal_get_has_selection (terminal), FALSE);
207 +       priv = g_object_get_data(G_OBJECT(text),
208 +                                VTE_TERMINAL_ACCESSIBLE_PRIVATE_DATA);
209 +       xy_from_offset (priv, start_offset, &start_x, &start_y);
210 +       xy_from_offset (priv, end_offset, &end_x, &end_y);
211 +       _vte_terminal_select_text (terminal, start_x, start_y, end_x, end_y, start_offset, end_offset);
212 +       return TRUE;
213  }
214  
215  static gboolean
216  vte_terminal_accessible_remove_selection(AtkText *text,
217                                          gint selection_number)
218  {
219 +       GtkWidget *widget;
220 +       VteTerminal *terminal;
221 +
222         g_return_val_if_fail(VTE_IS_TERMINAL_ACCESSIBLE(text), FALSE);
223         vte_terminal_accessible_update_private_data_if_needed(ATK_OBJECT(text),
224                                                               NULL, NULL);
225 -       /* FIXME? */
226 -       return FALSE;
227 +       widget = GTK_ACCESSIBLE(text)->widget;
228 +       if (widget == NULL) {
229 +               /* State is defunct */
230 +               return FALSE;
231 +       }
232 +       g_return_val_if_fail (VTE_IS_TERMINAL (widget), FALSE);
233 +       terminal = VTE_TERMINAL (widget);
234 +       if (selection_number == 0 && vte_terminal_get_has_selection (terminal)) {
235 +               _vte_terminal_remove_selection (terminal);
236 +               return TRUE;
237 +       } else {
238 +               return FALSE;
239 +       }
240  }
241  
242  static gboolean
243  vte_terminal_accessible_set_selection(AtkText *text, gint selection_number,
244                                       gint start_offset, gint end_offset)
245  {
246 +       GtkWidget *widget;
247 +       VteTerminal *terminal;
248 +
249         g_return_val_if_fail(VTE_IS_TERMINAL_ACCESSIBLE(text), FALSE);
250         vte_terminal_accessible_update_private_data_if_needed(ATK_OBJECT(text),
251                                                               NULL, NULL);
252 -       /* FIXME? */
253 -       return FALSE;
254 +       widget = GTK_ACCESSIBLE(text)->widget;
255 +       if (widget == NULL) {
256 +               /* State is defunct */
257 +               return FALSE;
258 +       }
259 +       g_return_val_if_fail (VTE_IS_TERMINAL (widget), FALSE);
260 +       terminal = VTE_TERMINAL (widget);
261 +       if (selection_number != 0) {
262 +               return FALSE;
263 +       }
264 +       if (vte_terminal_get_has_selection (terminal)) {
265 +               _vte_terminal_remove_selection (terminal);
266 +       }
267 +
268 +       return vte_terminal_accessible_add_selection (text, start_offset, end_offset);
269  }
270  
271  static gboolean
272 @@ -1519,6 +1613,9 @@
273         *x = 0;
274         *y = 0;
275         widget = (GTK_ACCESSIBLE(component))->widget;
276 +       if (widget == NULL) {
277 +               return;
278 +       }
279         if (!GTK_WIDGET_REALIZED(widget)) {
280                 return;
281         }
282 @@ -1543,6 +1640,9 @@
283         *width = 0;
284         *height = 0;
285         widget = (GTK_ACCESSIBLE(component))->widget;
286 +       if (widget == NULL) {
287 +               return;
288 +       }
289         if (!GTK_WIDGET_REALIZED(widget)) {
290                 return;
291         }
292 @@ -1575,7 +1675,12 @@
293  {
294         VteTerminal *terminal;
295         gint columns, rows, xpad, ypad;
296 -       terminal = VTE_TERMINAL((GTK_ACCESSIBLE(component))->widget);
297 +       GtkWidget *widget;
298 +       widget = GTK_ACCESSIBLE(component)->widget;
299 +       if (widget == NULL) {
300 +               return FALSE;
301 +       }
302 +       terminal = VTE_TERMINAL(widget);
303         vte_terminal_get_padding(terminal, &xpad, &ypad);
304         /* If the size is an exact multiple of the cell size, use that,
305          * otherwise round down. */
306 @@ -1599,6 +1704,9 @@
307  {
308         GtkWidget *widget;
309         widget = (GTK_ACCESSIBLE(component))->widget;
310 +       if (widget == NULL) {
311 +               return FALSE;
312 +       }
313         if (GTK_WIDGET_HAS_FOCUS(widget)) {
314                 return TRUE;
315         }
316 diff -aurN vte-0.11.13.orig/src/vteint.h vte-0.11.13/src/vteint.h
317 --- vte-0.11.13.orig/src/vteint.h       2003-06-16 23:16:33.000000000 +0200
318 +++ vte-0.11.13/src/vteint.h    2005-04-15 21:13:33.000000000 +0200
319 @@ -26,6 +26,11 @@
320  G_BEGIN_DECLS
321  
322  void _vte_terminal_accessible_ref(VteTerminal *terminal);
323 +char* _vte_terminal_get_selection(VteTerminal *terminal);
324 +void _vte_terminal_get_start_selection(VteTerminal *terminal, long *x, long *y);
325 +void _vte_terminal_get_end_selection(VteTerminal *terminal, long *x, long *y);
326 +void _vte_terminal_select_text(VteTerminal *terminal, long start_x, long start_y, long end_x, long end_y, int start_offset, int end_offset);
327 +void _vte_terminal_remove_selection(VteTerminal *terminal);
328  
329  G_END_DECLS
330  
This page took 0.064738 seconds and 3 git commands to generate.