Lines Matching defs: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, (int)(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) {
211 if (el->el_chared.c_vcmd.action != NOP) {
212 cv_delfini(el);
226 ed_move_to_beg(EditLine *el, int c __unused)
229 el->el_line.cursor = el->el_line.buffer;
231 if (el->el_map.type == MAP_VI) {
233 while (isspace((unsigned char) *el->el_line.cursor))
234 el->el_line.cursor++;
235 if (el->el_chared.c_vcmd.action != NOP) {
236 cv_delfini(el);
249 ed_transpose_chars(EditLine *el, int c)
252 if (el->el_line.cursor < el->el_line.lastchar) {
253 if (el->el_line.lastchar <= &el->el_line.buffer[1])
256 el->el_line.cursor++;
258 if (el->el_line.cursor > &el->el_line.buffer[1]) {
260 c = el->el_line.cursor[-2];
261 el->el_line.cursor[-2] = el->el_line.cursor[-1];
262 el->el_line.cursor[-1] = c;
275 ed_next_char(EditLine *el, int c __unused)
277 char *lim = el->el_line.lastchar;
279 if (el->el_line.cursor >= lim ||
280 (el->el_line.cursor == lim - 1 &&
281 el->el_map.type == MAP_VI &&
282 el->el_chared.c_vcmd.action == NOP))
285 el->el_line.cursor += el->el_state.argument;
286 if (el->el_line.cursor > lim)
287 el->el_line.cursor = lim;
289 if (el->el_map.type == MAP_VI)
290 if (el->el_chared.c_vcmd.action != NOP) {
291 cv_delfini(el);
304 ed_prev_word(EditLine *el, int c __unused)
307 if (el->el_line.cursor == el->el_line.buffer)
310 el->el_line.cursor = c__prev_word(el->el_line.cursor,
311 el->el_line.buffer,
312 el->el_state.argument,
315 if (el->el_map.type == MAP_VI)
316 if (el->el_chared.c_vcmd.action != NOP) {
317 cv_delfini(el);
330 ed_prev_char(EditLine *el, int c __unused)
333 if (el->el_line.cursor > el->el_line.buffer) {
334 el->el_line.cursor -= el->el_state.argument;
335 if (el->el_line.cursor < el->el_line.buffer)
336 el->el_line.cursor = el->el_line.buffer;
338 if (el->el_map.type == MAP_VI)
339 if (el->el_chared.c_vcmd.action != NOP) {
340 cv_delfini(el);
354 ed_quoted_insert(EditLine *el, int c)
359 tty_quotemode(el);
360 num = el_getc(el, &tc);
362 tty_noquotemode(el);
364 return (ed_insert(el, c));
366 return (ed_end_of_file(el, 0));
374 ed_digit(EditLine *el, int c)
380 if (el->el_state.doingarg) {
382 if (el->el_state.lastcmd == EM_UNIVERSAL_ARGUMENT)
383 el->el_state.argument = c - '0';
385 if (el->el_state.argument > 1000000)
387 el->el_state.argument =
388 (el->el_state.argument * 10) + (c - '0');
393 return ed_insert(el, c);
402 ed_argument_digit(EditLine *el, int c)
408 if (el->el_state.doingarg) {
409 if (el->el_state.argument > 1000000)
411 el->el_state.argument = (el->el_state.argument * 10) +
414 el->el_state.argument = c - '0';
415 el->el_state.doingarg = 1;
427 ed_unassigned(EditLine *el, int c __unused)
444 ed_tty_sigint(EditLine *el __unused,
458 ed_tty_dsusp(EditLine *el __unused,
472 ed_tty_flush_output(EditLine *el __unused,
486 ed_tty_sigquit(EditLine *el __unused,
500 ed_tty_sigtstp(EditLine *el __unused,
514 ed_tty_stop_output(EditLine *el __unused,
528 ed_tty_start_output(EditLine *el __unused,
542 ed_newline(EditLine *el, int c __unused)
545 re_goto_bottom(el);
546 *el->el_line.lastchar++ = '\n';
547 *el->el_line.lastchar = '\0';
558 ed_delete_prev_char(EditLine *el, int c __unused)
561 if (el->el_line.cursor <= el->el_line.buffer)
564 c_delbefore(el, el->el_state.argument);
565 el->el_line.cursor -= el->el_state.argument;
566 if (el->el_line.cursor < el->el_line.buffer)
567 el->el_line.cursor = el->el_line.buffer;
578 ed_clear_screen(EditLine *el, int c __unused)
581 term_clear_screen(el); /* clear the whole real screen */
582 re_clear_display(el); /* reset everything */
593 ed_redisplay(EditLine *el __unused,
607 ed_start_over(EditLine *el, int c __unused)
610 ch_reset(el, 0);
621 ed_sequence_lead_in(EditLine *el __unused,
635 ed_prev_history(EditLine *el, int c __unused)
638 int sv_event = el->el_history.eventno;
640 el->el_chared.c_undo.len = -1;
641 *el->el_line.lastchar = '\0'; /* just in case */
643 if (el->el_history.eventno == 0) { /* save the current buffer
645 (void) strncpy(el->el_history.buf, el->el_line.buffer,
647 el->el_history.last = el->el_history.buf +
648 (el->el_line.lastchar - el->el_line.buffer);
650 el->el_history.eventno += el->el_state.argument;
652 if (hist_get(el) == CC_ERROR) {
653 if (el->el_map.type == MAP_VI) {
654 el->el_history.eventno = sv_event;
658 /* el->el_history.eventno was fixed by first call */
659 (void) hist_get(el);
673 ed_next_history(EditLine *el, int c __unused)
677 el->el_chared.c_undo.len = -1;
678 *el->el_line.lastchar = '\0'; /* just in case */
680 el->el_history.eventno -= el->el_state.argument;
682 if (el->el_history.eventno < 0) {
683 el->el_history.eventno = 0;
686 rval = hist_get(el);
700 ed_search_prev_history(EditLine *el, int c __unused)
706 el->el_chared.c_vcmd.action = NOP;
707 el->el_chared.c_undo.len = -1;
708 *el->el_line.lastchar = '\0'; /* just in case */
709 if (el->el_history.eventno < 0) {
711 (void) fprintf(el->el_errfile,
714 el->el_history.eventno = 0;
717 if (el->el_history.eventno == 0) {
718 (void) strncpy(el->el_history.buf, el->el_line.buffer,
720 el->el_history.last = el->el_history.buf +
721 (el->el_line.lastchar - el->el_line.buffer);
723 if (el->el_history.ref == NULL)
726 hp = HIST_FIRST(el);
730 c_setpat(el); /* Set search pattern !! */
732 for (h = 1; h <= el->el_history.eventno; h++)
733 hp = HIST_NEXT(el);
737 (void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
739 if ((strncmp(hp, el->el_line.buffer, (size_t)
740 (el->el_line.lastchar - el->el_line.buffer)) ||
741 hp[el->el_line.lastchar - el->el_line.buffer]) &&
742 c_hmatch(el, hp)) {
747 hp = HIST_NEXT(el);
752 (void) fprintf(el->el_errfile, "not found\n");
756 el->el_history.eventno = h;
758 return (hist_get(el));
768 ed_search_next_history(EditLine *el, int c __unused)
774 el->el_chared.c_vcmd.action = NOP;
775 el->el_chared.c_undo.len = -1;
776 *el->el_line.lastchar = '\0'; /* just in case */
778 if (el->el_history.eventno == 0)
781 if (el->el_history.ref == NULL)
784 hp = HIST_FIRST(el);
788 c_setpat(el); /* Set search pattern !! */
790 for (h = 1; h < el->el_history.eventno && hp; h++) {
792 (void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
794 if ((strncmp(hp, el->el_line.buffer, (size_t)
795 (el->el_line.lastchar - el->el_line.buffer)) ||
796 hp[el->el_line.lastchar - el->el_line.buffer]) &&
797 c_hmatch(el, hp))
799 hp = HIST_NEXT(el);
803 if (!c_hmatch(el, el->el_history.buf)) {
805 (void) fprintf(el->el_errfile, "not found\n");
810 el->el_history.eventno = found;
812 return (hist_get(el));
822 ed_prev_line(EditLine *el, int c __unused)
825 int nchars = c_hpos(el);
830 if (*(ptr = el->el_line.cursor) == '\n')
833 for (; ptr >= el->el_line.buffer; ptr--)
834 if (*ptr == '\n' && --el->el_state.argument <= 0)
837 if (el->el_state.argument > 0)
843 for (ptr--; ptr >= el->el_line.buffer && *ptr != '\n'; ptr--)
850 nchars-- > 0 && ptr < el->el_line.lastchar && *ptr != '\n';
854 el->el_line.cursor = ptr;
865 ed_next_line(EditLine *el, int c __unused)
868 int nchars = c_hpos(el);
873 for (ptr = el->el_line.cursor; ptr < el->el_line.lastchar; ptr++)
874 if (*ptr == '\n' && --el->el_state.argument <= 0)
877 if (el->el_state.argument > 0)
884 nchars-- > 0 && ptr < el->el_line.lastchar && *ptr != '\n';
888 el->el_line.cursor = ptr;
899 ed_command(EditLine *el, int c __unused)
904 tmplen = c_gets(el, tmpbuf, "\n: ");
905 term__putc(el, '\n');
907 if (tmplen < 0 || (tmpbuf[tmplen] = 0, parse_line(el, tmpbuf)) == -1)
908 term_beep(el);
910 el->el_map.current = el->el_map.key;
911 re_clear_display(el);