Lines Matching refs:el
54 #include "el.h"
67 cv_action(EditLine *el, wint_t c)
70 if (el->el_chared.c_vcmd.action != NOP) {
72 if (c != (wint_t)el->el_chared.c_vcmd.action)
76 cv_undo(el);
77 cv_yank(el, el->el_line.buffer,
78 (int)(el->el_line.lastchar - el->el_line.buffer));
79 el->el_chared.c_vcmd.action = NOP;
80 el->el_chared.c_vcmd.pos = 0;
82 el->el_line.lastchar = el->el_line.buffer;
83 el->el_line.cursor = el->el_line.buffer;
86 el->el_map.current = el->el_map.key;
90 el->el_chared.c_vcmd.pos = el->el_line.cursor;
91 el->el_chared.c_vcmd.action = c;
99 cv_paste(EditLine *el, wint_t c)
101 c_kill_t *k = &el->el_chared.c_kill;
107 (void) fprintf(el->el_errfile, "Paste: \"%.*ls\"\n", (int)len,
111 cv_undo(el);
113 if (!c && el->el_line.cursor < el->el_line.lastchar)
114 el->el_line.cursor++;
116 c_insert(el, (int)len);
117 if (el->el_line.cursor + len > el->el_line.lastchar)
119 (void) memcpy(el->el_line.cursor, k->buf, len *
120 sizeof(*el->el_line.cursor));
132 vi_paste_next(EditLine *el, wint_t c __attribute__((__unused__)))
135 return cv_paste(el, 0);
145 vi_paste_prev(EditLine *el, wint_t c __attribute__((__unused__)))
148 return cv_paste(el, 1);
158 vi_prev_big_word(EditLine *el, wint_t c __attribute__((__unused__)))
161 if (el->el_line.cursor == el->el_line.buffer)
164 el->el_line.cursor = cv_prev_word(el->el_line.cursor,
165 el->el_line.buffer,
166 el->el_state.argument,
169 if (el->el_chared.c_vcmd.action != NOP) {
170 cv_delfini(el);
183 vi_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
186 if (el->el_line.cursor == el->el_line.buffer)
189 el->el_line.cursor = cv_prev_word(el->el_line.cursor,
190 el->el_line.buffer,
191 el->el_state.argument,
194 if (el->el_chared.c_vcmd.action != NOP) {
195 cv_delfini(el);
208 vi_next_big_word(EditLine *el, wint_t c __attribute__((__unused__)))
211 if (el->el_line.cursor >= el->el_line.lastchar - 1)
214 el->el_line.cursor = cv_next_word(el, el->el_line.cursor,
215 el->el_line.lastchar, el->el_state.argument, cv__isWord);
217 if (el->el_map.type == MAP_VI)
218 if (el->el_chared.c_vcmd.action != NOP) {
219 cv_delfini(el);
232 vi_next_word(EditLine *el, wint_t c __attribute__((__unused__)))
235 if (el->el_line.cursor >= el->el_line.lastchar - 1)
238 el->el_line.cursor = cv_next_word(el, el->el_line.cursor,
239 el->el_line.lastchar, el->el_state.argument, cv__isword);
241 if (el->el_map.type == MAP_VI)
242 if (el->el_chared.c_vcmd.action != NOP) {
243 cv_delfini(el);
255 vi_change_case(EditLine *el, wint_t c)
259 if (el->el_line.cursor >= el->el_line.lastchar)
261 cv_undo(el);
262 for (i = 0; i < el->el_state.argument; i++) {
264 c = *el->el_line.cursor;
266 *el->el_line.cursor = towlower(c);
268 *el->el_line.cursor = towupper(c);
270 if (++el->el_line.cursor >= el->el_line.lastchar) {
271 el->el_line.cursor--;
272 re_fastaddc(el);
275 re_fastaddc(el);
287 vi_change_meta(EditLine *el, wint_t c __attribute__((__unused__)))
294 return cv_action(el, DELETE | INSERT);
304 vi_insert_at_bol(EditLine *el, wint_t c __attribute__((__unused__)))
307 el->el_line.cursor = el->el_line.buffer;
308 cv_undo(el);
309 el->el_map.current = el->el_map.key;
320 vi_replace_char(EditLine *el, wint_t c __attribute__((__unused__)))
323 if (el->el_line.cursor >= el->el_line.lastchar)
326 el->el_map.current = el->el_map.key;
327 el->el_state.inputmode = MODE_REPLACE_1;
328 cv_undo(el);
339 vi_replace_mode(EditLine *el, wint_t c __attribute__((__unused__)))
342 el->el_map.current = el->el_map.key;
343 el->el_state.inputmode = MODE_REPLACE;
344 cv_undo(el);
355 vi_substitute_char(EditLine *el, wint_t c __attribute__((__unused__)))
358 c_delafter(el, el->el_state.argument);
359 el->el_map.current = el->el_map.key;
370 vi_substitute_line(EditLine *el, wint_t c __attribute__((__unused__)))
373 cv_undo(el);
374 cv_yank(el, el->el_line.buffer,
375 (int)(el->el_line.lastchar - el->el_line.buffer));
376 (void) em_kill_line(el, 0);
377 el->el_map.current = el->el_map.key;
388 vi_change_to_eol(EditLine *el, wint_t c __attribute__((__unused__)))
391 cv_undo(el);
392 cv_yank(el, el->el_line.cursor,
393 (int)(el->el_line.lastchar - el->el_line.cursor));
394 (void) ed_kill_line(el, 0);
395 el->el_map.current = el->el_map.key;
406 vi_insert(EditLine *el, wint_t c __attribute__((__unused__)))
409 el->el_map.current = el->el_map.key;
410 cv_undo(el);
421 vi_add(EditLine *el, wint_t c __attribute__((__unused__)))
425 el->el_map.current = el->el_map.key;
426 if (el->el_line.cursor < el->el_line.lastchar) {
427 el->el_line.cursor++;
428 if (el->el_line.cursor > el->el_line.lastchar)
429 el->el_line.cursor = el->el_line.lastchar;
434 cv_undo(el);
446 vi_add_at_eol(EditLine *el, wint_t c __attribute__((__unused__)))
449 el->el_map.current = el->el_map.key;
450 el->el_line.cursor = el->el_line.lastchar;
451 cv_undo(el);
462 vi_delete_meta(EditLine *el, wint_t c __attribute__((__unused__)))
465 return cv_action(el, DELETE);
475 vi_end_big_word(EditLine *el, wint_t c __attribute__((__unused__)))
478 if (el->el_line.cursor == el->el_line.lastchar)
481 el->el_line.cursor = cv__endword(el->el_line.cursor,
482 el->el_line.lastchar, el->el_state.argument, cv__isWord);
484 if (el->el_chared.c_vcmd.action != NOP) {
485 el->el_line.cursor++;
486 cv_delfini(el);
499 vi_end_word(EditLine *el, wint_t c __attribute__((__unused__)))
502 if (el->el_line.cursor == el->el_line.lastchar)
505 el->el_line.cursor = cv__endword(el->el_line.cursor,
506 el->el_line.lastchar, el->el_state.argument, cv__isword);
508 if (el->el_chared.c_vcmd.action != NOP) {
509 el->el_line.cursor++;
510 cv_delfini(el);
523 vi_undo(EditLine *el, wint_t c __attribute__((__unused__)))
525 c_undo_t un = el->el_chared.c_undo;
531 el->el_chared.c_undo.buf = el->el_line.buffer;
532 el->el_chared.c_undo.len = el->el_line.lastchar - el->el_line.buffer;
533 el->el_chared.c_undo.cursor =
534 (int)(el->el_line.cursor - el->el_line.buffer);
535 el->el_line.limit = un.buf + (el->el_line.limit - el->el_line.buffer);
536 el->el_line.buffer = un.buf;
537 el->el_line.cursor = un.buf + un.cursor;
538 el->el_line.lastchar = un.buf + un.len;
550 vi_command_mode(EditLine *el, wint_t c __attribute__((__unused__)))
554 el->el_chared.c_vcmd.action = NOP;
555 el->el_chared.c_vcmd.pos = 0;
557 el->el_state.doingarg = 0;
559 el->el_state.inputmode = MODE_INSERT;
560 el->el_map.current = el->el_map.alt;
562 if (el->el_line.cursor > el->el_line.buffer)
563 el->el_line.cursor--;
574 vi_zero(EditLine *el, wint_t c)
577 if (el->el_state.doingarg)
578 return ed_argument_digit(el, c);
580 el->el_line.cursor = el->el_line.buffer;
581 if (el->el_chared.c_vcmd.action != NOP) {
582 cv_delfini(el);
595 vi_delete_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
598 if (el->el_line.cursor <= el->el_line.buffer)
601 c_delbefore1(el);
602 el->el_line.cursor--;
613 vi_list_or_eof(EditLine *el, wint_t c)
616 if (el->el_line.cursor == el->el_line.lastchar) {
617 if (el->el_line.cursor == el->el_line.buffer) {
618 terminal_writec(el, c); /* then do a EOF */
625 terminal_beep(el);
630 re_goto_bottom(el);
631 *el->el_line.lastchar = '\0'; /* just in case */
637 terminal_beep(el);
650 vi_kill_line_prev(EditLine *el, wint_t c __attribute__((__unused__)))
654 cp = el->el_line.buffer;
655 kp = el->el_chared.c_kill.buf;
656 while (cp < el->el_line.cursor)
658 el->el_chared.c_kill.last = kp;
659 c_delbefore(el, (int)(el->el_line.cursor - el->el_line.buffer));
660 el->el_line.cursor = el->el_line.buffer; /* zap! */
671 vi_search_prev(EditLine *el, wint_t c __attribute__((__unused__)))
674 return cv_search(el, ED_SEARCH_PREV_HISTORY);
684 vi_search_next(EditLine *el, wint_t c __attribute__((__unused__)))
687 return cv_search(el, ED_SEARCH_NEXT_HISTORY);
697 vi_repeat_search_next(EditLine *el, wint_t c __attribute__((__unused__)))
700 if (el->el_search.patlen == 0)
703 return cv_repeat_srch(el, el->el_search.patdir);
713 vi_repeat_search_prev(EditLine *el, wint_t c __attribute__((__unused__)))
716 if (el->el_search.patlen == 0)
719 return (cv_repeat_srch(el,
720 el->el_search.patdir == ED_SEARCH_PREV_HISTORY ?
731 vi_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
733 return cv_csearch(el, CHAR_FWD, -1, el->el_state.argument, 0);
743 vi_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
745 return cv_csearch(el, CHAR_BACK, -1, el->el_state.argument, 0);
755 vi_to_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
757 return cv_csearch(el, CHAR_FWD, -1, el->el_state.argument, 1);
767 vi_to_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
769 return cv_csearch(el, CHAR_BACK, -1, el->el_state.argument, 1);
779 vi_repeat_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
782 return cv_csearch(el, el->el_search.chadir, el->el_search.chacha,
783 el->el_state.argument, el->el_search.chatflg);
793 vi_repeat_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
796 int dir = el->el_search.chadir;
798 r = cv_csearch(el, -dir, el->el_search.chacha,
799 el->el_state.argument, el->el_search.chatflg);
800 el->el_search.chadir = dir;
811 vi_match(EditLine *el, wint_t c __attribute__((__unused__)))
818 *el->el_line.lastchar = '\0'; /* just in case */
820 i = wcscspn(el->el_line.cursor, match_chars);
821 o_ch = el->el_line.cursor[i];
829 for (cp = &el->el_line.cursor[i]; count; ) {
831 if (cp < el->el_line.buffer || cp >= el->el_line.lastchar)
839 el->el_line.cursor = cp;
841 if (el->el_chared.c_vcmd.action != NOP) {
845 el->el_line.cursor++;
846 cv_delfini(el);
858 vi_undo_line(EditLine *el, wint_t c __attribute__((__unused__)))
861 cv_undo(el);
862 return hist_get(el);
872 vi_to_column(EditLine *el, wint_t c __attribute__((__unused__)))
875 el->el_line.cursor = el->el_line.buffer;
876 el->el_state.argument--;
877 return ed_next_char(el, 0);
886 vi_yank_end(EditLine *el, wint_t c __attribute__((__unused__)))
889 cv_yank(el, el->el_line.cursor,
890 (int)(el->el_line.lastchar - el->el_line.cursor));
900 vi_yank(EditLine *el, wint_t c __attribute__((__unused__)))
903 return cv_action(el, YANK);
912 vi_comment_out(EditLine *el, wint_t c __attribute__((__unused__)))
915 el->el_line.cursor = el->el_line.buffer;
916 c_insert(el, 1);
917 *el->el_line.cursor = '#';
918 re_refresh(el);
919 return ed_newline(el, 0);
930 vi_alias(EditLine *el, wint_t c __attribute__((__unused__)))
935 if (el->el_chared.c_aliasfun == NULL)
940 if (el_getc(el, &alias_name[1]) != 1)
943 alias_text = (*el->el_chared.c_aliasfun)(el->el_chared.c_aliasarg,
946 el_wpush(el, ct_decode_string(alias_text, &el->el_scratch));
956 vi_to_history_line(EditLine *el, wint_t c __attribute__((__unused__)))
958 int sv_event_no = el->el_history.eventno;
962 if (el->el_history.eventno == 0) {
963 (void) wcsncpy(el->el_history.buf, el->el_line.buffer,
965 el->el_history.last = el->el_history.buf +
966 (el->el_line.lastchar - el->el_line.buffer);
970 if (!el->el_state.doingarg) {
971 el->el_history.eventno = 0x7fffffff;
972 hist_get(el);
979 el->el_history.eventno = 1;
980 if (hist_get(el) == CC_ERROR)
982 el->el_history.eventno = 1 + el->el_history.ev.num
983 - el->el_state.argument;
984 if (el->el_history.eventno < 0) {
985 el->el_history.eventno = sv_event_no;
989 rval = hist_get(el);
991 el->el_history.eventno = sv_event_no;
1001 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)
1023 len = (size_t)(el->el_line.lastchar - el->el_line.buffer);
1031 wcsncpy(line, el->el_line.buffer, len);
1054 len = (size_t)(el->el_line.limit - el->el_line.buffer);
1055 len = mbstowcs(el->el_line.buffer, cp, len);
1056 if (len > 0 && el->el_line.buffer[len - 1] == '\n')
1061 el->el_line.cursor = el->el_line.buffer;
1062 el->el_line.lastchar = el->el_line.buffer + len;
1071 return ed_newline(el, 0);
1088 vi_history_word(EditLine *el, wint_t c __attribute__((__unused__)))
1090 const wchar_t *wp = HIST_FIRST(el);
1109 } while ((!el->el_state.doingarg || --el->el_state.argument > 0)
1112 if (wsp == NULL || (el->el_state.doingarg && el->el_state.argument != 0))
1115 cv_undo(el);
1117 if (el->el_line.cursor < el->el_line.lastchar)
1118 el->el_line.cursor++;
1119 c_insert(el, len + 1);
1120 cp = el->el_line.cursor;
1121 lim = el->el_line.limit;
1126 el->el_line.cursor = cp;
1128 el->el_map.current = el->el_map.key;
1138 vi_redo(EditLine *el, wint_t c __attribute__((__unused__)))
1140 c_redo_t *r = &el->el_chared.c_redo;
1142 if (!el->el_state.doingarg && r->count) {
1143 el->el_state.doingarg = 1;
1144 el->el_state.argument = r->count;
1147 el->el_chared.c_vcmd.pos = el->el_line.cursor;
1148 el->el_chared.c_vcmd.action = r->action;
1154 el_wpush(el, r->buf);
1157 el->el_state.thiscmd = r->cmd;
1158 el->el_state.thisch = r->ch;
1159 return (*el->el_map.func[r->cmd])(el, r->ch);