diff options
Diffstat (limited to 'cmd-line-utils/libedit/refresh.c')
-rw-r--r-- | cmd-line-utils/libedit/refresh.c | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/cmd-line-utils/libedit/refresh.c b/cmd-line-utils/libedit/refresh.c index 534e7e12304..e71bdba2b61 100644 --- a/cmd-line-utils/libedit/refresh.c +++ b/cmd-line-utils/libedit/refresh.c @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.17 2001/04/13 00:53:11 lukem Exp $ */ +/* $NetBSD: refresh.c,v 1.24 2003/03/10 21:18:49 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -36,12 +36,18 @@ * SUCH DAMAGE. */ -#include "compat.h" +#include "config.h" +#if !defined(lint) && !defined(SCCSID) +#if 0 +static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93"; +#else +__RCSID("$NetBSD: refresh.c,v 1.24 2003/03/10 21:18:49 christos Exp $"); +#endif +#endif /* not lint && not SCCSID */ /* * refresh.c: Lower level screen refreshing functions */ -#include "sys.h" #include <stdio.h> #include <ctype.h> #include <unistd.h> @@ -51,28 +57,28 @@ private void re_addc(EditLine *, int); private void re_update_line(EditLine *, char *, char *, int); -private void re_insert (EditLine *, char *, int, int, char *, int); -private void re_delete(EditLine *, char *, int, int, int); +private void re_insert (EditLine *el, char *, int, int, char *, int); +private void re_delete(EditLine *el, char *, int, int, int); private void re_fastputc(EditLine *, int); private void re__strncopy(char *, char *, size_t); private void re__copy_and_pad(char *, const char *, size_t); #ifdef DEBUG_REFRESH -private void re_printstr(EditLine *, char *, char *, char *); +private void re_printstr(EditLine *, const char *, char *, char *); #define __F el->el_errfile #define ELRE_ASSERT(a, b, c) do \ - if (a) { \ + if (/*CONSTCOND*/ a) { \ (void) fprintf b; \ c; \ } \ - while (0) + while (/*CONSTCOND*/0) #define ELRE_DEBUG(a, b) ELRE_ASSERT(a,b,;) /* re_printstr(): * Print a string on the debugging pty */ private void -re_printstr(EditLine *el, char *str, char *f, char *t) +re_printstr(EditLine *el, const char *str, char *f, char *t) { ELRE_DEBUG(1, (__F, "%s:\"", str)); @@ -203,6 +209,14 @@ re_refresh(EditLine *el) el->el_refresh.r_cursor.h = 0; el->el_refresh.r_cursor.v = 0; + if (el->el_line.cursor >= el->el_line.lastchar) { + if (el->el_map.current == el->el_map.alt + && el->el_line.lastchar != el->el_line.buffer) + el->el_line.cursor = el->el_line.lastchar - 1; + else + el->el_line.cursor = el->el_line.lastchar; + } + cur.h = -1; /* set flag in case I'm not set */ cur.v = 0; @@ -312,7 +326,6 @@ re_goto_bottom(EditLine *el) { term_move_to_line(el, el->el_refresh.r_oldcv); - term__putc('\r'); term__putc('\n'); re_clear_display(el); term__flush(); @@ -325,7 +338,7 @@ re_goto_bottom(EditLine *el) */ private void /*ARGSUSED*/ -re_insert(EditLine *el __attribute__((unused)), +re_insert(EditLine *el __attribute__((unused)), char *d, int dat, int dlen, char *s, int num) { char *a, *b; @@ -369,7 +382,7 @@ re_insert(EditLine *el __attribute__((unused)), */ private void /*ARGSUSED*/ -re_delete(EditLine *el __attribute__((unused)), +re_delete(EditLine *el __attribute__((unused)), char *d, int dat, int dlen, int num) { char *a, *b; @@ -905,7 +918,7 @@ re_update_line(EditLine *el, char *old, char *new, int i) private void re__copy_and_pad(char *dst, const char *src, size_t width) { - unsigned int i; + size_t i; for (i = 0; i < width; i++) { if (*src == '\0') @@ -929,6 +942,14 @@ re_refresh_cursor(EditLine *el) char *cp, c; int h, v, th; + if (el->el_line.cursor >= el->el_line.lastchar) { + if (el->el_map.current == el->el_map.alt + && el->el_line.lastchar != el->el_line.buffer) + el->el_line.cursor = el->el_line.lastchar - 1; + else + el->el_line.cursor = el->el_line.lastchar; + } + /* first we must find where the cursor is... */ h = el->el_prompt.p_pos.h; v = el->el_prompt.p_pos.v; @@ -1051,8 +1072,8 @@ re_fastaddc(EditLine *el) re_fastputc(el, c); } else { re_fastputc(el, '\\'); - re_fastputc(el, (int) ((((unsigned int) c >> 6) & 7) + '0')); - re_fastputc(el, (int) ((((unsigned int) c >> 3) & 7) + '0')); + re_fastputc(el, (int)(((((unsigned int)c) >> 6) & 3) + '0')); + re_fastputc(el, (int)(((((unsigned int)c) >> 3) & 7) + '0')); re_fastputc(el, (c & 7) + '0'); } term__flush(); |