annotate finch/libgnt/gntentry.c @ 30246:3fdb8ef0fec7

Whoops.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Mon, 05 Jul 2010 15:03:28 +0000
parents aaec35719201
children 7c871249318b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17928
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 16899
diff changeset
1 /**
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 16899
diff changeset
2 * GNT - The GLib Ncurses Toolkit
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 16899
diff changeset
3 *
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 16899
diff changeset
4 * GNT is the legal property of its developers, whose names are too numerous
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 16899
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 16899
diff changeset
6 * source distribution.
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 16899
diff changeset
7 *
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 16899
diff changeset
8 * This library is free software; you can redistribute it and/or modify
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 16899
diff changeset
9 * it under the terms of the GNU General Public License as published by
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 16899
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 16899
diff changeset
11 * (at your option) any later version.
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 16899
diff changeset
12 *
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 16899
diff changeset
13 * This program is distributed in the hope that it will be useful,
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 16899
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 16899
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 16899
diff changeset
16 * GNU General Public License for more details.
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 16899
diff changeset
17 *
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 16899
diff changeset
18 * You should have received a copy of the GNU General Public License
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 16899
diff changeset
19 * along with this program; if not, write to the Free Software
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18873
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
17928
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 16899
diff changeset
21 */
8410511f4dbb applied changes from 016401bd409e6229fae0ab1e80d9fef9365511b3
Eric Polino <aluink@pidgin.im>
parents: 16899
diff changeset
22
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 #include <ctype.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 #include <string.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25
28604
a18f421696dc Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28454
diff changeset
26 #include "gntinternal.h"
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "gntbox.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "gntentry.h"
18382
aa60f5a89286 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18346
diff changeset
29 #include "gntmarshal.h"
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "gntstyle.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "gnttree.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "gntutils.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 enum
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 SIG_TEXT_CHANGED,
18382
aa60f5a89286 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18346
diff changeset
37 SIG_COMPLETION,
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 SIGS,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 };
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
40
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
41 typedef enum
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
42 {
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
43 ENTRY_JAIL = -1, /* Suspend the kill ring. */
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
44 ENTRY_DEL_BWD_WORD = 1,
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
45 ENTRY_DEL_BWD_CHAR,
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
46 ENTRY_DEL_FWD_WORD,
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
47 ENTRY_DEL_FWD_CHAR,
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
48 ENTRY_DEL_EOL,
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
49 ENTRY_DEL_BOL,
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
50 } GntEntryAction;
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
51
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
52 struct _GntEntryKillRing
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
53 {
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
54 GString *buffer;
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
55 GntEntryAction last;
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
56 };
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
57
29671
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
58 struct _GntEntrySearch
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
59 {
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
60 char *needle;
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
61 };
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
62
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 static guint signals[SIGS] = { 0 };
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 static GntWidgetClass *parent_class = NULL;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66
15959
efbced3f38ac Update the tab completion a little bit. The binding for suggest-show will perform suggest-next if the suggest-dropdown is already showing. If there's just one suggestion, then complete with that suggestion.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15817
diff changeset
67 static gboolean gnt_entry_key_pressed(GntWidget *widget, const char *text);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 static void gnt_entry_set_text_internal(GntEntry *entry, const char *text);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
70 static gboolean
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
71 update_kill_ring(GntEntry *entry, GntEntryAction action, const char *text, int len)
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
72 {
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
73 if (action < 0) {
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
74 entry->killring->last = action;
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
75 return FALSE;
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
76 }
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
77
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
78 if (len == 0)
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
79 len = strlen(text);
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
80 else if (len < 0) {
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
81 text += len;
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
82 len = -len;
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
83 }
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
84
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
85 if (action != entry->killring->last) {
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
86 struct {
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
87 GntEntryAction one;
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
88 GntEntryAction two;
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
89 } merges[] = {
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
90 {ENTRY_DEL_BWD_WORD, ENTRY_DEL_FWD_WORD},
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
91 {ENTRY_DEL_BWD_CHAR, ENTRY_DEL_FWD_CHAR},
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
92 {ENTRY_DEL_BOL, ENTRY_DEL_EOL},
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
93 {ENTRY_JAIL, ENTRY_JAIL},
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
94 };
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
95 int i;
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
96
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
97 for (i = 0; merges[i].one != ENTRY_JAIL; i++) {
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
98 if (merges[i].one == entry->killring->last &&
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
99 merges[i].two == action) {
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
100 g_string_append_len(entry->killring->buffer, text, len);
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
101 break;
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
102 } else if (merges[i].one == action &&
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
103 merges[i].two == entry->killring->last) {
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
104 g_string_prepend_len(entry->killring->buffer, text, len);
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
105 break;
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
106 }
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
107 }
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
108 if (merges[i].one == ENTRY_JAIL) {
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
109 g_string_assign(entry->killring->buffer, text);
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
110 g_string_truncate(entry->killring->buffer, len);
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
111 }
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
112 entry->killring->last = action;
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
113 } else {
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
114 if (action == ENTRY_DEL_BWD_CHAR || action == ENTRY_DEL_BWD_WORD)
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
115 g_string_prepend_len(entry->killring->buffer, text, len);
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
116 else
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
117 g_string_append_len(entry->killring->buffer, text, len);
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
118 }
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
119 return TRUE;
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
120 }
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
121
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 destroy_suggest(GntEntry *entry)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 if (entry->ddown)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 gnt_widget_destroy(entry->ddown->parent);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 entry->ddown = NULL;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 static char *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 get_beginning_of_word(GntEntry *entry)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 char *s = entry->cursor;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 while (s > entry->start)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 char *t = g_utf8_find_prev_char(entry->start, s);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 if (isspace(*t))
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 break;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 s = t;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 return s;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 static gboolean
16889
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
147 complete_suggest(GntEntry *entry, const char *text)
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
148 {
18382
aa60f5a89286 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18346
diff changeset
149 int offstart = 0, offend = 0;
aa60f5a89286 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18346
diff changeset
150
16889
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
151 if (entry->word) {
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
152 char *s = get_beginning_of_word(entry);
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
153 const char *iter = text;
18382
aa60f5a89286 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18346
diff changeset
154 offstart = g_utf8_pointer_to_offset(entry->start, s);
16889
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
155 while (*iter && toupper(*s) == toupper(*iter)) {
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
156 *s++ = *iter++;
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
157 }
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
158 if (*iter) {
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
159 gnt_entry_key_pressed(GNT_WIDGET(entry), iter);
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
160 }
18382
aa60f5a89286 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18346
diff changeset
161 offend = g_utf8_pointer_to_offset(entry->start, entry->cursor);
16889
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
162 } else {
18382
aa60f5a89286 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18346
diff changeset
163 offstart = 0;
16889
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
164 gnt_entry_set_text_internal(entry, text);
18382
aa60f5a89286 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18346
diff changeset
165 offend = g_utf8_strlen(text, -1);
16889
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
166 }
18382
aa60f5a89286 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18346
diff changeset
167
21699
760a8e024142 Emit the 'completion' signal when tab is pressed from a suggest word.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21680
diff changeset
168 g_signal_emit(G_OBJECT(entry), signals[SIG_COMPLETION], 0,
760a8e024142 Emit the 'completion' signal when tab is pressed from a suggest word.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21680
diff changeset
169 entry->start + offstart, entry->start + offend);
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
170 update_kill_ring(entry, ENTRY_JAIL, NULL, 0);
21699
760a8e024142 Emit the 'completion' signal when tab is pressed from a suggest word.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21680
diff changeset
171 return TRUE;
16889
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
172 }
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
173
20088
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
174 static int
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
175 max_common_prefix(const char *s, const char *t)
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
176 {
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
177 const char *f = s;
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
178 while (*f && *t && *f == *t++)
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
179 f++;
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
180 return f - s;
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
181 }
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
182
16889
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
183 static gboolean
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 show_suggest_dropdown(GntEntry *entry)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 char *suggest = NULL;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 int len;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 int offset = 0, x, y;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 int count = 0;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 GList *iter;
16889
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
191 const char *text = NULL;
16899
6502a3846264 Fix tab-completion.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16889
diff changeset
192 const char *sgst = NULL;
20088
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
193 int max = -1;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 if (entry->word)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 char *s = get_beginning_of_word(entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 suggest = g_strndup(s, entry->cursor - s);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 if (entry->scroll < s)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 offset = gnt_util_onscreen_width(entry->scroll, s);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 else
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 suggest = g_strdup(entry->start);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 len = strlen(suggest); /* Don't need to use the utf8-function here */
20088
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
205
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 if (entry->ddown == NULL)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 GntWidget *box = gnt_vbox_new(FALSE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 entry->ddown = gnt_tree_new();
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 gnt_tree_set_compare_func(GNT_TREE(entry->ddown), (GCompareFunc)g_utf8_collate);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 gnt_box_add_widget(GNT_BOX(box), entry->ddown);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_TRANSIENT);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 gnt_widget_get_position(GNT_WIDGET(entry), &x, &y);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 x += offset;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 y++;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 if (y + 10 >= getmaxy(stdscr))
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 y -= 11;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 gnt_widget_set_position(box, x, y);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 else
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 gnt_tree_remove_all(GNT_TREE(entry->ddown));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 for (count = 0, iter = entry->suggests; iter; iter = iter->next)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 {
16889
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
227 text = iter->data;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 if (g_ascii_strncasecmp(suggest, text, len) == 0 && strlen(text) >= len)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 gnt_tree_add_row_after(GNT_TREE(entry->ddown), (gpointer)text,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 gnt_tree_create_row(GNT_TREE(entry->ddown), text),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 NULL, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 count++;
20088
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
234 if (max == -1)
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
235 max = strlen(text) - len;
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
236 else if (max)
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
237 max = MIN(max, max_common_prefix(sgst + len, text + len));
16899
6502a3846264 Fix tab-completion.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16889
diff changeset
238 sgst = text;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 g_free(suggest);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242
16889
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
243 if (count == 0) {
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 destroy_suggest(entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 return FALSE;
16889
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
246 } else if (count == 1) {
22698
4a05b9db0b91 Return FALSE when nothing changes after an attempted tab-completion.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22434
diff changeset
247 char *store = g_strndup(entry->start, entry->end - entry->start);
4a05b9db0b91 Return FALSE when nothing changes after an attempted tab-completion.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22434
diff changeset
248 gboolean ret;
4a05b9db0b91 Return FALSE when nothing changes after an attempted tab-completion.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22434
diff changeset
249
16889
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
250 destroy_suggest(entry);
22698
4a05b9db0b91 Return FALSE when nothing changes after an attempted tab-completion.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22434
diff changeset
251 complete_suggest(entry, sgst);
4a05b9db0b91 Return FALSE when nothing changes after an attempted tab-completion.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22434
diff changeset
252
4a05b9db0b91 Return FALSE when nothing changes after an attempted tab-completion.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22434
diff changeset
253 ret = (strncmp(store, entry->start, entry->end - entry->start) != 0);
4a05b9db0b91 Return FALSE when nothing changes after an attempted tab-completion.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22434
diff changeset
254 g_free(store);
4a05b9db0b91 Return FALSE when nothing changes after an attempted tab-completion.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22434
diff changeset
255 return ret;
16889
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
256 } else {
20088
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
257 if (max > 0) {
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
258 GntWidget *ddown = entry->ddown;
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
259 char *match = g_strndup(sgst + len, max);
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
260 entry->ddown = NULL;
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
261 gnt_entry_key_pressed(GNT_WIDGET(entry), match);
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
262 g_free(match);
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
263 if (entry->ddown)
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
264 gnt_widget_destroy(ddown);
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
265 else
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
266 entry->ddown = ddown;
470feb3084a4 Tab-complete as much as possible when there are multiple suggests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
267 }
16889
c31328dba5c2 Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15959
diff changeset
268 gnt_widget_draw(entry->ddown->parent);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 gnt_entry_draw(GntWidget *widget)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 GntEntry *entry = GNT_ENTRY(widget);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 int stop;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 gboolean focus;
26439
c67d43408daa Update hardware cursor correctly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24586
diff changeset
280 int curpos;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 if ((focus = gnt_widget_has_focus(widget)))
21250
9187d331aebe Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20088
diff changeset
283 wbkgdset(widget->window, '\0' | gnt_color_pair(GNT_COLOR_TEXT_NORMAL));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 else
21250
9187d331aebe Add gnt_color_pair, which will replace color codes with 'appropriate' text
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20088
diff changeset
285 wbkgdset(widget->window, '\0' | gnt_color_pair(GNT_COLOR_HIGHLIGHT_D));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 if (entry->masked)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 mvwhline(widget->window, 0, 0, gnt_ascii_only() ? '*' : ACS_BULLET,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 g_utf8_pointer_to_offset(entry->scroll, entry->end));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 else
28604
a18f421696dc Fix showing umlauts etc. on non-utf8 locales.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28454
diff changeset
293 mvwprintw(widget->window, 0, 0, "%s", C_(entry->scroll));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 stop = gnt_util_onscreen_width(entry->scroll, entry->end);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 if (stop < widget->priv.width)
18346
72a52cff76f3 Draw the password entries correctly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17928
diff changeset
297 mvwhline(widget->window, 0, stop, ENTRY_CHAR, widget->priv.width - stop);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298
26439
c67d43408daa Update hardware cursor correctly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24586
diff changeset
299 curpos = gnt_util_onscreen_width(entry->scroll, entry->cursor);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300 if (focus)
26439
c67d43408daa Update hardware cursor correctly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24586
diff changeset
301 mvwchgat(widget->window, 0, curpos, 1, A_REVERSE, GNT_COLOR_TEXT_NORMAL, NULL);
c67d43408daa Update hardware cursor correctly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24586
diff changeset
302 wmove(widget->window, 0, curpos);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 GNTDEBUG;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308 gnt_entry_size_request(GntWidget *widget)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310 if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_MAPPED))
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 widget->priv.height = 1;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 widget->priv.width = 20;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
317 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 gnt_entry_map(GntWidget *widget)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 if (widget->priv.width == 0 || widget->priv.height == 0)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321 gnt_widget_size_request(widget);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322 GNTDEBUG;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 entry_redraw(GntWidget *widget)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 gnt_entry_draw(widget);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 gnt_widget_queue_update(widget);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 entry_text_changed(GntEntry *entry)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 g_signal_emit(entry, signals[SIG_TEXT_CHANGED], 0);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 static gboolean
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 move_back(GntBindable *bind, GList *null)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341 GntEntry *entry = GNT_ENTRY(bind);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 if (entry->cursor <= entry->start)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 return FALSE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344 entry->cursor = g_utf8_find_prev_char(entry->start, entry->cursor);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 if (entry->cursor < entry->scroll)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 entry->scroll = entry->cursor;
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
347 update_kill_ring(entry, ENTRY_JAIL, NULL, 0);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 entry_redraw(GNT_WIDGET(entry));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 static gboolean
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 move_forward(GntBindable *bind, GList *list)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355 GntEntry *entry = GNT_ENTRY(bind);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 if (entry->cursor >= entry->end)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357 return FALSE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358 entry->cursor = g_utf8_find_next_char(entry->cursor, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 while (gnt_util_onscreen_width(entry->scroll, entry->cursor) >= GNT_WIDGET(entry)->priv.width)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360 entry->scroll = g_utf8_find_next_char(entry->scroll, NULL);
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
361 update_kill_ring(entry, ENTRY_JAIL, NULL, 0);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 entry_redraw(GNT_WIDGET(entry));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 static gboolean
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367 backspace(GntBindable *bind, GList *null)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 int len;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370 GntEntry *entry = GNT_ENTRY(bind);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372 if (entry->cursor <= entry->start)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 return TRUE;
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
374
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375 len = entry->cursor - g_utf8_find_prev_char(entry->start, entry->cursor);
24553
2675fda76ddf Do not alter the killring on delete-prev or delete-next (char) operations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24410
diff changeset
376 update_kill_ring(entry, ENTRY_JAIL, entry->cursor, -len);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377 entry->cursor -= len;
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
378
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 memmove(entry->cursor, entry->cursor + len, entry->end - entry->cursor);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380 entry->end -= len;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 if (entry->scroll > entry->start)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
383 entry->scroll = g_utf8_find_prev_char(entry->start, entry->scroll);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 entry_redraw(GNT_WIDGET(entry));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 if (entry->ddown)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387 show_suggest_dropdown(entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388 entry_text_changed(entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 static gboolean
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393 delkey(GntBindable *bind, GList *null)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 int len;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 GntEntry *entry = GNT_ENTRY(bind);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 if (entry->cursor >= entry->end)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399 return FALSE;
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
400
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401 len = g_utf8_find_next_char(entry->cursor, NULL) - entry->cursor;
24553
2675fda76ddf Do not alter the killring on delete-prev or delete-next (char) operations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24410
diff changeset
402 update_kill_ring(entry, ENTRY_JAIL, entry->cursor, len);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403 memmove(entry->cursor, entry->cursor + len, entry->end - entry->cursor - len + 1);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
404 entry->end -= len;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
405 entry_redraw(GNT_WIDGET(entry));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
406
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
407 if (entry->ddown)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408 show_suggest_dropdown(entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409 entry_text_changed(entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
410 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
411 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
412
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413 static gboolean
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 move_start(GntBindable *bind, GList *null)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416 GntEntry *entry = GNT_ENTRY(bind);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
417 entry->scroll = entry->cursor = entry->start;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418 entry_redraw(GNT_WIDGET(entry));
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
419 update_kill_ring(entry, ENTRY_JAIL, NULL, 0);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
423 static gboolean
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424 move_end(GntBindable *bind, GList *null)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426 GntEntry *entry = GNT_ENTRY(bind);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
427 entry->cursor = entry->end;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
428 /* This should be better than this */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429 while (gnt_util_onscreen_width(entry->scroll, entry->cursor) >= GNT_WIDGET(entry)->priv.width)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430 entry->scroll = g_utf8_find_next_char(entry->scroll, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431 entry_redraw(GNT_WIDGET(entry));
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
432 update_kill_ring(entry, ENTRY_JAIL, NULL, 0);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
433 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
434 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
435
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
436 static gboolean
22434
77737a3526f1 The names history-next and history-prev were backwards! Make them right, and add c-n/c-p bindings as the default bindings. Thanks to shofixti for reporting the bug. Fixes #4593.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22289
diff changeset
437 history_next(GntBindable *bind, GList *null)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
438 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439 GntEntry *entry = GNT_ENTRY(bind);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440 if (entry->histlength && entry->history->prev)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
441 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
442 entry->history = entry->history->prev;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
443 gnt_entry_set_text_internal(entry, entry->history->data);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444 destroy_suggest(entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 entry_text_changed(entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
446
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
447 update_kill_ring(entry, ENTRY_JAIL, NULL, 0);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
448 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450 return FALSE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
451 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
453 static gboolean
22434
77737a3526f1 The names history-next and history-prev were backwards! Make them right, and add c-n/c-p bindings as the default bindings. Thanks to shofixti for reporting the bug. Fixes #4593.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22289
diff changeset
454 history_prev(GntBindable *bind, GList *null)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
456 GntEntry *entry = GNT_ENTRY(bind);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
457 if (entry->histlength && entry->history->next)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 if (entry->history->prev == NULL)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
460 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
461 /* Save the current contents */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
462 char *text = g_strdup(gnt_entry_get_text(entry));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
463 g_free(entry->history->data);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
464 entry->history->data = text;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
465 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
466
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
467 entry->history = entry->history->next;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
468 gnt_entry_set_text_internal(entry, entry->history->data);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
469 destroy_suggest(entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470 entry_text_changed(entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
471
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
472 update_kill_ring(entry, ENTRY_JAIL, NULL, 0);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
473 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
474 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475 return FALSE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
476 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
477
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478 static gboolean
29671
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
479 history_search(GntBindable *bind, GList *null)
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
480 {
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
481 GntEntry *entry = GNT_ENTRY(bind);
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
482 GList *iter;
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
483 const char *current , *pos;
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
484 int len;
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
485
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
486 if (entry->history->prev && entry->search->needle)
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
487 current = entry->search->needle;
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
488 else
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
489 current = gnt_entry_get_text(entry);
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
490
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
491 if (!entry->histlength || !entry->history->next || !*current)
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
492 return FALSE;
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
493
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
494 len = g_utf8_strlen(current, -1);
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
495
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
496 for (iter = entry->history->next; iter; iter = iter->next) {
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
497 const char *str = iter->data;
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
498 /* A more utf8-friendly version of strstr would have been better, but
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
499 * for now, this will have to do. */
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
500 if ((pos = strstr(str, current)))
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
501 break;
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
502 }
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
503
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
504 if (!iter)
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
505 return TRUE;
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
506
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
507 if (entry->history->prev == NULL) {
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
508 /* We are doing it for the first time. Save the current contents */
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
509 char *text = g_strdup(gnt_entry_get_text(entry));
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
510
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
511 g_free(entry->search->needle);
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
512 entry->search->needle = g_strdup(current);
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
513
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
514 g_free(entry->history->data);
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
515 entry->history->data = text;
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
516 }
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
517
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
518 entry->history = iter;
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
519 gnt_entry_set_text_internal(entry, entry->history->data);
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
520 destroy_suggest(entry);
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
521 entry_text_changed(entry);
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
522
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
523 update_kill_ring(entry, ENTRY_JAIL, NULL, 0);
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
524 return TRUE;
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
525 }
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
526
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
527 static gboolean
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
528 clipboard_paste(GntBindable *bind, GList *n)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530 GntEntry *entry = GNT_ENTRY(bind);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531 gchar *i, *text, *a, *all;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
532 text = i = gnt_get_clipboard_string();
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533 while (*i != '\0') {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
534 i = g_utf8_next_char(i);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
535 if (*i == '\r' || *i == '\n')
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
536 *i = ' ';
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
537 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
538 a = g_strndup(entry->start, entry->cursor - entry->start);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
539 all = g_strconcat(a, text, entry->cursor, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
540 gnt_entry_set_text_internal(entry, all);
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
541 update_kill_ring(entry, ENTRY_JAIL, NULL, 0);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
542 g_free(a);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
543 g_free(text);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
544 g_free(all);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
545 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
546 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
548 static gboolean
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
549 suggest_show(GntBindable *bind, GList *null)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
550 {
15959
efbced3f38ac Update the tab completion a little bit. The binding for suggest-show will perform suggest-next if the suggest-dropdown is already showing. If there's just one suggestion, then complete with that suggestion.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15817
diff changeset
551 GntEntry *entry = GNT_ENTRY(bind);
efbced3f38ac Update the tab completion a little bit. The binding for suggest-show will perform suggest-next if the suggest-dropdown is already showing. If there's just one suggestion, then complete with that suggestion.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15817
diff changeset
552 if (entry->ddown) {
28337
650ab9eb4b21 Add missing null sentinels, and help the compiler catch such errors.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26439
diff changeset
553 gnt_bindable_perform_action_named(GNT_BINDABLE(entry->ddown), "move-down", NULL);
15959
efbced3f38ac Update the tab completion a little bit. The binding for suggest-show will perform suggest-next if the suggest-dropdown is already showing. If there's just one suggestion, then complete with that suggestion.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15817
diff changeset
554 return TRUE;
efbced3f38ac Update the tab completion a little bit. The binding for suggest-show will perform suggest-next if the suggest-dropdown is already showing. If there's just one suggestion, then complete with that suggestion.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15817
diff changeset
555 }
efbced3f38ac Update the tab completion a little bit. The binding for suggest-show will perform suggest-next if the suggest-dropdown is already showing. If there's just one suggestion, then complete with that suggestion.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15817
diff changeset
556 return show_suggest_dropdown(entry);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
557 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
558
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
559 static gboolean
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
560 suggest_next(GntBindable *bind, GList *null)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
561 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
562 GntEntry *entry = GNT_ENTRY(bind);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
563 if (entry->ddown) {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
564 gnt_bindable_perform_action_named(GNT_BINDABLE(entry->ddown), "move-down", NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
566 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
567 return FALSE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
568 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
569
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
570 static gboolean
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
571 suggest_prev(GntBindable *bind, GList *null)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
572 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
573 GntEntry *entry = GNT_ENTRY(bind);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
574 if (entry->ddown) {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
575 gnt_bindable_perform_action_named(GNT_BINDABLE(entry->ddown), "move-up", NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
576 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
577 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
578 return FALSE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
579 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
580
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
581 static gboolean
30171
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
582 suggest_next_page(GntBindable *bind, GList *null)
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
583 {
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
584 GntEntry *entry = GNT_ENTRY(bind);
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
585 if (entry->ddown) {
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
586 gnt_bindable_perform_action_named(GNT_BINDABLE(entry->ddown), "page-down", NULL);
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
587 return TRUE;
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
588 }
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
589 return FALSE;
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
590 }
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
591
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
592 static gboolean
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
593 suggest_prev_page(GntBindable *bind, GList *null)
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
594 {
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
595 GntEntry *entry = GNT_ENTRY(bind);
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
596 if (entry->ddown) {
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
597 gnt_bindable_perform_action_named(GNT_BINDABLE(entry->ddown), "page-up", NULL);
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
598 return TRUE;
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
599 }
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
600 return FALSE;
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
601 }
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
602
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
603 static gboolean
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
604 del_to_home(GntBindable *bind, GList *null)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
605 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
606 GntEntry *entry = GNT_ENTRY(bind);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
607 if (entry->cursor <= entry->start)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
608 return TRUE;
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
609 update_kill_ring(entry, ENTRY_DEL_BOL, entry->start, entry->cursor - entry->start);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
610 memmove(entry->start, entry->cursor, entry->end - entry->cursor);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
611 entry->end -= (entry->cursor - entry->start);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
612 entry->cursor = entry->scroll = entry->start;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
613 memset(entry->end, '\0', entry->buffer - (entry->end - entry->start));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
614 entry_redraw(GNT_WIDGET(bind));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
615 entry_text_changed(entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
616 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
617 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
618
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
619 static gboolean
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
620 del_to_end(GntBindable *bind, GList *null)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
621 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
622 GntEntry *entry = GNT_ENTRY(bind);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
623 if (entry->end <= entry->cursor)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
624 return TRUE;
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
625 update_kill_ring(entry, ENTRY_DEL_EOL, entry->cursor, entry->end - entry->cursor);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
626 entry->end = entry->cursor;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
627 memset(entry->end, '\0', entry->buffer - (entry->end - entry->start));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
628 entry_redraw(GNT_WIDGET(bind));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
629 entry_text_changed(entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
630 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
631 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
632
23174
f3087936d594 Treat digits and alphabets as the same class of characters when looking
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22900
diff changeset
633 #define SAME(a,b) ((g_unichar_isalnum(a) && g_unichar_isalnum(b)) || \
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
634 (g_unichar_isspace(a) && g_unichar_isspace(b)) || \
23174
f3087936d594 Treat digits and alphabets as the same class of characters when looking
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22900
diff changeset
635 (g_unichar_iswide(a) && g_unichar_iswide(b)) || \
f3087936d594 Treat digits and alphabets as the same class of characters when looking
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22900
diff changeset
636 (g_unichar_ispunct(a) && g_unichar_ispunct(b)))
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
637
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
638 static const char *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
639 begin_word(const char *text, const char *begin)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
640 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
641 gunichar ch = 0;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
642 while (text > begin && (!*text || g_unichar_isspace(g_utf8_get_char(text))))
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
643 text = g_utf8_find_prev_char(begin, text);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
644 ch = g_utf8_get_char(text);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
645 while ((text = g_utf8_find_prev_char(begin, text)) >= begin) {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
646 gunichar cur = g_utf8_get_char(text);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
647 if (!SAME(ch, cur))
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
648 break;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
649 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
650
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
651 return (text ? g_utf8_find_next_char(text, NULL) : begin);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
652 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
653
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
654 static const char *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
655 next_begin_word(const char *text, const char *end)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
656 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
657 gunichar ch = 0;
21680
65f2a29617a2 Fix cursor-next-word behaviour, noticed by jtb.
Richard Nelson <wabz@pidgin.im>
parents: 21280
diff changeset
658
65f2a29617a2 Fix cursor-next-word behaviour, noticed by jtb.
Richard Nelson <wabz@pidgin.im>
parents: 21280
diff changeset
659 while (text && text < end && g_unichar_isspace(g_utf8_get_char(text)))
65f2a29617a2 Fix cursor-next-word behaviour, noticed by jtb.
Richard Nelson <wabz@pidgin.im>
parents: 21280
diff changeset
660 text = g_utf8_find_next_char(text, end);
65f2a29617a2 Fix cursor-next-word behaviour, noticed by jtb.
Richard Nelson <wabz@pidgin.im>
parents: 21280
diff changeset
661
23294
47492dabcb4a Fixes a crash when next_begin_word is called on trailing spaces at the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23174
diff changeset
662 if (text) {
47492dabcb4a Fixes a crash when next_begin_word is called on trailing spaces at the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23174
diff changeset
663 ch = g_utf8_get_char(text);
47492dabcb4a Fixes a crash when next_begin_word is called on trailing spaces at the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23174
diff changeset
664 while ((text = g_utf8_find_next_char(text, end)) != NULL && text <= end) {
47492dabcb4a Fixes a crash when next_begin_word is called on trailing spaces at the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23174
diff changeset
665 gunichar cur = g_utf8_get_char(text);
47492dabcb4a Fixes a crash when next_begin_word is called on trailing spaces at the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23174
diff changeset
666 if (!SAME(ch, cur))
47492dabcb4a Fixes a crash when next_begin_word is called on trailing spaces at the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23174
diff changeset
667 break;
47492dabcb4a Fixes a crash when next_begin_word is called on trailing spaces at the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23174
diff changeset
668 }
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
669 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
670 return (text ? text : end);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
671 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
672
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
673 #undef SAME
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
674 static gboolean
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
675 move_back_word(GntBindable *bind, GList *null)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
676 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
677 GntEntry *entry = GNT_ENTRY(bind);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
678 const char *iter = g_utf8_find_prev_char(entry->start, entry->cursor);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
679
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
680 if (iter < entry->start)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
681 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
682 iter = begin_word(iter, entry->start);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
683 entry->cursor = (char*)iter;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
684 if (entry->cursor < entry->scroll)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
685 entry->scroll = entry->cursor;
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
686 update_kill_ring(entry, ENTRY_JAIL, NULL, 0);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
687 entry_redraw(GNT_WIDGET(bind));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
688 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
689 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
690
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
691 static gboolean
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
692 del_prev_word(GntBindable *bind, GList *null)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
693 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
694 GntWidget *widget = GNT_WIDGET(bind);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
695 GntEntry *entry = GNT_ENTRY(bind);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
696 char *iter = g_utf8_find_prev_char(entry->start, entry->cursor);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
697 int count;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
698
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
699 if (iter < entry->start)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
700 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
701 iter = (char*)begin_word(iter, entry->start);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
702 count = entry->cursor - iter;
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
703 update_kill_ring(entry, ENTRY_DEL_BWD_WORD, iter, count);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
704 memmove(iter, entry->cursor, entry->end - entry->cursor);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
705 entry->end -= count;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
706 entry->cursor = iter;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
707 if (entry->cursor <= entry->scroll) {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
708 entry->scroll = entry->cursor - widget->priv.width + 2;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
709 if (entry->scroll < entry->start)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
710 entry->scroll = entry->start;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
711 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
712 memset(entry->end, '\0', entry->buffer - (entry->end - entry->start));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
713 entry_redraw(widget);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
714 entry_text_changed(entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
715
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
716 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
717 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
718
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
719 static gboolean
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
720 move_forward_word(GntBindable *bind, GList *list)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
721 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
722 GntEntry *entry = GNT_ENTRY(bind);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
723 GntWidget *widget = GNT_WIDGET(bind);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
724 entry->cursor = (char *)next_begin_word(entry->cursor, entry->end);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
725 while (gnt_util_onscreen_width(entry->scroll, entry->cursor) >= widget->priv.width) {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
726 entry->scroll = g_utf8_find_next_char(entry->scroll, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
727 }
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
728 update_kill_ring(entry, ENTRY_JAIL, NULL, 0);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
729 entry_redraw(widget);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
730 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
731 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
732
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
733 static gboolean
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
734 delete_forward_word(GntBindable *bind, GList *list)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
735 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
736 GntEntry *entry = GNT_ENTRY(bind);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
737 GntWidget *widget = GNT_WIDGET(bind);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
738 char *iter = (char *)next_begin_word(entry->cursor, entry->end);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
739 int len = entry->end - iter + 1;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
740 if (len <= 0)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
741 return TRUE;
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
742 update_kill_ring(entry, ENTRY_DEL_FWD_WORD, entry->cursor, iter - entry->cursor);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
743 memmove(entry->cursor, iter, len);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
744 len = iter - entry->cursor;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
745 entry->end -= len;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
746 memset(entry->end, '\0', len);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
747 entry_redraw(widget);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
748 entry_text_changed(entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
749 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
750 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
751
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
752 static gboolean
21262
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
753 transpose_chars(GntBindable *bind, GList *null)
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
754 {
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
755 GntEntry *entry = GNT_ENTRY(bind);
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
756 char *current, *prev;
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
757 char hold[8]; /* that's right */
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
758
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
759 if (entry->cursor <= entry->start)
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
760 return FALSE;
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
761
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
762 if (!*entry->cursor)
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
763 entry->cursor = g_utf8_find_prev_char(entry->start, entry->cursor);
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
764
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
765 current = entry->cursor;
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
766 prev = g_utf8_find_prev_char(entry->start, entry->cursor);
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
767 move_forward(bind, null);
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
768
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
769 /* Let's do this dance! */
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
770 memcpy(hold, prev, current - prev);
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
771 memmove(prev, current, entry->cursor - current);
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
772 memcpy(prev + (entry->cursor - current), hold, current - prev);
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
773
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
774 update_kill_ring(entry, ENTRY_JAIL, NULL, 0);
21262
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
775 entry_redraw(GNT_WIDGET(entry));
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
776 entry_text_changed(entry);
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
777 return TRUE;
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
778 }
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
779
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
780 static gboolean
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
781 entry_yank(GntBindable *bind, GList *null)
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
782 {
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
783 GntEntry *entry = GNT_ENTRY(bind);
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
784 gnt_entry_key_pressed(GNT_WIDGET(entry), entry->killring->buffer->str);
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
785 return TRUE;
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
786 }
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
787
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
788 static gboolean
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
789 gnt_entry_key_pressed(GntWidget *widget, const char *text)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
790 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
791 GntEntry *entry = GNT_ENTRY(widget);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
792
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
793 if (text[0] == 27)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
794 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
795 if (text[1] == 0)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
796 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
797 destroy_suggest(entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
798 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
799 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
800
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
801 return FALSE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
802 }
21280
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
803
22289
0ba0f2804299 '\n' (ctrl-j) should behave similar to '\r' (ctrl-m). Fixes #4833.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
804 if ((text[0] == '\r' || text[0] == ' ' || text[0] == '\n') && entry->ddown)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
805 {
21280
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
806 char *text = g_strdup(gnt_tree_get_selection_data(GNT_TREE(entry->ddown)));
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
807 destroy_suggest(entry);
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
808 complete_suggest(entry, text);
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
809 g_free(text);
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
810 update_kill_ring(entry, ENTRY_JAIL, NULL, 0);
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
811 entry_text_changed(entry);
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
812 return TRUE;
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
813 }
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
814
21280
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
815 if (!iscntrl(text[0]))
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
816 {
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
817 const char *str, *next;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
818
21280
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
819 for (str = text; *str; str = next)
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
820 {
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
821 int len;
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
822 next = g_utf8_find_next_char(str, NULL);
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
823 len = next - str;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
824
21280
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
825 /* Valid input? */
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
826 /* XXX: Is it necessary to use _unichar_ variants here? */
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
827 if (ispunct(*str) && (entry->flag & GNT_ENTRY_FLAG_NO_PUNCT))
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
828 continue;
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
829 if (isspace(*str) && (entry->flag & GNT_ENTRY_FLAG_NO_SPACE))
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
830 continue;
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
831 if (isalpha(*str) && !(entry->flag & GNT_ENTRY_FLAG_ALPHA))
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
832 continue;
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
833 if (isdigit(*str) && !(entry->flag & GNT_ENTRY_FLAG_INT))
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
834 continue;
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
835
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
836 /* Reached the max? */
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
837 if (entry->max && g_utf8_pointer_to_offset(entry->start, entry->end) >= entry->max)
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
838 continue;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
839
21280
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
840 if (entry->end + len - entry->start >= entry->buffer)
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
841 {
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
842 /* This will cause the buffer to grow */
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
843 char *tmp = g_strdup(entry->start);
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
844 gnt_entry_set_text_internal(entry, tmp);
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
845 g_free(tmp);
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
846 }
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
847
21280
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
848 memmove(entry->cursor + len, entry->cursor, entry->end - entry->cursor + 1);
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
849 entry->end += len;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
850
21280
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
851 while (str < next)
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
852 {
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
853 if (*str == '\r' || *str == '\n')
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
854 *entry->cursor = ' ';
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
855 else
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
856 *entry->cursor = *str;
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
857 entry->cursor++;
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
858 str++;
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
859 }
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
860
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
861 while (gnt_util_onscreen_width(entry->scroll, entry->cursor) >= widget->priv.width)
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
862 entry->scroll = g_utf8_find_next_char(entry->scroll, NULL);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
863
21280
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
864 if (entry->ddown)
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
865 show_suggest_dropdown(entry);
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
866 }
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
867 update_kill_ring(entry, ENTRY_JAIL, NULL, 0);
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
868 entry_redraw(widget);
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
869 entry_text_changed(entry);
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
870 return TRUE;
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
871 }
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
872
22289
0ba0f2804299 '\n' (ctrl-j) should behave similar to '\r' (ctrl-m). Fixes #4833.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
873 if (text[0] == '\r' || text[0] == '\n') {
21280
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
874 gnt_widget_activate(widget);
cfbff4a9b2b6 Hitting Return in the entry will trigger the 'activate' signal.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21266
diff changeset
875 return TRUE;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
876 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
877
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
878 return FALSE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
879 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
880
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
881 static void
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
882 jail_killring(GntEntryKillRing *kr)
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
883 {
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
884 g_string_free(kr->buffer, TRUE);
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
885 g_free(kr);
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
886 }
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
887
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
888 static void
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
889 gnt_entry_destroy(GntWidget *widget)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
890 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
891 GntEntry *entry = GNT_ENTRY(widget);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
892 g_free(entry->start);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
893
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
894 if (entry->history)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
895 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
896 entry->history = g_list_first(entry->history);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
897 g_list_foreach(entry->history, (GFunc)g_free, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
898 g_list_free(entry->history);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
899 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
900
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
901 if (entry->suggests)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
902 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
903 g_list_foreach(entry->suggests, (GFunc)g_free, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
904 g_list_free(entry->suggests);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
905 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
906
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
907 if (entry->ddown)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
908 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
909 gnt_widget_destroy(entry->ddown->parent);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
910 }
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
911
29671
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
912 g_free(entry->search->needle);
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
913 g_free(entry->search);
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
914
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
915 jail_killring(entry->killring);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
916 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
917
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
918 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
919 gnt_entry_lost_focus(GntWidget *widget)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
920 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
921 GntEntry *entry = GNT_ENTRY(widget);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
922 destroy_suggest(entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
923 entry_redraw(widget);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
924 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
925
22900
c9aebd4762a8 Middle click pastes the internal clipboard
Richard Nelson <wabz@pidgin.im>
parents: 22698
diff changeset
926 static gboolean
c9aebd4762a8 Middle click pastes the internal clipboard
Richard Nelson <wabz@pidgin.im>
parents: 22698
diff changeset
927 gnt_entry_clicked(GntWidget *widget, GntMouseEvent event, int x, int y)
c9aebd4762a8 Middle click pastes the internal clipboard
Richard Nelson <wabz@pidgin.im>
parents: 22698
diff changeset
928 {
c9aebd4762a8 Middle click pastes the internal clipboard
Richard Nelson <wabz@pidgin.im>
parents: 22698
diff changeset
929 if (event == GNT_MIDDLE_MOUSE_DOWN) {
c9aebd4762a8 Middle click pastes the internal clipboard
Richard Nelson <wabz@pidgin.im>
parents: 22698
diff changeset
930 clipboard_paste(GNT_BINDABLE(widget), NULL);
c9aebd4762a8 Middle click pastes the internal clipboard
Richard Nelson <wabz@pidgin.im>
parents: 22698
diff changeset
931 return TRUE;
c9aebd4762a8 Middle click pastes the internal clipboard
Richard Nelson <wabz@pidgin.im>
parents: 22698
diff changeset
932 }
c9aebd4762a8 Middle click pastes the internal clipboard
Richard Nelson <wabz@pidgin.im>
parents: 22698
diff changeset
933 return FALSE;
c9aebd4762a8 Middle click pastes the internal clipboard
Richard Nelson <wabz@pidgin.im>
parents: 22698
diff changeset
934
c9aebd4762a8 Middle click pastes the internal clipboard
Richard Nelson <wabz@pidgin.im>
parents: 22698
diff changeset
935 }
c9aebd4762a8 Middle click pastes the internal clipboard
Richard Nelson <wabz@pidgin.im>
parents: 22698
diff changeset
936
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
937 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
938 gnt_entry_class_init(GntEntryClass *klass)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
939 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
940 GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass);
24586
e1c3a984e47a Binding fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24553
diff changeset
941 char s[3] = {'\033', erasechar(), 0};
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
942
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
943 parent_class = GNT_WIDGET_CLASS(klass);
22900
c9aebd4762a8 Middle click pastes the internal clipboard
Richard Nelson <wabz@pidgin.im>
parents: 22698
diff changeset
944 parent_class->clicked = gnt_entry_clicked;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
945 parent_class->destroy = gnt_entry_destroy;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
946 parent_class->draw = gnt_entry_draw;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
947 parent_class->map = gnt_entry_map;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
948 parent_class->size_request = gnt_entry_size_request;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
949 parent_class->key_pressed = gnt_entry_key_pressed;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
950 parent_class->lost_focus = gnt_entry_lost_focus;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
951
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
952 signals[SIG_TEXT_CHANGED] =
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
953 g_signal_new("text_changed",
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
954 G_TYPE_FROM_CLASS(klass),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
955 G_SIGNAL_RUN_LAST,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
956 G_STRUCT_OFFSET(GntEntryClass, text_changed),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
957 NULL, NULL,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
958 g_cclosure_marshal_VOID__VOID,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
959 G_TYPE_NONE, 0);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
960
18382
aa60f5a89286 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18346
diff changeset
961 signals[SIG_COMPLETION] =
aa60f5a89286 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18346
diff changeset
962 g_signal_new("completion",
aa60f5a89286 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18346
diff changeset
963 G_TYPE_FROM_CLASS(klass),
aa60f5a89286 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18346
diff changeset
964 G_SIGNAL_RUN_LAST,
aa60f5a89286 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18346
diff changeset
965 0, NULL, NULL,
aa60f5a89286 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18346
diff changeset
966 gnt_closure_marshal_VOID__POINTER_POINTER,
aa60f5a89286 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18346
diff changeset
967 G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
aa60f5a89286 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18346
diff changeset
968
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
969 gnt_bindable_class_register_action(bindable, "cursor-home", move_start,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
970 GNT_KEY_CTRL_A, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
971 gnt_bindable_register_binding(bindable, "cursor-home", GNT_KEY_HOME, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
972 gnt_bindable_class_register_action(bindable, "cursor-end", move_end,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
973 GNT_KEY_CTRL_E, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
974 gnt_bindable_register_binding(bindable, "cursor-end", GNT_KEY_END, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
975 gnt_bindable_class_register_action(bindable, "delete-prev", backspace,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
976 GNT_KEY_BACKSPACE, NULL);
24586
e1c3a984e47a Binding fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24553
diff changeset
977 gnt_bindable_register_binding(bindable, "delete-prev", s + 1, NULL);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
978 gnt_bindable_register_binding(bindable, "delete-prev", GNT_KEY_CTRL_H, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
979 gnt_bindable_class_register_action(bindable, "delete-next", delkey,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
980 GNT_KEY_DEL, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
981 gnt_bindable_register_binding(bindable, "delete-next", GNT_KEY_CTRL_D, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
982 gnt_bindable_class_register_action(bindable, "delete-start", del_to_home,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
983 GNT_KEY_CTRL_U, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
984 gnt_bindable_class_register_action(bindable, "delete-end", del_to_end,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
985 GNT_KEY_CTRL_K, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
986 gnt_bindable_class_register_action(bindable, "delete-prev-word", del_prev_word,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
987 GNT_KEY_CTRL_W, NULL);
24586
e1c3a984e47a Binding fixes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24553
diff changeset
988 gnt_bindable_register_binding(bindable, "delete-prev-word", s, NULL);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
989 gnt_bindable_class_register_action(bindable, "cursor-prev-word", move_back_word,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
990 "\033" "b", NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
991 gnt_bindable_class_register_action(bindable, "cursor-prev", move_back,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
992 GNT_KEY_LEFT, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
993 gnt_bindable_register_binding(bindable, "cursor-prev", GNT_KEY_CTRL_B, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
994 gnt_bindable_class_register_action(bindable, "cursor-next", move_forward,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
995 GNT_KEY_RIGHT, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
996 gnt_bindable_register_binding(bindable, "cursor-next", GNT_KEY_CTRL_F, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
997 gnt_bindable_class_register_action(bindable, "cursor-next-word", move_forward_word,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
998 "\033" "f", NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
999 gnt_bindable_class_register_action(bindable, "delete-next-word", delete_forward_word,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1000 "\033" "d", NULL);
21262
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
1001 gnt_bindable_class_register_action(bindable, "transpose-chars", transpose_chars,
aee0d7fef769 transpose-chars action for the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21250
diff changeset
1002 GNT_KEY_CTRL_T, NULL);
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
1003 gnt_bindable_class_register_action(bindable, "yank", entry_yank,
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
1004 GNT_KEY_CTRL_Y, NULL);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1005 gnt_bindable_class_register_action(bindable, "suggest-show", suggest_show,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1006 "\t", NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1007 gnt_bindable_class_register_action(bindable, "suggest-next", suggest_next,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1008 GNT_KEY_DOWN, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1009 gnt_bindable_class_register_action(bindable, "suggest-prev", suggest_prev,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1010 GNT_KEY_UP, NULL);
30171
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
1011 gnt_bindable_class_register_action(bindable, "suggest-next-page", suggest_next_page,
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
1012 GNT_KEY_PGDOWN, NULL);
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
1013 gnt_bindable_class_register_action(bindable, "suggest-prev-page", suggest_prev_page,
aaec35719201 Allow page-up/downing in the suggestion list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29671
diff changeset
1014 GNT_KEY_PGUP, NULL);
22434
77737a3526f1 The names history-next and history-prev were backwards! Make them right, and add c-n/c-p bindings as the default bindings. Thanks to shofixti for reporting the bug. Fixes #4593.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22289
diff changeset
1015 gnt_bindable_class_register_action(bindable, "history-next", history_next,
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1016 GNT_KEY_CTRL_DOWN, NULL);
22434
77737a3526f1 The names history-next and history-prev were backwards! Make them right, and add c-n/c-p bindings as the default bindings. Thanks to shofixti for reporting the bug. Fixes #4593.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22289
diff changeset
1017 gnt_bindable_class_register_action(bindable, "history-prev", history_prev,
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1018 GNT_KEY_CTRL_UP, NULL);
22434
77737a3526f1 The names history-next and history-prev were backwards! Make them right, and add c-n/c-p bindings as the default bindings. Thanks to shofixti for reporting the bug. Fixes #4593.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22289
diff changeset
1019 gnt_bindable_register_binding(bindable, "history-prev", GNT_KEY_CTRL_P, NULL);
77737a3526f1 The names history-next and history-prev were backwards! Make them right, and add c-n/c-p bindings as the default bindings. Thanks to shofixti for reporting the bug. Fixes #4593.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22289
diff changeset
1020 gnt_bindable_register_binding(bindable, "history-next", GNT_KEY_CTRL_N, NULL);
29671
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
1021 gnt_bindable_class_register_action(bindable, "history-search", history_search,
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
1022 GNT_KEY_CTRL_R, NULL);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1023 gnt_bindable_class_register_action(bindable, "clipboard-paste", clipboard_paste,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1024 GNT_KEY_CTRL_V, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1025
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1026 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1027 GNTDEBUG;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1028 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1029
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
1030 static GntEntryKillRing *
22007
c38d72677c8a Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents: 21699
diff changeset
1031 new_killring(void)
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
1032 {
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
1033 GntEntryKillRing *kr = g_new0(GntEntryKillRing, 1);
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
1034 kr->buffer = g_string_new(NULL);
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
1035 return kr;
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
1036 }
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
1037
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1038 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1039 gnt_entry_init(GTypeInstance *instance, gpointer class)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1040 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1041 GntWidget *widget = GNT_WIDGET(instance);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1042 GntEntry *entry = GNT_ENTRY(instance);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1043
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1044 entry->flag = GNT_ENTRY_FLAG_ALL;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1045 entry->max = 0;
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
1046
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1047 entry->histlength = 0;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1048 entry->history = NULL;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1049
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1050 entry->word = TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1051 entry->always = FALSE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1052 entry->suggests = NULL;
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
1053 entry->killring = new_killring();
29671
69decc147e5b history-search action for text-entries.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28604
diff changeset
1054 entry->search = g_new0(GntEntrySearch, 1);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1055
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1056 GNT_WIDGET_SET_FLAGS(GNT_WIDGET(entry),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1057 GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW | GNT_WIDGET_CAN_TAKE_FOCUS);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1058 GNT_WIDGET_SET_FLAGS(GNT_WIDGET(entry), GNT_WIDGET_GROW_X);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1059
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1060 widget->priv.minw = 3;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1061 widget->priv.minh = 1;
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
1062
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1063 GNTDEBUG;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1064 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1065
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1066 /******************************************************************************
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1067 * GntEntry API
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1068 *****************************************************************************/
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1069 GType
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1070 gnt_entry_get_gtype(void)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1071 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1072 static GType type = 0;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1073
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1074 if(type == 0)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1075 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1076 static const GTypeInfo info = {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1077 sizeof(GntEntryClass),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1078 NULL, /* base_init */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1079 NULL, /* base_finalize */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1080 (GClassInitFunc)gnt_entry_class_init,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1081 NULL, /* class_finalize */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1082 NULL, /* class_data */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1083 sizeof(GntEntry),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1084 0, /* n_preallocs */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1085 gnt_entry_init, /* instance_init */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1086 NULL /* value_table */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1087 };
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1088
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1089 type = g_type_register_static(GNT_TYPE_WIDGET,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1090 "GntEntry",
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1091 &info, 0);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1092 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1093
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1094 return type;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1095 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1096
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1097 GntWidget *gnt_entry_new(const char *text)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1098 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1099 GntWidget *widget = g_object_new(GNT_TYPE_ENTRY, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1100 GntEntry *entry = GNT_ENTRY(widget);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1101
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1102 gnt_entry_set_text_internal(entry, text);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1103
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1104 return widget;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1105 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1106
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1107 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1108 gnt_entry_set_text_internal(GntEntry *entry, const char *text)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1109 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1110 int len;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1111 int scroll, cursor;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1112
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1113 g_free(entry->start);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1114
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1115 if (text && text[0])
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1116 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1117 len = strlen(text);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1118 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1119 else
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1120 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1121 len = 0;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1122 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1123
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1124 entry->buffer = len + 128;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1125
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1126 scroll = entry->scroll - entry->start;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1127 cursor = entry->end - entry->cursor;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1128
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1129 entry->start = g_new0(char, entry->buffer);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1130 if (text)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1131 snprintf(entry->start, len + 1, "%s", text);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1132 entry->end = entry->start + len;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1133
28454
f36c4a76a7ac Fix a couple of invalid reads after clearing the text in an entry box.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28337
diff changeset
1134 if ((entry->scroll = entry->start + scroll) > entry->end)
f36c4a76a7ac Fix a couple of invalid reads after clearing the text in an entry box.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28337
diff changeset
1135 entry->scroll = entry->end;
f36c4a76a7ac Fix a couple of invalid reads after clearing the text in an entry box.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28337
diff changeset
1136
f36c4a76a7ac Fix a couple of invalid reads after clearing the text in an entry box.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28337
diff changeset
1137 if ((entry->cursor = entry->end - cursor) > entry->end)
f36c4a76a7ac Fix a couple of invalid reads after clearing the text in an entry box.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28337
diff changeset
1138 entry->cursor = entry->end;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1139
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1140 if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(entry), GNT_WIDGET_MAPPED))
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1141 entry_redraw(GNT_WIDGET(entry));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1142 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1143
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1144 void gnt_entry_set_text(GntEntry *entry, const char *text)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1145 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1146 gboolean changed = TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1147 if (text == NULL && entry->start == NULL)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1148 changed = FALSE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1149 if (text && entry->start && g_utf8_collate(text, entry->start) == 0)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1150 changed = FALSE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1151 gnt_entry_set_text_internal(entry, text);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1152 if (changed)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1153 entry_text_changed(entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1154 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1155
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1156 void gnt_entry_set_max(GntEntry *entry, int max)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1157 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1158 entry->max = max;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1159 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1160
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1161 void gnt_entry_set_flag(GntEntry *entry, GntEntryFlag flag)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1162 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1163 entry->flag = flag;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1164 /* XXX: Check the existing string to make sure the flags are respected? */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1165 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1166
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1167 const char *gnt_entry_get_text(GntEntry *entry)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1168 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1169 return entry->start;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1170 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1171
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1172 void gnt_entry_clear(GntEntry *entry)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1173 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1174 gnt_entry_set_text_internal(entry, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1175 entry->scroll = entry->cursor = entry->end = entry->start;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1176 entry_redraw(GNT_WIDGET(entry));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1177 destroy_suggest(entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1178 entry_text_changed(entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1179 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1180
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1181 void gnt_entry_set_masked(GntEntry *entry, gboolean set)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1182 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1183 entry->masked = set;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1184 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1185
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1186 void gnt_entry_add_to_history(GntEntry *entry, const char *text)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1187 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1188 g_return_if_fail(entry->history != NULL); /* Need to set_history_length first */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1189
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1190 if (g_list_length(entry->history) >= entry->histlength)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1191 return;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1192
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1193 entry->history = g_list_first(entry->history);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1194 g_free(entry->history->data);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1195 entry->history->data = g_strdup(text);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1196 entry->history = g_list_prepend(entry->history, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1197 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1198
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1199 void gnt_entry_set_history_length(GntEntry *entry, int num)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1200 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1201 if (num == 0)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1202 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1203 entry->histlength = num;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1204 if (entry->history)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1205 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1206 entry->history = g_list_first(entry->history);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1207 g_list_foreach(entry->history, (GFunc)g_free, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1208 g_list_free(entry->history);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1209 entry->history = NULL;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1210 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1211 return;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1212 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1213
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1214 if (entry->histlength == 0)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1215 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1216 entry->histlength = num;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1217 entry->history = g_list_append(NULL, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1218 return;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1219 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1220
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1221 if (num > 0 && num < entry->histlength)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1222 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1223 GList *first, *iter;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1224 int index = 0;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1225 for (first = entry->history, index = 0; first->prev; first = first->prev, index++);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1226 while ((iter = g_list_nth(first, num)) != NULL)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1227 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1228 g_free(iter->data);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1229 first = g_list_delete_link(first, iter);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1230 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1231 entry->histlength = num;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1232 if (index >= num)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1233 entry->history = g_list_last(first);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1234 return;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1235 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1236
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1237 entry->histlength = num;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1238 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1239
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1240 void gnt_entry_set_word_suggest(GntEntry *entry, gboolean word)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1241 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1242 entry->word = word;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1243 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1244
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1245 void gnt_entry_set_always_suggest(GntEntry *entry, gboolean always)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1246 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1247 entry->always = always;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1248 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1249
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1250 void gnt_entry_add_suggest(GntEntry *entry, const char *text)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1251 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1252 GList *find;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1253
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1254 if (!text || !*text)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1255 return;
21266
1f59065c606a Add 'yank' action in the entry boxes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21262
diff changeset
1256
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1257 find = g_list_find_custom(entry->suggests, text, (GCompareFunc)g_utf8_collate);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1258 if (find)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1259 return;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1260 entry->suggests = g_list_append(entry->suggests, g_strdup(text));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1261 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1262
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1263 void gnt_entry_remove_suggest(GntEntry *entry, const char *text)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1264 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1265 GList *find = g_list_find_custom(entry->suggests, text, (GCompareFunc)g_utf8_collate);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1266 if (find)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1267 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1268 g_free(find->data);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1269 entry->suggests = g_list_delete_link(entry->suggests, find);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1270 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1271 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1272