Lines Matching refs:el

52 #include "el.h"
61 cv_action(EditLine *el, Int c)
64 if (el->el_chared.c_vcmd.action != NOP) {
66 if (c != (Int)el->el_chared.c_vcmd.action)
70 cv_undo(el);
71 cv_yank(el, el->el_line.buffer,
72 (int)(el->el_line.lastchar - el->el_line.buffer));
73 el->el_chared.c_vcmd.action = NOP;
74 el->el_chared.c_vcmd.pos = 0;
76 el->el_line.lastchar = el->el_line.buffer;
77 el->el_line.cursor = el->el_line.buffer;
80 el->el_map.current = el->el_map.key;
84 el->el_chared.c_vcmd.pos = el->el_line.cursor;
85 el->el_chared.c_vcmd.action = c;
93 cv_paste(EditLine *el, Int c)
95 c_kill_t *k = &el->el_chared.c_kill;
101 (void) fprintf(el->el_errfile, "Paste: \"%.*s\"\n", (int)len, k->buf);
104 cv_undo(el);
106 if (!c && el->el_line.cursor < el->el_line.lastchar)
107 el->el_line.cursor++;
109 c_insert(el, (int)len);
110 if (el->el_line.cursor + len > el->el_line.lastchar)
112 (void) memcpy(el->el_line.cursor, k->buf, len *
113 sizeof(*el->el_line.cursor));
125 vi_paste_next(EditLine *el, Int c __attribute__((__unused__)))
128 return cv_paste(el, 0);
138 vi_paste_prev(EditLine *el, Int c __attribute__((__unused__)))
141 return cv_paste(el, 1);
151 vi_prev_big_word(EditLine *el, Int c __attribute__((__unused__)))
154 if (el->el_line.cursor == el->el_line.buffer)
157 el->el_line.cursor = cv_prev_word(el->el_line.cursor,
158 el->el_line.buffer,
159 el->el_state.argument,
162 if (el->el_chared.c_vcmd.action != NOP) {
163 cv_delfini(el);
176 vi_prev_word(EditLine *el, Int c __attribute__((__unused__)))
179 if (el->el_line.cursor == el->el_line.buffer)
182 el->el_line.cursor = cv_prev_word(el->el_line.cursor,
183 el->el_line.buffer,
184 el->el_state.argument,
187 if (el->el_chared.c_vcmd.action != NOP) {
188 cv_delfini(el);
201 vi_next_big_word(EditLine *el, Int c __attribute__((__unused__)))
204 if (el->el_line.cursor >= el->el_line.lastchar - 1)
207 el->el_line.cursor = cv_next_word(el, el->el_line.cursor,
208 el->el_line.lastchar, el->el_state.argument, cv__isWord);
210 if (el->el_map.type == MAP_VI)
211 if (el->el_chared.c_vcmd.action != NOP) {
212 cv_delfini(el);
225 vi_next_word(EditLine *el, Int c __attribute__((__unused__)))
228 if (el->el_line.cursor >= el->el_line.lastchar - 1)
231 el->el_line.cursor = cv_next_word(el, el->el_line.cursor,
232 el->el_line.lastchar, el->el_state.argument, cv__isword);
234 if (el->el_map.type == MAP_VI)
235 if (el->el_chared.c_vcmd.action != NOP) {
236 cv_delfini(el);
248 vi_change_case(EditLine *el, Int c)
252 if (el->el_line.cursor >= el->el_line.lastchar)
254 cv_undo(el);
255 for (i = 0; i < el->el_state.argument; i++) {
257 c = *el->el_line.cursor;
259 *el->el_line.cursor = Tolower(c);
261 *el->el_line.cursor = Toupper(c);
263 if (++el->el_line.cursor >= el->el_line.lastchar) {
264 el->el_line.cursor--;
265 re_fastaddc(el);
268 re_fastaddc(el);
280 vi_change_meta(EditLine *el, Int c __attribute__((__unused__)))
287 return cv_action(el, DELETE | INSERT);
297 vi_insert_at_bol(EditLine *el, Int c __attribute__((__unused__)))
300 el->el_line.cursor = el->el_line.buffer;
301 cv_undo(el);
302 el->el_map.current = el->el_map.key;
313 vi_replace_char(EditLine *el, Int c __attribute__((__unused__)))
316 if (el->el_line.cursor >= el->el_line.lastchar)
319 el->el_map.current = el->el_map.key;
320 el->el_state.inputmode = MODE_REPLACE_1;
321 cv_undo(el);
332 vi_replace_mode(EditLine *el, Int c __attribute__((__unused__)))
335 el->el_map.current = el->el_map.key;
336 el->el_state.inputmode = MODE_REPLACE;
337 cv_undo(el);
348 vi_substitute_char(EditLine *el, Int c __attribute__((__unused__)))
351 c_delafter(el, el->el_state.argument);
352 el->el_map.current = el->el_map.key;
363 vi_substitute_line(EditLine *el, Int c __attribute__((__unused__)))
366 cv_undo(el);
367 cv_yank(el, el->el_line.buffer,
368 (int)(el->el_line.lastchar - el->el_line.buffer));
369 (void) em_kill_line(el, 0);
370 el->el_map.current = el->el_map.key;
381 vi_change_to_eol(EditLine *el, Int c __attribute__((__unused__)))
384 cv_undo(el);
385 cv_yank(el, el->el_line.cursor,
386 (int)(el->el_line.lastchar - el->el_line.cursor));
387 (void) ed_kill_line(el, 0);
388 el->el_map.current = el->el_map.key;
399 vi_insert(EditLine *el, Int c __attribute__((__unused__)))
402 el->el_map.current = el->el_map.key;
403 cv_undo(el);
414 vi_add(EditLine *el, Int c __attribute__((__unused__)))
418 el->el_map.current = el->el_map.key;
419 if (el->el_line.cursor < el->el_line.lastchar) {
420 el->el_line.cursor++;
421 if (el->el_line.cursor > el->el_line.lastchar)
422 el->el_line.cursor = el->el_line.lastchar;
427 cv_undo(el);
439 vi_add_at_eol(EditLine *el, Int c __attribute__((__unused__)))
442 el->el_map.current = el->el_map.key;
443 el->el_line.cursor = el->el_line.lastchar;
444 cv_undo(el);
455 vi_delete_meta(EditLine *el, Int c __attribute__((__unused__)))
458 return cv_action(el, DELETE);
468 vi_end_big_word(EditLine *el, Int c __attribute__((__unused__)))
471 if (el->el_line.cursor == el->el_line.lastchar)
474 el->el_line.cursor = cv__endword(el->el_line.cursor,
475 el->el_line.lastchar, el->el_state.argument, cv__isWord);
477 if (el->el_chared.c_vcmd.action != NOP) {
478 el->el_line.cursor++;
479 cv_delfini(el);
492 vi_end_word(EditLine *el, Int c __attribute__((__unused__)))
495 if (el->el_line.cursor == el->el_line.lastchar)
498 el->el_line.cursor = cv__endword(el->el_line.cursor,
499 el->el_line.lastchar, el->el_state.argument, cv__isword);
501 if (el->el_chared.c_vcmd.action != NOP) {
502 el->el_line.cursor++;
503 cv_delfini(el);
516 vi_undo(EditLine *el, Int c __attribute__((__unused__)))
518 c_undo_t un = el->el_chared.c_undo;
524 el->el_chared.c_undo.buf = el->el_line.buffer;
525 el->el_chared.c_undo.len = el->el_line.lastchar - el->el_line.buffer;
526 el->el_chared.c_undo.cursor =
527 (int)(el->el_line.cursor - el->el_line.buffer);
528 el->el_line.limit = un.buf + (el->el_line.limit - el->el_line.buffer);
529 el->el_line.buffer = un.buf;
530 el->el_line.cursor = un.buf + un.cursor;
531 el->el_line.lastchar = un.buf + un.len;
543 vi_command_mode(EditLine *el, Int c __attribute__((__unused__)))
547 el->el_chared.c_vcmd.action = NOP;
548 el->el_chared.c_vcmd.pos = 0;
550 el->el_state.doingarg = 0;
552 el->el_state.inputmode = MODE_INSERT;
553 el->el_map.current = el->el_map.alt;
555 if (el->el_line.cursor > el->el_line.buffer)
556 el->el_line.cursor--;
567 vi_zero(EditLine *el, Int c)
570 if (el->el_state.doingarg)
571 return ed_argument_digit(el, c);
573 el->el_line.cursor = el->el_line.buffer;
574 if (el->el_chared.c_vcmd.action != NOP) {
575 cv_delfini(el);
588 vi_delete_prev_char(EditLine *el, Int c __attribute__((__unused__)))
591 if (el->el_line.cursor <= el->el_line.buffer)
594 c_delbefore1(el);
595 el->el_line.cursor--;
606 vi_list_or_eof(EditLine *el, Int c)
609 if (el->el_line.cursor == el->el_line.lastchar) {
610 if (el->el_line.cursor == el->el_line.buffer) {
611 terminal_writec(el, c); /* then do a EOF */
618 terminal_beep(el);
623 re_goto_bottom(el);
624 *el->el_line.lastchar = '\0'; /* just in case */
630 terminal_beep(el);
643 vi_kill_line_prev(EditLine *el, Int c __attribute__((__unused__)))
647 cp = el->el_line.buffer;
648 kp = el->el_chared.c_kill.buf;
649 while (cp < el->el_line.cursor)
651 el->el_chared.c_kill.last = kp;
652 c_delbefore(el, (int)(el->el_line.cursor - el->el_line.buffer));
653 el->el_line.cursor = el->el_line.buffer; /* zap! */
664 vi_search_prev(EditLine *el, Int c __attribute__((__unused__)))
667 return cv_search(el, ED_SEARCH_PREV_HISTORY);
677 vi_search_next(EditLine *el, Int c __attribute__((__unused__)))
680 return cv_search(el, ED_SEARCH_NEXT_HISTORY);
690 vi_repeat_search_next(EditLine *el, Int c __attribute__((__unused__)))
693 if (el->el_search.patlen == 0)
696 return cv_repeat_srch(el, el->el_search.patdir);
706 vi_repeat_search_prev(EditLine *el, Int c __attribute__((__unused__)))
709 if (el->el_search.patlen == 0)
712 return (cv_repeat_srch(el,
713 el->el_search.patdir == ED_SEARCH_PREV_HISTORY ?
724 vi_next_char(EditLine *el, Int c __attribute__((__unused__)))
726 return cv_csearch(el, CHAR_FWD, -1, el->el_state.argument, 0);
736 vi_prev_char(EditLine *el, Int c __attribute__((__unused__)))
738 return cv_csearch(el, CHAR_BACK, -1, el->el_state.argument, 0);
748 vi_to_next_char(EditLine *el, Int c __attribute__((__unused__)))
750 return cv_csearch(el, CHAR_FWD, -1, el->el_state.argument, 1);
760 vi_to_prev_char(EditLine *el, Int c __attribute__((__unused__)))
762 return cv_csearch(el, CHAR_BACK, -1, el->el_state.argument, 1);
772 vi_repeat_next_char(EditLine *el, Int c __attribute__((__unused__)))
775 return cv_csearch(el, el->el_search.chadir, el->el_search.chacha,
776 el->el_state.argument, el->el_search.chatflg);
786 vi_repeat_prev_char(EditLine *el, Int c __attribute__((__unused__)))
789 int dir = el->el_search.chadir;
791 r = cv_csearch(el, -dir, el->el_search.chacha,
792 el->el_state.argument, el->el_search.chatflg);
793 el->el_search.chadir = dir;
804 vi_match(EditLine *el, Int c __attribute__((__unused__)))
811 *el->el_line.lastchar = '\0'; /* just in case */
813 i = Strcspn(el->el_line.cursor, match_chars);
814 o_ch = el->el_line.cursor[i];
822 for (cp = &el->el_line.cursor[i]; count; ) {
824 if (cp < el->el_line.buffer || cp >= el->el_line.lastchar)
832 el->el_line.cursor = cp;
834 if (el->el_chared.c_vcmd.action != NOP) {
838 el->el_line.cursor++;
839 cv_delfini(el);
851 vi_undo_line(EditLine *el, Int c __attribute__((__unused__)))
854 cv_undo(el);
855 return hist_get(el);
865 vi_to_column(EditLine *el, Int c __attribute__((__unused__)))
868 el->el_line.cursor = el->el_line.buffer;
869 el->el_state.argument--;
870 return ed_next_char(el, 0);
879 vi_yank_end(EditLine *el, Int c __attribute__((__unused__)))
882 cv_yank(el, el->el_line.cursor,
883 (int)(el->el_line.lastchar - el->el_line.cursor));
893 vi_yank(EditLine *el, Int c __attribute__((__unused__)))
896 return cv_action(el, YANK);
905 vi_comment_out(EditLine *el, Int c __attribute__((__unused__)))
908 el->el_line.cursor = el->el_line.buffer;
909 c_insert(el, 1);
910 *el->el_line.cursor = '#';
911 re_refresh(el);
912 return ed_newline(el, 0);
927 vi_alias(EditLine *el, Int c __attribute__((__unused__)))
939 if (el_getc(el, &alias_name[1]) != 1)
944 FUN(el,push)(el, ct_decode_string(alias_text, &el->el_scratch));
957 vi_to_history_line(EditLine *el, Int c __attribute__((__unused__)))
959 int sv_event_no = el->el_history.eventno;
963 if (el->el_history.eventno == 0) {
964 (void) Strncpy(el->el_history.buf, el->el_line.buffer,
966 el->el_history.last = el->el_history.buf +
967 (el->el_line.lastchar - el->el_line.buffer);
971 if (!el->el_state.doingarg) {
972 el->el_history.eventno = 0x7fffffff;
973 hist_get(el);
980 el->el_history.eventno = 1;
981 if (hist_get(el) == CC_ERROR)
983 el->el_history.eventno = 1 + el->el_history.ev.num
984 - el->el_state.argument;
985 if (el->el_history.eventno < 0) {
986 el->el_history.eventno = sv_event_no;
990 rval = hist_get(el);
992 el->el_history.eventno = sv_event_no;
1002 vi_histedit(EditLine *el, Int c __attribute__((__unused__)))
1013 if (el->el_state.doingarg) {
1014 if (vi_to_history_line(el, 0) == CC_ERROR)
1021 len = (size_t)(el->el_line.lastchar - el->el_line.buffer);
1029 Strncpy(line, el->el_line.buffer, len);
1051 len = (size_t)(el->el_line.lastchar -
1052 el->el_line.buffer);
1053 len = ct_mbstowcs(el->el_line.buffer, cp, len);
1054 if (len > 0 && el->el_line.buffer[len -1] == '\n')
1059 el->el_line.cursor = el->el_line.buffer;
1060 el->el_line.lastchar = el->el_line.buffer + len;
1069 return ed_newline(el, 0);
1086 vi_history_word(EditLine *el, Int c __attribute__((__unused__)))
1088 const Char *wp = HIST_FIRST(el);
1107 } while ((!el->el_state.doingarg || --el->el_state.argument > 0)
1110 if (wsp == 0 || (el->el_state.doingarg && el->el_state.argument != 0))
1113 cv_undo(el);
1115 if (el->el_line.cursor < el->el_line.lastchar)
1116 el->el_line.cursor++;
1117 c_insert(el, len + 1);
1118 cp = el->el_line.cursor;
1119 lim = el->el_line.limit;
1124 el->el_line.cursor = cp;
1126 el->el_map.current = el->el_map.key;
1136 vi_redo(EditLine *el, Int c __attribute__((__unused__)))
1138 c_redo_t *r = &el->el_chared.c_redo;
1140 if (!el->el_state.doingarg && r->count) {
1141 el->el_state.doingarg = 1;
1142 el->el_state.argument = r->count;
1145 el->el_chared.c_vcmd.pos = el->el_line.cursor;
1146 el->el_chared.c_vcmd.action = r->action;
1152 FUN(el,push)(el, r->buf);
1155 el->el_state.thiscmd = r->cmd;
1156 el->el_state.thisch = r->ch;
1157 return (*el->el_map.func[r->cmd])(el, r->ch);