Lines Matching refs:el

56 #include "el.h"
68 cv_action(EditLine *el, wint_t c)
71 if (el->el_chared.c_vcmd.action != NOP) {
73 if (c != (wint_t)el->el_chared.c_vcmd.action)
77 cv_undo(el);
78 cv_yank(el, el->el_line.buffer,
79 (int)(el->el_line.lastchar - el->el_line.buffer));
80 el->el_chared.c_vcmd.action = NOP;
81 el->el_chared.c_vcmd.pos = 0;
83 el->el_line.lastchar = el->el_line.buffer;
84 el->el_line.cursor = el->el_line.buffer;
87 el->el_map.current = el->el_map.key;
91 el->el_chared.c_vcmd.pos = el->el_line.cursor;
92 el->el_chared.c_vcmd.action = c;
100 cv_paste(EditLine *el, wint_t c)
102 c_kill_t *k = &el->el_chared.c_kill;
108 (void) fprintf(el->el_errfile, "Paste: \"" FSTARSTR "\"\n", (int)len,
112 cv_undo(el);
114 if (!c && el->el_line.cursor < el->el_line.lastchar)
115 el->el_line.cursor++;
117 c_insert(el, (int)len);
118 if (el->el_line.cursor + len > el->el_line.lastchar)
120 (void) memcpy(el->el_line.cursor, k->buf, len *
121 sizeof(*el->el_line.cursor));
133 vi_paste_next(EditLine *el, wint_t c __attribute__((__unused__)))
136 return cv_paste(el, 0);
146 vi_paste_prev(EditLine *el, wint_t c __attribute__((__unused__)))
149 return cv_paste(el, 1);
159 vi_prev_big_word(EditLine *el, wint_t c __attribute__((__unused__)))
162 if (el->el_line.cursor == el->el_line.buffer)
165 el->el_line.cursor = cv_prev_word(el->el_line.cursor,
166 el->el_line.buffer,
167 el->el_state.argument,
170 if (el->el_chared.c_vcmd.action != NOP) {
171 cv_delfini(el);
184 vi_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
187 if (el->el_line.cursor == el->el_line.buffer)
190 el->el_line.cursor = cv_prev_word(el->el_line.cursor,
191 el->el_line.buffer,
192 el->el_state.argument,
195 if (el->el_chared.c_vcmd.action != NOP) {
196 cv_delfini(el);
209 vi_next_big_word(EditLine *el, wint_t c __attribute__((__unused__)))
212 if (el->el_line.cursor >= el->el_line.lastchar - 1)
215 el->el_line.cursor = cv_next_word(el, el->el_line.cursor,
216 el->el_line.lastchar, el->el_state.argument, cv__isWord);
218 if (el->el_map.type == MAP_VI)
219 if (el->el_chared.c_vcmd.action != NOP) {
220 cv_delfini(el);
233 vi_next_word(EditLine *el, wint_t c __attribute__((__unused__)))
236 if (el->el_line.cursor >= el->el_line.lastchar - 1)
239 el->el_line.cursor = cv_next_word(el, el->el_line.cursor,
240 el->el_line.lastchar, el->el_state.argument, cv__isword);
242 if (el->el_map.type == MAP_VI)
243 if (el->el_chared.c_vcmd.action != NOP) {
244 cv_delfini(el);
256 vi_change_case(EditLine *el, wint_t c)
260 if (el->el_line.cursor >= el->el_line.lastchar)
262 cv_undo(el);
263 for (i = 0; i < el->el_state.argument; i++) {
265 c = *el->el_line.cursor;
267 *el->el_line.cursor = Tolower(c);
269 *el->el_line.cursor = Toupper(c);
271 if (++el->el_line.cursor >= el->el_line.lastchar) {
272 el->el_line.cursor--;
273 re_fastaddc(el);
276 re_fastaddc(el);
288 vi_change_meta(EditLine *el, wint_t c __attribute__((__unused__)))
295 return cv_action(el, DELETE | INSERT);
305 vi_insert_at_bol(EditLine *el, wint_t c __attribute__((__unused__)))
308 el->el_line.cursor = el->el_line.buffer;
309 cv_undo(el);
310 el->el_map.current = el->el_map.key;
321 vi_replace_char(EditLine *el, wint_t c __attribute__((__unused__)))
324 if (el->el_line.cursor >= el->el_line.lastchar)
327 el->el_map.current = el->el_map.key;
328 el->el_state.inputmode = MODE_REPLACE_1;
329 cv_undo(el);
340 vi_replace_mode(EditLine *el, wint_t c __attribute__((__unused__)))
343 el->el_map.current = el->el_map.key;
344 el->el_state.inputmode = MODE_REPLACE;
345 cv_undo(el);
356 vi_substitute_char(EditLine *el, wint_t c __attribute__((__unused__)))
359 c_delafter(el, el->el_state.argument);
360 el->el_map.current = el->el_map.key;
371 vi_substitute_line(EditLine *el, wint_t c __attribute__((__unused__)))
374 cv_undo(el);
375 cv_yank(el, el->el_line.buffer,
376 (int)(el->el_line.lastchar - el->el_line.buffer));
377 (void) em_kill_line(el, 0);
378 el->el_map.current = el->el_map.key;
389 vi_change_to_eol(EditLine *el, wint_t c __attribute__((__unused__)))
392 cv_undo(el);
393 cv_yank(el, el->el_line.cursor,
394 (int)(el->el_line.lastchar - el->el_line.cursor));
395 (void) ed_kill_line(el, 0);
396 el->el_map.current = el->el_map.key;
407 vi_insert(EditLine *el, wint_t c __attribute__((__unused__)))
410 el->el_map.current = el->el_map.key;
411 cv_undo(el);
422 vi_add(EditLine *el, wint_t c __attribute__((__unused__)))
426 el->el_map.current = el->el_map.key;
427 if (el->el_line.cursor < el->el_line.lastchar) {
428 el->el_line.cursor++;
429 if (el->el_line.cursor > el->el_line.lastchar)
430 el->el_line.cursor = el->el_line.lastchar;
435 cv_undo(el);
447 vi_add_at_eol(EditLine *el, wint_t c __attribute__((__unused__)))
450 el->el_map.current = el->el_map.key;
451 el->el_line.cursor = el->el_line.lastchar;
452 cv_undo(el);
463 vi_delete_meta(EditLine *el, wint_t c __attribute__((__unused__)))
466 return cv_action(el, DELETE);
476 vi_end_big_word(EditLine *el, wint_t c __attribute__((__unused__)))
479 if (el->el_line.cursor == el->el_line.lastchar)
482 el->el_line.cursor = cv__endword(el->el_line.cursor,
483 el->el_line.lastchar, el->el_state.argument, cv__isWord);
485 if (el->el_chared.c_vcmd.action != NOP) {
486 el->el_line.cursor++;
487 cv_delfini(el);
500 vi_end_word(EditLine *el, wint_t c __attribute__((__unused__)))
503 if (el->el_line.cursor == el->el_line.lastchar)
506 el->el_line.cursor = cv__endword(el->el_line.cursor,
507 el->el_line.lastchar, el->el_state.argument, cv__isword);
509 if (el->el_chared.c_vcmd.action != NOP) {
510 el->el_line.cursor++;
511 cv_delfini(el);
524 vi_undo(EditLine *el, wint_t c __attribute__((__unused__)))
526 c_undo_t un = el->el_chared.c_undo;
532 el->el_chared.c_undo.buf = el->el_line.buffer;
533 el->el_chared.c_undo.len = el->el_line.lastchar - el->el_line.buffer;
534 el->el_chared.c_undo.cursor =
535 (int)(el->el_line.cursor - el->el_line.buffer);
536 el->el_line.limit = un.buf + (el->el_line.limit - el->el_line.buffer);
537 el->el_line.buffer = un.buf;
538 el->el_line.cursor = un.buf + un.cursor;
539 el->el_line.lastchar = un.buf + un.len;
551 vi_command_mode(EditLine *el, wint_t c __attribute__((__unused__)))
555 el->el_chared.c_vcmd.action = NOP;
556 el->el_chared.c_vcmd.pos = 0;
558 el->el_state.doingarg = 0;
560 el->el_state.inputmode = MODE_INSERT;
561 el->el_map.current = el->el_map.alt;
563 if (el->el_line.cursor > el->el_line.buffer)
564 el->el_line.cursor--;
575 vi_zero(EditLine *el, wint_t c)
578 if (el->el_state.doingarg)
579 return ed_argument_digit(el, c);
581 el->el_line.cursor = el->el_line.buffer;
582 if (el->el_chared.c_vcmd.action != NOP) {
583 cv_delfini(el);
596 vi_delete_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
599 if (el->el_line.cursor <= el->el_line.buffer)
602 c_delbefore1(el);
603 el->el_line.cursor--;
614 vi_list_or_eof(EditLine *el, wint_t c)
617 if (el->el_line.cursor == el->el_line.lastchar) {
618 if (el->el_line.cursor == el->el_line.buffer) {
619 terminal_writec(el, c); /* then do a EOF */
626 terminal_beep(el);
631 re_goto_bottom(el);
632 *el->el_line.lastchar = '\0'; /* just in case */
638 terminal_beep(el);
651 vi_kill_line_prev(EditLine *el, wint_t c __attribute__((__unused__)))
655 cp = el->el_line.buffer;
656 kp = el->el_chared.c_kill.buf;
657 while (cp < el->el_line.cursor)
659 el->el_chared.c_kill.last = kp;
660 c_delbefore(el, (int)(el->el_line.cursor - el->el_line.buffer));
661 el->el_line.cursor = el->el_line.buffer; /* zap! */
672 vi_search_prev(EditLine *el, wint_t c __attribute__((__unused__)))
675 return cv_search(el, ED_SEARCH_PREV_HISTORY);
685 vi_search_next(EditLine *el, wint_t c __attribute__((__unused__)))
688 return cv_search(el, ED_SEARCH_NEXT_HISTORY);
698 vi_repeat_search_next(EditLine *el, wint_t c __attribute__((__unused__)))
701 if (el->el_search.patlen == 0)
704 return cv_repeat_srch(el, el->el_search.patdir);
714 vi_repeat_search_prev(EditLine *el, wint_t c __attribute__((__unused__)))
717 if (el->el_search.patlen == 0)
720 return (cv_repeat_srch(el,
721 el->el_search.patdir == ED_SEARCH_PREV_HISTORY ?
732 vi_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
734 return cv_csearch(el, CHAR_FWD, -1, el->el_state.argument, 0);
744 vi_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
746 return cv_csearch(el, CHAR_BACK, -1, el->el_state.argument, 0);
756 vi_to_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
758 return cv_csearch(el, CHAR_FWD, -1, el->el_state.argument, 1);
768 vi_to_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
770 return cv_csearch(el, CHAR_BACK, -1, el->el_state.argument, 1);
780 vi_repeat_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
783 return cv_csearch(el, el->el_search.chadir, el->el_search.chacha,
784 el->el_state.argument, el->el_search.chatflg);
794 vi_repeat_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
797 int dir = el->el_search.chadir;
799 r = cv_csearch(el, -dir, el->el_search.chacha,
800 el->el_state.argument, el->el_search.chatflg);
801 el->el_search.chadir = dir;
812 vi_match(EditLine *el, wint_t c __attribute__((__unused__)))
819 *el->el_line.lastchar = '\0'; /* just in case */
821 i = Strcspn(el->el_line.cursor, match_chars);
822 o_ch = el->el_line.cursor[i];
830 for (cp = &el->el_line.cursor[i]; count; ) {
832 if (cp < el->el_line.buffer || cp >= el->el_line.lastchar)
840 el->el_line.cursor = cp;
842 if (el->el_chared.c_vcmd.action != NOP) {
846 el->el_line.cursor++;
847 cv_delfini(el);
859 vi_undo_line(EditLine *el, wint_t c __attribute__((__unused__)))
862 cv_undo(el);
863 return hist_get(el);
873 vi_to_column(EditLine *el, wint_t c __attribute__((__unused__)))
876 el->el_line.cursor = el->el_line.buffer;
877 el->el_state.argument--;
878 return ed_next_char(el, 0);
887 vi_yank_end(EditLine *el, wint_t c __attribute__((__unused__)))
890 cv_yank(el, el->el_line.cursor,
891 (int)(el->el_line.lastchar - el->el_line.cursor));
901 vi_yank(EditLine *el, wint_t c __attribute__((__unused__)))
904 return cv_action(el, YANK);
913 vi_comment_out(EditLine *el, wint_t c __attribute__((__unused__)))
916 el->el_line.cursor = el->el_line.buffer;
917 c_insert(el, 1);
918 *el->el_line.cursor = '#';
919 re_refresh(el);
920 return ed_newline(el, 0);
931 vi_alias(EditLine *el, wint_t c __attribute__((__unused__)))
936 if (el->el_chared.c_aliasfun == NULL)
941 if (el_getc(el, &alias_name[1]) != 1)
944 alias_text = (*el->el_chared.c_aliasfun)(el->el_chared.c_aliasarg,
947 FUN(el,push)(el, ct_decode_string(alias_text, &el->el_scratch));
957 vi_to_history_line(EditLine *el, wint_t 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, wint_t 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);
1052 len = (size_t)(el->el_line.limit - 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, wint_t c __attribute__((__unused__)))
1088 const Char *wp = HIST_FIRST(el);
1107 } while ((!el->el_state.doingarg || --el->el_state.argument > 0)
1110 if (wsp == NULL || (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, wint_t 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);