Lines Matching defs:el

53 #include "el.h"
67 read_init(EditLine *el)
70 el->el_read.read_char = read_char;
80 el_read_setfn(EditLine *el, el_rfunc_t rc)
82 el->el_read.read_char = (rc == EL_BUILTIN_GETCFN) ? read_char : rc;
92 el_read_getfn(EditLine *el)
94 return el->el_read.read_char == read_char ?
95 EL_BUILTIN_GETCFN : el->el_read.read_char;
105 read_debug(EditLine *el)
108 if (el->el_line.cursor > el->el_line.lastchar)
109 (void) fprintf(el->el_errfile, "cursor > lastchar\r\n");
110 if (el->el_line.cursor < el->el_line.buffer)
111 (void) fprintf(el->el_errfile, "cursor < buffer\r\n");
112 if (el->el_line.cursor > el->el_line.limit)
113 (void) fprintf(el->el_errfile, "cursor > limit\r\n");
114 if (el->el_line.lastchar > el->el_line.limit)
115 (void) fprintf(el->el_errfile, "lastchar > limit\r\n");
116 if (el->el_line.limit != &el->el_line.buffer[EL_BUFSIZ - 2])
117 (void) fprintf(el->el_errfile, "limit != &buffer[EL_BUFSIZ-2]\r\n");
188 read_preread(EditLine *el)
192 if (el->el_tty.t_mode == ED_IO)
199 (void) ioctl(el->el_infd, FIONREAD, &chrs);
203 chrs = read(el->el_infd, buf,
207 el_push(el, buf);
220 FUN(el,push)(EditLine *el, const Char *str)
222 c_macro_t *ma = &el->el_chared.c_macro;
230 terminal_beep(el);
231 terminal__flush(el);
240 read_getcmd(EditLine *el, el_action_t *cmdnum, Char *ch)
245 el->el_errno = 0;
247 if ((num = FUN(el,getc)(el, ch)) != 1) {/* if EOF or error */
248 el->el_errno = num == 0 ? 0 : errno;
254 el->el_state.metanext = 0;
260 if (el->el_state.metanext) {
261 el->el_state.metanext = 0;
269 cmd = el->el_map.current[(unsigned char) *ch];
272 switch (keymacro_get(el, ch, &val)) {
277 FUN(el,push)(el, val.str);
286 EL_ABORT((el->el_errfile, "Bad XK_ type \n"));
290 if (el->el_map.alt == NULL)
291 el->el_map.current = el->el_map.key;
313 read_char(EditLine *el, Char *cp)
322 el->el_signal->sig_no = 0;
323 while ((num_read = read(el->el_infd, cbuf + cbp, (size_t)1)) == -1) {
324 switch (el->el_signal->sig_no) {
326 FUN(el,set)(el, EL_REFRESH);
329 sig_set(el);
334 if (!tried && read__fixio(el->el_infd, errno) == 0)
343 if (el->el_flags & CHARSET_IS_UTF8) {
363 if ((el->el_flags & IGNORE_EXTCHARS) && bytes > 1) {
390 FUN(el,getc)(EditLine *el, Char *cp)
393 c_macro_t *ma = &el->el_chared.c_macro;
395 terminal__flush(el);
398 if (!read_preread(el))
421 (void) fprintf(el->el_errfile, "Turning raw mode on\n");
423 if (tty_rawmode(el) < 0)/* make sure the tty is set up correctly */
427 (void) fprintf(el->el_errfile, "Reading a character\n");
429 num_read = (*el->el_read.read_char)(el, cp);
431 if (el->el_flags & NARROW_READ)
435 (void) fprintf(el->el_errfile, "Got it %c\n", *cp);
441 read_prepare(EditLine *el)
443 if (el->el_flags & HANDLE_SIGNALS)
444 sig_set(el);
445 if (el->el_flags & NO_TTY)
447 if ((el->el_flags & (UNBUFFERED|EDIT_DISABLED)) == UNBUFFERED)
448 tty_rawmode(el);
452 el_resize(el);
453 re_clear_display(el); /* reset the display stuff */
454 ch_reset(el, 0);
455 re_refresh(el); /* print the prompt */
457 if (el->el_flags & UNBUFFERED)
458 terminal__flush(el);
462 read_finish(EditLine *el)
464 if ((el->el_flags & UNBUFFERED) == 0)
465 (void) tty_cookedmode(el);
466 if (el->el_flags & HANDLE_SIGNALS)
467 sig_clr(el);
471 FUN(el,gets)(EditLine *el, int *nread)
480 c_macro_t *ma = &el->el_chared.c_macro;
487 if (el->el_flags & NO_TTY) {
490 cp = el->el_line.buffer;
491 while ((num = (*el->el_read.read_char)(el, cp)) == 1) {
493 if (cp + 1 >= el->el_line.limit) {
494 idx = (size_t)(cp - el->el_line.buffer);
495 if (!ch_enlargebufs(el, (size_t)2))
497 cp = &el->el_line.buffer[idx];
500 if (el->el_flags & UNBUFFERED)
507 cp = el->el_line.buffer;
508 el->el_errno = errno;
516 if (el->el_tty.t_mode == EX_IO && ma->level < 0) {
519 (void) ioctl(el->el_infd, FIONREAD, &chrs);
521 if (tty_rawmode(el) < 0) {
530 if ((el->el_flags & UNBUFFERED) == 0)
531 read_prepare(el);
533 if (el->el_flags & EDIT_DISABLED) {
536 if ((el->el_flags & UNBUFFERED) == 0)
537 cp = el->el_line.buffer;
539 cp = el->el_line.lastchar;
541 terminal__flush(el);
543 while ((num = (*el->el_read.read_char)(el, cp)) == 1) {
545 if (cp + 1 >= el->el_line.limit) {
546 idx = (size_t)(cp - el->el_line.buffer);
547 if (!ch_enlargebufs(el, (size_t)2))
549 cp = &el->el_line.buffer[idx];
553 if (el->el_flags & UNBUFFERED)
561 cp = el->el_line.buffer;
562 el->el_errno = errno;
571 read_debug(el);
574 if ((num = read_getcmd(el, &cmdnum, &ch)) != OKCMD) {
576 (void) fprintf(el->el_errfile,
581 if (el->el_errno == EINTR) {
582 el->el_line.buffer[0] = '\0';
583 el->el_line.lastchar =
584 el->el_line.cursor = el->el_line.buffer;
587 if ((unsigned int)cmdnum >= (unsigned int)el->el_map.nfunc) { /* BUG CHECK command */
589 (void) fprintf(el->el_errfile,
598 for (b = el->el_map.help; b->name; b++)
602 (void) fprintf(el->el_errfile,
605 (void) fprintf(el->el_errfile,
610 el->el_state.thiscmd = cmdnum;
611 el->el_state.thisch = ch;
612 if (el->el_map.type == MAP_VI &&
613 el->el_map.current == el->el_map.key &&
614 el->el_chared.c_redo.pos < el->el_chared.c_redo.lim) {
616 el->el_chared.c_redo.pos != el->el_chared.c_redo.buf
617 && Isprint(el->el_chared.c_redo.pos[-1]))
618 el->el_chared.c_redo.pos--;
620 *el->el_chared.c_redo.pos++ = ch;
622 retval = (*el->el_map.func[cmdnum]) (el, ch);
624 (void) fprintf(el->el_errfile,
629 el->el_state.lastcmd = cmdnum;
634 re_refresh_cursor(el);
638 re_clear_lines(el);
639 re_clear_display(el);
643 re_refresh(el);
647 re_refresh(el);
648 terminal_beep(el);
659 if ((el->el_flags & UNBUFFERED) == 0)
662 *el->el_line.lastchar++ = CONTROL('d');
663 el->el_line.cursor = el->el_line.lastchar;
669 num = (int)(el->el_line.lastchar - el->el_line.buffer);
674 (void) fprintf(el->el_errfile,
678 re_clear_display(el); /* reset the display stuff */
679 ch_reset(el, 1); /* reset the input pointers */
680 re_refresh(el); /* print the prompt again */
686 (void) fprintf(el->el_errfile,
689 terminal_beep(el);
690 terminal__flush(el);
693 el->el_state.argument = 1;
694 el->el_state.doingarg = 0;
695 el->el_chared.c_vcmd.action = NOP;
696 if (el->el_flags & UNBUFFERED)
700 terminal__flush(el); /* flush any buffered output */
702 if ((el->el_flags & UNBUFFERED) == 0) {
703 read_finish(el);
706 *nread = (int)(el->el_line.lastchar - el->el_line.buffer);
710 el->el_line.cursor = el->el_line.lastchar = cp;
712 *nread = (int)(el->el_line.cursor - el->el_line.buffer);
717 errno = el->el_errno;
721 return el->el_line.buffer;