Add command options for cursor mode and key 'press' input to listview driver

This commit is contained in:
Florian Münchbach 2023-04-23 15:19:35 +02:00
parent add3982d2e
commit e7a4e388a2

View File

@ -98,8 +98,12 @@ main(int argc, char* argv[])
lv.set_window(win); lv.set_window(win);
noecho(); 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) { switch (c) {
case 'c':
// Enable cursor mode
lv.set_selectable(true);
break;
case 'y': case 'y':
lv.set_y(atoi(optarg)); lv.set_y(atoi(optarg));
break; break;
@ -107,6 +111,15 @@ main(int argc, char* argv[])
lv.set_height(vis_line_t(atoi(optarg))); lv.set_height(vis_line_t(atoi(optarg)));
set_height = true; set_height = true;
break; 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': case 't':
lv.set_top(vis_line_t(atoi(optarg))); lv.set_top(vis_line_t(atoi(optarg)));
break; break;