Lines Matching refs:el

45 #include "el.h"
53 ed_end_of_file(EditLine *el, int c __unused)
56 re_goto_bottom(el);
57 *el->el_line.lastchar = '\0';
67 ed_insert(EditLine *el, int c)
69 int count = el->el_state.argument;
74 if (el->el_line.lastchar + el->el_state.argument >=
75 el->el_line.limit) {
77 if (!ch_enlargebufs(el, (size_t) count))
82 if (el->el_state.inputmode == MODE_INSERT
83 || el->el_line.cursor >= el->el_line.lastchar)
84 c_insert(el, 1);
86 *el->el_line.cursor++ = c;
87 re_fastaddc(el); /* fast refresh for one char. */
89 if (el->el_state.inputmode != MODE_REPLACE_1)
90 c_insert(el, el->el_state.argument);
92 while (count-- && el->el_line.cursor < el->el_line.lastchar)
93 *el->el_line.cursor++ = c;
94 re_refresh(el);
97 if (el->el_state.inputmode == MODE_REPLACE_1)
98 return vi_command_mode(el, 0);
110 ed_delete_prev_word(EditLine *el, int c __unused)
114 if (el->el_line.cursor == el->el_line.buffer)
117 cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
118 el->el_state.argument, ce__isword);
120 for (p = cp, kp = el->el_chared.c_kill.buf; p < el->el_line.cursor; p++)
122 el->el_chared.c_kill.last = kp;
124 c_delbefore(el, el->el_line.cursor - cp); /* delete before dot */
125 el->el_line.cursor = cp;
126 if (el->el_line.cursor < el->el_line.buffer)
127 el->el_line.cursor = el->el_line.buffer; /* bounds check */
138 ed_delete_next_char(EditLine *el, int c)
141 #define EL el->el_line
142 (void) fprintf(el->el_errlfile,
147 if (el->el_line.cursor == el->el_line.lastchar) {
149 if (el->el_map.type == MAP_VI) {
150 if (el->el_line.cursor == el->el_line.buffer) {
156 term_writechar(el, c);
161 el->el_line.cursor--;
169 c_delafter(el, el->el_state.argument); /* delete after dot */
170 if (el->el_map.type == MAP_VI &&
171 el->el_line.cursor >= el->el_line.lastchar &&
172 el->el_line.cursor > el->el_line.buffer)
174 el->el_line.cursor = el->el_line.lastchar - 1;
185 ed_kill_line(EditLine *el, int c __unused)
189 cp = el->el_line.cursor;
190 kp = el->el_chared.c_kill.buf;
191 while (cp < el->el_line.lastchar)
193 el->el_chared.c_kill.last = kp;
195 el->el_line.lastchar = el->el_line.cursor;
206 ed_move_to_end(EditLine *el, int c __unused)
209 el->el_line.cursor = el->el_line.lastchar;
210 if (el->el_map.type == MAP_VI) {
212 el->el_line.cursor--;
214 if (el->el_chared.c_vcmd.action != NOP) {
215 cv_delfini(el);
229 ed_move_to_beg(EditLine *el, int c __unused)
232 el->el_line.cursor = el->el_line.buffer;
234 if (el->el_map.type == MAP_VI) {
236 while (isspace((unsigned char) *el->el_line.cursor))
237 el->el_line.cursor++;
238 if (el->el_chared.c_vcmd.action != NOP) {
239 cv_delfini(el);
252 ed_transpose_chars(EditLine *el, int c)
255 if (el->el_line.cursor < el->el_line.lastchar) {
256 if (el->el_line.lastchar <= &el->el_line.buffer[1])
259 el->el_line.cursor++;
261 if (el->el_line.cursor > &el->el_line.buffer[1]) {
263 c = el->el_line.cursor[-2];
264 el->el_line.cursor[-2] = el->el_line.cursor[-1];
265 el->el_line.cursor[-1] = c;
278 ed_next_char(EditLine *el, int c __unused)
280 char *lim = el->el_line.lastchar;
282 if (el->el_line.cursor >= lim ||
283 (el->el_line.cursor == lim - 1 &&
284 el->el_map.type == MAP_VI &&
285 el->el_chared.c_vcmd.action == NOP))
288 el->el_line.cursor += el->el_state.argument;
289 if (el->el_line.cursor > lim)
290 el->el_line.cursor = lim;
292 if (el->el_map.type == MAP_VI)
293 if (el->el_chared.c_vcmd.action != NOP) {
294 cv_delfini(el);
307 ed_prev_word(EditLine *el, int c __unused)
310 if (el->el_line.cursor == el->el_line.buffer)
313 el->el_line.cursor = c__prev_word(el->el_line.cursor,
314 el->el_line.buffer,
315 el->el_state.argument,
318 if (el->el_map.type == MAP_VI)
319 if (el->el_chared.c_vcmd.action != NOP) {
320 cv_delfini(el);
333 ed_prev_char(EditLine *el, int c __unused)
336 if (el->el_line.cursor > el->el_line.buffer) {
337 el->el_line.cursor -= el->el_state.argument;
338 if (el->el_line.cursor < el->el_line.buffer)
339 el->el_line.cursor = el->el_line.buffer;
341 if (el->el_map.type == MAP_VI)
342 if (el->el_chared.c_vcmd.action != NOP) {
343 cv_delfini(el);
357 ed_quoted_insert(EditLine *el, int c)
362 tty_quotemode(el);
363 num = el_getc(el, &tc);
365 tty_noquotemode(el);
367 return (ed_insert(el, c));
369 return (ed_end_of_file(el, 0));
377 ed_digit(EditLine *el, int c)
383 if (el->el_state.doingarg) {
385 if (el->el_state.lastcmd == EM_UNIVERSAL_ARGUMENT)
386 el->el_state.argument = c - '0';
388 if (el->el_state.argument > 1000000)
390 el->el_state.argument =
391 (el->el_state.argument * 10) + (c - '0');
396 return ed_insert(el, c);
405 ed_argument_digit(EditLine *el, int c)
411 if (el->el_state.doingarg) {
412 if (el->el_state.argument > 1000000)
414 el->el_state.argument = (el->el_state.argument * 10) +
417 el->el_state.argument = c - '0';
418 el->el_state.doingarg = 1;
430 ed_unassigned(EditLine *el, int c __unused)
447 ed_tty_sigint(EditLine *el __unused,
461 ed_tty_dsusp(EditLine *el __unused,
475 ed_tty_flush_output(EditLine *el __unused,
489 ed_tty_sigquit(EditLine *el __unused,
503 ed_tty_sigtstp(EditLine *el __unused,
517 ed_tty_stop_output(EditLine *el __unused,
531 ed_tty_start_output(EditLine *el __unused,
545 ed_newline(EditLine *el, int c __unused)
548 re_goto_bottom(el);
549 *el->el_line.lastchar++ = '\n';
550 *el->el_line.lastchar = '\0';
561 ed_delete_prev_char(EditLine *el, int c __unused)
564 if (el->el_line.cursor <= el->el_line.buffer)
567 c_delbefore(el, el->el_state.argument);
568 el->el_line.cursor -= el->el_state.argument;
569 if (el->el_line.cursor < el->el_line.buffer)
570 el->el_line.cursor = el->el_line.buffer;
581 ed_clear_screen(EditLine *el, int c __unused)
584 term_clear_screen(el); /* clear the whole real screen */
585 re_clear_display(el); /* reset everything */
596 ed_redisplay(EditLine *el __unused,
610 ed_start_over(EditLine *el, int c __unused)
613 ch_reset(el, 0);
624 ed_sequence_lead_in(EditLine *el __unused,
638 ed_prev_history(EditLine *el, int c __unused)
641 int sv_event = el->el_history.eventno;
643 el->el_chared.c_undo.len = -1;
644 *el->el_line.lastchar = '\0'; /* just in case */
646 if (el->el_history.eventno == 0) { /* save the current buffer
648 (void) strncpy(el->el_history.buf, el->el_line.buffer,
650 el->el_history.last = el->el_history.buf +
651 (el->el_line.lastchar - el->el_line.buffer);
653 el->el_history.eventno += el->el_state.argument;
655 if (hist_get(el) == CC_ERROR) {
656 if (el->el_map.type == MAP_VI) {
657 el->el_history.eventno = sv_event;
661 /* el->el_history.eventno was fixed by first call */
662 (void) hist_get(el);
676 ed_next_history(EditLine *el, int c __unused)
680 el->el_chared.c_undo.len = -1;
681 *el->el_line.lastchar = '\0'; /* just in case */
683 el->el_history.eventno -= el->el_state.argument;
685 if (el->el_history.eventno < 0) {
686 el->el_history.eventno = 0;
689 rval = hist_get(el);
703 ed_search_prev_history(EditLine *el, int c __unused)
709 el->el_chared.c_vcmd.action = NOP;
710 el->el_chared.c_undo.len = -1;
711 *el->el_line.lastchar = '\0'; /* just in case */
712 if (el->el_history.eventno < 0) {
714 (void) fprintf(el->el_errfile,
717 el->el_history.eventno = 0;
720 if (el->el_history.eventno == 0) {
721 (void) strncpy(el->el_history.buf, el->el_line.buffer,
723 el->el_history.last = el->el_history.buf +
724 (el->el_line.lastchar - el->el_line.buffer);
726 if (el->el_history.ref == NULL)
729 hp = HIST_FIRST(el);
733 c_setpat(el); /* Set search pattern !! */
735 for (h = 1; h <= el->el_history.eventno; h++)
736 hp = HIST_NEXT(el);
740 (void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
742 if ((strncmp(hp, el->el_line.buffer, (size_t)
743 (el->el_line.lastchar - el->el_line.buffer)) ||
744 hp[el->el_line.lastchar - el->el_line.buffer]) &&
745 c_hmatch(el, hp)) {
750 hp = HIST_NEXT(el);
755 (void) fprintf(el->el_errfile, "not found\n");
759 el->el_history.eventno = h;
761 return (hist_get(el));
771 ed_search_next_history(EditLine *el, int c __unused)
777 el->el_chared.c_vcmd.action = NOP;
778 el->el_chared.c_undo.len = -1;
779 *el->el_line.lastchar = '\0'; /* just in case */
781 if (el->el_history.eventno == 0)
784 if (el->el_history.ref == NULL)
787 hp = HIST_FIRST(el);
791 c_setpat(el); /* Set search pattern !! */
793 for (h = 1; h < el->el_history.eventno && hp; h++) {
795 (void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
797 if ((strncmp(hp, el->el_line.buffer, (size_t)
798 (el->el_line.lastchar - el->el_line.buffer)) ||
799 hp[el->el_line.lastchar - el->el_line.buffer]) &&
800 c_hmatch(el, hp))
802 hp = HIST_NEXT(el);
806 if (!c_hmatch(el, el->el_history.buf)) {
808 (void) fprintf(el->el_errfile, "not found\n");
813 el->el_history.eventno = found;
815 return (hist_get(el));
825 ed_prev_line(EditLine *el, int c __unused)
828 int nchars = c_hpos(el);
833 if (*(ptr = el->el_line.cursor) == '\n')
836 for (; ptr >= el->el_line.buffer; ptr--)
837 if (*ptr == '\n' && --el->el_state.argument <= 0)
840 if (el->el_state.argument > 0)
846 for (ptr--; ptr >= el->el_line.buffer && *ptr != '\n'; ptr--)
853 nchars-- > 0 && ptr < el->el_line.lastchar && *ptr != '\n';
857 el->el_line.cursor = ptr;
868 ed_next_line(EditLine *el, int c __unused)
871 int nchars = c_hpos(el);
876 for (ptr = el->el_line.cursor; ptr < el->el_line.lastchar; ptr++)
877 if (*ptr == '\n' && --el->el_state.argument <= 0)
880 if (el->el_state.argument > 0)
887 nchars-- > 0 && ptr < el->el_line.lastchar && *ptr != '\n';
891 el->el_line.cursor = ptr;
902 ed_command(EditLine *el, int c __unused)
907 tmplen = c_gets(el, tmpbuf, "\n: ");
908 term__putc(el, '\n');
910 if (tmplen < 0 || (tmpbuf[tmplen] = 0, parse_line(el, tmpbuf)) == -1)
911 term_beep(el);
913 el->el_map.current = el->el_map.key;
914 re_clear_display(el);