Lines Matching +full:high +full:- +full:current

3 /*-
64 c_undo_t *vu = &el->el_chared.c_undo; in cv_undo()
65 c_redo_t *r = &el->el_chared.c_redo; in cv_undo()
69 size = (size_t)(el->el_line.lastchar - el->el_line.buffer); in cv_undo()
70 vu->len = (ssize_t)size; in cv_undo()
71 vu->cursor = (int)(el->el_line.cursor - el->el_line.buffer); in cv_undo()
72 (void)memcpy(vu->buf, el->el_line.buffer, size * sizeof(*vu->buf)); in cv_undo()
75 r->count = el->el_state.doingarg ? el->el_state.argument : 0; in cv_undo()
76 r->action = el->el_chared.c_vcmd.action; in cv_undo()
77 r->pos = r->buf; in cv_undo()
78 r->cmd = el->el_state.thiscmd; in cv_undo()
79 r->ch = el->el_state.thisch; in cv_undo()
88 c_kill_t *k = &el->el_chared.c_kill; in cv_yank()
90 (void)memcpy(k->buf, ptr, (size_t)size * sizeof(*k->buf)); in cv_yank()
91 k->last = k->buf + size; in cv_yank()
103 if (el->el_line.lastchar + num >= el->el_line.limit) { in c_insert()
108 if (el->el_line.cursor < el->el_line.lastchar) { in c_insert()
110 for (cp = el->el_line.lastchar; cp >= el->el_line.cursor; cp--) in c_insert()
113 el->el_line.lastchar += num; in c_insert()
124 if (el->el_line.cursor + num > el->el_line.lastchar) in c_delafter()
125 num = (int)(el->el_line.lastchar - el->el_line.cursor); in c_delafter()
127 if (el->el_map.current != el->el_map.emacs) { in c_delafter()
129 cv_yank(el, el->el_line.cursor, num); in c_delafter()
135 for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++) in c_delafter()
138 el->el_line.lastchar -= num; in c_delafter()
151 for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++) in c_delafter1()
154 el->el_line.lastchar--; in c_delafter1()
165 if (el->el_line.cursor - num < el->el_line.buffer) in c_delbefore()
166 num = (int)(el->el_line.cursor - el->el_line.buffer); in c_delbefore()
168 if (el->el_map.current != el->el_map.emacs) { in c_delbefore()
170 cv_yank(el, el->el_line.cursor - num, num); in c_delbefore()
176 for (cp = el->el_line.cursor - num; in c_delbefore()
177 &cp[num] <= el->el_line.lastchar; in c_delbefore()
181 el->el_line.lastchar -= num; in c_delbefore()
194 for (cp = el->el_line.cursor - 1; cp <= el->el_line.lastchar; cp++) in c_delbefore1()
197 el->el_line.lastchar--; in c_delbefore1()
207 return iswalnum(p) || wcschr(L"*?_-.[]~=", p) != NULL; in ce__isword()
241 p--; in c__prev_word()
243 while (n--) { in c__prev_word()
245 p--; in c__prev_word()
247 p--; in c__prev_word()
263 c__next_word(wchar_t *p, wchar_t *high, int n, int (*wtest)(wint_t)) in c__next_word() argument
265 while (n--) { in c__next_word()
266 while ((p < high) && !(*wtest)(*p)) in c__next_word()
268 while ((p < high) && (*wtest)(*p)) in c__next_word()
271 if (p > high) in c__next_word()
272 p = high; in c__next_word()
281 cv_next_word(EditLine *el, wchar_t *p, wchar_t *high, int n, in cv_next_word() argument
286 while (n--) { in cv_next_word()
288 while ((p < high) && (*wtest)(*p) == test) in cv_next_word()
294 if (n || el->el_chared.c_vcmd.action != (DELETE|INSERT)) in cv_next_word()
295 while ((p < high) && iswspace(*p)) in cv_next_word()
300 if (p > high) in cv_next_word()
301 return high; in cv_next_word()
315 p--; in cv_prev_word()
316 while (n--) { in cv_prev_word()
318 p--; in cv_prev_word()
321 p--; in cv_prev_word()
340 int action = el->el_chared.c_vcmd.action; in cv_delfini()
343 el->el_map.current = el->el_map.key; in cv_delfini()
345 if (el->el_chared.c_vcmd.pos == 0) in cv_delfini()
349 size = (int)(el->el_line.cursor - el->el_chared.c_vcmd.pos); in cv_delfini()
352 el->el_line.cursor = el->el_chared.c_vcmd.pos; in cv_delfini()
355 cv_yank(el, el->el_line.cursor, size); in cv_delfini()
357 cv_yank(el, el->el_line.cursor + size, -size); in cv_delfini()
363 c_delbefore(el, -size); in cv_delfini()
364 el->el_line.cursor += size; in cv_delfini()
367 el->el_chared.c_vcmd.action = NOP; in cv_delfini()
375 cv__endword(wchar_t *p, wchar_t *high, int n, int (*wtest)(wint_t)) in cv__endword() argument
381 while (n--) { in cv__endword()
382 while ((p < high) && iswspace(*p)) in cv__endword()
386 while ((p < high) && (*wtest)(*p) == test) in cv__endword()
389 p--; in cv__endword()
399 el->el_line.buffer = el_calloc(EL_BUFSIZ, in ch_init()
400 sizeof(*el->el_line.buffer)); in ch_init()
401 if (el->el_line.buffer == NULL) in ch_init()
402 return -1; 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_calloc(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()
411 return -1; in ch_init()
412 el->el_chared.c_undo.len = -1; in ch_init()
413 el->el_chared.c_undo.cursor = 0; in ch_init()
414 el->el_chared.c_redo.buf = el_calloc(EL_BUFSIZ, in ch_init()
415 sizeof(*el->el_chared.c_redo.buf)); in ch_init()
416 if (el->el_chared.c_redo.buf == NULL) in ch_init()
418 el->el_chared.c_redo.pos = el->el_chared.c_redo.buf; in ch_init()
419 el->el_chared.c_redo.lim = el->el_chared.c_redo.buf + EL_BUFSIZ; in ch_init()
420 el->el_chared.c_redo.cmd = ED_UNASSIGNED; in ch_init()
422 el->el_chared.c_vcmd.action = NOP; in ch_init()
423 el->el_chared.c_vcmd.pos = el->el_line.buffer; in ch_init()
425 el->el_chared.c_kill.buf = el_calloc(EL_BUFSIZ, in ch_init()
426 sizeof(*el->el_chared.c_kill.buf)); in ch_init()
427 if (el->el_chared.c_kill.buf == NULL) in ch_init()
429 el->el_chared.c_kill.mark = el->el_line.buffer; in ch_init()
430 el->el_chared.c_kill.last = el->el_chared.c_kill.buf; in ch_init()
431 el->el_chared.c_resizefun = NULL; in ch_init()
432 el->el_chared.c_resizearg = NULL; in ch_init()
433 el->el_chared.c_aliasfun = NULL; in ch_init()
434 el->el_chared.c_aliasarg = NULL; in ch_init()
436 el->el_map.current = el->el_map.key; in ch_init()
438 el->el_state.inputmode = MODE_INSERT; /* XXX: save a default */ in ch_init()
439 el->el_state.doingarg = 0; in ch_init()
440 el->el_state.metanext = 0; in ch_init()
441 el->el_state.argument = 1; in ch_init()
442 el->el_state.lastcmd = ED_UNASSIGNED; in ch_init()
447 return -1; in ch_init()
456 el->el_line.cursor = el->el_line.buffer; in ch_reset()
457 el->el_line.lastchar = el->el_line.buffer; in ch_reset()
459 el->el_chared.c_undo.len = -1; in ch_reset()
460 el->el_chared.c_undo.cursor = 0; in ch_reset()
462 el->el_chared.c_vcmd.action = NOP; in ch_reset()
463 el->el_chared.c_vcmd.pos = el->el_line.buffer; in ch_reset()
465 el->el_chared.c_kill.mark = el->el_line.buffer; in ch_reset()
467 el->el_map.current = el->el_map.key; in ch_reset()
469 el->el_state.inputmode = MODE_INSERT; /* XXX: save a default */ in ch_reset()
470 el->el_state.doingarg = 0; in ch_reset()
471 el->el_state.metanext = 0; in ch_reset()
472 el->el_state.argument = 1; in ch_reset()
473 el->el_state.lastcmd = ED_UNASSIGNED; in ch_reset()
475 el->el_history.eventno = 0; in ch_reset()
488 sz = (size_t)(el->el_line.limit - el->el_line.buffer + EL_LEAVE); in ch_enlargebufs()
491 * If newly required length is longer than current buffer, we need in ch_enlargebufs()
495 while(newsz - sz < addlen) in ch_enlargebufs()
502 newbuffer = el_realloc(el->el_line.buffer, newsz * sizeof(*newbuffer)); in ch_enlargebufs()
507 (void) memset(&newbuffer[sz], 0, (newsz - sz) * sizeof(*newbuffer)); in ch_enlargebufs()
509 oldbuf = el->el_line.buffer; in ch_enlargebufs()
511 el->el_line.buffer = newbuffer; in ch_enlargebufs()
512 el->el_line.cursor = newbuffer + (el->el_line.cursor - oldbuf); in ch_enlargebufs()
513 el->el_line.lastchar = newbuffer + (el->el_line.lastchar - oldbuf); in ch_enlargebufs()
515 el->el_line.limit = &newbuffer[sz - EL_LEAVE]; in ch_enlargebufs()
520 newbuffer = el_realloc(el->el_chared.c_kill.buf, newsz * in ch_enlargebufs()
526 (void) memset(&newbuffer[sz], 0, (newsz - sz) * sizeof(*newbuffer)); in ch_enlargebufs()
528 oldkbuf = el->el_chared.c_kill.buf; in ch_enlargebufs()
530 el->el_chared.c_kill.buf = newbuffer; in ch_enlargebufs()
531 el->el_chared.c_kill.last = newbuffer + in ch_enlargebufs()
532 (el->el_chared.c_kill.last - oldkbuf); in ch_enlargebufs()
533 el->el_chared.c_kill.mark = el->el_line.buffer + in ch_enlargebufs()
534 (el->el_chared.c_kill.mark - oldbuf); in ch_enlargebufs()
539 newbuffer = el_realloc(el->el_chared.c_undo.buf, in ch_enlargebufs()
545 (void) memset(&newbuffer[sz], 0, (newsz - sz) * sizeof(*newbuffer)); in ch_enlargebufs()
546 el->el_chared.c_undo.buf = newbuffer; in ch_enlargebufs()
548 newbuffer = el_realloc(el->el_chared.c_redo.buf, in ch_enlargebufs()
552 el->el_chared.c_redo.pos = newbuffer + in ch_enlargebufs()
553 (el->el_chared.c_redo.pos - el->el_chared.c_redo.buf); in ch_enlargebufs()
554 el->el_chared.c_redo.lim = newbuffer + in ch_enlargebufs()
555 (el->el_chared.c_redo.lim - el->el_chared.c_redo.buf); in ch_enlargebufs()
556 el->el_chared.c_redo.buf = newbuffer; in ch_enlargebufs()
562 el->el_line.limit = &el->el_line.buffer[newsz - EL_LEAVE]; in ch_enlargebufs()
563 if (el->el_chared.c_resizefun) in ch_enlargebufs()
564 (*el->el_chared.c_resizefun)(el, el->el_chared.c_resizearg); in ch_enlargebufs()
574 el_free(el->el_line.buffer); in ch_end()
575 el->el_line.buffer = NULL; in ch_end()
576 el->el_line.limit = NULL; in ch_end()
577 el_free(el->el_chared.c_undo.buf); in ch_end()
578 el->el_chared.c_undo.buf = NULL; in ch_end()
579 el_free(el->el_chared.c_redo.buf); in ch_end()
580 el->el_chared.c_redo.buf = NULL; in ch_end()
581 el->el_chared.c_redo.pos = NULL; in ch_end()
582 el->el_chared.c_redo.lim = NULL; in ch_end()
583 el->el_chared.c_redo.cmd = ED_UNASSIGNED; in ch_end()
584 el_free(el->el_chared.c_kill.buf); in ch_end()
585 el->el_chared.c_kill.buf = NULL; in ch_end()
599 return -1; in el_winsertstr()
600 if (el->el_line.lastchar + len >= el->el_line.limit) { in el_winsertstr()
602 return -1; in el_winsertstr()
607 *el->el_line.cursor++ = *s++; in el_winsertstr()
621 if (el->el_line.cursor < &el->el_line.buffer[n]) in el_deletestr()
625 el->el_line.cursor -= n; in el_deletestr()
626 if (el->el_line.cursor < el->el_line.buffer) in el_deletestr()
627 el->el_line.cursor = el->el_line.buffer; in el_deletestr()
642 line_length = (size_t)(el->el_line.lastchar - el->el_line.buffer); in el_deletestr1()
647 len = (size_t)(end - start); in el_deletestr1()
648 if (len > line_length - (size_t)end) in el_deletestr1()
649 len = line_length - (size_t)end; in el_deletestr1()
651 p1 = el->el_line.buffer + start; in el_deletestr1()
652 p2 = el->el_line.buffer + end; in el_deletestr1()
655 el->el_line.lastchar--; in el_deletestr1()
658 if (el->el_line.cursor < el->el_line.buffer) in el_deletestr1()
659 el->el_line.cursor = el->el_line.buffer; in el_deletestr1()
661 return end - start; in el_deletestr1()
674 return -1; in el_wreplacestr()
676 if (el->el_line.buffer + len >= el->el_line.limit) { in el_wreplacestr()
678 return -1; in el_wreplacestr()
681 p = el->el_line.buffer; in el_wreplacestr()
685 el->el_line.buffer[len] = '\0'; in el_wreplacestr()
686 el->el_line.lastchar = el->el_line.buffer + len; in el_wreplacestr()
687 if (el->el_line.cursor > el->el_line.lastchar) in el_wreplacestr()
688 el->el_line.cursor = el->el_line.lastchar; in el_wreplacestr()
694 * Move the cursor to the left or the right of the current position
702 el->el_line.cursor += n; in el_cursor()
704 if (el->el_line.cursor < el->el_line.buffer) in el_cursor()
705 el->el_line.cursor = el->el_line.buffer; in el_cursor()
706 if (el->el_line.cursor > el->el_line.lastchar) in el_cursor()
707 el->el_line.cursor = el->el_line.lastchar; in el_cursor()
709 return (int)(el->el_line.cursor - el->el_line.buffer); in el_cursor()
719 wchar_t *cp = el->el_line.buffer, ch; in c_gets()
729 el->el_line.cursor = cp; in c_gets()
731 el->el_line.lastchar = cp + 1; in c_gets()
736 len = -1; in c_gets()
745 len = -1; in c_gets()
748 len--; in c_gets()
749 cp--; in c_gets()
759 if (len >= (ssize_t)(EL_BUFSIZ - 16)) in c_gets()
770 el->el_line.buffer[0] = '\0'; in c_gets()
771 el->el_line.lastchar = el->el_line.buffer; in c_gets()
772 el->el_line.cursor = el->el_line.buffer; in c_gets()
778 * Return the current horizontal position of the cursor
788 if (el->el_line.cursor == el->el_line.buffer) in c_hpos()
791 for (ptr = el->el_line.cursor - 1; in c_hpos()
792 ptr >= el->el_line.buffer && *ptr != '\n'; in c_hpos()
793 ptr--) in c_hpos()
795 return (int)(el->el_line.cursor - ptr - 1); in c_hpos()
802 el->el_chared.c_resizefun = f; in ch_resizefun()
803 el->el_chared.c_resizearg = a; in ch_resizefun()
810 el->el_chared.c_aliasfun = f; in ch_aliasfun()
811 el->el_chared.c_aliasarg = a; in ch_aliasfun()