diff options
Diffstat (limited to 'lib/libedit/refresh.c')
-rw-r--r-- | lib/libedit/refresh.c | 70 |
1 files changed, 36 insertions, 34 deletions
diff --git a/lib/libedit/refresh.c b/lib/libedit/refresh.c index cd516f6..8f4b08e 100644 --- a/lib/libedit/refresh.c +++ b/lib/libedit/refresh.c @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.c,v 1.37 2011/07/29 23:44:45 christos Exp $ */ +/* $NetBSD: refresh.c,v 1.45 2016/03/02 19:24:20 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: refresh.c,v 1.37 2011/07/29 23:44:45 christos Exp $"); +__RCSID("$NetBSD: refresh.c,v 1.45 2016/03/02 19:24:20 christos Exp $"); #endif #endif /* not lint && not SCCSID */ #include <sys/cdefs.h> @@ -47,26 +47,25 @@ __FBSDID("$FreeBSD$"); * refresh.c: Lower level screen refreshing functions */ #include <stdio.h> -#include <ctype.h> -#include <unistd.h> #include <string.h> +#include <unistd.h> #include "el.h" private void re_nextline(EditLine *); -private void re_addc(EditLine *, Int); +private void re_addc(EditLine *, wint_t); 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_fastputc(EditLine *, Int); +private void re_fastputc(EditLine *, wint_t); private void re_clear_eol(EditLine *, int, int, 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 *, const char *, char *, char *); +private void re_printstr(EditLine *, const char *, Char *, Char *); #define __F el->el_errfile -#define ELRE_ASSERT(a, b, c) do \ +#define ELRE_ASSERT(a, b, c) do \ if (/*CONSTCOND*/ a) { \ (void) fprintf b; \ c; \ @@ -78,7 +77,7 @@ private void re_printstr(EditLine *, const char *, char *, char *); * Print a string on the debugging pty */ private void -re_printstr(EditLine *el, const char *str, char *f, char *t) +re_printstr(EditLine *el, const char *str, Char *f, Char *t) { ELRE_DEBUG(1, (__F, "%s:\"", str)); @@ -112,7 +111,7 @@ re_nextline(EditLine *el) for(i = 1; i < lins; i++) el->el_vdisplay[i - 1] = el->el_vdisplay[i]; - firstline[0] = '\0'; /* empty the string */ + firstline[0] = '\0'; /* empty the string */ el->el_vdisplay[i - 1] = firstline; } else el->el_refresh.r_cursor.v++; @@ -127,7 +126,7 @@ re_nextline(EditLine *el) * Draw c, expanding tabs, control chars etc. */ private void -re_addc(EditLine *el, Int c) +re_addc(EditLine *el, wint_t c) { switch (ct_chr_class((Char)c)) { case CHTYPE_TAB: /* expand the tab */ @@ -163,16 +162,16 @@ re_addc(EditLine *el, Int c) * Draw the character given */ protected void -re_putc(EditLine *el, Int c, int shift) +re_putc(EditLine *el, wint_t c, int shift) { int i, w = Width(c); - ELRE_DEBUG(1, (__F, "printing %5x '%c'\r\n", c, c)); + ELRE_DEBUG(1, (__F, "printing %5x '%lc'\r\n", c, c)); while (shift && (el->el_refresh.r_cursor.h + w > el->el_terminal.t_size.h)) re_putc(el, ' ', 1); el->el_vdisplay[el->el_refresh.r_cursor.v] - [el->el_refresh.r_cursor.h] = c; + [el->el_refresh.r_cursor.h] = (Char)c; /* assumes !shift is only used for single-column chars */ i = w; while (--i > 0) @@ -194,7 +193,7 @@ re_putc(EditLine *el, Int c, int shift) /* re_refresh(): * draws the new virtual screen image from the current input - * line, then goes line-by-line changing the real image to the new + * line, then goes line-by-line changing the real image to the new * virtual image. The routine to re-draw a line can be replaced * easily in hopes of a smarter one being placed there. */ @@ -208,7 +207,7 @@ re_refresh(EditLine *el) size_t termsz; #endif - ELRE_DEBUG(1, (__F, "el->el_line.buffer = :%s:\r\n", + ELRE_DEBUG(1, (__F, "el->el_line.buffer = :" FSTR ":\r\n", el->el_line.buffer)); /* reset the Drawing cursor */ @@ -296,7 +295,8 @@ re_refresh(EditLine *el) ELRE_DEBUG(1, (__F, "term.h=%d vcur.h=%d vcur.v=%d vdisplay[0]=\r\n:%80.80s:\r\n", el->el_terminal.t_size.h, el->el_refresh.r_cursor.h, - el->el_refresh.r_cursor.v, ct_encode_string(el->el_vdisplay[0]))); + el->el_refresh.r_cursor.v, ct_encode_string(el->el_vdisplay[0], + &el->el_scratch))); ELRE_DEBUG(1, (__F, "updating %d lines.\r\n", el->el_refresh.r_newcv)); for (i = 0; i <= el->el_refresh.r_newcv; i++) { @@ -324,7 +324,7 @@ re_refresh(EditLine *el) /* This Strlen should be safe even with MB_FILL_CHARs */ terminal_clear_EOL(el, (int) Strlen(el->el_display[i])); #ifdef DEBUG_REFRESH - terminal_overwrite(el, "C\b", (size_t)2); + terminal_overwrite(el, STR("C\b"), 2); #endif /* DEBUG_REFRESH */ el->el_display[i][0] = '\0'; } @@ -371,8 +371,9 @@ re_insert(EditLine *el __attribute__((__unused__)), ELRE_DEBUG(1, (__F, "re_insert() starting: %d at %d max %d, d == \"%s\"\n", - num, dat, dlen, ct_encode_string(d))); - ELRE_DEBUG(1, (__F, "s == \"%s\"\n", ct_encode_string(s))); + num, dat, dlen, ct_encode_string(d, &el->el_scratch))); + ELRE_DEBUG(1, (__F, "s == \"%s\"\n", ct_encode_string(s, + &el->el_scratch))); /* open up the space for num chars */ if (num > 0) { @@ -385,8 +386,9 @@ re_insert(EditLine *el __attribute__((__unused__)), ELRE_DEBUG(1, (__F, "re_insert() after insert: %d at %d max %d, d == \"%s\"\n", - num, dat, dlen, ct_encode_string(d))); - ELRE_DEBUG(1, (__F, "s == \"%s\"\n", ct_encode_string(s))); + num, dat, dlen, ct_encode_string(d, &el->el_scratch))); + ELRE_DEBUG(1, (__F, "s == \"%s\"\n", ct_encode_string(s, + &el->el_scratch))); /* copy the characters */ for (a = d + dat; (a < d + dlen) && (num > 0); num--) @@ -421,7 +423,7 @@ re_delete(EditLine *el __attribute__((__unused__)), } ELRE_DEBUG(1, (__F, "re_delete() starting: %d at %d max %d, d == \"%s\"\n", - num, dat, dlen, ct_encode_string(d))); + num, dat, dlen, ct_encode_string(d, &el->el_scratch))); /* open up the space for num chars */ if (num > 0) { @@ -433,7 +435,7 @@ re_delete(EditLine *el __attribute__((__unused__)), } ELRE_DEBUG(1, (__F, "re_delete() after delete: %d at %d max %d, d == \"%s\"\n", - num, dat, dlen, ct_encode_string(d))); + num, dat, dlen, ct_encode_string(d, &el->el_scratch))); } @@ -453,7 +455,7 @@ re__strncopy(Char *a, Char *b, size_t n) * in order to make sure that we have cleared the previous contents of * the line. fx and sx is the number of characters inserted or deleted * in the first or second diff, diff is the difference between the - * number of characters between the new and old line. + * number of characters between the new and old line. */ private void re_clear_eol(EditLine *el, int fx, int sx, int diff) @@ -691,9 +693,9 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) sx = (int)((nls - nse) - (ols - ose)); ELRE_DEBUG(1, (__F, "fx %d, sx %d\n", fx, sx)); - ELRE_DEBUG(1, (__F, "ofd %d, osb %d, ose %d, ols %d, oe %d\n", + ELRE_DEBUG(1, (__F, "ofd %td, osb %td, ose %td, ols %td, oe %td\n", ofd - old, osb - old, ose - old, ols - old, oe - old)); - ELRE_DEBUG(1, (__F, "nfd %d, nsb %d, nse %d, nls %d, ne %d\n", + ELRE_DEBUG(1, (__F, "nfd %td, nsb %td, nse %td, nls %td, ne %td\n", nfd - new, nsb - new, nse - new, nls - new, ne - new)); ELRE_DEBUG(1, (__F, "xxx-xxx:\"00000000001111111111222222222233333333334\"\r\n")); @@ -767,7 +769,7 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) if ((nsb != nfd) && fx > 0 && ((p - old) + fx <= el->el_terminal.t_size.h)) { ELRE_DEBUG(1, - (__F, "first diff insert at %d...\r\n", nfd - new)); + (__F, "first diff insert at %td...\r\n", nfd - new)); /* * Move to the first char to insert, where the first diff is. */ @@ -806,7 +808,7 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) } } else if (fx < 0) { ELRE_DEBUG(1, - (__F, "first diff delete at %d...\r\n", ofd - old)); + (__F, "first diff delete at %td...\r\n", ofd - old)); /* * move to the first char to delete where the first diff is */ @@ -853,7 +855,7 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) if (sx < 0 && (ose - old) + fx < el->el_terminal.t_size.h) { ELRE_DEBUG(1, (__F, - "second diff delete at %d...\r\n", (ose - old) + fx)); + "second diff delete at %td...\r\n", (ose - old) + fx)); /* * Check if we have stuff to delete */ @@ -891,7 +893,7 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) * if we have a first insert AND WE HAVEN'T ALREADY DONE IT... */ if ((nsb != nfd) && (osb - ofd) <= (nsb - nfd) && (fx == 0)) { - ELRE_DEBUG(1, (__F, "late first diff insert at %d...\r\n", + ELRE_DEBUG(1, (__F, "late first diff insert at %td...\r\n", nfd - new)); terminal_move_to_char(el, (int)(nfd - new)); @@ -1054,14 +1056,14 @@ re_refresh_cursor(EditLine *el) * Add a character fast. */ private void -re_fastputc(EditLine *el, Int c) +re_fastputc(EditLine *el, wint_t c) { int w = Width((Char)c); while (w > 1 && el->el_cursor.h + w > el->el_terminal.t_size.h) re_fastputc(el, ' '); terminal__putc(el, c); - el->el_display[el->el_cursor.v][el->el_cursor.h++] = c; + el->el_display[el->el_cursor.v][el->el_cursor.h++] = (Char)c; while (--w > 0) el->el_display[el->el_cursor.v][el->el_cursor.h++] = MB_FILL_CHAR; @@ -1079,7 +1081,7 @@ re_fastputc(EditLine *el, Int c) if (el->el_cursor.v + 1 >= el->el_terminal.t_size.v) { int i, lins = el->el_terminal.t_size.v; Char *firstline = el->el_display[0]; - + for(i = 1; i < lins; i++) el->el_display[i - 1] = el->el_display[i]; |