/* winlnk: cmd.o debug.o tui.o -lpdcurses */
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include "cmd.h"
clsbody ();
int i = 0;
int eol = 0;
- for (i = 0; i <= ymax; i++) {
+ for (i = 0; i < ymax - 1; i++) {
if (lines [skip + i] == NULL) {
break;
}
bodymsg (lines[skip + i]);
eol = (lines[skip + i][xmax - 1 ] == '\0');
}
+ if (lines [skip + i] != NULL) {
+ if (eol) {
+ bodymsg ("\n");
+ }
+ char *str = (char *) calloc (1, xmax + 1);
+ strcpy (str, lines[skip + i]);
+ if (str[xmax - 1] != '\0') {
+ VERBOSE (DEBUG, fprintf (stdout, "last line too long\n"));
+ strcpy (str + xmax - 3, ">>");
+ }
+ bodymsg (str);
+ free (str);
+ }
+
if (second > 0) {
DoExit ();
break;
}
int key = waitforkey ();
+ VERBOSE (DEBUG, fprintf (stdout, "key pressed: 0x%04x (%c)\n", key, (key >= ' ') && (key < 256) ? key : '.'));
switch (key) {
case KEY_ESC:
#ifndef __PDCURSES__
stop = 1;
break;
#endif
- default:
- printf ("key pressed: %c (0x%04x)\n", (char)key, key);
}
}
/* test: (sleep 1; echo -n q) | cmore.exe -c 'ip addr' */
/* test: (sleep 1; echo -ne '\e\e') | cmore.exe -f tui.c */
/* test: (sleep 1; echo -n kkkkk; sleep 1; echo -n i; sleep 1; echo -n q) | cmore.exe -c 'ip addr' */
+/* test: (sleep 1; echo -n q) | cmore.exe -c 'echo -n a; for i in $(seq 1 '$(( $COLUMNS*($LINES-4)-2 ))'); do echo -n .; done; echo -n z' -v 5 | grep -q 'last line too long' */
+/* test: (sleep 1; echo -n q) | cmore.exe -c 'echo -n a; for i in $(seq 1 '$(( $COLUMNS*($LINES-4)-3 ))'); do echo -n .; done; echo -n z' -v 5 | grep -q 'last line too long'; test $? -eq 1 */
/* vim: set ts=4 sw=4 et: */