Lines Matching refs:el

52 #include "el.h"
63 ed_end_of_file(EditLine *el, wint_t c __attribute__((__unused__)))
66 re_goto_bottom(el);
67 *el->el_line.lastchar = '\0';
77 ed_insert(EditLine *el, wint_t c)
79 int count = el->el_state.argument;
84 if (el->el_line.lastchar + el->el_state.argument >=
85 el->el_line.limit) {
87 if (!ch_enlargebufs(el, (size_t) count))
92 if (el->el_state.inputmode == MODE_INSERT
93 || el->el_line.cursor >= el->el_line.lastchar)
94 c_insert(el, 1);
96 *el->el_line.cursor++ = (Char)c;
97 re_fastaddc(el); /* fast refresh for one char. */
99 if (el->el_state.inputmode != MODE_REPLACE_1)
100 c_insert(el, el->el_state.argument);
102 while (count-- && el->el_line.cursor < el->el_line.lastchar)
103 *el->el_line.cursor++ = (Char)c;
104 re_refresh(el);
107 if (el->el_state.inputmode == MODE_REPLACE_1)
108 return vi_command_mode(el, 0);
120 ed_delete_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
124 if (el->el_line.cursor == el->el_line.buffer)
127 cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
128 el->el_state.argument, ce__isword);
130 for (p = cp, kp = el->el_chared.c_kill.buf; p < el->el_line.cursor; p++)
132 el->el_chared.c_kill.last = kp;
134 c_delbefore(el, (int)(el->el_line.cursor - cp));/* delete before dot */
135 el->el_line.cursor = cp;
136 if (el->el_line.cursor < el->el_line.buffer)
137 el->el_line.cursor = el->el_line.buffer; /* bounds check */
148 ed_delete_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
151 #define EL el->el_line
152 (void) fprintf(el->el_errfile,
158 if (el->el_line.cursor == el->el_line.lastchar) {
160 if (el->el_map.type == MAP_VI) {
161 if (el->el_line.cursor == el->el_line.buffer) {
167 terminal_writec(el, c);
172 el->el_line.cursor--;
180 c_delafter(el, el->el_state.argument); /* delete after dot */
181 if (el->el_map.type == MAP_VI &&
182 el->el_line.cursor >= el->el_line.lastchar &&
183 el->el_line.cursor > el->el_line.buffer)
185 el->el_line.cursor = el->el_line.lastchar - 1;
196 ed_kill_line(EditLine *el, wint_t c __attribute__((__unused__)))
200 cp = el->el_line.cursor;
201 kp = el->el_chared.c_kill.buf;
202 while (cp < el->el_line.lastchar)
204 el->el_chared.c_kill.last = kp;
206 el->el_line.lastchar = el->el_line.cursor;
217 ed_move_to_end(EditLine *el, wint_t c __attribute__((__unused__)))
220 el->el_line.cursor = el->el_line.lastchar;
221 if (el->el_map.type == MAP_VI) {
222 if (el->el_chared.c_vcmd.action != NOP) {
223 cv_delfini(el);
227 el->el_line.cursor--;
240 ed_move_to_beg(EditLine *el, wint_t c __attribute__((__unused__)))
243 el->el_line.cursor = el->el_line.buffer;
245 if (el->el_map.type == MAP_VI) {
247 while (Isspace(*el->el_line.cursor))
248 el->el_line.cursor++;
249 if (el->el_chared.c_vcmd.action != NOP) {
250 cv_delfini(el);
263 ed_transpose_chars(EditLine *el, wint_t c)
266 if (el->el_line.cursor < el->el_line.lastchar) {
267 if (el->el_line.lastchar <= &el->el_line.buffer[1])
270 el->el_line.cursor++;
272 if (el->el_line.cursor > &el->el_line.buffer[1]) {
274 c = el->el_line.cursor[-2];
275 el->el_line.cursor[-2] = el->el_line.cursor[-1];
276 el->el_line.cursor[-1] = (Char)c;
289 ed_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
291 Char *lim = el->el_line.lastchar;
293 if (el->el_line.cursor >= lim ||
294 (el->el_line.cursor == lim - 1 &&
295 el->el_map.type == MAP_VI &&
296 el->el_chared.c_vcmd.action == NOP))
299 el->el_line.cursor += el->el_state.argument;
300 if (el->el_line.cursor > lim)
301 el->el_line.cursor = lim;
303 if (el->el_map.type == MAP_VI)
304 if (el->el_chared.c_vcmd.action != NOP) {
305 cv_delfini(el);
318 ed_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
321 if (el->el_line.cursor == el->el_line.buffer)
324 el->el_line.cursor = c__prev_word(el->el_line.cursor,
325 el->el_line.buffer,
326 el->el_state.argument,
329 if (el->el_map.type == MAP_VI)
330 if (el->el_chared.c_vcmd.action != NOP) {
331 cv_delfini(el);
344 ed_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
347 if (el->el_line.cursor > el->el_line.buffer) {
348 el->el_line.cursor -= el->el_state.argument;
349 if (el->el_line.cursor < el->el_line.buffer)
350 el->el_line.cursor = el->el_line.buffer;
352 if (el->el_map.type == MAP_VI)
353 if (el->el_chared.c_vcmd.action != NOP) {
354 cv_delfini(el);
368 ed_quoted_insert(EditLine *el, wint_t c)
372 tty_quotemode(el);
373 num = el_wgetc(el, &c);
374 tty_noquotemode(el);
376 return ed_insert(el, c);
378 return ed_end_of_file(el, 0);
386 ed_digit(EditLine *el, wint_t c)
392 if (el->el_state.doingarg) {
394 if (el->el_state.lastcmd == EM_UNIVERSAL_ARGUMENT)
395 el->el_state.argument = c - '0';
397 if (el->el_state.argument > 1000000)
399 el->el_state.argument =
400 (el->el_state.argument * 10) + (c - '0');
405 return ed_insert(el, c);
414 ed_argument_digit(EditLine *el, wint_t c)
420 if (el->el_state.doingarg) {
421 if (el->el_state.argument > 1000000)
423 el->el_state.argument = (el->el_state.argument * 10) +
426 el->el_state.argument = c - '0';
427 el->el_state.doingarg = 1;
439 ed_unassigned(EditLine *el __attribute__((__unused__)),
457 ed_tty_sigint(EditLine *el __attribute__((__unused__)),
471 ed_tty_dsusp(EditLine *el __attribute__((__unused__)),
485 ed_tty_flush_output(EditLine *el __attribute__((__unused__)),
499 ed_tty_sigquit(EditLine *el __attribute__((__unused__)),
513 ed_tty_sigtstp(EditLine *el __attribute__((__unused__)),
527 ed_tty_stop_output(EditLine *el __attribute__((__unused__)),
541 ed_tty_start_output(EditLine *el __attribute__((__unused__)),
555 ed_newline(EditLine *el, wint_t c __attribute__((__unused__)))
558 re_goto_bottom(el);
559 *el->el_line.lastchar++ = '\n';
560 *el->el_line.lastchar = '\0';
571 ed_delete_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
574 if (el->el_line.cursor <= el->el_line.buffer)
577 c_delbefore(el, el->el_state.argument);
578 el->el_line.cursor -= el->el_state.argument;
579 if (el->el_line.cursor < el->el_line.buffer)
580 el->el_line.cursor = el->el_line.buffer;
591 ed_clear_screen(EditLine *el, wint_t c __attribute__((__unused__)))
594 terminal_clear_screen(el); /* clear the whole real screen */
595 re_clear_display(el); /* reset everything */
606 ed_redisplay(EditLine *el __attribute__((__unused__)),
620 ed_start_over(EditLine *el, wint_t c __attribute__((__unused__)))
623 ch_reset(el, 0);
634 ed_sequence_lead_in(EditLine *el __attribute__((__unused__)),
648 ed_prev_history(EditLine *el, wint_t c __attribute__((__unused__)))
651 int sv_event = el->el_history.eventno;
653 el->el_chared.c_undo.len = -1;
654 *el->el_line.lastchar = '\0'; /* just in case */
656 if (el->el_history.eventno == 0) { /* save the current buffer
658 (void) Strncpy(el->el_history.buf, el->el_line.buffer,
660 el->el_history.last = el->el_history.buf +
661 (el->el_line.lastchar - el->el_line.buffer);
663 el->el_history.eventno += el->el_state.argument;
665 if (hist_get(el) == CC_ERROR) {
666 if (el->el_map.type == MAP_VI) {
667 el->el_history.eventno = sv_event;
670 /* el->el_history.eventno was fixed by first call */
671 (void) hist_get(el);
685 ed_next_history(EditLine *el, wint_t c __attribute__((__unused__)))
689 el->el_chared.c_undo.len = -1;
690 *el->el_line.lastchar = '\0'; /* just in case */
692 el->el_history.eventno -= el->el_state.argument;
694 if (el->el_history.eventno < 0) {
695 el->el_history.eventno = 0;
698 rval = hist_get(el);
712 ed_search_prev_history(EditLine *el, wint_t c __attribute__((__unused__)))
718 el->el_chared.c_vcmd.action = NOP;
719 el->el_chared.c_undo.len = -1;
720 *el->el_line.lastchar = '\0'; /* just in case */
721 if (el->el_history.eventno < 0) {
723 (void) fprintf(el->el_errfile,
726 el->el_history.eventno = 0;
729 if (el->el_history.eventno == 0) {
730 (void) Strncpy(el->el_history.buf, el->el_line.buffer,
732 el->el_history.last = el->el_history.buf +
733 (el->el_line.lastchar - el->el_line.buffer);
735 if (el->el_history.ref == NULL)
738 hp = HIST_FIRST(el);
742 c_setpat(el); /* Set search pattern !! */
744 for (h = 1; h <= el->el_history.eventno; h++)
745 hp = HIST_NEXT(el);
749 (void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
751 if ((Strncmp(hp, el->el_line.buffer, (size_t)
752 (el->el_line.lastchar - el->el_line.buffer)) ||
753 hp[el->el_line.lastchar - el->el_line.buffer]) &&
754 c_hmatch(el, hp)) {
759 hp = HIST_NEXT(el);
764 (void) fprintf(el->el_errfile, "not found\n");
768 el->el_history.eventno = h;
770 return hist_get(el);
780 ed_search_next_history(EditLine *el, wint_t c __attribute__((__unused__)))
786 el->el_chared.c_vcmd.action = NOP;
787 el->el_chared.c_undo.len = -1;
788 *el->el_line.lastchar = '\0'; /* just in case */
790 if (el->el_history.eventno == 0)
793 if (el->el_history.ref == NULL)
796 hp = HIST_FIRST(el);
800 c_setpat(el); /* Set search pattern !! */
802 for (h = 1; h < el->el_history.eventno && hp; h++) {
804 (void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
806 if ((Strncmp(hp, el->el_line.buffer, (size_t)
807 (el->el_line.lastchar - el->el_line.buffer)) ||
808 hp[el->el_line.lastchar - el->el_line.buffer]) &&
809 c_hmatch(el, hp))
811 hp = HIST_NEXT(el);
815 if (!c_hmatch(el, el->el_history.buf)) {
817 (void) fprintf(el->el_errfile, "not found\n");
822 el->el_history.eventno = found;
824 return hist_get(el);
834 ed_prev_line(EditLine *el, wint_t c __attribute__((__unused__)))
837 int nchars = c_hpos(el);
842 if (*(ptr = el->el_line.cursor) == '\n')
845 for (; ptr >= el->el_line.buffer; ptr--)
846 if (*ptr == '\n' && --el->el_state.argument <= 0)
849 if (el->el_state.argument > 0)
855 for (ptr--; ptr >= el->el_line.buffer && *ptr != '\n'; ptr--)
862 nchars-- > 0 && ptr < el->el_line.lastchar && *ptr != '\n';
866 el->el_line.cursor = ptr;
877 ed_next_line(EditLine *el, wint_t c __attribute__((__unused__)))
880 int nchars = c_hpos(el);
885 for (ptr = el->el_line.cursor; ptr < el->el_line.lastchar; ptr++)
886 if (*ptr == '\n' && --el->el_state.argument <= 0)
889 if (el->el_state.argument > 0)
896 nchars-- > 0 && ptr < el->el_line.lastchar && *ptr != '\n';
900 el->el_line.cursor = ptr;
911 ed_command(EditLine *el, wint_t c __attribute__((__unused__)))
916 tmplen = c_gets(el, tmpbuf, STR("\n: "));
917 terminal__putc(el, '\n');
919 if (tmplen < 0 || (tmpbuf[tmplen] = 0, parse_line(el, tmpbuf)) == -1)
920 terminal_beep(el);
922 el->el_map.current = el->el_map.key;
923 re_clear_display(el);