summaryrefslogtreecommitdiffstats
path: root/lib/libncurses/lib_addch.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1994-12-02 06:40:24 +0000
committerache <ache@FreeBSD.org>1994-12-02 06:40:24 +0000
commitda3bc85e1374c51c5dced6baacf60288a5a3ea40 (patch)
tree0beef683196d6d2f76165d3756c20ac09c0ee20b /lib/libncurses/lib_addch.c
parentd856190a55e1ac4bbc1e389083c70c3a9c37746e (diff)
downloadFreeBSD-src-da3bc85e1374c51c5dced6baacf60288a5a3ea40.zip
FreeBSD-src-da3bc85e1374c51c5dced6baacf60288a5a3ea40.tar.gz
Upgrade to version 1.8.6
Diffstat (limited to 'lib/libncurses/lib_addch.c')
-rw-r--r--lib/libncurses/lib_addch.c39
1 files changed, 30 insertions, 9 deletions
diff --git a/lib/libncurses/lib_addch.c b/lib/libncurses/lib_addch.c
index 50c4ae7..00684ed 100644
--- a/lib/libncurses/lib_addch.c
+++ b/lib/libncurses/lib_addch.c
@@ -13,25 +13,23 @@
#include "curses.priv.h"
#include "unctrl.h"
-int
-waddch(WINDOW *win, chtype c)
+static int
+wladdch(WINDOW *win, chtype c, bool literal)
{
int x, y;
int newx;
chtype ch = c;
-#if 0
- /* enabling this causes tons of tracing output
- and slow ncurses down to a crawl */
- T(("waddch(%x,%c (%x)) called", win, ch&A_CHARTEXT, ch));
-#endif
-
x = win->_curx;
y = win->_cury;
if (y > win->_maxy || x > win->_maxx || y < 0 || x < 0)
return(ERR);
+ /* ugly, but necessary --- and, bizarrely enough, even portable! */
+ if (literal)
+ goto noctrl;
+
switch (ch&A_CHARTEXT) {
case '\t':
for (newx = x + (8 - (x & 07)); x < newx; x++)
@@ -40,7 +38,7 @@ chtype ch = c;
return(OK);
case '\n':
wclrtoeol(win);
- x = 0;
+ x = 0;
goto newline;
case '\r':
x = 0;
@@ -53,8 +51,17 @@ chtype ch = c;
if (ch < ' ')
return(waddstr(win, unctrl(ch)));
+ /* FALL THROUGH */
+ noctrl:
+ T(("win attr = %x", win->_attrs));
ch |= win->_attrs;
+ if (win->_line[y][x]&A_CHARTEXT == ' ')
+ ch |= win->_bkgd;
+ else
+ ch |= (win->_bkgd&A_ATTRIBUTES);
+ T(("bkg = %x -> ch = %x", win->_bkgd, ch));
+
if (win->_line[y][x] != ch) {
if (win->_firstchar[y] == _NOCHANGE)
win->_firstchar[y] = win->_lastchar[y] = x;
@@ -65,6 +72,7 @@ chtype ch = c;
}
+ T(("char %d of line %d is %x", x, y, ch));
win->_line[y][x++] = ch;
if (x > win->_maxx) {
x = 0;
@@ -84,3 +92,16 @@ newline:
return(OK);
}
+
+int waddch(WINDOW *win, chtype ch)
+{
+ TR(TRACE_CHARPUT, ("waddch(%x,%c (%x)) called", win, ch&A_CHARTEXT, ch));
+ return wladdch(win, ch, FALSE);
+}
+
+int wechochar(WINDOW *win, chtype ch)
+{
+ T(("wechochar(%x,%c (%x)) called", win, ch&A_CHARTEXT, ch));
+
+ return wladdch(win, ch, TRUE);
+}
OpenPOWER on IntegriCloud