summaryrefslogtreecommitdiff
path: root/lib/libcurses/lib_addstr.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-12-03 05:21:47 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-12-03 05:21:47 +0000
commit211326e37501ac01a66994a221020b75ab5f63f0 (patch)
tree6d6c7182f1034b1b04c98386a1c3ba44e8accd5f /lib/libcurses/lib_addstr.c
parent7c742f381e7808d0b12c17b534305751f3ebb0cb (diff)
Merge of ncurses-4.1-971129
Diffstat (limited to 'lib/libcurses/lib_addstr.c')
-rw-r--r--lib/libcurses/lib_addstr.c75
1 files changed, 44 insertions, 31 deletions
diff --git a/lib/libcurses/lib_addstr.c b/lib/libcurses/lib_addstr.c
index 2ece75c6cd7..0b8cc81e6c0 100644
--- a/lib/libcurses/lib_addstr.c
+++ b/lib/libcurses/lib_addstr.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: lib_addstr.c,v 1.3 1997/12/03 05:21:11 millert Exp $ */
+
/***************************************************************************
* COPYRIGHT NOTICE *
@@ -28,7 +30,7 @@
#include <curses.priv.h>
-MODULE_ID("Id: lib_addstr.c,v 1.11 1997/03/08 21:38:52 tom Exp $")
+MODULE_ID("Id: lib_addstr.c,v 1.13 1997/09/20 15:02:34 juergen Exp $")
int
waddnstr(WINDOW *win, const char *const astr, int n)
@@ -37,24 +39,23 @@ unsigned const char *str = (unsigned const char *)astr;
int code = ERR;
T((T_CALLED("waddnstr(%p,%s,%d)"), win, _nc_visbuf(astr), n));
- T(("... current %s", _traceattr(win->_attrs)));
-
- if (str != 0) {
-
- TR(TRACE_VIRTPUT, ("str is not null"));
- code = OK;
- if (n < 0)
- n = (int)strlen(astr);
-
- while((n-- > 0) && (*str != '\0')) {
- TR(TRACE_VIRTPUT, ("*str = %#x", *str));
- if (_nc_waddch_nosync(win, (chtype)*str++) == ERR) {
- code = ERR;
- break;
- }
- }
+
+ if (win && (str != 0)) {
+ T(("... current %s", _traceattr(win->_attrs)));
+ TR(TRACE_VIRTPUT, ("str is not null"));
+ code = OK;
+ if (n < 0)
+ n = (int)strlen(astr);
+
+ while((n-- > 0) && (*str != '\0')) {
+ TR(TRACE_VIRTPUT, ("*str = %#x", *str));
+ if (_nc_waddch_nosync(win, (chtype)*str++) == ERR) {
+ code = ERR;
+ break;
+ }
+ }
+ _nc_synchook(win);
}
- _nc_synchook(win);
TR(TRACE_VIRTPUT, ("waddnstr returns %d", code));
returnCode(code);
}
@@ -62,29 +63,41 @@ int code = ERR;
int
waddchnstr(WINDOW *win, const chtype *const astr, int n)
{
-short oy = win->_cury;
-short ox = win->_curx;
-const chtype *str = (const chtype *)astr;
+short y = win->_cury;
+short x = win->_curx;
int code = OK;
- T((T_CALLED("waddchnstr(%p,%p,%d)"), win, str, n));
+ T((T_CALLED("waddchnstr(%p,%p,%d)"), win, astr, n));
+
+ if (!win)
+ returnCode(ERR);
if (n < 0) {
+ const chtype *str;
n = 0;
- while (*str++ != 0)
+ for (str=(const chtype *)astr; *str!=0; str++)
n++;
- str = (const chtype *)astr;
}
+ if (n > win->_maxx - x + 1)
+ n = win->_maxx - x + 1;
+ if (n == 0)
+ returnCode(code);
- while(n-- > 0) {
- if (_nc_waddch_nosync(win, *str++) == ERR) {
- code = ERR;
- break;
- }
+ if (win->_line[y].firstchar == _NOCHANGE)
+ {
+ win->_line[y].firstchar = x;
+ win->_line[y].lastchar = x+n-1;
+ }
+ else
+ {
+ if (x < win->_line[y].firstchar)
+ win->_line[y].firstchar = x;
+ if (x+n-1 > win->_line[y].lastchar)
+ win->_line[y].lastchar = x+n-1;
}
+
+ memcpy(win->_line[y].text+x, astr, n*sizeof(*astr));
- win->_curx = ox;
- win->_cury = oy;
_nc_synchook(win);
returnCode(code);
}