#include <ctype.h>#include <string.h>#include "histedit.h"#include "common.h"#include "vi.h"#include "emacs.h"#include "search.h"#include "fcns.h"Include dependency graph for chared.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Classes | |
| struct | c_kill_t |
| struct | c_macro_t |
| struct | c_undo_t |
| struct | c_vcmd_t |
| struct | el_chared_t |
Defines | |
| #define | EL_MAXMACRO 10 |
| #define | VI_MOVE |
| #define | STReof "^D\b\b" |
| #define | STRQQ "\"\"" |
| #define | isglob(a) (strchr("*[]?", (a)) != NULL) |
| #define | isword(a) (isprint(a)) |
| #define | NOP 0x00 |
| #define | DELETE 0x01 |
| #define | INSERT 0x02 |
| #define | CHANGE 0x04 |
| #define | CHAR_FWD 0 |
| #define | CHAR_BACK 1 |
| #define | MODE_INSERT 0 |
| #define | MODE_REPLACE 1 |
| #define | MODE_REPLACE_1 2 |
Typedefs | |
| typedef c_macro_t | c_macro_t |
| typedef c_undo_t | c_undo_t |
| typedef c_vcmd_t | c_vcmd_t |
| typedef c_kill_t | c_kill_t |
| typedef el_chared_t | el_chared_t |
Functions | |
| protected int | cv__isword (int) |
| protected void | cv_delfini (EditLine *) |
| protected char * | cv__endword (char *, char *, int) |
| protected int | ce__isword (int) |
| protected void | cv_undo (EditLine *, int, size_t, char *) |
| protected char * | cv_next_word (EditLine *, char *, char *, int, int(*)(int)) |
| protected char * | cv_prev_word (EditLine *, char *, char *, int, int(*)(int)) |
| protected char * | c__next_word (char *, char *, int, int(*)(int)) |
| protected char * | c__prev_word (char *, char *, int, int(*)(int)) |
| protected void | c_insert (EditLine *, int) |
| protected void | c_delbefore (EditLine *, int) |
| protected void | c_delafter (EditLine *, int) |
| protected int | c_gets (EditLine *, char *) |
| protected int | c_hpos (EditLine *) |
| protected int | ch_init (EditLine *) |
| protected void | ch_reset (EditLine *) |
| protected int ch_enlargebufs | __P ((EditLine *, size_t)) |
| protected void | ch_end (EditLine *) |
|
|
Definition at line 123 of file chared.h. Referenced by vi_replace_char(), vi_replace_mode(), and vi_undo(). |
|
|
Definition at line 126 of file chared.h. Referenced by vi_prev_char(), and vi_repeat_prev_char(). |
|
|
Definition at line 125 of file chared.h. Referenced by vi_next_char(), and vi_repeat_next_char(). |
|
|
Definition at line 121 of file chared.h. Referenced by cv_action(), cv_csearch_back(), cv_csearch_fwd(), cv_delfini(), cv_next_word(), cv_prev_word(), ed_move_to_beg(), ed_move_to_end(), ed_next_char(), ed_prev_char(), ed_prev_word(), em_next_word(), vi_add(), vi_add_at_eol(), vi_change_meta(), vi_command_mode(), vi_delete_meta(), vi_end_word(), vi_insert(), vi_insert_at_bol(), vi_next_space_word(), vi_next_word(), vi_prev_space_word(), vi_prev_word(), vi_to_end_word(), vi_undo(), and vi_zero(). |
|
|
|
|
|
Definition at line 122 of file chared.h. Referenced by c_delafter(), c_delbefore(), cv_action(), cv_delfini(), cv_next_word(), cv_prev_word(), vi_change_meta(), vi_command_mode(), and vi_undo(). |
|
|
Definition at line 117 of file chared.h. Referenced by ce_inc_search(). |
|
|
|
|
|
Definition at line 128 of file chared.h. Referenced by ch_init(), ch_reset(), ed_digit(), ed_insert(), em_toggle_overwrite(), and vi_command_mode(). |
|
|
Definition at line 129 of file chared.h. Referenced by em_toggle_overwrite(), and vi_replace_mode(). |
|
|
Definition at line 130 of file chared.h. Referenced by ed_insert(), and vi_replace_char(). |
|
|
|
|
|
Definition at line 114 of file chared.h. Referenced by ed_delete_next_char(), em_delete_or_list(), and vi_list_or_eof(). |
|
|
Definition at line 115 of file chared.h. Referenced by map_print_some_keys(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||||||||||||||||
|
Definition at line 196 of file chared.c. References p. Referenced by ce_inc_search(), em_capitol_case(), em_delete_next_word(), em_lower_case(), em_next_word(), and em_upper_case().
|
|
||||||||||||||||||||
|
Definition at line 172 of file chared.c. References p. Referenced by ed_delete_prev_word(), ed_prev_word(), and em_copy_prev_word().
00173 {
00174 p--;
00175
00176 while (n--) {
00177 while ((p >= low) && !(*wtest)((unsigned char) *p))
00178 p--;
00179 while ((p >= low) && (*wtest)((unsigned char) *p))
00180 p--;
00181 }
00182
00183 /* cp now points to one character before the word */
00184 p++;
00185 if (p < low)
00186 p = low;
00187 /* cp now points where we want it */
00188 return (p);
00189 }
|
|
||||||||||||
|
Definition at line 101 of file chared.c. References el_map_t::current, el_line_t::cursor, cv_undo(), EditLine, editline::el_line, editline::el_map, el_map_t::emacs, INSERT, and el_line_t::lastchar. Referenced by cv_delfini(), ed_delete_next_char(), ed_digit(), ed_insert(), em_delete_next_word(), em_delete_or_list(), em_kill_region(), and vi_substitute_char().
00102 {
00103
00104 if (el->el_line.cursor + num > el->el_line.lastchar)
00105 num = el->el_line.lastchar - el->el_line.cursor;
00106
00107 if (num > 0) {
00108 char *cp;
00109
00110 if (el->el_map.current != el->el_map.emacs)
00111 cv_undo(el, INSERT, (size_t)num, el->el_line.cursor);
00112
00113 for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++)
00114 *cp = cp[num];
00115
00116 el->el_line.lastchar -= num;
00117 }
00118 }
|
|
||||||||||||
|
Definition at line 125 of file chared.c. References el_line_t::buffer, el_map_t::current, el_line_t::cursor, cv_undo(), EditLine, editline::el_line, editline::el_map, el_map_t::emacs, INSERT, and el_line_t::lastchar. Referenced by cv_delfini(), ed_delete_prev_char(), ed_delete_prev_word(), el_deletestr(), em_kill_region(), vi_delete_prev_char(), and vi_kill_line_prev().
00126 {
00127
00128 if (el->el_line.cursor - num < el->el_line.buffer)
00129 num = el->el_line.cursor - el->el_line.buffer;
00130
00131 if (num > 0) {
00132 char *cp;
00133
00134 if (el->el_map.current != el->el_map.emacs)
00135 cv_undo(el, INSERT, (size_t)num,
00136 el->el_line.cursor - num);
00137
00138 for (cp = el->el_line.cursor - num;
00139 cp <= el->el_line.lastchar;
00140 cp++)
00141 *cp = cp[num];
00142
00143 el->el_line.lastchar -= num;
00144 }
00145 }
|
|
||||||||||||
|
Definition at line 629 of file chared.c. References el_line_t::buffer, CC_REFRESH, el_line_t::cursor, ed_end_of_file(), EditLine, EL_BUFSIZ, el_getc(), editline::el_line, el_line_t::lastchar, len, re_refresh(), and term_beep(). Referenced by cv_search(), and ed_command().
00630 {
00631 char ch;
00632 int len = 0;
00633
00634 for (ch = 0; ch == 0;) {
00635 if (el_getc(el, &ch) != 1)
00636 return (ed_end_of_file(el, 0));
00637 switch (ch) {
00638 case 0010: /* Delete and backspace */
00639 case 0177:
00640 if (len > 1) {
00641 *el->el_line.cursor-- = '\0';
00642 el->el_line.lastchar = el->el_line.cursor;
00643 buf[len--] = '\0';
00644 } else {
00645 el->el_line.buffer[0] = '\0';
00646 el->el_line.lastchar = el->el_line.buffer;
00647 el->el_line.cursor = el->el_line.buffer;
00648 return (CC_REFRESH);
00649 }
00650 re_refresh(el);
00651 ch = 0;
00652 break;
00653
00654 case 0033: /* ESC */
00655 case '\r': /* Newline */
00656 case '\n':
00657 break;
00658
00659 default:
00660 if (len >= EL_BUFSIZ)
00661 term_beep(el);
00662 else {
00663 buf[len++] = ch;
00664 *el->el_line.cursor++ = ch;
00665 el->el_line.lastchar = el->el_line.cursor;
00666 }
00667 re_refresh(el);
00668 ch = 0;
00669 break;
00670 }
00671 }
00672 buf[len] = ch;
00673 return (len);
00674 }
|
|
|
Definition at line 681 of file chared.c. References el_line_t::buffer, el_line_t::cursor, EditLine, and editline::el_line. Referenced by ed_next_line(), and ed_prev_line().
00682 {
00683 char *ptr;
00684
00685 /*
00686 * Find how many characters till the beginning of this line.
00687 */
00688 if (el->el_line.cursor == el->el_line.buffer)
00689 return (0);
00690 else {
00691 for (ptr = el->el_line.cursor - 1;
00692 ptr >= el->el_line.buffer && *ptr != '\n';
00693 ptr--)
00694 continue;
00695 return (el->el_line.cursor - ptr - 1);
00696 }
00697 }
|
|
||||||||||||
|
Definition at line 81 of file chared.c. References el_line_t::cursor, EditLine, editline::el_line, el_line_t::lastchar, and el_line_t::limit. Referenced by cv_paste(), cv_search(), ed_command(), ed_digit(), ed_insert(), el_insertstr(), em_copy_prev_word(), em_yank(), and vi_undo().
00082 {
00083 char *cp;
00084
00085 if (el->el_line.lastchar + num >= el->el_line.limit)
00086 return; /* can't go past end of buffer */
00087
00088 if (el->el_line.cursor < el->el_line.lastchar) {
00089 /* if I must move chars */
00090 for (cp = el->el_line.lastchar; cp >= el->el_line.cursor; cp--)
00091 cp[num] = *cp;
00092 }
00093 el->el_line.lastchar += num;
00094 }
|
|
|
Definition at line 152 of file chared.c. References p. Referenced by ce_inc_search(), ed_delete_prev_word(), ed_prev_word(), em_capitol_case(), em_copy_prev_word(), em_delete_next_word(), em_lower_case(), em_next_word(), em_upper_case(), vi_next_word(), and vi_prev_word().
00153 {
00154 return (isalpha(p) || isdigit(p) || strchr("*?_-.[]~=", p) != NULL);
00155 }
|
|
|
Definition at line 570 of file chared.c. References c_kill_t::buf, c_undo_t::buf, el_line_t::buffer, el_chared_t::c_kill, el_chared_t::c_macro, el_chared_t::c_undo, ch_reset(), EditLine, editline::el_chared, el_free, editline::el_line, el_line_t::limit, c_macro_t::macro, and ptr_t. Referenced by el_end().
00571 {
00572 el_free((ptr_t) el->el_line.buffer);
00573 el->el_line.buffer = NULL;
00574 el->el_line.limit = NULL;
00575 el_free((ptr_t) el->el_chared.c_undo.buf);
00576 el->el_chared.c_undo.buf = NULL;
00577 el_free((ptr_t) el->el_chared.c_kill.buf);
00578 el->el_chared.c_kill.buf = NULL;
00579 el_free((ptr_t) el->el_chared.c_macro.macro);
00580 el->el_chared.c_macro.macro = NULL;
00581 ch_reset(el);
00582 }
|
|
|
Definition at line 407 of file chared.c. References c_vcmd_t::action, c_undo_t::action, el_state_t::argument, c_kill_t::buf, c_undo_t::buf, el_line_t::buffer, el_chared_t::c_kill, el_chared_t::c_macro, el_chared_t::c_undo, el_chared_t::c_vcmd, el_map_t::current, el_line_t::cursor, el_state_t::doingarg, c_undo_t::dsize, ED_UNASSIGNED, EditLine, EL_BUFSIZ, editline::el_chared, editline::el_line, el_malloc, editline::el_map, EL_MAXMACRO, editline::el_state, el_state_t::inputmode, c_vcmd_t::ins, c_undo_t::isize, el_map_t::key, c_kill_t::last, el_line_t::lastchar, el_state_t::lastcmd, c_macro_t::level, el_line_t::limit, c_macro_t::macro, c_kill_t::mark, el_state_t::metanext, MODE_INSERT, c_macro_t::nline, NOP, c_vcmd_t::pos, and c_undo_t::ptr. Referenced by el_init().
00408 {
00409 el->el_line.buffer = (char *) el_malloc(EL_BUFSIZ);
00410 if (el->el_line.buffer == NULL)
00411 return (-1);
00412
00413 (void) memset(el->el_line.buffer, 0, EL_BUFSIZ);
00414 el->el_line.cursor = el->el_line.buffer;
00415 el->el_line.lastchar = el->el_line.buffer;
00416 el->el_line.limit = &el->el_line.buffer[EL_BUFSIZ - 2];
00417
00418 el->el_chared.c_undo.buf = (char *) el_malloc(EL_BUFSIZ);
00419 if (el->el_chared.c_undo.buf == NULL)
00420 return (-1);
00421 (void) memset(el->el_chared.c_undo.buf, 0, EL_BUFSIZ);
00422 el->el_chared.c_undo.action = NOP;
00423 el->el_chared.c_undo.isize = 0;
00424 el->el_chared.c_undo.dsize = 0;
00425 el->el_chared.c_undo.ptr = el->el_line.buffer;
00426
00427 el->el_chared.c_vcmd.action = NOP;
00428 el->el_chared.c_vcmd.pos = el->el_line.buffer;
00429 el->el_chared.c_vcmd.ins = el->el_line.buffer;
00430
00431 el->el_chared.c_kill.buf = (char *) el_malloc(EL_BUFSIZ);
00432 if (el->el_chared.c_kill.buf == NULL)
00433 return (-1);
00434 (void) memset(el->el_chared.c_kill.buf, 0, EL_BUFSIZ);
00435 el->el_chared.c_kill.mark = el->el_line.buffer;
00436 el->el_chared.c_kill.last = el->el_chared.c_kill.buf;
00437
00438 el->el_map.current = el->el_map.key;
00439
00440 el->el_state.inputmode = MODE_INSERT; /* XXX: save a default */
00441 el->el_state.doingarg = 0;
00442 el->el_state.metanext = 0;
00443 el->el_state.argument = 1;
00444 el->el_state.lastcmd = ED_UNASSIGNED;
00445
00446 el->el_chared.c_macro.nline = NULL;
00447 el->el_chared.c_macro.level = -1;
00448 el->el_chared.c_macro.macro = (char **) el_malloc(EL_MAXMACRO *
00449 sizeof(char *));
00450 if (el->el_chared.c_macro.macro == NULL)
00451 return (-1);
00452 return (0);
00453 }
|
|
|
Definition at line 459 of file chared.c. References c_vcmd_t::action, c_undo_t::action, el_state_t::argument, el_line_t::buffer, el_chared_t::c_kill, el_chared_t::c_macro, el_chared_t::c_undo, el_chared_t::c_vcmd, el_map_t::current, el_line_t::cursor, el_state_t::doingarg, c_undo_t::dsize, ED_UNASSIGNED, EditLine, editline::el_chared, editline::el_history, editline::el_line, editline::el_map, editline::el_state, el_history_t::eventno, el_state_t::inputmode, c_vcmd_t::ins, c_undo_t::isize, el_map_t::key, el_line_t::lastchar, el_state_t::lastcmd, c_macro_t::level, c_kill_t::mark, el_state_t::metanext, MODE_INSERT, NOP, c_vcmd_t::pos, and c_undo_t::ptr. Referenced by ch_end(), ed_start_over(), el_gets(), and el_reset().
00460 {
00461 el->el_line.cursor = el->el_line.buffer;
00462 el->el_line.lastchar = el->el_line.buffer;
00463
00464 el->el_chared.c_undo.action = NOP;
00465 el->el_chared.c_undo.isize = 0;
00466 el->el_chared.c_undo.dsize = 0;
00467 el->el_chared.c_undo.ptr = el->el_line.buffer;
00468
00469 el->el_chared.c_vcmd.action = NOP;
00470 el->el_chared.c_vcmd.pos = el->el_line.buffer;
00471 el->el_chared.c_vcmd.ins = el->el_line.buffer;
00472
00473 el->el_chared.c_kill.mark = el->el_line.buffer;
00474
00475 el->el_map.current = el->el_map.key;
00476
00477 el->el_state.inputmode = MODE_INSERT; /* XXX: save a default */
00478 el->el_state.doingarg = 0;
00479 el->el_state.metanext = 0;
00480 el->el_state.argument = 1;
00481 el->el_state.lastcmd = ED_UNASSIGNED;
00482
00483 el->el_chared.c_macro.level = -1;
00484
00485 el->el_history.eventno = 0;
00486 }
|
|
||||||||||||||||
|
Definition at line 383 of file chared.c. References p. Referenced by vi_end_word(), and vi_to_end_word().
00384 {
00385 p++;
00386
00387 while (n--) {
00388 while ((p < high) && isspace((unsigned char) *p))
00389 p++;
00390
00391 if (isalnum((unsigned char) *p))
00392 while ((p < high) && isalnum((unsigned char) *p))
00393 p++;
00394 else
00395 while ((p < high) && !(isspace((unsigned char) *p) ||
00396 isalnum((unsigned char) *p)))
00397 p++;
00398 }
00399 p--;
00400 return (p);
00401 }
|
|
|
Definition at line 162 of file chared.c. References p. Referenced by vi_next_space_word(), and vi_prev_space_word().
00163 {
00164 return (!isspace(p));
00165 }
|
|
|
Definition at line 310 of file chared.c. References c_undo_t::action, c_vcmd_t::action, c_delafter(), c_delbefore(), el_chared_t::c_undo, el_chared_t::c_vcmd, el_map_t::current, el_line_t::cursor, DELETE, c_undo_t::dsize, EditLine, EL_ABORT, editline::el_chared, editline::el_errfile, editline::el_line, editline::el_map, INSERT, el_map_t::key, NOP, c_vcmd_t::pos, c_undo_t::ptr, re_refresh_cursor(), and size. Referenced by cv_csearch_back(), cv_csearch_fwd(), ed_move_to_beg(), ed_move_to_end(), ed_next_char(), ed_prev_char(), ed_prev_word(), em_next_word(), vi_end_word(), vi_next_space_word(), vi_next_word(), vi_prev_space_word(), vi_prev_word(), vi_to_end_word(), and vi_zero().
00311 {
00312 int size;
00313 int oaction;
00314
00315 if (el->el_chared.c_vcmd.action & INSERT)
00316 el->el_map.current = el->el_map.key;
00317
00318 oaction = el->el_chared.c_vcmd.action;
00319 el->el_chared.c_vcmd.action = NOP;
00320
00321 if (el->el_chared.c_vcmd.pos == 0)
00322 return;
00323
00324
00325 if (el->el_line.cursor > el->el_chared.c_vcmd.pos) {
00326 size = (int) (el->el_line.cursor - el->el_chared.c_vcmd.pos);
00327 c_delbefore(el, size);
00328 el->el_line.cursor = el->el_chared.c_vcmd.pos;
00329 re_refresh_cursor(el);
00330 } else if (el->el_line.cursor < el->el_chared.c_vcmd.pos) {
00331 size = (int)(el->el_chared.c_vcmd.pos - el->el_line.cursor);
00332 c_delafter(el, size);
00333 } else {
00334 size = 1;
00335 c_delafter(el, size);
00336 }
00337 switch (oaction) {
00338 case DELETE|INSERT:
00339 el->el_chared.c_undo.action = DELETE|INSERT;
00340 break;
00341 case DELETE:
00342 el->el_chared.c_undo.action = INSERT;
00343 break;
00344 case NOP:
00345 case INSERT:
00346 default:
00347 EL_ABORT((el->el_errfile, "Bad oaction %d\n", oaction));
00348 break;
00349 }
00350
00351
00352 el->el_chared.c_undo.ptr = el->el_line.cursor;
00353 el->el_chared.c_undo.dsize = size;
00354 }
|
|
||||||||||||||||||||||||
|
Definition at line 214 of file chared.c. References c_vcmd_t::action, el_chared_t::c_vcmd, DELETE, EditLine, editline::el_chared, INSERT, and p. Referenced by vi_next_space_word(), and vi_next_word().
00215 {
00216 int test;
00217
00218 while (n--) {
00219 test = (*wtest)((unsigned char) *p);
00220 while ((p < high) && (*wtest)((unsigned char) *p) == test)
00221 p++;
00222 /*
00223 * vi historically deletes with cw only the word preserving the
00224 * trailing whitespace! This is not what 'w' does..
00225 */
00226 if (el->el_chared.c_vcmd.action != (DELETE|INSERT))
00227 while ((p < high) && isspace((unsigned char) *p))
00228 p++;
00229 }
00230
00231 /* p now points where we want it */
00232 if (p > high)
00233 return (high);
00234 else
00235 return (p);
00236 }
|
|
||||||||||||||||||||||||
|
Definition at line 243 of file chared.c. References c_vcmd_t::action, el_chared_t::c_vcmd, DELETE, EditLine, editline::el_chared, INSERT, and p. Referenced by vi_prev_space_word(), and vi_prev_word().
00244 {
00245 int test;
00246
00247 while (n--) {
00248 p--;
00249 /*
00250 * vi historically deletes with cb only the word preserving the
00251 * leading whitespace! This is not what 'b' does..
00252 */
00253 if (el->el_chared.c_vcmd.action != (DELETE|INSERT))
00254 while ((p > low) && isspace((unsigned char) *p))
00255 p--;
00256 test = (*wtest)((unsigned char) *p);
00257 while ((p >= low) && (*wtest)((unsigned char) *p) == test)
00258 p--;
00259 p++;
00260 while (isspace((unsigned char) *p))
00261 p++;
00262 }
00263
00264 /* p now points where we want it */
00265 if (p < low)
00266 return (low);
00267 else
00268 return (p);
00269 }
|
|
||||||||||||||||||||
|
Definition at line 63 of file chared.c. References c_undo_t::action, c_undo_t::buf, el_chared_t::c_undo, c_undo_t::dsize, EditLine, editline::el_chared, editline::el_errfile, c_undo_t::isize, c_undo_t::ptr, and size. Referenced by c_delafter(), and c_delbefore().
00064 {
00065 c_undo_t *vu = &el->el_chared.c_undo;
00066 vu->action = action;
00067 vu->ptr = ptr;
00068 vu->isize = size;
00069 (void) memcpy(vu->buf, vu->ptr, size);
00070 #ifdef DEBUG_UNDO
00071 (void) fprintf(el->el_errfile, "Undo buffer \"%s\" size = +%d -%d\n",
00072 vu->ptr, vu->isize, vu->dsize);
00073 #endif
00074 }
|
1.3.5