Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libedit - add literal sequence handling.
details: https://anonhg.NetBSD.org/src/rev/44caa818b73d
branches: trunk
changeset: 354747:44caa818b73d
user: christos <christos%NetBSD.org@localhost>
date: Tue Jun 27 23:23:48 2017 +0000
description:
- add literal sequence handling.
diffstat:
lib/libedit/refresh.c | 46 +++++++++++++++++++++++++++++++++++-----------
lib/libedit/refresh.h | 4 +++-
2 files changed, 38 insertions(+), 12 deletions(-)
diffs (118 lines):
diff -r 62288c46c6f5 -r 44caa818b73d lib/libedit/refresh.c
--- a/lib/libedit/refresh.c Tue Jun 27 23:23:09 2017 +0000
+++ b/lib/libedit/refresh.c Tue Jun 27 23:23:48 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: refresh.c,v 1.51 2016/05/09 21:46:56 christos Exp $ */
+/* $NetBSD: refresh.c,v 1.52 2017/06/27 23:23:48 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.51 2016/05/09 21:46:56 christos Exp $");
+__RCSID("$NetBSD: refresh.c,v 1.52 2017/06/27 23:23:48 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -155,6 +155,27 @@
}
}
+/* re_putc():
+ * Place the literal string given
+ */
+libedit_private void
+re_putliteral(EditLine *el, const wchar_t *begin, const wchar_t *end)
+{
+ coord_t *cur = &el->el_refresh.r_cursor;
+ wint_t c;
+ int sizeh = el->el_terminal.t_size.h;
+
+ c = literal_add(el, begin, end);
+ if (c == 0)
+ return;
+ el->el_vdisplay[cur->v][cur->h] = c;
+ cur->h += 1; /* XXX: only for narrow */
+ if (cur->h >= sizeh) {
+ /* assure end of line */
+ el->el_vdisplay[cur->v][sizeh] = '\0';
+ re_nextline(el);
+ }
+}
/* re_putc():
* Draw the character given
@@ -162,30 +183,30 @@
libedit_private void
re_putc(EditLine *el, wint_t c, int shift)
{
+ coord_t *cur = &el->el_refresh.r_cursor;
int i, w = wcwidth(c);
+ int sizeh = el->el_terminal.t_size.h;
+
ELRE_DEBUG(1, (__F, "printing %5x '%lc'\r\n", c, c));
if (w == -1)
w = 0;
- while (shift && (el->el_refresh.r_cursor.h + w > el->el_terminal.t_size.h))
+ while (shift && (cur->h + w > sizeh))
re_putc(el, ' ', 1);
- el->el_vdisplay[el->el_refresh.r_cursor.v]
- [el->el_refresh.r_cursor.h] = c;
+ el->el_vdisplay[cur->v][cur->h] = c;
/* assumes !shift is only used for single-column chars */
i = w;
while (--i > 0)
- el->el_vdisplay[el->el_refresh.r_cursor.v]
- [el->el_refresh.r_cursor.h + i] = MB_FILL_CHAR;
+ el->el_vdisplay[cur->v][cur->h + i] = MB_FILL_CHAR;
if (!shift)
return;
- el->el_refresh.r_cursor.h += w; /* advance to next place */
- if (el->el_refresh.r_cursor.h >= el->el_terminal.t_size.h) {
+ cur->h += w; /* advance to next place */
+ if (cur->h >= sizeh) {
/* assure end of line */
- el->el_vdisplay[el->el_refresh.r_cursor.v][el->el_terminal.t_size.h]
- = '\0';
+ el->el_vdisplay[cur->v][sizeh] = '\0';
re_nextline(el);
}
}
@@ -210,10 +231,13 @@
ELRE_DEBUG(1, (__F, "el->el_line.buffer = :%ls:\r\n",
el->el_line.buffer));
+ literal_clear(el);
/* reset the Drawing cursor */
el->el_refresh.r_cursor.h = 0;
el->el_refresh.r_cursor.v = 0;
+ terminal_move_to_char(el, 0);
+
/* temporarily draw rprompt to calculate its size */
prompt_print(el, EL_RPROMPT);
diff -r 62288c46c6f5 -r 44caa818b73d lib/libedit/refresh.h
--- a/lib/libedit/refresh.h Tue Jun 27 23:23:09 2017 +0000
+++ b/lib/libedit/refresh.h Tue Jun 27 23:23:48 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: refresh.h,v 1.10 2016/05/09 21:46:56 christos Exp $ */
+/* $NetBSD: refresh.h,v 1.11 2017/06/27 23:23:48 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -47,6 +47,8 @@
} el_refresh_t;
libedit_private void re_putc(EditLine *, wint_t, int);
+libedit_private void re_putliteral(EditLine *, const wchar_t *,
+ const wchar_t *);
libedit_private void re_clear_lines(EditLine *);
libedit_private void re_clear_display(EditLine *);
libedit_private void re_refresh(EditLine *);
Home |
Main Index |
Thread Index |
Old Index