emacs.c revision 1.34 1 1.34 christos /* $NetBSD: emacs.c,v 1.34 2016/04/11 00:50:13 christos Exp $ */
2 1.3 lukem
3 1.1 cgd /*-
4 1.1 cgd * Copyright (c) 1992, 1993
5 1.1 cgd * The Regents of the University of California. All rights reserved.
6 1.1 cgd *
7 1.1 cgd * This code is derived from software contributed to Berkeley by
8 1.1 cgd * Christos Zoulas of Cornell University.
9 1.1 cgd *
10 1.1 cgd * Redistribution and use in source and binary forms, with or without
11 1.1 cgd * modification, are permitted provided that the following conditions
12 1.1 cgd * are met:
13 1.1 cgd * 1. Redistributions of source code must retain the above copyright
14 1.1 cgd * notice, this list of conditions and the following disclaimer.
15 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 cgd * notice, this list of conditions and the following disclaimer in the
17 1.1 cgd * documentation and/or other materials provided with the distribution.
18 1.15 agc * 3. Neither the name of the University nor the names of its contributors
19 1.1 cgd * may be used to endorse or promote products derived from this software
20 1.1 cgd * without specific prior written permission.
21 1.1 cgd *
22 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.1 cgd * SUCH DAMAGE.
33 1.1 cgd */
34 1.1 cgd
35 1.10 christos #include "config.h"
36 1.1 cgd #if !defined(lint) && !defined(SCCSID)
37 1.3 lukem #if 0
38 1.1 cgd static char sccsid[] = "@(#)emacs.c 8.1 (Berkeley) 6/4/93";
39 1.3 lukem #else
40 1.34 christos __RCSID("$NetBSD: emacs.c,v 1.34 2016/04/11 00:50:13 christos Exp $");
41 1.3 lukem #endif
42 1.1 cgd #endif /* not lint && not SCCSID */
43 1.1 cgd
44 1.7 simonb /*
45 1.1 cgd * emacs.c: Emacs functions
46 1.1 cgd */
47 1.32 christos #include <ctype.h>
48 1.32 christos
49 1.1 cgd #include "el.h"
50 1.31 christos #include "emacs.h"
51 1.1 cgd
52 1.1 cgd /* em_delete_or_list():
53 1.1 cgd * Delete character under cursor or list completions if at end of line
54 1.1 cgd * [^D]
55 1.1 cgd */
56 1.1 cgd protected el_action_t
57 1.1 cgd /*ARGSUSED*/
58 1.27 christos em_delete_or_list(EditLine *el, wint_t c)
59 1.8 lukem {
60 1.8 lukem
61 1.8 lukem if (el->el_line.cursor == el->el_line.lastchar) {
62 1.8 lukem /* if I'm at the end */
63 1.8 lukem if (el->el_line.cursor == el->el_line.buffer) {
64 1.8 lukem /* and the beginning */
65 1.24 christos terminal_writec(el, c); /* then do an EOF */
66 1.25 christos return CC_EOF;
67 1.8 lukem } else {
68 1.8 lukem /*
69 1.8 lukem * Here we could list completions, but it is an
70 1.8 lukem * error right now
71 1.8 lukem */
72 1.24 christos terminal_beep(el);
73 1.25 christos return CC_ERROR;
74 1.8 lukem }
75 1.8 lukem } else {
76 1.17 mycroft if (el->el_state.doingarg)
77 1.17 mycroft c_delafter(el, el->el_state.argument);
78 1.17 mycroft else
79 1.17 mycroft c_delafter1(el);
80 1.8 lukem if (el->el_line.cursor > el->el_line.lastchar)
81 1.8 lukem el->el_line.cursor = el->el_line.lastchar;
82 1.8 lukem /* bounds check */
83 1.25 christos return CC_REFRESH;
84 1.1 cgd }
85 1.1 cgd }
86 1.1 cgd
87 1.1 cgd
88 1.1 cgd /* em_delete_next_word():
89 1.1 cgd * Cut from cursor to end of current word
90 1.1 cgd * [M-d]
91 1.1 cgd */
92 1.1 cgd protected el_action_t
93 1.1 cgd /*ARGSUSED*/
94 1.27 christos em_delete_next_word(EditLine *el, wint_t c __attribute__((__unused__)))
95 1.8 lukem {
96 1.34 christos wchar_t *cp, *p, *kp;
97 1.8 lukem
98 1.8 lukem if (el->el_line.cursor == el->el_line.lastchar)
99 1.25 christos return CC_ERROR;
100 1.8 lukem
101 1.8 lukem cp = c__next_word(el->el_line.cursor, el->el_line.lastchar,
102 1.8 lukem el->el_state.argument, ce__isword);
103 1.8 lukem
104 1.8 lukem for (p = el->el_line.cursor, kp = el->el_chared.c_kill.buf; p < cp; p++)
105 1.8 lukem /* save the text */
106 1.8 lukem *kp++ = *p;
107 1.8 lukem el->el_chared.c_kill.last = kp;
108 1.8 lukem
109 1.22 christos c_delafter(el, (int)(cp - el->el_line.cursor)); /* delete after dot */
110 1.8 lukem if (el->el_line.cursor > el->el_line.lastchar)
111 1.8 lukem el->el_line.cursor = el->el_line.lastchar;
112 1.8 lukem /* bounds check */
113 1.25 christos return CC_REFRESH;
114 1.1 cgd }
115 1.1 cgd
116 1.1 cgd
117 1.1 cgd /* em_yank():
118 1.1 cgd * Paste cut buffer at cursor position
119 1.1 cgd * [^Y]
120 1.1 cgd */
121 1.1 cgd protected el_action_t
122 1.1 cgd /*ARGSUSED*/
123 1.27 christos em_yank(EditLine *el, wint_t c __attribute__((__unused__)))
124 1.8 lukem {
125 1.34 christos wchar_t *kp, *cp;
126 1.8 lukem
127 1.16 christos if (el->el_chared.c_kill.last == el->el_chared.c_kill.buf)
128 1.25 christos return CC_NORM;
129 1.8 lukem
130 1.8 lukem if (el->el_line.lastchar +
131 1.8 lukem (el->el_chared.c_kill.last - el->el_chared.c_kill.buf) >=
132 1.8 lukem el->el_line.limit)
133 1.25 christos return CC_ERROR;
134 1.8 lukem
135 1.8 lukem el->el_chared.c_kill.mark = el->el_line.cursor;
136 1.8 lukem cp = el->el_line.cursor;
137 1.8 lukem
138 1.8 lukem /* open the space, */
139 1.22 christos c_insert(el,
140 1.22 christos (int)(el->el_chared.c_kill.last - el->el_chared.c_kill.buf));
141 1.8 lukem /* copy the chars */
142 1.8 lukem for (kp = el->el_chared.c_kill.buf; kp < el->el_chared.c_kill.last; kp++)
143 1.8 lukem *cp++ = *kp;
144 1.8 lukem
145 1.8 lukem /* if an arg, cursor at beginning else cursor at end */
146 1.8 lukem if (el->el_state.argument == 1)
147 1.8 lukem el->el_line.cursor = cp;
148 1.1 cgd
149 1.25 christos return CC_REFRESH;
150 1.1 cgd }
151 1.1 cgd
152 1.1 cgd
153 1.1 cgd /* em_kill_line():
154 1.1 cgd * Cut the entire line and save in cut buffer
155 1.1 cgd * [^U]
156 1.1 cgd */
157 1.1 cgd protected el_action_t
158 1.1 cgd /*ARGSUSED*/
159 1.27 christos em_kill_line(EditLine *el, wint_t c __attribute__((__unused__)))
160 1.8 lukem {
161 1.34 christos wchar_t *kp, *cp;
162 1.8 lukem
163 1.8 lukem cp = el->el_line.buffer;
164 1.8 lukem kp = el->el_chared.c_kill.buf;
165 1.8 lukem while (cp < el->el_line.lastchar)
166 1.8 lukem *kp++ = *cp++; /* copy it */
167 1.8 lukem el->el_chared.c_kill.last = kp;
168 1.8 lukem /* zap! -- delete all of it */
169 1.8 lukem el->el_line.lastchar = el->el_line.buffer;
170 1.8 lukem el->el_line.cursor = el->el_line.buffer;
171 1.25 christos return CC_REFRESH;
172 1.1 cgd }
173 1.1 cgd
174 1.1 cgd
175 1.1 cgd /* em_kill_region():
176 1.1 cgd * Cut area between mark and cursor and save in cut buffer
177 1.1 cgd * [^W]
178 1.1 cgd */
179 1.1 cgd protected el_action_t
180 1.1 cgd /*ARGSUSED*/
181 1.27 christos em_kill_region(EditLine *el, wint_t c __attribute__((__unused__)))
182 1.1 cgd {
183 1.34 christos wchar_t *kp, *cp;
184 1.1 cgd
185 1.8 lukem if (!el->el_chared.c_kill.mark)
186 1.25 christos return CC_ERROR;
187 1.1 cgd
188 1.8 lukem if (el->el_chared.c_kill.mark > el->el_line.cursor) {
189 1.8 lukem cp = el->el_line.cursor;
190 1.8 lukem kp = el->el_chared.c_kill.buf;
191 1.8 lukem while (cp < el->el_chared.c_kill.mark)
192 1.8 lukem *kp++ = *cp++; /* copy it */
193 1.8 lukem el->el_chared.c_kill.last = kp;
194 1.22 christos c_delafter(el, (int)(cp - el->el_line.cursor));
195 1.8 lukem } else { /* mark is before cursor */
196 1.8 lukem cp = el->el_chared.c_kill.mark;
197 1.8 lukem kp = el->el_chared.c_kill.buf;
198 1.8 lukem while (cp < el->el_line.cursor)
199 1.8 lukem *kp++ = *cp++; /* copy it */
200 1.8 lukem el->el_chared.c_kill.last = kp;
201 1.22 christos c_delbefore(el, (int)(cp - el->el_chared.c_kill.mark));
202 1.8 lukem el->el_line.cursor = el->el_chared.c_kill.mark;
203 1.8 lukem }
204 1.25 christos return CC_REFRESH;
205 1.1 cgd }
206 1.1 cgd
207 1.1 cgd
208 1.1 cgd /* em_copy_region():
209 1.1 cgd * Copy area between mark and cursor to cut buffer
210 1.1 cgd * [M-W]
211 1.1 cgd */
212 1.1 cgd protected el_action_t
213 1.1 cgd /*ARGSUSED*/
214 1.27 christos em_copy_region(EditLine *el, wint_t c __attribute__((__unused__)))
215 1.1 cgd {
216 1.34 christos wchar_t *kp, *cp;
217 1.1 cgd
218 1.11 christos if (!el->el_chared.c_kill.mark)
219 1.25 christos return CC_ERROR;
220 1.1 cgd
221 1.8 lukem if (el->el_chared.c_kill.mark > el->el_line.cursor) {
222 1.8 lukem cp = el->el_line.cursor;
223 1.8 lukem kp = el->el_chared.c_kill.buf;
224 1.8 lukem while (cp < el->el_chared.c_kill.mark)
225 1.8 lukem *kp++ = *cp++; /* copy it */
226 1.8 lukem el->el_chared.c_kill.last = kp;
227 1.8 lukem } else {
228 1.8 lukem cp = el->el_chared.c_kill.mark;
229 1.8 lukem kp = el->el_chared.c_kill.buf;
230 1.8 lukem while (cp < el->el_line.cursor)
231 1.8 lukem *kp++ = *cp++; /* copy it */
232 1.8 lukem el->el_chared.c_kill.last = kp;
233 1.8 lukem }
234 1.25 christos return CC_NORM;
235 1.1 cgd }
236 1.1 cgd
237 1.1 cgd
238 1.13 perry /* em_gosmacs_transpose():
239 1.1 cgd * Exchange the two characters before the cursor
240 1.1 cgd * Gosling emacs transpose chars [^T]
241 1.1 cgd */
242 1.1 cgd protected el_action_t
243 1.27 christos em_gosmacs_transpose(EditLine *el, wint_t c)
244 1.1 cgd {
245 1.1 cgd
246 1.8 lukem if (el->el_line.cursor > &el->el_line.buffer[1]) {
247 1.8 lukem /* must have at least two chars entered */
248 1.8 lukem c = el->el_line.cursor[-2];
249 1.8 lukem el->el_line.cursor[-2] = el->el_line.cursor[-1];
250 1.34 christos el->el_line.cursor[-1] = c;
251 1.25 christos return CC_REFRESH;
252 1.8 lukem } else
253 1.25 christos return CC_ERROR;
254 1.1 cgd }
255 1.1 cgd
256 1.1 cgd
257 1.1 cgd /* em_next_word():
258 1.1 cgd * Move next to end of current word
259 1.1 cgd * [M-f]
260 1.1 cgd */
261 1.1 cgd protected el_action_t
262 1.1 cgd /*ARGSUSED*/
263 1.27 christos em_next_word(EditLine *el, wint_t c __attribute__((__unused__)))
264 1.8 lukem {
265 1.8 lukem if (el->el_line.cursor == el->el_line.lastchar)
266 1.25 christos return CC_ERROR;
267 1.1 cgd
268 1.8 lukem el->el_line.cursor = c__next_word(el->el_line.cursor,
269 1.8 lukem el->el_line.lastchar,
270 1.8 lukem el->el_state.argument,
271 1.8 lukem ce__isword);
272 1.8 lukem
273 1.8 lukem if (el->el_map.type == MAP_VI)
274 1.12 christos if (el->el_chared.c_vcmd.action != NOP) {
275 1.8 lukem cv_delfini(el);
276 1.25 christos return CC_REFRESH;
277 1.8 lukem }
278 1.25 christos return CC_CURSOR;
279 1.1 cgd }
280 1.1 cgd
281 1.8 lukem
282 1.1 cgd /* em_upper_case():
283 1.1 cgd * Uppercase the characters from cursor to end of current word
284 1.1 cgd * [M-u]
285 1.1 cgd */
286 1.1 cgd protected el_action_t
287 1.1 cgd /*ARGSUSED*/
288 1.27 christos em_upper_case(EditLine *el, wint_t c __attribute__((__unused__)))
289 1.8 lukem {
290 1.34 christos wchar_t *cp, *ep;
291 1.8 lukem
292 1.8 lukem ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
293 1.8 lukem el->el_state.argument, ce__isword);
294 1.8 lukem
295 1.8 lukem for (cp = el->el_line.cursor; cp < ep; cp++)
296 1.33 christos if (iswlower(*cp))
297 1.33 christos *cp = towupper(*cp);
298 1.8 lukem
299 1.8 lukem el->el_line.cursor = ep;
300 1.8 lukem if (el->el_line.cursor > el->el_line.lastchar)
301 1.8 lukem el->el_line.cursor = el->el_line.lastchar;
302 1.25 christos return CC_REFRESH;
303 1.1 cgd }
304 1.1 cgd
305 1.1 cgd
306 1.1 cgd /* em_capitol_case():
307 1.1 cgd * Capitalize the characters from cursor to end of current word
308 1.1 cgd * [M-c]
309 1.1 cgd */
310 1.1 cgd protected el_action_t
311 1.1 cgd /*ARGSUSED*/
312 1.27 christos em_capitol_case(EditLine *el, wint_t c __attribute__((__unused__)))
313 1.8 lukem {
314 1.34 christos wchar_t *cp, *ep;
315 1.8 lukem
316 1.8 lukem ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
317 1.8 lukem el->el_state.argument, ce__isword);
318 1.8 lukem
319 1.8 lukem for (cp = el->el_line.cursor; cp < ep; cp++) {
320 1.33 christos if (iswalpha(*cp)) {
321 1.33 christos if (iswlower(*cp))
322 1.33 christos *cp = towupper(*cp);
323 1.8 lukem cp++;
324 1.8 lukem break;
325 1.8 lukem }
326 1.1 cgd }
327 1.8 lukem for (; cp < ep; cp++)
328 1.33 christos if (iswupper(*cp))
329 1.33 christos *cp = towlower(*cp);
330 1.8 lukem
331 1.8 lukem el->el_line.cursor = ep;
332 1.8 lukem if (el->el_line.cursor > el->el_line.lastchar)
333 1.8 lukem el->el_line.cursor = el->el_line.lastchar;
334 1.25 christos return CC_REFRESH;
335 1.1 cgd }
336 1.1 cgd
337 1.8 lukem
338 1.1 cgd /* em_lower_case():
339 1.1 cgd * Lowercase the characters from cursor to end of current word
340 1.1 cgd * [M-l]
341 1.1 cgd */
342 1.1 cgd protected el_action_t
343 1.1 cgd /*ARGSUSED*/
344 1.27 christos em_lower_case(EditLine *el, wint_t c __attribute__((__unused__)))
345 1.8 lukem {
346 1.34 christos wchar_t *cp, *ep;
347 1.8 lukem
348 1.8 lukem ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
349 1.8 lukem el->el_state.argument, ce__isword);
350 1.8 lukem
351 1.8 lukem for (cp = el->el_line.cursor; cp < ep; cp++)
352 1.33 christos if (iswupper(*cp))
353 1.33 christos *cp = towlower(*cp);
354 1.8 lukem
355 1.8 lukem el->el_line.cursor = ep;
356 1.8 lukem if (el->el_line.cursor > el->el_line.lastchar)
357 1.8 lukem el->el_line.cursor = el->el_line.lastchar;
358 1.25 christos return CC_REFRESH;
359 1.1 cgd }
360 1.1 cgd
361 1.1 cgd
362 1.1 cgd /* em_set_mark():
363 1.1 cgd * Set the mark at cursor
364 1.1 cgd * [^@]
365 1.1 cgd */
366 1.1 cgd protected el_action_t
367 1.1 cgd /*ARGSUSED*/
368 1.27 christos em_set_mark(EditLine *el, wint_t c __attribute__((__unused__)))
369 1.1 cgd {
370 1.8 lukem
371 1.8 lukem el->el_chared.c_kill.mark = el->el_line.cursor;
372 1.25 christos return CC_NORM;
373 1.1 cgd }
374 1.1 cgd
375 1.1 cgd
376 1.1 cgd /* em_exchange_mark():
377 1.7 simonb * Exchange the cursor and mark
378 1.1 cgd * [^X^X]
379 1.1 cgd */
380 1.1 cgd protected el_action_t
381 1.1 cgd /*ARGSUSED*/
382 1.27 christos em_exchange_mark(EditLine *el, wint_t c __attribute__((__unused__)))
383 1.8 lukem {
384 1.34 christos wchar_t *cp;
385 1.8 lukem
386 1.8 lukem cp = el->el_line.cursor;
387 1.8 lukem el->el_line.cursor = el->el_chared.c_kill.mark;
388 1.8 lukem el->el_chared.c_kill.mark = cp;
389 1.25 christos return CC_CURSOR;
390 1.1 cgd }
391 1.1 cgd
392 1.8 lukem
393 1.1 cgd /* em_universal_argument():
394 1.1 cgd * Universal argument (argument times 4)
395 1.1 cgd * [^U]
396 1.1 cgd */
397 1.1 cgd protected el_action_t
398 1.1 cgd /*ARGSUSED*/
399 1.27 christos em_universal_argument(EditLine *el, wint_t c __attribute__((__unused__)))
400 1.1 cgd { /* multiply current argument by 4 */
401 1.8 lukem
402 1.8 lukem if (el->el_state.argument > 1000000)
403 1.25 christos return CC_ERROR;
404 1.8 lukem el->el_state.doingarg = 1;
405 1.8 lukem el->el_state.argument *= 4;
406 1.25 christos return CC_ARGHACK;
407 1.1 cgd }
408 1.1 cgd
409 1.8 lukem
410 1.1 cgd /* em_meta_next():
411 1.1 cgd * Add 8th bit to next character typed
412 1.1 cgd * [<ESC>]
413 1.1 cgd */
414 1.1 cgd protected el_action_t
415 1.1 cgd /*ARGSUSED*/
416 1.27 christos em_meta_next(EditLine *el, wint_t c __attribute__((__unused__)))
417 1.1 cgd {
418 1.8 lukem
419 1.8 lukem el->el_state.metanext = 1;
420 1.25 christos return CC_ARGHACK;
421 1.1 cgd }
422 1.1 cgd
423 1.1 cgd
424 1.1 cgd /* em_toggle_overwrite():
425 1.1 cgd * Switch from insert to overwrite mode or vice versa
426 1.1 cgd */
427 1.1 cgd protected el_action_t
428 1.1 cgd /*ARGSUSED*/
429 1.27 christos em_toggle_overwrite(EditLine *el, wint_t c __attribute__((__unused__)))
430 1.8 lukem {
431 1.8 lukem
432 1.8 lukem el->el_state.inputmode = (el->el_state.inputmode == MODE_INSERT) ?
433 1.8 lukem MODE_REPLACE : MODE_INSERT;
434 1.25 christos return CC_NORM;
435 1.1 cgd }
436 1.1 cgd
437 1.1 cgd
438 1.1 cgd /* em_copy_prev_word():
439 1.1 cgd * Copy current word to cursor
440 1.1 cgd */
441 1.1 cgd protected el_action_t
442 1.1 cgd /*ARGSUSED*/
443 1.27 christos em_copy_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
444 1.1 cgd {
445 1.34 christos wchar_t *cp, *oldc, *dp;
446 1.1 cgd
447 1.8 lukem if (el->el_line.cursor == el->el_line.buffer)
448 1.25 christos return CC_ERROR;
449 1.1 cgd
450 1.8 lukem oldc = el->el_line.cursor;
451 1.8 lukem /* does a bounds check */
452 1.8 lukem cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
453 1.8 lukem el->el_state.argument, ce__isword);
454 1.1 cgd
455 1.22 christos c_insert(el, (int)(oldc - cp));
456 1.8 lukem for (dp = oldc; cp < oldc && dp < el->el_line.lastchar; cp++)
457 1.8 lukem *dp++ = *cp;
458 1.1 cgd
459 1.8 lukem el->el_line.cursor = dp;/* put cursor at end */
460 1.1 cgd
461 1.25 christos return CC_REFRESH;
462 1.1 cgd }
463 1.1 cgd
464 1.1 cgd
465 1.1 cgd /* em_inc_search_next():
466 1.1 cgd * Emacs incremental next search
467 1.1 cgd */
468 1.1 cgd protected el_action_t
469 1.1 cgd /*ARGSUSED*/
470 1.27 christos em_inc_search_next(EditLine *el, wint_t c __attribute__((__unused__)))
471 1.1 cgd {
472 1.8 lukem
473 1.8 lukem el->el_search.patlen = 0;
474 1.25 christos return ce_inc_search(el, ED_SEARCH_NEXT_HISTORY);
475 1.1 cgd }
476 1.1 cgd
477 1.1 cgd
478 1.1 cgd /* em_inc_search_prev():
479 1.1 cgd * Emacs incremental reverse search
480 1.1 cgd */
481 1.1 cgd protected el_action_t
482 1.1 cgd /*ARGSUSED*/
483 1.27 christos em_inc_search_prev(EditLine *el, wint_t c __attribute__((__unused__)))
484 1.1 cgd {
485 1.8 lukem
486 1.8 lukem el->el_search.patlen = 0;
487 1.25 christos return ce_inc_search(el, ED_SEARCH_PREV_HISTORY);
488 1.1 cgd }
489 1.17 mycroft
490 1.17 mycroft
491 1.17 mycroft /* em_delete_prev_char():
492 1.17 mycroft * Delete the character to the left of the cursor
493 1.17 mycroft * [^?]
494 1.17 mycroft */
495 1.17 mycroft protected el_action_t
496 1.17 mycroft /*ARGSUSED*/
497 1.27 christos em_delete_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
498 1.17 mycroft {
499 1.17 mycroft
500 1.17 mycroft if (el->el_line.cursor <= el->el_line.buffer)
501 1.25 christos return CC_ERROR;
502 1.17 mycroft
503 1.17 mycroft if (el->el_state.doingarg)
504 1.17 mycroft c_delbefore(el, el->el_state.argument);
505 1.17 mycroft else
506 1.17 mycroft c_delbefore1(el);
507 1.17 mycroft el->el_line.cursor -= el->el_state.argument;
508 1.17 mycroft if (el->el_line.cursor < el->el_line.buffer)
509 1.17 mycroft el->el_line.cursor = el->el_line.buffer;
510 1.25 christos return CC_REFRESH;
511 1.17 mycroft }
512