Merge pull request #1147 from FlorianMuenchbach/feature/cursor-mode-tests

Some test cases for listview behavior in cursor mode
pull/1159/head
Tim Stack 1 year ago committed by GitHub
commit cd59577324
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -277,6 +277,13 @@ dist_noinst_DATA = \
listview_output.4 \
listview_output.5 \
listview_output.6 \
listview_output_cursor.0 \
listview_output_cursor.1 \
listview_output_cursor.2 \
listview_output_cursor.3 \
listview_output_cursor.4 \
listview_output_cursor.5 \
listview_output_cursor.6 \
log.clog \
logfile_access_log.0 \
logfile_access_log.1 \

@ -53,15 +53,15 @@ public:
vector<attr_line_t>& rows)
{
for (auto& value_out : rows) {
value_out = (lv.is_selectable() && row == lv.get_selection()) ? "+"
: "";
if (row == 0) {
value_out = "Hello";
value_out.al_string += "Hello";
} else if (row == 1) {
value_out = "World!";
value_out.al_string += "World!";
} else if (row < this->ms_rows) {
char buffer[32];
snprintf(buffer, sizeof(buffer), "%d", (int) row);
value_out = string(buffer);
value_out.al_string += std::to_string(static_cast<int>(row));
} else {
assert(0);
}
@ -98,8 +98,12 @@ main(int argc, char* argv[])
lv.set_window(win);
noecho();
while ((c = getopt(argc, argv, "y:t:l:r:h:w")) != -1) {
while ((c = getopt(argc, argv, "cy:t:k:l:r:h:w")) != -1) {
switch (c) {
case 'c':
// Enable cursor mode
lv.set_selectable(true);
break;
case 'y':
lv.set_y(atoi(optarg));
break;
@ -107,8 +111,17 @@ main(int argc, char* argv[])
lv.set_height(vis_line_t(atoi(optarg)));
set_height = true;
break;
case 'k': {
// Treats the string argument as sequence of key presses (only
// individual characters supported as key input)
for (char* ptr = optarg; ptr != nullptr && *ptr != '\0'; ++ptr)
{
lv.handle_key(static_cast<int>(*ptr));
}
break;
}
case 't':
lv.set_top(vis_line_t(atoi(optarg)));
lv.set_selection(vis_line_t(atoi(optarg)));
break;
case 'l':
lv.set_left(atoi(optarg));

@ -0,0 +1,70 @@
CTRL Use alt charset
CTRL save cursor
CSI Use alternate screen buffer
CSI set scrolling region 1-24
S -1 ┋ ┋
A └ normal
CSI Reset Replace mode
CSI Erase all
S 1 ┋+Hello x┋
A └┛ alt
S 2 ┋World! x┋
A └┛ alt
S 3 ┋ x┋
A └┛ alt
S 4 ┋ x┋
A └┛ alt
S 5 ┋ x┋
A └┛ alt
S 6 ┋ x┋
A └┛ alt
S 7 ┋ x┋
A └┛ alt
S 8 ┋ x┋
A └┛ alt
S 9 ┋ x┋
A └┛ alt
S 10 ┋ x┋
A └┛ alt
S 11 ┋ x┋
A └┛ alt
S 12 ┋ x┋
A └┛ alt
S 13 ┋ x┋
A └┛ alt
S 14 ┋ x┋
A └┛ alt
S 15 ┋ x┋
A └┛ alt
S 16 ┋ x┋
A └┛ alt
S 17 ┋ x┋
A └┛ alt
S 18 ┋ x┋
A └┛ alt
S 19 ┋ x┋
A └┛ alt
S 20 ┋ x┋
A └┛ alt
S 21 ┋ x┋
A └┛ alt
S 22 ┋ x┋
A └┛ alt
S 23 ┋ x┋
A └┛ alt
S 24 ┋ x ┋
A ···············································································└ backspace
A └┛ alt
A ···············································································└ backspace
CSI Set Replace mode
S 24 ┋ ┋
CSI Reset Replace mode
S 24 ┋ ┋
A ···············································································└ carriage-return
CSI Erase all
CSI Use normal screen buffer
CTRL restore cursor
S 24 ┋ ┋
A └ carriage-return
CSI Normal cursor keys
CTRL Normal keypad

@ -0,0 +1,70 @@
CTRL Use alt charset
CTRL save cursor
CSI Use alternate screen buffer
CSI set scrolling region 1-24
S -1 ┋ ┋
A └ normal
CSI Reset Replace mode
CSI Erase all
S 1 ┋Hello x┋
A └┛ alt
S 2 ┋World! x┋
A └┛ alt
S 3 ┋2 x┋
A └┛ alt
S 4 ┋3 x┋
A └┛ alt
S 5 ┋4 x┋
A └┛ alt
S 6 ┋+5 x┋
A └┛ alt
S 7 ┋6 x┋
A └┛ alt
S 8 ┋7 x┋
A └┛ alt
S 9 ┋8 x┋
A └┛ alt
S 10 ┋9 x┋
A └┛ alt
S 11 ┋10 x┋
A └┛ alt
S 12 ┋11 x┋
A └┛ alt
S 13 ┋12 x┋
A └┛ alt
S 14 ┋13 x┋
A └┛ alt
S 15 ┋14 x┋
A └┛ alt
S 16 ┋15 x┋
A └┛ alt
S 17 ┋16 x┋
A └┛ alt
S 18 ┋17 x┋
A └┛ alt
S 19 ┋18 x┋
A └┛ alt
S 20 ┋19 x┋
A └┛ alt
S 21 ┋ x┋
A └┛ alt
S 22 ┋ x┋
A └┛ alt
S 23 ┋ x┋
A └┛ alt
S 24 ┋ x ┋
A ···············································································└ backspace
A └┛ alt
A ···············································································└ backspace
CSI Set Replace mode
S 24 ┋ ┋
CSI Reset Replace mode
S 24 ┋ ┋
A ···············································································└ carriage-return
CSI Erase all
CSI Use normal screen buffer
CTRL restore cursor
S 24 ┋ ┋
A └ carriage-return
CSI Normal cursor keys
CTRL Normal keypad

@ -0,0 +1,70 @@
CTRL Use alt charset
CTRL save cursor
CSI Use alternate screen buffer
CSI set scrolling region 1-24
S -1 ┋ ┋
A └ normal
CSI Reset Replace mode
CSI Erase all
S 1 ┋Hello x┋
A └┛ alt
S 2 ┋World! x┋
A └┛ alt
S 3 ┋2 x┋
A └┛ alt
S 4 ┋+3 x┋
A └┛ alt
S 5 ┋4 x┋
A └┛ alt
S 6 ┋5 x┋
A └┛ alt
S 7 ┋6 x┋
A └┛ alt
S 8 ┋7 x┋
A └┛ alt
S 9 ┋8 x┋
A └┛ alt
S 10 ┋9 x┋
A └┛ alt
S 11 ┋10 x┋
A └┛ alt
S 12 ┋11 x┋
A └┛ alt
S 13 ┋12 x┋
A └┛ alt
S 14 ┋13 x┋
A └┛ alt
S 15 ┋14 x┋
A └┛ alt
S 16 ┋15 x┋
A └┛ alt
S 17 ┋16 x┋
A └┛ alt
S 18 ┋17 x┋
A └┛ alt
S 19 ┋18 x┋
A └┛ alt
S 20 ┋19 x┋
A └┛ alt
S 21 ┋ x┋
A └┛ alt
S 22 ┋ x┋
A └┛ alt
S 23 ┋ x┋
A └┛ alt
S 24 ┋ x ┋
A ···············································································└ backspace
A └┛ alt
A ···············································································└ backspace
CSI Set Replace mode
S 24 ┋ ┋
CSI Reset Replace mode
S 24 ┋ ┋
A ···············································································└ carriage-return
CSI Erase all
CSI Use normal screen buffer
CTRL restore cursor
S 24 ┋ ┋
A └ carriage-return
CSI Normal cursor keys
CTRL Normal keypad

@ -0,0 +1,25 @@
CTRL Use alt charset
CTRL save cursor
CSI Use alternate screen buffer
CSI set scrolling region 1-24
S -1 ┋ ┋
A └ normal
CSI Reset Replace mode
CSI Erase all
S 1 ┋World! x┋
A └┛ alt
S 2 ┋2 x┋
A └┛ alt
S 3 ┋3 x┋
A └┛ alt
S 4 ┋+4 x┋
A └┛ alt
S 5 ┋5 x┋
A └┛ alt
CSI Erase all
CSI Use normal screen buffer
CTRL restore cursor
S 24 ┋ ┋
A └ carriage-return
CSI Normal cursor keys
CTRL Normal keypad

@ -0,0 +1,25 @@
CTRL Use alt charset
CTRL save cursor
CSI Use alternate screen buffer
CSI set scrolling region 1-24
S -1 ┋ ┋
A └ normal
CSI Reset Replace mode
CSI Erase all
S 1 ┋Hello x┋
A └┛ alt
S 2 ┋World! x┋
A └┛ alt
S 3 ┋2 x┋
A └┛ alt
S 4 ┋+3 x┋
A └┛ alt
S 5 ┋4 x┋
A └┛ alt
CSI Erase all
CSI Use normal screen buffer
CTRL restore cursor
S 24 ┋ ┋
A └ carriage-return
CSI Normal cursor keys
CTRL Normal keypad

@ -0,0 +1,35 @@
CTRL Use alt charset
CTRL save cursor
CSI Use alternate screen buffer
CSI set scrolling region 1-24
S -1 ┋ ┋
A └ normal
CSI Reset Replace mode
CSI Erase all
S 1 ┋+18 x┋
A └┛ alt
S 2 ┋19 x┋
A └┛ alt
S 3 ┋20 x┋
A └┛ alt
S 4 ┋21 x┋
A └┛ alt
S 5 ┋22 x┋
A └┛ alt
S 6 ┋23 x┋
A └┛ alt
S 7 ┋24 x┋
A └┛ alt
S 8 ┋25 x┋
A └┛ alt
S 9 ┋26 x┋
A └┛ alt
S 10 ┋27 x┋
A └┛ alt
CSI Erase all
CSI Use normal screen buffer
CTRL restore cursor
S 24 ┋ ┋
A └ carriage-return
CSI Normal cursor keys
CTRL Normal keypad

@ -0,0 +1,35 @@
CTRL Use alt charset
CTRL save cursor
CSI Use alternate screen buffer
CSI set scrolling region 1-24
S -1 ┋ ┋
A └ normal
CSI Reset Replace mode
CSI Erase all
S 1 ┋9 x┋
A └┛ alt
S 2 ┋10 x┋
A └┛ alt
S 3 ┋11 x┋
A └┛ alt
S 4 ┋12 x┋
A └┛ alt
S 5 ┋13 x┋
A └┛ alt
S 6 ┋14 x┋
A └┛ alt
S 7 ┋15 x┋
A └┛ alt
S 8 ┋16 x┋
A └┛ alt
S 9 ┋+17 x┋
A └┛ alt
S 10 ┋18 x┋
A └┛ alt
CSI Erase all
CSI Use normal screen buffer
CTRL restore cursor
S 24 ┋ ┋
A └ carriage-return
CSI Normal cursor keys
CTRL Normal keypad

@ -34,3 +34,50 @@ run_test ./scripty -n -e ${srcdir}/listview_output.6 -- \
./drive_listview -y 1 -r 50 -h -1 -t 1 < /dev/null
on_error_fail_with "Listview didn't move down (2)?"
###
# Cursor mode tests
###
# Cursor appears on first line
run_test ./scripty -n -e ${srcdir}/listview_output_cursor.0 -- \
./drive_listview -c < /dev/null
on_error_fail_with "Listview Cursor Mode: Didn't enable (not selectable)"
# Move down within visible area between top (at 0) and tail space
run_test ./scripty -n -e ${srcdir}/listview_output_cursor.1 -- \
./drive_listview -r 20 -c -k jjjjj < /dev/null
on_error_fail_with "Listview Cursor Mode: Didn-t move cursor down?"
# Move up within visible area between top (at 0) and tail space
run_test ./scripty -n -e ${srcdir}/listview_output_cursor.2 -- \
./drive_listview -r 20 -c -k jjjjjkk < /dev/null
on_error_fail_with "Listview Cursor Mode: Didn't move cursor up?"
# Scroll file when reaching tail space
run_test ./scripty -n -e ${srcdir}/listview_output_cursor.3 -- \
./drive_listview -r 30 -h 5 -c -k jjjj < /dev/null
on_error_fail_with "Listview Cursor Mode: Didn't scroll down when reaching tail space?"
# Do not scroll up when moving up after reaching tail space
run_test ./scripty -n -e ${srcdir}/listview_output_cursor.4 -- \
./drive_listview -r 30 -h 5 -c -k jjjjk < /dev/null
on_error_fail_with "Listview Cursor Mode: scrolled when moving up from tail space?"
# Page down move
run_test ./scripty -n -e ${srcdir}/listview_output_cursor.5 -- \
./drive_listview -r 30 -h 10 -c -k ' ' < /dev/null
on_error_fail_with "Listview Cursor Mode: didn't moved down on page jump?"
# Page up move
run_test ./scripty -n -e ${srcdir}/listview_output_cursor.6 -- \
./drive_listview -r 30 -h 10 -c -k ' b' < /dev/null
on_error_fail_with "Listview Cursor Mode: didn't moved up on page jump?"

Loading…
Cancel
Save