summaryrefslogtreecommitdiff
path: root/lib/libcurses/EXAMPLES/view.c
diff options
context:
space:
mode:
authorblymn <blymn@NetBSD.org>2007-05-28 15:01:53 +0000
committerblymn <blymn@NetBSD.org>2007-05-28 15:01:53 +0000
commite124de36d8a3bb2fd90b77ec25eb7736f29ee44d (patch)
tree0dac708fd51eee66b5194f8e69d6fe165e953031 /lib/libcurses/EXAMPLES/view.c
parent599840187d9b53fe3353daa7f2892b387a1c2f29 (diff)
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
Diffstat (limited to 'lib/libcurses/EXAMPLES/view.c')
-rw-r--r--lib/libcurses/EXAMPLES/view.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/libcurses/EXAMPLES/view.c b/lib/libcurses/EXAMPLES/view.c
index b0a56b75925..74df2a83d21 100644
--- a/lib/libcurses/EXAMPLES/view.c
+++ b/lib/libcurses/EXAMPLES/view.c
@@ -23,7 +23,7 @@
* scroll operation worked, and the refresh() code only had to do a
* partial repaint.
*
- * $Id: view.c,v 1.1 2007/01/21 11:38:59 blymn Exp $
+ * $Id: view.c,v 1.2 2007/05/28 15:01:58 blymn Exp $
*/
#include <stdlib.h>
@@ -72,6 +72,7 @@ static bool try_color = FALSE;
static char *fname;
static CURSES_CH_T **my_lines;
static CURSES_CH_T **lptr;
+static unsigned num_lines;
static void usage(void)
{
@@ -232,6 +233,7 @@ int main(int argc, char *argv[])
}
/* slurp the file */
+ num_lines = 0;
for (lptr = &my_lines[0]; (lptr - my_lines) < MAXLINES; lptr++) {
char temp[BUFSIZ], *s, *d;
int col;
@@ -263,6 +265,7 @@ int main(int argc, char *argv[])
#endif
}
*lptr = ch_dup(temp);
+ num_lines++;
}
(void) fclose(fp);
length = lptr - my_lines;
@@ -506,14 +509,16 @@ static void show_all(const char *tag)
printw("%3ld:", (long) (lptr + i - my_lines));
clrtoeol();
if ((s = lptr[i - 1]) != 0) {
- int len = ch_len(s);
- if (len > shift) {
+ if (i < num_lines) {
+ int len = ch_len(s);
+ if (len > shift) {
#ifdef HAVE_WCHAR
- add_wchstr(s + shift);
+ add_wchstr(s + shift);
#else
- addchstr(s + shift);
+ addchstr(s + shift);
#endif
- }
+ }
+ }
}
}
setscrreg(1, LINES - 1);