]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/view.c
ncurses 6.0 - patch 20170909
[ncurses.git] / test / view.c
index 5d94cda05751a7a841c66f9700fa465215cea2d6..1f960b9aa2b846affa5d54bc610176057b2becfd 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2015,2016 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2016,2017 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
  * scroll operation worked, and the refresh() code only had to do a
  * partial repaint.
  *
- * $Id: view.c,v 1.97 2016/09/10 21:05:46 tom Exp $
+ * $Id: view.c,v 1.102 2017/09/04 00:39:24 tom Exp $
  */
 
 #include <test.priv.h>
 #include <widechars.h>
+#include <popup_msg.h>
 
 #include <time.h>
 
@@ -227,6 +228,28 @@ ch_dup(char *src)
 int
 main(int argc, char *argv[])
 {
+    static const char *help[] =
+    {
+       "Commands:",
+       "  q,^Q,ESC       - quit this program",
+       "",
+       "  p,<Up>         - scroll the viewport up by one row",
+       "  n,<Down>       - scroll the viewport down by one row",
+       "  l,<Left>       - scroll the viewport left by one column",
+       "  r,<Right>      - scroll the viewport right by one column",
+       "",
+       "  h,<Home>       - scroll the viewport to top of file",
+       "  e,<End>        - scroll the viewport to end of file",
+       "",
+       "  ^L             - repaint using redrawwin()",
+       "",
+       "  0 through 9    - enter digits for count",
+       "  s              - use entered count for halfdelay() parameter",
+       "                 - if no entered count, stop nodelay()",
+       "  <space>        - begin nodelay()",
+       0
+    };
+
     int MAXLINES = 1000;
     FILE *fp;
     char buf[BUFSIZ];
@@ -473,6 +496,8 @@ main(int argc, char *argv[])
            break;
 
        case 'q':
+       case QUIT:
+       case ESCAPE:
            done = TRUE;
            break;
 
@@ -481,12 +506,17 @@ main(int argc, char *argv[])
            break;
 #endif
        case 's':
+#if HAVE_HALFDELAY
            if (got_number) {
                halfdelay(my_delay = n);
            } else {
                nodelay(stdscr, FALSE);
                my_delay = -1;
            }
+#else
+           nodelay(stdscr, FALSE);
+           my_delay = -1;
+#endif
            break;
        case ' ':
            nodelay(stdscr, TRUE);
@@ -499,6 +529,9 @@ main(int argc, char *argv[])
            if (!my_delay)
                napms(50);
            break;
+       case HELP_KEY_1:
+           popup_msg(stdscr, help);
+           break;
        default:
            beep();
            break;
@@ -571,7 +604,7 @@ show_all(const char *tag)
                "%.20s (%3dx%3d) col %d ", tag, LINES, COLS, shift);
     i = (int) strlen(temp);
     if ((i + 7) < (int) sizeof(temp)) {
-       _nc_SPRINTF(temp + i, _nc_SLIMIT(sizeof(temp) - i)
+       _nc_SPRINTF(temp + i, _nc_SLIMIT(sizeof(temp) - (size_t) i)
                    "view %.*s",
                    (int) (sizeof(temp) - 7 - (size_t) i),
                    fname);