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