From e7a4e388a2c18f409078bdb2bf17cf57dca7a281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCnchbach?= Date: Sun, 23 Apr 2023 15:19:35 +0200 Subject: [PATCH] Add command options for cursor mode and key 'press' input to listview driver --- test/drive_listview.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/drive_listview.cc b/test/drive_listview.cc index 9938431b..e1563089 100644 --- a/test/drive_listview.cc +++ b/test/drive_listview.cc @@ -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,6 +111,15 @@ 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(*ptr)); + } + break; + } case 't': lv.set_top(vis_line_t(atoi(optarg))); break;