Lines Matching defs:el

50 #include "el.h"
64 read_init(EditLine *el)
67 el->el_read.read_char = read_char;
77 el_read_setfn(EditLine *el, el_rfunc_t rc)
79 el->el_read.read_char = (rc == EL_BUILTIN_GETCFN) ? read_char : rc;
89 el_read_getfn(EditLine *el)
91 return (el->el_read.read_char == read_char) ?
92 EL_BUILTIN_GETCFN : el->el_read.read_char;
102 read_debug(EditLine *el)
105 if (el->el_line.cursor > el->el_line.lastchar)
106 (void) fprintf(el->el_errfile, "cursor > lastchar\r\n");
107 if (el->el_line.cursor < el->el_line.buffer)
108 (void) fprintf(el->el_errfile, "cursor < buffer\r\n");
109 if (el->el_line.cursor > el->el_line.limit)
110 (void) fprintf(el->el_errfile, "cursor > limit\r\n");
111 if (el->el_line.lastchar > el->el_line.limit)
112 (void) fprintf(el->el_errfile, "lastchar > limit\r\n");
113 if (el->el_line.limit != &el->el_line.buffer[EL_BUFSIZ - 2])
114 (void) fprintf(el->el_errfile, "limit != &buffer[EL_BUFSIZ-2]\r\n");
185 read_preread(EditLine *el)
189 if (el->el_tty.t_mode == ED_IO)
193 (void) ioctl(el->el_infd, FIONREAD, (ioctl_t) & chrs);
197 chrs = read(el->el_infd, buf,
201 el_push(el, buf);
214 el_push(EditLine *el, const char *str)
216 c_macro_t *ma = &el->el_chared.c_macro;
224 term_beep(el);
225 term__flush(el);
233 read_getcmd(EditLine *el, el_action_t *cmdnum, char *ch)
238 el->el_errno = 0;
240 if ((num = el_getc(el, ch)) != 1) { /* if EOF or error */
241 el->el_errno = num == 0 ? 0 : errno;
247 el->el_state.metanext = 0;
253 if (el->el_state.metanext) {
254 el->el_state.metanext = 0;
257 cmd = el->el_map.current[(unsigned char) *ch];
260 switch (key_get(el, ch, &val)) {
265 el_push(el, val.str);
274 EL_ABORT((el->el_errfile, "Bad XK_ type \n"));
278 if (el->el_map.alt == NULL)
279 el->el_map.current = el->el_map.key;
290 read_char(EditLine *el, char *cp)
296 el->el_signal->sig_no = 0;
297 while ((num_read = read(el->el_infd, cp, 1)) == -1) {
298 if (el->el_signal->sig_no == SIGCONT) {
299 sig_set(el);
300 el_set(el, EL_REFRESH);
303 if (!tried && read__fixio(el->el_infd, errno) == 0)
332 el_getc(EditLine *el, char *cp)
335 c_macro_t *ma = &el->el_chared.c_macro;
337 term__flush(el);
340 if (!read_preread(el))
363 (void) fprintf(el->el_errfile, "Turning raw mode on\n");
365 if (tty_rawmode(el) < 0)/* make sure the tty is set up correctly */
369 (void) fprintf(el->el_errfile, "Reading a character\n");
371 num_read = (*el->el_read.read_char)(el, cp);
373 (void) fprintf(el->el_errfile, "Got it %c\n", *cp);
379 read_prepare(EditLine *el)
381 if (el->el_flags & HANDLE_SIGNALS)
382 sig_set(el);
383 if (el->el_flags & NO_TTY)
385 if ((el->el_flags & (UNBUFFERED|EDIT_DISABLED)) == UNBUFFERED)
386 tty_rawmode(el);
390 el_resize(el);
391 re_clear_display(el); /* reset the display stuff */
392 ch_reset(el, 0);
393 re_refresh(el); /* print the prompt */
395 if (el->el_flags & UNBUFFERED)
396 term__flush(el);
400 read_finish(EditLine *el)
402 if ((el->el_flags & UNBUFFERED) == 0)
403 (void) tty_cookedmode(el);
404 if (el->el_flags & HANDLE_SIGNALS)
405 sig_clr(el);
409 el_gets(EditLine *el, int *nread)
418 c_macro_t *ma = &el->el_chared.c_macro;
425 if (el->el_flags & NO_TTY) {
426 char *cp = el->el_line.buffer;
429 while ((num = (*el->el_read.read_char)(el, cp)) == 1) {
431 if (cp + 1 >= el->el_line.limit) {
432 idx = (cp - el->el_line.buffer);
433 if (!ch_enlargebufs(el, 2))
435 cp = &el->el_line.buffer[idx];
438 if (el->el_flags & UNBUFFERED)
444 el->el_errno = errno;
446 el->el_line.cursor = el->el_line.lastchar = cp;
448 *nread = (int)(el->el_line.cursor - el->el_line.buffer);
454 if (el->el_tty.t_mode == EX_IO && ma->level < 0) {
457 (void) ioctl(el->el_infd, FIONREAD, (ioctl_t) & chrs);
459 if (tty_rawmode(el) < 0) {
468 if ((el->el_flags & UNBUFFERED) == 0)
469 read_prepare(el);
471 if (el->el_flags & EDIT_DISABLED) {
475 if ((el->el_flags & UNBUFFERED) == 0)
476 cp = el->el_line.buffer;
478 cp = el->el_line.lastchar;
480 term__flush(el);
482 while ((num = (*el->el_read.read_char)(el, cp)) == 1) {
484 if (cp + 1 >= el->el_line.limit) {
485 idx = (cp - el->el_line.buffer);
486 if (!ch_enlargebufs(el, 2))
488 cp = &el->el_line.buffer[idx];
492 if (el->el_flags & UNBUFFERED)
499 el->el_errno = errno;
502 el->el_line.cursor = el->el_line.lastchar = cp;
510 read_debug(el);
513 if ((num = read_getcmd(el, &cmdnum, &ch)) != OKCMD) {
515 (void) fprintf(el->el_errfile,
520 if ((unsigned int)cmdnum >= (unsigned int)el->el_map.nfunc) { /* BUG CHECK command */
522 (void) fprintf(el->el_errfile,
531 for (b = el->el_map.help; b->name; b++)
535 (void) fprintf(el->el_errfile,
538 (void) fprintf(el->el_errfile,
543 el->el_state.thiscmd = cmdnum;
544 el->el_state.thisch = ch;
545 if (el->el_map.type == MAP_VI &&
546 el->el_map.current == el->el_map.key &&
547 el->el_chared.c_redo.pos < el->el_chared.c_redo.lim) {
549 el->el_chared.c_redo.pos != el->el_chared.c_redo.buf
550 && isprint((unsigned char)el->el_chared.c_redo.pos[-1]))
551 el->el_chared.c_redo.pos--;
553 *el->el_chared.c_redo.pos++ = ch;
555 retval = (*el->el_map.func[cmdnum]) (el, ch);
557 (void) fprintf(el->el_errfile,
562 el->el_state.lastcmd = cmdnum;
567 re_refresh_cursor(el);
571 re_clear_lines(el);
572 re_clear_display(el);
576 re_refresh(el);
580 re_refresh(el);
581 term_beep(el);
592 if ((el->el_flags & UNBUFFERED) == 0)
595 *el->el_line.lastchar++ = CONTROL('d');
596 el->el_line.cursor = el->el_line.lastchar;
602 num = (int)(el->el_line.lastchar - el->el_line.buffer);
607 (void) fprintf(el->el_errfile,
611 re_clear_display(el); /* reset the display stuff */
612 ch_reset(el, 1); /* reset the input pointers */
613 re_refresh(el); /* print the prompt again */
619 (void) fprintf(el->el_errfile,
622 term_beep(el);
623 term__flush(el);
626 el->el_state.argument = 1;
627 el->el_state.doingarg = 0;
628 el->el_chared.c_vcmd.action = NOP;
629 if (el->el_flags & UNBUFFERED)
633 term__flush(el); /* flush any buffered output */
635 if ((el->el_flags & UNBUFFERED) == 0) {
636 read_finish(el);
639 *nread = (int)(el->el_line.lastchar - el->el_line.buffer);
645 errno = el->el_errno;
649 return el->el_line.buffer;