clean help window
authorLaurent MAZET <laurent.mazet@thalesgroup.com>
Tue, 14 May 2024 10:07:55 +0000 (12:07 +0200)
committerLaurent MAZET <laurent.mazet@thalesgroup.com>
Tue, 14 May 2024 10:07:55 +0000 (12:07 +0200)
cmore.c

diff --git a/cmore.c b/cmore.c
index 703cbf2e27f45e45ff1527e443a60da82ee1a2d3..ccf61589c77adc7600d1787a5af1b86b688a2870 100644 (file)
--- a/cmore.c
+++ b/cmore.c
@@ -167,6 +167,8 @@ void follow (void)
 
 void about (void)
 {
+    char *message = "CMore: a curses more\n \nThis program is a pager with a text user interface.\n- To move displayed text or in menu, use arrow keys or vim keys (i, j, k, l).\n- To access menus, use Alt-f of Alt-h.\n- To quit displayed text, press Escape or 'q'.";
+
     int xmax, ymax;
     WINDOW *wbody = bodywin ();
     getmaxyx (stdscr, ymax, xmax);
@@ -174,8 +176,24 @@ void about (void)
     wmove (stdscr, ymax / 4, xmax / 4);
     WINDOW *whelp = winputbox (stdscr, ymax / 2, xmax / 2);
 
-    wmove (whelp, 1, 1);
-    waddstr (whelp, "CMore: a curses more\nThis program is a pager with a text user interface.\nTo move displayed text or in menu, use arrow keys or vim keys (i, j, k, l).\nTo access menus, use Alt-f of Alt-h.\nTo quit displayed text, press Escape or 'q'.");
+    int i, j;
+    for (i = 1; i < ymax / 2 - 1; i++) {
+        char c[2] = {0};
+        for (j = 1; j < xmax / 2 - 1; j++) {
+            *c = *message++;
+            if ((*c == '\n') && (j == 1)) {
+                *c = *message++;
+            }
+            if ((*c == '\n') || (*c == '\0')) {
+                break;
+            }
+            wmove (whelp, i, j);
+            waddstr (whelp, c);
+        }
+        if (*c == '\0') {
+            break;
+        }
+    }
     wrefresh (whelp);
 
     waitforkey ();