]> git.decadent.org.uk Git - ion3.git/blob - mod_query/wedln-wrappers.c
fa5f0e4bd05b39f4db1ab3274ade136d05168817
[ion3.git] / mod_query / wedln-wrappers.c
1 /*
2  * ion/mod_query/wedln-wrappers.c
3  *
4  * Copyright (c) Tuomo Valkonen 1999-2007. 
5  *
6  * Ion is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or
9  * (at your option) any later version.
10  */
11
12 #include "wedln.h"
13 #include "edln.h"
14 #include "complete.h"
15
16 /*EXTL_DOC
17  * Move backward one character.
18  */
19 EXTL_EXPORT_MEMBER
20 void wedln_back(WEdln *wedln)
21 {
22     edln_back(&(wedln->edln));
23 }
24
25 /*EXTL_DOC
26  * Move forward one character.
27  */
28 EXTL_EXPORT_MEMBER
29 void wedln_forward(WEdln *wedln)
30 {
31     edln_forward(&(wedln->edln));
32 }
33
34 /*EXTL_DOC
35  * Transpose characters.
36  */
37 EXTL_EXPORT_MEMBER
38 void wedln_transpose_chars(WEdln *wedln)
39 {
40     edln_transpose_chars(&(wedln->edln));
41 }
42
43 /*EXTL_DOC
44  * Transpose words.
45  */
46 EXTL_EXPORT_MEMBER
47 void wedln_transpose_words(WEdln *wedln)
48 {
49     edln_transpose_words(&(wedln->edln));
50 }
51
52 /*EXTL_DOC
53  * Go to the beginning of line.
54  */
55 EXTL_EXPORT_MEMBER
56 void wedln_bol(WEdln *wedln)
57 {
58     edln_bol(&(wedln->edln));
59 }
60
61 /*EXTL_DOC
62  * Go to the end of line.
63  */
64 EXTL_EXPORT_MEMBER
65 void wedln_eol(WEdln *wedln)
66 {
67     edln_eol(&(wedln->edln));
68 }
69
70 /*EXTL_DOC
71  * Go to to end of current sequence of whitespace followed by alphanumeric
72  * characters..
73  */
74 EXTL_EXPORT_MEMBER
75 void wedln_skip_word(WEdln *wedln)
76 {
77     edln_skip_word(&(wedln->edln));
78 }
79
80 /*EXTL_DOC
81  * Go to to beginning of current sequence of alphanumeric characters
82  * followed by whitespace.
83  */
84 EXTL_EXPORT_MEMBER
85 void wedln_bskip_word(WEdln *wedln)
86 {
87     edln_bskip_word(&(wedln->edln));
88 }
89
90 /*EXTL_DOC
91  * Delete current character.
92  */
93 EXTL_EXPORT_MEMBER
94 void wedln_delete(WEdln *wedln)
95 {
96     edln_delete(&(wedln->edln));
97 }
98
99 /*EXTL_DOC
100  * Delete previous character.
101  */
102 EXTL_EXPORT_MEMBER
103 void wedln_backspace(WEdln *wedln)
104 {
105     edln_backspace(&(wedln->edln));
106 }
107
108 /*EXTL_DOC
109  * Delete all characters from current to end of line.
110  */
111 EXTL_EXPORT_MEMBER
112 void wedln_kill_to_eol(WEdln *wedln)
113 {
114     edln_kill_to_eol(&(wedln->edln));
115 }
116
117 /*EXTL_DOC
118  * Delete all characters from previous to beginning of line.
119  */
120 EXTL_EXPORT_MEMBER
121 void wedln_kill_to_bol(WEdln *wedln)
122 {
123     edln_kill_to_bol(&(wedln->edln));
124 }
125
126 /*EXTL_DOC
127  * Delete the whole line.
128  */
129 EXTL_EXPORT_MEMBER
130 void wedln_kill_line(WEdln *wedln)
131 {
132     edln_kill_line(&(wedln->edln));
133 }
134
135 /*EXTL_DOC
136  * Starting from the current point, delete possible whitespace and
137  * following alphanumeric characters until next non-alphanumeric character.
138  */
139 EXTL_EXPORT_MEMBER
140 void wedln_kill_word(WEdln *wedln)
141 {
142     edln_kill_word(&(wedln->edln));
143 }
144
145 /*EXTL_DOC
146  * Starting from the previous characters, delete possible whitespace and
147  * preceding alphanumeric characters until previous non-alphanumeric character.
148  */
149 EXTL_EXPORT_MEMBER
150 void wedln_bkill_word(WEdln *wedln)
151 {
152     edln_bkill_word(&(wedln->edln));
153 }
154
155 /*EXTL_DOC
156  * Set \emph{mark} to current cursor position.
157  */
158 EXTL_EXPORT_MEMBER
159 void wedln_set_mark(WEdln *wedln)
160 {
161     edln_set_mark(&(wedln->edln));
162 }
163
164 /*EXTL_DOC
165  * Clear \emph{mark}.
166  */
167 EXTL_EXPORT_MEMBER
168 void wedln_clear_mark(WEdln *wedln)
169 {
170     edln_clear_mark(&(wedln->edln));
171 }
172
173 /*EXTL_DOC
174  * Copy text between \emph{mark} and current cursor position to clipboard
175  * and then delete that sequence.
176  */
177 EXTL_EXPORT_MEMBER
178 void wedln_cut(WEdln *wedln)
179 {
180     edln_cut(&(wedln->edln));
181 }
182
183 /*EXTL_DOC
184  * Copy text between \emph{mark} and current cursor position to clipboard.
185  */
186 EXTL_EXPORT_MEMBER
187 void wedln_copy(WEdln *wedln)
188 {
189     edln_copy(&(wedln->edln));
190 }
191
192 /*EXTL_DOC
193  * Replace line editor contents with next entry in history if one exists.
194  * If \var{match} is \code{true}, the initial part of the history entry
195  * must match the current line from beginning to point.
196  */
197 EXTL_EXPORT_MEMBER
198 void wedln_history_next(WEdln *wedln, bool match)
199 {
200     edln_history_next(&(wedln->edln), match);
201 }
202
203 /*EXTL_DOC
204  * Replace line editor contents with previous in history if one exists.
205  * If \var{match} is \code{true}, the initial part of the history entry
206  * must match the current line from beginning to point.
207  */
208 EXTL_EXPORT_MEMBER
209 void wedln_history_prev(WEdln *wedln, bool match)
210 {
211     edln_history_prev(&(wedln->edln), match);
212 }
213
214
215 /*EXTL_DOC
216  * Input \var{str} in wedln at current editing point.
217  */
218 EXTL_EXPORT_AS(WEdln, insstr)
219 void wedln_insstr_exported(WEdln *wedln, const char *str)
220 {
221     edln_insstr(&(wedln->edln), str);
222 }
223
224
225 /*EXTL_DOC
226  * Get line editor contents.
227  */
228 EXTL_SAFE
229 EXTL_EXPORT_MEMBER
230 const char *wedln_contents(WEdln *wedln)
231 {
232     return wedln->edln.p;
233 }
234
235 /*EXTL_DOC
236  * Get current editing point. 
237  * Beginning of the edited line is point 0.
238  */
239 EXTL_SAFE
240 EXTL_EXPORT_MEMBER
241 int wedln_point(WEdln *wedln)
242 {
243     return wedln->edln.point;
244 }
245
246 /*EXTL_DOC
247  * Get current mark (start of selection) for \var{wedln}.
248  * Return value of -1 indicates that there is no mark, and
249  * 0 is the beginning of the line.
250  */
251 EXTL_SAFE
252 EXTL_EXPORT_MEMBER
253 int wedln_mark(WEdln *wedln)
254 {
255     return wedln->edln.mark;
256 }
257
258
259 /*EXTL_DOC
260  * Set history context for \var{wedln}.
261  */
262 EXTL_EXPORT_MEMBER
263 void wedln_set_context(WEdln *wedln, const char *context)
264 {
265     edln_set_context(&(wedln->edln), context);
266 }
267
268
269 /*EXTL_DOC
270  * Get history context for \var{wedln}.
271  */
272 EXTL_SAFE
273 EXTL_EXPORT_MEMBER
274 const char *wedln_context(WEdln *wedln)
275 {
276     return wedln->edln.context;
277 }
278