Lines Matching refs:el
59 cv_undo(EditLine *el) in cv_undo() argument
61 c_undo_t *vu = &el->el_chared.c_undo; in cv_undo()
62 c_redo_t *r = &el->el_chared.c_redo; in cv_undo()
66 size = (size_t)(el->el_line.lastchar - el->el_line.buffer); in cv_undo()
68 vu->cursor = (int)(el->el_line.cursor - el->el_line.buffer); in cv_undo()
69 (void)memcpy(vu->buf, el->el_line.buffer, size * sizeof(*vu->buf)); in cv_undo()
72 r->count = el->el_state.doingarg ? el->el_state.argument : 0; in cv_undo()
73 r->action = el->el_chared.c_vcmd.action; in cv_undo()
75 r->cmd = el->el_state.thiscmd; in cv_undo()
76 r->ch = el->el_state.thisch; in cv_undo()
83 cv_yank(EditLine *el, const Char *ptr, int size) in cv_yank() argument
85 c_kill_t *k = &el->el_chared.c_kill; in cv_yank()
96 c_insert(EditLine *el, int num) in c_insert() argument
100 if (el->el_line.lastchar + num >= el->el_line.limit) { in c_insert()
101 if (!ch_enlargebufs(el, (size_t)num)) in c_insert()
105 if (el->el_line.cursor < el->el_line.lastchar) { in c_insert()
107 for (cp = el->el_line.lastchar; cp >= el->el_line.cursor; cp--) in c_insert()
110 el->el_line.lastchar += num; in c_insert()
118 c_delafter(EditLine *el, int num) in c_delafter() argument
121 if (el->el_line.cursor + num > el->el_line.lastchar) in c_delafter()
122 num = (int)(el->el_line.lastchar - el->el_line.cursor); in c_delafter()
124 if (el->el_map.current != el->el_map.emacs) { in c_delafter()
125 cv_undo(el); in c_delafter()
126 cv_yank(el, el->el_line.cursor, num); in c_delafter()
132 for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++) in c_delafter()
135 el->el_line.lastchar -= num; in c_delafter()
144 c_delafter1(EditLine *el) in c_delafter1() argument
148 for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++) in c_delafter1()
151 el->el_line.lastchar--; in c_delafter1()
159 c_delbefore(EditLine *el, int num) in c_delbefore() argument
162 if (el->el_line.cursor - num < el->el_line.buffer) in c_delbefore()
163 num = (int)(el->el_line.cursor - el->el_line.buffer); in c_delbefore()
165 if (el->el_map.current != el->el_map.emacs) { in c_delbefore()
166 cv_undo(el); in c_delbefore()
167 cv_yank(el, el->el_line.cursor - num, num); in c_delbefore()
173 for (cp = el->el_line.cursor - num; in c_delbefore()
174 cp <= el->el_line.lastchar; in c_delbefore()
178 el->el_line.lastchar -= num; in c_delbefore()
187 c_delbefore1(EditLine *el) in c_delbefore1() argument
191 for (cp = el->el_line.cursor - 1; cp <= el->el_line.lastchar; cp++) in c_delbefore1()
194 el->el_line.lastchar--; in c_delbefore1()
278 cv_next_word(EditLine *el, Char *p, Char *high, int n, int (*wtest)(Int)) in cv_next_word() argument
290 if (n || el->el_chared.c_vcmd.action != (DELETE|INSERT)) in cv_next_word()
333 cv_delfini(EditLine *el) in cv_delfini() argument
336 int action = el->el_chared.c_vcmd.action; in cv_delfini()
339 el->el_map.current = el->el_map.key; in cv_delfini()
341 if (el->el_chared.c_vcmd.pos == 0) in cv_delfini()
345 size = (int)(el->el_line.cursor - el->el_chared.c_vcmd.pos); in cv_delfini()
348 el->el_line.cursor = el->el_chared.c_vcmd.pos; in cv_delfini()
351 cv_yank(el, el->el_line.cursor, size); in cv_delfini()
353 cv_yank(el, el->el_line.cursor + size, -size); in cv_delfini()
356 c_delafter(el, size); in cv_delfini()
357 re_refresh_cursor(el); in cv_delfini()
359 c_delbefore(el, -size); in cv_delfini()
360 el->el_line.cursor += size; in cv_delfini()
363 el->el_chared.c_vcmd.action = NOP; in cv_delfini()
393 ch_init(EditLine *el) in ch_init() argument
395 c_macro_t *ma = &el->el_chared.c_macro; in ch_init()
397 el->el_line.buffer = el_malloc(EL_BUFSIZ * in ch_init()
398 sizeof(*el->el_line.buffer)); in ch_init()
399 if (el->el_line.buffer == NULL) in ch_init()
402 (void) memset(el->el_line.buffer, 0, EL_BUFSIZ * in ch_init()
403 sizeof(*el->el_line.buffer)); in ch_init()
404 el->el_line.cursor = el->el_line.buffer; in ch_init()
405 el->el_line.lastchar = el->el_line.buffer; in ch_init()
406 el->el_line.limit = &el->el_line.buffer[EL_BUFSIZ - EL_LEAVE]; in ch_init()
408 el->el_chared.c_undo.buf = el_malloc(EL_BUFSIZ * in ch_init()
409 sizeof(*el->el_chared.c_undo.buf)); in ch_init()
410 if (el->el_chared.c_undo.buf == NULL) in ch_init()
412 (void) memset(el->el_chared.c_undo.buf, 0, EL_BUFSIZ * in ch_init()
413 sizeof(*el->el_chared.c_undo.buf)); in ch_init()
414 el->el_chared.c_undo.len = -1; in ch_init()
415 el->el_chared.c_undo.cursor = 0; in ch_init()
416 el->el_chared.c_redo.buf = el_malloc(EL_BUFSIZ * in ch_init()
417 sizeof(*el->el_chared.c_redo.buf)); in ch_init()
418 if (el->el_chared.c_redo.buf == NULL) in ch_init()
420 el->el_chared.c_redo.pos = el->el_chared.c_redo.buf; in ch_init()
421 el->el_chared.c_redo.lim = el->el_chared.c_redo.buf + EL_BUFSIZ; in ch_init()
422 el->el_chared.c_redo.cmd = ED_UNASSIGNED; in ch_init()
424 el->el_chared.c_vcmd.action = NOP; in ch_init()
425 el->el_chared.c_vcmd.pos = el->el_line.buffer; in ch_init()
427 el->el_chared.c_kill.buf = el_malloc(EL_BUFSIZ * in ch_init()
428 sizeof(*el->el_chared.c_kill.buf)); in ch_init()
429 if (el->el_chared.c_kill.buf == NULL) in ch_init()
431 (void) memset(el->el_chared.c_kill.buf, 0, EL_BUFSIZ * in ch_init()
432 sizeof(*el->el_chared.c_kill.buf)); in ch_init()
433 el->el_chared.c_kill.mark = el->el_line.buffer; in ch_init()
434 el->el_chared.c_kill.last = el->el_chared.c_kill.buf; in ch_init()
435 el->el_chared.c_resizefun = NULL; in ch_init()
436 el->el_chared.c_resizearg = NULL; in ch_init()
438 el->el_map.current = el->el_map.key; in ch_init()
440 el->el_state.inputmode = MODE_INSERT; /* XXX: save a default */ in ch_init()
441 el->el_state.doingarg = 0; in ch_init()
442 el->el_state.metanext = 0; in ch_init()
443 el->el_state.argument = 1; in ch_init()
444 el->el_state.lastcmd = ED_UNASSIGNED; in ch_init()
458 ch_reset(EditLine *el, int mclear) in ch_reset() argument
460 el->el_line.cursor = el->el_line.buffer; in ch_reset()
461 el->el_line.lastchar = el->el_line.buffer; in ch_reset()
463 el->el_chared.c_undo.len = -1; in ch_reset()
464 el->el_chared.c_undo.cursor = 0; in ch_reset()
466 el->el_chared.c_vcmd.action = NOP; in ch_reset()
467 el->el_chared.c_vcmd.pos = el->el_line.buffer; in ch_reset()
469 el->el_chared.c_kill.mark = el->el_line.buffer; in ch_reset()
471 el->el_map.current = el->el_map.key; in ch_reset()
473 el->el_state.inputmode = MODE_INSERT; /* XXX: save a default */ in ch_reset()
474 el->el_state.doingarg = 0; in ch_reset()
475 el->el_state.metanext = 0; in ch_reset()
476 el->el_state.argument = 1; in ch_reset()
477 el->el_state.lastcmd = ED_UNASSIGNED; in ch_reset()
479 el->el_history.eventno = 0; in ch_reset()
482 ch__clearmacro(el); in ch_reset()
486 ch__clearmacro(EditLine *el) in ch__clearmacro() argument
488 c_macro_t *ma = &el->el_chared.c_macro; in ch__clearmacro()
498 ch_enlargebufs(EditLine *el, size_t addlen) in ch_enlargebufs() argument
503 sz = (size_t)(el->el_line.limit - el->el_line.buffer + EL_LEAVE); in ch_enlargebufs()
517 newbuffer = el_realloc(el->el_line.buffer, newsz * sizeof(*newbuffer)); in ch_enlargebufs()
524 oldbuf = el->el_line.buffer; in ch_enlargebufs()
526 el->el_line.buffer = newbuffer; in ch_enlargebufs()
527 el->el_line.cursor = newbuffer + (el->el_line.cursor - oldbuf); in ch_enlargebufs()
528 el->el_line.lastchar = newbuffer + (el->el_line.lastchar - oldbuf); in ch_enlargebufs()
530 el->el_line.limit = &newbuffer[sz - EL_LEAVE]; in ch_enlargebufs()
535 newbuffer = el_realloc(el->el_chared.c_kill.buf, newsz * in ch_enlargebufs()
543 oldkbuf = el->el_chared.c_kill.buf; in ch_enlargebufs()
545 el->el_chared.c_kill.buf = newbuffer; in ch_enlargebufs()
546 el->el_chared.c_kill.last = newbuffer + in ch_enlargebufs()
547 (el->el_chared.c_kill.last - oldkbuf); in ch_enlargebufs()
548 el->el_chared.c_kill.mark = el->el_line.buffer + in ch_enlargebufs()
549 (el->el_chared.c_kill.mark - oldbuf); in ch_enlargebufs()
554 newbuffer = el_realloc(el->el_chared.c_undo.buf, in ch_enlargebufs()
561 el->el_chared.c_undo.buf = newbuffer; in ch_enlargebufs()
563 newbuffer = el_realloc(el->el_chared.c_redo.buf, in ch_enlargebufs()
567 el->el_chared.c_redo.pos = newbuffer + in ch_enlargebufs()
568 (el->el_chared.c_redo.pos - el->el_chared.c_redo.buf); in ch_enlargebufs()
569 el->el_chared.c_redo.lim = newbuffer + in ch_enlargebufs()
570 (el->el_chared.c_redo.lim - el->el_chared.c_redo.buf); in ch_enlargebufs()
571 el->el_chared.c_redo.buf = newbuffer; in ch_enlargebufs()
573 if (!hist_enlargebuf(el, sz, newsz)) in ch_enlargebufs()
577 el->el_line.limit = &el->el_line.buffer[newsz - EL_LEAVE]; in ch_enlargebufs()
578 if (el->el_chared.c_resizefun) in ch_enlargebufs()
579 (*el->el_chared.c_resizefun)(el, el->el_chared.c_resizearg); in ch_enlargebufs()
587 ch_end(EditLine *el) in ch_end() argument
589 el_free(el->el_line.buffer); in ch_end()
590 el->el_line.buffer = NULL; in ch_end()
591 el->el_line.limit = NULL; in ch_end()
592 el_free(el->el_chared.c_undo.buf); in ch_end()
593 el->el_chared.c_undo.buf = NULL; in ch_end()
594 el_free(el->el_chared.c_redo.buf); in ch_end()
595 el->el_chared.c_redo.buf = NULL; in ch_end()
596 el->el_chared.c_redo.pos = NULL; in ch_end()
597 el->el_chared.c_redo.lim = NULL; in ch_end()
598 el->el_chared.c_redo.cmd = ED_UNASSIGNED; in ch_end()
599 el_free(el->el_chared.c_kill.buf); in ch_end()
600 el->el_chared.c_kill.buf = NULL; in ch_end()
601 ch_reset(el, 1); in ch_end()
602 el_free(el->el_chared.c_macro.macro); in ch_end()
603 el->el_chared.c_macro.macro = NULL; in ch_end()
611 FUN(el,insertstr)(EditLine *el, const Char *s) in FUN() argument
617 if (el->el_line.lastchar + len >= el->el_line.limit) { in FUN()
618 if (!ch_enlargebufs(el, len)) in FUN()
622 c_insert(el, (int)len); in FUN()
624 *el->el_line.cursor++ = *s++; in FUN()
633 el_deletestr(EditLine *el, int n) in el_deletestr() argument
638 if (el->el_line.cursor < &el->el_line.buffer[n]) in el_deletestr()
641 c_delbefore(el, n); /* delete before dot */ in el_deletestr()
642 el->el_line.cursor -= n; in el_deletestr()
643 if (el->el_line.cursor < el->el_line.buffer) in el_deletestr()
644 el->el_line.cursor = el->el_line.buffer; in el_deletestr()
651 el_cursor(EditLine *el, int n) in el_cursor() argument
656 el->el_line.cursor += n; in el_cursor()
658 if (el->el_line.cursor < el->el_line.buffer) in el_cursor()
659 el->el_line.cursor = el->el_line.buffer; in el_cursor()
660 if (el->el_line.cursor > el->el_line.lastchar) in el_cursor()
661 el->el_line.cursor = el->el_line.lastchar; in el_cursor()
663 return el->el_line.cursor - el->el_line.buffer; in el_cursor()
670 c_gets(EditLine *el, Char *buf, const Char *prompt) in c_gets() argument
674 Char *cp = el->el_line.buffer; in c_gets()
684 el->el_line.cursor = cp; in c_gets()
686 el->el_line.lastchar = cp + 1; in c_gets()
687 re_refresh(el); in c_gets()
689 if (FUN(el,getc)(el, &ch) != 1) { in c_gets()
690 ed_end_of_file(el, 0); in c_gets()
714 terminal_beep(el); in c_gets()
724 el->el_line.buffer[0] = '\0'; in c_gets()
725 el->el_line.lastchar = el->el_line.buffer; in c_gets()
726 el->el_line.cursor = el->el_line.buffer; in c_gets()
735 c_hpos(EditLine *el) in c_hpos() argument
742 if (el->el_line.cursor == el->el_line.buffer) in c_hpos()
745 for (ptr = el->el_line.cursor - 1; in c_hpos()
746 ptr >= el->el_line.buffer && *ptr != '\n'; in c_hpos()
749 return (int)(el->el_line.cursor - ptr - 1); in c_hpos()
754 ch_resizefun(EditLine *el, el_zfunc_t f, void *a) in ch_resizefun() argument
756 el->el_chared.c_resizefun = f; in ch_resizefun()
757 el->el_chared.c_resizearg = a; in ch_resizefun()