Lines Matching defs:el

47 #include "el.h"
55 ed_end_of_file(EditLine *el, Int c __attribute__((__unused__)))
58 re_goto_bottom(el);
59 *el->el_line.lastchar = '\0';
69 ed_insert(EditLine *el, Int c)
71 int count = el->el_state.argument;
76 if (el->el_line.lastchar + el->el_state.argument >=
77 el->el_line.limit) {
79 if (!ch_enlargebufs(el, (size_t) count))
84 if (el->el_state.inputmode == MODE_INSERT
85 || el->el_line.cursor >= el->el_line.lastchar)
86 c_insert(el, 1);
88 *el->el_line.cursor++ = c;
89 re_fastaddc(el); /* fast refresh for one char. */
91 if (el->el_state.inputmode != MODE_REPLACE_1)
92 c_insert(el, el->el_state.argument);
94 while (count-- && el->el_line.cursor < el->el_line.lastchar)
95 *el->el_line.cursor++ = c;
96 re_refresh(el);
99 if (el->el_state.inputmode == MODE_REPLACE_1)
100 return vi_command_mode(el, 0);
112 ed_delete_prev_word(EditLine *el, Int c __attribute__((__unused__)))
116 if (el->el_line.cursor == el->el_line.buffer)
119 cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
120 el->el_state.argument, ce__isword);
122 for (p = cp, kp = el->el_chared.c_kill.buf; p < el->el_line.cursor; p++)
124 el->el_chared.c_kill.last = kp;
126 c_delbefore(el, (int)(el->el_line.cursor - cp));/* delete before dot */
127 el->el_line.cursor = cp;
128 if (el->el_line.cursor < el->el_line.buffer)
129 el->el_line.cursor = el->el_line.buffer; /* bounds check */
140 ed_delete_next_char(EditLine *el, Int c __attribute__((__unused__)))
143 #define EL el->el_line
144 (void) fprintf(el->el_errlfile,
149 if (el->el_line.cursor == el->el_line.lastchar) {
151 if (el->el_map.type == MAP_VI) {
152 if (el->el_line.cursor == el->el_line.buffer) {
158 terminal_writec(el, c);
163 el->el_line.cursor--;
169 if (el->el_line.cursor != el->el_line.buffer)
170 el->el_line.cursor--;
175 c_delafter(el, el->el_state.argument); /* delete after dot */
176 if (el->el_line.cursor >= el->el_line.lastchar &&
177 el->el_line.cursor > el->el_line.buffer)
179 el->el_line.cursor = el->el_line.lastchar - 1;
190 ed_kill_line(EditLine *el, Int c __attribute__((__unused__)))
194 cp = el->el_line.cursor;
195 kp = el->el_chared.c_kill.buf;
196 while (cp < el->el_line.lastchar)
198 el->el_chared.c_kill.last = kp;
200 el->el_line.lastchar = el->el_line.cursor;
211 ed_move_to_end(EditLine *el, Int c __attribute__((__unused__)))
214 el->el_line.cursor = el->el_line.lastchar;
215 if (el->el_map.type == MAP_VI) {
216 if (el->el_chared.c_vcmd.action != NOP) {
217 cv_delfini(el);
221 el->el_line.cursor--;
234 ed_move_to_beg(EditLine *el, Int c __attribute__((__unused__)))
237 el->el_line.cursor = el->el_line.buffer;
239 if (el->el_map.type == MAP_VI) {
241 while (Isspace(*el->el_line.cursor))
242 el->el_line.cursor++;
243 if (el->el_chared.c_vcmd.action != NOP) {
244 cv_delfini(el);
257 ed_transpose_chars(EditLine *el, Int c)
260 if (el->el_line.cursor < el->el_line.lastchar) {
261 if (el->el_line.lastchar <= &el->el_line.buffer[1])
264 el->el_line.cursor++;
266 if (el->el_line.cursor > &el->el_line.buffer[1]) {
268 c = el->el_line.cursor[-2];
269 el->el_line.cursor[-2] = el->el_line.cursor[-1];
270 el->el_line.cursor[-1] = c;
283 ed_next_char(EditLine *el, Int c __attribute__((__unused__)))
285 Char *lim = el->el_line.lastchar;
287 if (el->el_line.cursor >= lim ||
288 (el->el_line.cursor == lim - 1 &&
289 el->el_map.type == MAP_VI &&
290 el->el_chared.c_vcmd.action == NOP))
293 el->el_line.cursor += el->el_state.argument;
294 if (el->el_line.cursor > lim)
295 el->el_line.cursor = lim;
297 if (el->el_map.type == MAP_VI)
298 if (el->el_chared.c_vcmd.action != NOP) {
299 cv_delfini(el);
312 ed_prev_word(EditLine *el, Int c __attribute__((__unused__)))
315 if (el->el_line.cursor == el->el_line.buffer)
318 el->el_line.cursor = c__prev_word(el->el_line.cursor,
319 el->el_line.buffer,
320 el->el_state.argument,
323 if (el->el_map.type == MAP_VI)
324 if (el->el_chared.c_vcmd.action != NOP) {
325 cv_delfini(el);
338 ed_prev_char(EditLine *el, Int c __attribute__((__unused__)))
341 if (el->el_line.cursor > el->el_line.buffer) {
342 el->el_line.cursor -= el->el_state.argument;
343 if (el->el_line.cursor < el->el_line.buffer)
344 el->el_line.cursor = el->el_line.buffer;
346 if (el->el_map.type == MAP_VI)
347 if (el->el_chared.c_vcmd.action != NOP) {
348 cv_delfini(el);
362 ed_quoted_insert(EditLine *el, Int c)
367 tty_quotemode(el);
368 num = FUN(el,getc)(el, &tc);
370 tty_noquotemode(el);
372 return ed_insert(el, c);
374 return ed_end_of_file(el, 0);
382 ed_digit(EditLine *el, Int c)
388 if (el->el_state.doingarg) {
390 if (el->el_state.lastcmd == EM_UNIVERSAL_ARGUMENT)
391 el->el_state.argument = c - '0';
393 if (el->el_state.argument > 1000000)
395 el->el_state.argument =
396 (el->el_state.argument * 10) + (c - '0');
401 return ed_insert(el, c);
410 ed_argument_digit(EditLine *el, Int c)
416 if (el->el_state.doingarg) {
417 if (el->el_state.argument > 1000000)
419 el->el_state.argument = (el->el_state.argument * 10) +
422 el->el_state.argument = c - '0';
423 el->el_state.doingarg = 1;
435 ed_unassigned(EditLine *el __attribute__((__unused__)),
453 ed_tty_sigint(EditLine *el __attribute__((__unused__)),
467 ed_tty_dsusp(EditLine *el __attribute__((__unused__)),
481 ed_tty_flush_output(EditLine *el __attribute__((__unused__)),
495 ed_tty_sigquit(EditLine *el __attribute__((__unused__)),
509 ed_tty_sigtstp(EditLine *el __attribute__((__unused__)),
523 ed_tty_stop_output(EditLine *el __attribute__((__unused__)),
537 ed_tty_start_output(EditLine *el __attribute__((__unused__)),
551 ed_newline(EditLine *el, Int c __attribute__((__unused__)))
554 re_goto_bottom(el);
555 *el->el_line.lastchar++ = '\n';
556 *el->el_line.lastchar = '\0';
567 ed_delete_prev_char(EditLine *el, Int c __attribute__((__unused__)))
570 if (el->el_line.cursor <= el->el_line.buffer)
573 c_delbefore(el, el->el_state.argument);
574 el->el_line.cursor -= el->el_state.argument;
575 if (el->el_line.cursor < el->el_line.buffer)
576 el->el_line.cursor = el->el_line.buffer;
587 ed_clear_screen(EditLine *el, Int c __attribute__((__unused__)))
590 terminal_clear_screen(el); /* clear the whole real screen */
591 re_clear_display(el); /* reset everything */
602 ed_redisplay(EditLine *el __attribute__((__unused__)),
616 ed_start_over(EditLine *el, Int c __attribute__((__unused__)))
619 ch_reset(el, 0);
630 ed_sequence_lead_in(EditLine *el __attribute__((__unused__)),
644 ed_prev_history(EditLine *el, Int c __attribute__((__unused__)))
647 int sv_event = el->el_history.eventno;
649 el->el_chared.c_undo.len = -1;
650 *el->el_line.lastchar = '\0'; /* just in case */
652 if (el->el_history.eventno == 0) { /* save the current buffer
654 (void) Strncpy(el->el_history.buf, el->el_line.buffer,
656 el->el_history.last = el->el_history.buf +
657 (el->el_line.lastchar - el->el_line.buffer);
659 el->el_history.eventno += el->el_state.argument;
661 if (hist_get(el) == CC_ERROR) {
662 if (el->el_map.type == MAP_VI) {
663 el->el_history.eventno = sv_event;
667 /* el->el_history.eventno was fixed by first call */
668 (void) hist_get(el);
682 ed_next_history(EditLine *el, Int c __attribute__((__unused__)))
686 el->el_chared.c_undo.len = -1;
687 *el->el_line.lastchar = '\0'; /* just in case */
689 el->el_history.eventno -= el->el_state.argument;
691 if (el->el_history.eventno < 0) {
692 el->el_history.eventno = 0;
695 rval = hist_get(el);
709 ed_search_prev_history(EditLine *el, Int c __attribute__((__unused__)))
715 el->el_chared.c_vcmd.action = NOP;
716 el->el_chared.c_undo.len = -1;
717 *el->el_line.lastchar = '\0'; /* just in case */
718 if (el->el_history.eventno < 0) {
720 (void) fprintf(el->el_errfile,
723 el->el_history.eventno = 0;
726 if (el->el_history.eventno == 0) {
727 (void) Strncpy(el->el_history.buf, el->el_line.buffer,
729 el->el_history.last = el->el_history.buf +
730 (el->el_line.lastchar - el->el_line.buffer);
732 if (el->el_history.ref == NULL)
735 hp = HIST_FIRST(el);
739 c_setpat(el); /* Set search pattern !! */
741 for (h = 1; h <= el->el_history.eventno; h++)
742 hp = HIST_NEXT(el);
746 (void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
748 if ((Strncmp(hp, el->el_line.buffer, (size_t)
749 (el->el_line.lastchar - el->el_line.buffer)) ||
750 hp[el->el_line.lastchar - el->el_line.buffer]) &&
751 c_hmatch(el, hp)) {
756 hp = HIST_NEXT(el);
761 (void) fprintf(el->el_errfile, "not found\n");
765 el->el_history.eventno = h;
767 return hist_get(el);
777 ed_search_next_history(EditLine *el, Int c __attribute__((__unused__)))
783 el->el_chared.c_vcmd.action = NOP;
784 el->el_chared.c_undo.len = -1;
785 *el->el_line.lastchar = '\0'; /* just in case */
787 if (el->el_history.eventno == 0)
790 if (el->el_history.ref == NULL)
793 hp = HIST_FIRST(el);
797 c_setpat(el); /* Set search pattern !! */
799 for (h = 1; h < el->el_history.eventno && hp; h++) {
801 (void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
803 if ((Strncmp(hp, el->el_line.buffer, (size_t)
804 (el->el_line.lastchar - el->el_line.buffer)) ||
805 hp[el->el_line.lastchar - el->el_line.buffer]) &&
806 c_hmatch(el, hp))
808 hp = HIST_NEXT(el);
812 if (!c_hmatch(el, el->el_history.buf)) {
814 (void) fprintf(el->el_errfile, "not found\n");
819 el->el_history.eventno = found;
821 return hist_get(el);
831 ed_prev_line(EditLine *el, Int c __attribute__((__unused__)))
834 int nchars = c_hpos(el);
839 if (*(ptr = el->el_line.cursor) == '\n')
842 for (; ptr >= el->el_line.buffer; ptr--)
843 if (*ptr == '\n' && --el->el_state.argument <= 0)
846 if (el->el_state.argument > 0)
852 for (ptr--; ptr >= el->el_line.buffer && *ptr != '\n'; ptr--)
859 nchars-- > 0 && ptr < el->el_line.lastchar && *ptr != '\n';
863 el->el_line.cursor = ptr;
874 ed_next_line(EditLine *el, Int c __attribute__((__unused__)))
877 int nchars = c_hpos(el);
882 for (ptr = el->el_line.cursor; ptr < el->el_line.lastchar; ptr++)
883 if (*ptr == '\n' && --el->el_state.argument <= 0)
886 if (el->el_state.argument > 0)
893 nchars-- > 0 && ptr < el->el_line.lastchar && *ptr != '\n';
897 el->el_line.cursor = ptr;
908 ed_command(EditLine *el, Int c __attribute__((__unused__)))
913 tmplen = c_gets(el, tmpbuf, STR("\n: "));
914 terminal__putc(el, '\n');
916 if (tmplen < 0 || (tmpbuf[tmplen] = 0, parse_line(el, tmpbuf)) == -1)
917 terminal_beep(el);
919 el->el_map.current = el->el_map.key;
920 re_clear_display(el);