Lines Matching refs:el

46 #include "el.h"
55 cv_action(EditLine *el, int c)
58 if (el->el_chared.c_vcmd.action != NOP) {
60 if (c != el->el_chared.c_vcmd.action)
64 cv_undo(el);
65 cv_yank(el, el->el_line.buffer,
66 (int)(el->el_line.lastchar - el->el_line.buffer));
67 el->el_chared.c_vcmd.action = NOP;
68 el->el_chared.c_vcmd.pos = 0;
70 el->el_line.lastchar = el->el_line.buffer;
71 el->el_line.cursor = el->el_line.buffer;
74 el->el_map.current = el->el_map.key;
78 el->el_chared.c_vcmd.pos = el->el_line.cursor;
79 el->el_chared.c_vcmd.action = c;
87 cv_paste(EditLine *el, int c)
89 c_kill_t *k = &el->el_chared.c_kill;
95 (void) fprintf(el->el_errfile, "Paste: \"%.*s\"\n", (int)len, k->buf);
98 cv_undo(el);
100 if (!c && el->el_line.cursor < el->el_line.lastchar)
101 el->el_line.cursor++;
103 c_insert(el, (int)len);
104 if (el->el_line.cursor + len > el->el_line.lastchar)
106 (void) memcpy(el->el_line.cursor, k->buf, len);
118 vi_paste_next(EditLine *el, int c __unused)
121 return (cv_paste(el, 0));
131 vi_paste_prev(EditLine *el, int c __unused)
134 return (cv_paste(el, 1));
144 vi_prev_big_word(EditLine *el, int c)
147 if (el->el_line.cursor == el->el_line.buffer)
150 el->el_line.cursor = cv_prev_word(el->el_line.cursor,
151 el->el_line.buffer,
152 el->el_state.argument,
155 if (el->el_chared.c_vcmd.action != NOP) {
156 cv_delfini(el);
169 vi_prev_word(EditLine *el, int c __unused)
172 if (el->el_line.cursor == el->el_line.buffer)
175 el->el_line.cursor = cv_prev_word(el->el_line.cursor,
176 el->el_line.buffer,
177 el->el_state.argument,
180 if (el->el_chared.c_vcmd.action != NOP) {
181 cv_delfini(el);
194 vi_next_big_word(EditLine *el, int c)
197 if (el->el_line.cursor >= el->el_line.lastchar - 1)
200 el->el_line.cursor = cv_next_word(el, el->el_line.cursor,
201 el->el_line.lastchar, el->el_state.argument, cv__isWord);
203 if (el->el_map.type == MAP_VI)
204 if (el->el_chared.c_vcmd.action != NOP) {
205 cv_delfini(el);
218 vi_next_word(EditLine *el, int c __unused)
221 if (el->el_line.cursor >= el->el_line.lastchar - 1)
224 el->el_line.cursor = cv_next_word(el, el->el_line.cursor,
225 el->el_line.lastchar, el->el_state.argument, cv__isword);
227 if (el->el_map.type == MAP_VI)
228 if (el->el_chared.c_vcmd.action != NOP) {
229 cv_delfini(el);
241 vi_change_case(EditLine *el, int c)
245 if (el->el_line.cursor >= el->el_line.lastchar)
247 cv_undo(el);
248 for (i = 0; i < el->el_state.argument; i++) {
250 c = *(unsigned char *)el->el_line.cursor;
252 *el->el_line.cursor = tolower(c);
254 *el->el_line.cursor = toupper(c);
256 if (++el->el_line.cursor >= el->el_line.lastchar) {
257 el->el_line.cursor--;
258 re_fastaddc(el);
261 re_fastaddc(el);
273 vi_change_meta(EditLine *el, int c __unused)
280 return (cv_action(el, DELETE | INSERT));
290 vi_insert_at_bol(EditLine *el, int c __unused)
293 el->el_line.cursor = el->el_line.buffer;
294 cv_undo(el);
295 el->el_map.current = el->el_map.key;
306 vi_replace_char(EditLine *el, int c __unused)
309 if (el->el_line.cursor >= el->el_line.lastchar)
312 el->el_map.current = el->el_map.key;
313 el->el_state.inputmode = MODE_REPLACE_1;
314 cv_undo(el);
325 vi_replace_mode(EditLine *el, int c __unused)
328 el->el_map.current = el->el_map.key;
329 el->el_state.inputmode = MODE_REPLACE;
330 cv_undo(el);
341 vi_substitute_char(EditLine *el, int c __unused)
344 c_delafter(el, el->el_state.argument);
345 el->el_map.current = el->el_map.key;
356 vi_substitute_line(EditLine *el, int c __unused)
359 cv_undo(el);
360 cv_yank(el, el->el_line.buffer,
361 (int)(el->el_line.lastchar - el->el_line.buffer));
362 (void) em_kill_line(el, 0);
363 el->el_map.current = el->el_map.key;
374 vi_change_to_eol(EditLine *el, int c __unused)
377 cv_undo(el);
378 cv_yank(el, el->el_line.cursor,
379 (int)(el->el_line.lastchar - el->el_line.cursor));
380 (void) ed_kill_line(el, 0);
381 el->el_map.current = el->el_map.key;
392 vi_insert(EditLine *el, int c __unused)
395 el->el_map.current = el->el_map.key;
396 cv_undo(el);
407 vi_add(EditLine *el, int c __unused)
411 el->el_map.current = el->el_map.key;
412 if (el->el_line.cursor < el->el_line.lastchar) {
413 el->el_line.cursor++;
414 if (el->el_line.cursor > el->el_line.lastchar)
415 el->el_line.cursor = el->el_line.lastchar;
420 cv_undo(el);
432 vi_add_at_eol(EditLine *el, int c __unused)
435 el->el_map.current = el->el_map.key;
436 el->el_line.cursor = el->el_line.lastchar;
437 cv_undo(el);
448 vi_delete_meta(EditLine *el, int c __unused)
451 return (cv_action(el, DELETE));
461 vi_end_big_word(EditLine *el, int c)
464 if (el->el_line.cursor == el->el_line.lastchar)
467 el->el_line.cursor = cv__endword(el->el_line.cursor,
468 el->el_line.lastchar, el->el_state.argument, cv__isWord);
470 if (el->el_chared.c_vcmd.action != NOP) {
471 el->el_line.cursor++;
472 cv_delfini(el);
485 vi_end_word(EditLine *el, int c __unused)
488 if (el->el_line.cursor == el->el_line.lastchar)
491 el->el_line.cursor = cv__endword(el->el_line.cursor,
492 el->el_line.lastchar, el->el_state.argument, cv__isword);
494 if (el->el_chared.c_vcmd.action != NOP) {
495 el->el_line.cursor++;
496 cv_delfini(el);
509 vi_undo(EditLine *el, int c __unused)
511 c_undo_t un = el->el_chared.c_undo;
517 el->el_chared.c_undo.buf = el->el_line.buffer;
518 el->el_chared.c_undo.len = el->el_line.lastchar - el->el_line.buffer;
519 el->el_chared.c_undo.cursor =
520 (int)(el->el_line.cursor - el->el_line.buffer);
521 el->el_line.limit = un.buf + (el->el_line.limit - el->el_line.buffer);
522 el->el_line.buffer = un.buf;
523 el->el_line.cursor = un.buf + un.cursor;
524 el->el_line.lastchar = un.buf + un.len;
536 vi_command_mode(EditLine *el, int c __unused)
540 el->el_chared.c_vcmd.action = NOP;
541 el->el_chared.c_vcmd.pos = 0;
543 el->el_state.doingarg = 0;
545 el->el_state.inputmode = MODE_INSERT;
546 el->el_map.current = el->el_map.alt;
548 if (el->el_line.cursor > el->el_line.buffer)
549 el->el_line.cursor--;
560 vi_zero(EditLine *el, int c)
563 if (el->el_state.doingarg)
564 return ed_argument_digit(el, c);
566 el->el_line.cursor = el->el_line.buffer;
567 if (el->el_chared.c_vcmd.action != NOP) {
568 cv_delfini(el);
581 vi_delete_prev_char(EditLine *el, int c __unused)
584 if (el->el_line.cursor <= el->el_line.buffer)
587 c_delbefore1(el);
588 el->el_line.cursor--;
599 vi_list_or_eof(EditLine *el, int c)
602 if (el->el_line.cursor == el->el_line.lastchar) {
603 if (el->el_line.cursor == el->el_line.buffer) {
604 term_writec(el, c); /* then do a EOF */
611 term_beep(el);
616 re_goto_bottom(el);
617 *el->el_line.lastchar = '\0'; /* just in case */
623 term_beep(el);
636 vi_kill_line_prev(EditLine *el, int c __unused)
640 cp = el->el_line.buffer;
641 kp = el->el_chared.c_kill.buf;
642 while (cp < el->el_line.cursor)
644 el->el_chared.c_kill.last = kp;
645 c_delbefore(el, (int)(el->el_line.cursor - el->el_line.buffer));
646 el->el_line.cursor = el->el_line.buffer; /* zap! */
657 vi_search_prev(EditLine *el, int c __unused)
660 return (cv_search(el, ED_SEARCH_PREV_HISTORY));
670 vi_search_next(EditLine *el, int c __unused)
673 return (cv_search(el, ED_SEARCH_NEXT_HISTORY));
683 vi_repeat_search_next(EditLine *el, int c __unused)
686 if (el->el_search.patlen == 0)
689 return (cv_repeat_srch(el, el->el_search.patdir));
699 vi_repeat_search_prev(EditLine *el, int c __unused)
702 if (el->el_search.patlen == 0)
705 return (cv_repeat_srch(el,
706 el->el_search.patdir == ED_SEARCH_PREV_HISTORY ?
717 vi_next_char(EditLine *el, int c __unused)
719 return cv_csearch(el, CHAR_FWD, -1, el->el_state.argument, 0);
729 vi_prev_char(EditLine *el, int c __unused)
731 return cv_csearch(el, CHAR_BACK, -1, el->el_state.argument, 0);
741 vi_to_next_char(EditLine *el, int c __unused)
743 return cv_csearch(el, CHAR_FWD, -1, el->el_state.argument, 1);
753 vi_to_prev_char(EditLine *el, int c __unused)
755 return cv_csearch(el, CHAR_BACK, -1, el->el_state.argument, 1);
765 vi_repeat_next_char(EditLine *el, int c __unused)
768 return cv_csearch(el, el->el_search.chadir, el->el_search.chacha,
769 el->el_state.argument, el->el_search.chatflg);
779 vi_repeat_prev_char(EditLine *el, int c __unused)
782 int dir = el->el_search.chadir;
784 r = cv_csearch(el, -dir, el->el_search.chacha,
785 el->el_state.argument, el->el_search.chatflg);
786 el->el_search.chadir = dir;
797 vi_match(EditLine *el, int c)
804 *el->el_line.lastchar = '\0'; /* just in case */
806 i = strcspn(el->el_line.cursor, match_chars);
807 o_ch = el->el_line.cursor[i];
815 for (cp = &el->el_line.cursor[i]; count; ) {
817 if (cp < el->el_line.buffer || cp >= el->el_line.lastchar)
825 el->el_line.cursor = cp;
827 if (el->el_chared.c_vcmd.action != NOP) {
831 el->el_line.cursor++;
832 cv_delfini(el);
844 vi_undo_line(EditLine *el, int c)
847 cv_undo(el);
848 return hist_get(el);
858 vi_to_column(EditLine *el, int c)
861 el->el_line.cursor = el->el_line.buffer;
862 el->el_state.argument--;
863 return ed_next_char(el, 0);
872 vi_yank_end(EditLine *el, int c)
875 cv_yank(el, el->el_line.cursor,
876 (int)(el->el_line.lastchar - el->el_line.cursor));
886 vi_yank(EditLine *el, int c)
889 return cv_action(el, YANK);
898 vi_comment_out(EditLine *el, int c)
901 el->el_line.cursor = el->el_line.buffer;
902 c_insert(el, 1);
903 *el->el_line.cursor = '#';
904 re_refresh(el);
905 return ed_newline(el, 0);
916 vi_alias(EditLine *el, int c)
930 if (el_getc(el, &alias_name[1]) != 1)
935 el_push(el, alias_text);
948 vi_to_history_line(EditLine *el, int c)
950 int sv_event_no = el->el_history.eventno;
954 if (el->el_history.eventno == 0) {
955 (void) strncpy(el->el_history.buf, el->el_line.buffer,
957 el->el_history.last = el->el_history.buf +
958 (el->el_line.lastchar - el->el_line.buffer);
962 if (!el->el_state.doingarg) {
963 el->el_history.eventno = 0x7fffffff;
964 hist_get(el);
971 el->el_history.eventno = 1;
972 if (hist_get(el) == CC_ERROR)
974 el->el_history.eventno = 1 + el->el_history.ev.num
975 - el->el_state.argument;
976 if (el->el_history.eventno < 0) {
977 el->el_history.eventno = sv_event_no;
981 rval = hist_get(el);
983 el->el_history.eventno = sv_event_no;
993 vi_histedit(EditLine *el, int c)
1002 if (el->el_state.doingarg) {
1003 if (vi_to_history_line(el, 0) == CC_ERROR)
1010 cp = el->el_line.buffer;
1011 write(fd, cp, (size_t)(el->el_line.lastchar - cp));
1028 st = read(fd, cp, (size_t)(el->el_line.limit - cp));
1031 el->el_line.cursor = cp;
1032 el->el_line.lastchar = cp + st;
1039 return ed_newline(el, 0);
1050 vi_history_word(EditLine *el, int c)
1052 const char *wp = HIST_FIRST(el);
1071 } while ((!el->el_state.doingarg || --el->el_state.argument > 0) && *wp != 0);
1073 if (wsp == 0 || (el->el_state.doingarg && el->el_state.argument != 0))
1076 cv_undo(el);
1078 if (el->el_line.cursor < el->el_line.lastchar)
1079 el->el_line.cursor++;
1080 c_insert(el, len + 1);
1081 cp = el->el_line.cursor;
1082 lim = el->el_line.limit;
1087 el->el_line.cursor = cp;
1089 el->el_map.current = el->el_map.key;
1099 vi_redo(EditLine *el, int c)
1101 c_redo_t *r = &el->el_chared.c_redo;
1103 if (!el->el_state.doingarg && r->count) {
1104 el->el_state.doingarg = 1;
1105 el->el_state.argument = r->count;
1108 el->el_chared.c_vcmd.pos = el->el_line.cursor;
1109 el->el_chared.c_vcmd.action = r->action;
1115 el_push(el, r->buf);
1118 el->el_state.thiscmd = r->cmd;
1119 el->el_state.thisch = r->ch;
1120 return (*el->el_map.func[r->cmd])(el, r->ch);