From 6deb7032a6159682062e8aa1c6a2fa0257c597c7 Mon Sep 17 00:00:00 2001 From: Timothy Stack Date: Fri, 5 Feb 2021 16:04:34 -0800 Subject: [PATCH] [tests] add more CSIs to scripty --- TESTS_ENVIRONMENT.in | 8 + src/internals/config-v1.schema.json | 2 +- src/lnav_config.cc | 2 +- src/views_vtab.cc | 16 +- test/Makefile.am | 1 + test/listview_output.0 | 9 +- test/listview_output.1 | 9 +- test/listview_output.2 | 9 +- test/listview_output.3 | 9 +- test/listview_output.4 | 9 +- test/listview_output.5 | 2 +- test/listview_output.6 | 2 +- test/mvwattrline_output.0 | 2 +- test/scripty.cc | 49 ++++- test/test_sql.sh | 72 +++++- test/test_tui.sh | 13 +- test/tui-captures/tui_echo.0 | 327 ++++++++++++++++++++++++++++ test/tui-captures/tui_help.0 | 9 +- test/view_colors_output.0 | 2 +- test/vt52_curses_input.0 | 2 +- 20 files changed, 514 insertions(+), 40 deletions(-) create mode 100644 test/tui-captures/tui_echo.0 diff --git a/TESTS_ENVIRONMENT.in b/TESTS_ENVIRONMENT.in index e21a170e..70648ea6 100644 --- a/TESTS_ENVIRONMENT.in +++ b/TESTS_ENVIRONMENT.in @@ -153,6 +153,14 @@ grep_output_for() { test_num=`expr ${test_num} \+ 1` } +on_error_log() { + if test $? -ne 0; then + echo $1 > /dev/stderr + cat ${test_file_base}_${test_num}.tmp + cat ${test_file_base}_${test_num}.err + fi +} + on_error_fail_with() { if test $? -ne 0; then echo $1 > /dev/stderr diff --git a/src/internals/config-v1.schema.json b/src/internals/config-v1.schema.json index 82a5a60f..a37b5f25 100644 --- a/src/internals/config-v1.schema.json +++ b/src/internals/config-v1.schema.json @@ -422,7 +422,7 @@ }, "background-color": { "title": "/background-color", - "description": "The foreground color value for this style. The value can be the name of an xterm color, the hexadecimal value, or a theme variable reference.", + "description": "The background color value for this style. The value can be the name of an xterm color, the hexadecimal value, or a theme variable reference.", "type": "string", "examples": [ "#2d2a2e", diff --git a/src/lnav_config.cc b/src/lnav_config.cc index 4de2e61a..bed3fe8d 100644 --- a/src/lnav_config.cc +++ b/src/lnav_config.cc @@ -476,7 +476,7 @@ static struct json_path_container style_config_handlers = yajlpp::property_handler("background-color") .with_synopsis("#hex|color_name") .with_description( - "The foreground color value for this style. The value can be " + "The background color value for this style. The value can be " "the name of an xterm color, the hexadecimal value, or a theme " "variable reference.") .with_example("#2d2a2e") diff --git a/src/views_vtab.cc b/src/views_vtab.cc index 826442d2..7b6f726a 100644 --- a/src/views_vtab.cc +++ b/src/views_vtab.cc @@ -99,7 +99,9 @@ struct from_sqlite>> { nullptr); if (code == nullptr) { - throw from_sqlite_conversion_error(errptr, argi); + throw sqlite_func_error( + "Invalid regular expression in column {}: {} at offset {}", + argi, errptr, eoff); } return make_pair(string(pattern), std::move(code)); @@ -629,6 +631,18 @@ CREATE TABLE lnav_view_files ( return SQLITE_OK; } + int delete_row(sqlite3_vtab *tab, sqlite3_int64 rowid) { + tab->zErrMsg = sqlite3_mprintf( + "Rows cannot be deleted from the lnav_view_files table"); + return SQLITE_ERROR; + } + + int insert_row(sqlite3_vtab *tab, sqlite3_int64 &rowid_out) { + tab->zErrMsg = sqlite3_mprintf( + "Rows cannot be inserted into the lnav_view_files table"); + return SQLITE_ERROR; + }; + int update_row(sqlite3_vtab *tab, sqlite3_int64 &rowid, const char *view_name, diff --git a/test/Makefile.am b/test/Makefile.am index 02773d40..bb01f758 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -308,6 +308,7 @@ dist_noinst_DATA = \ log-samples/sample-27353a72ba4025448f261dcfa6ea16e474187795.txt \ log-samples/sample-70c906b3c1a1cf03f15bde92ee78edfa6f9b7960.txt \ log-samples/sample-ad31f12d2adabd07e3ddda3ad5b0dbf6b49c4c99.txt \ + tui-captures/tui_echo.0 \ tui-captures/tui_help.0 TESTS = \ diff --git a/test/listview_output.0 b/test/listview_output.0 index 3dbce26b..3d82d0d6 100644 --- a/test/listview_output.0 +++ b/test/listview_output.0 @@ -4,7 +4,7 @@ CSI Use alternate screen buffer CSI set scrolling region 1-24 S -1 ┋ ┋ A └ normal -CSI Replace mode +CSI Reset Replace mode CSI Erase all S 1 ┋Hello x┋ A └┛ alt @@ -52,12 +52,13 @@ S 22 ┋ A └┛ alt S 23 ┋ x┋ A └┛ alt -S 24 ┋ ┋ +S 24 ┋ x ┋ A ···············································································└ backspace A └┛ alt A ···············································································└ backspace -A ··············································································└ [4h -CSI Replace mode +CSI Set Replace mode +S 24 ┋ ┋ +CSI Reset Replace mode S 24 ┋ ┋ A ···············································································└ carriage-return CSI Erase all diff --git a/test/listview_output.1 b/test/listview_output.1 index 32d10c60..17f72026 100644 --- a/test/listview_output.1 +++ b/test/listview_output.1 @@ -4,7 +4,7 @@ CSI Use alternate screen buffer CSI set scrolling region 1-24 S -1 ┋ ┋ A └ normal -CSI Replace mode +CSI Reset Replace mode CSI Erase all S 1 ┋World! x┋ A └┛ alt @@ -52,12 +52,13 @@ S 22 ┋ A └┛ alt S 23 ┋ x┋ A └┛ alt -S 24 ┋ ┋ +S 24 ┋ x ┋ A ···············································································└ backspace A └┛ alt A ···············································································└ backspace -A ··············································································└ [4h -CSI Replace mode +CSI Set Replace mode +S 24 ┋ ┋ +CSI Reset Replace mode S 24 ┋ ┋ A ···············································································└ carriage-return CSI Erase all diff --git a/test/listview_output.2 b/test/listview_output.2 index f3105f1d..a028d66e 100644 --- a/test/listview_output.2 +++ b/test/listview_output.2 @@ -4,7 +4,7 @@ CSI Use alternate screen buffer CSI set scrolling region 1-24 S -1 ┋ ┋ A └ normal -CSI Replace mode +CSI Reset Replace mode CSI Erase all S 1 ┋ello x┋ A └┛ alt @@ -52,12 +52,13 @@ S 22 ┋ A └┛ alt S 23 ┋ x┋ A └┛ alt -S 24 ┋ ┋ +S 24 ┋ x ┋ A ···············································································└ backspace A └┛ alt A ···············································································└ backspace -A ··············································································└ [4h -CSI Replace mode +CSI Set Replace mode +S 24 ┋ ┋ +CSI Reset Replace mode S 24 ┋ ┋ A ···············································································└ carriage-return CSI Erase all diff --git a/test/listview_output.3 b/test/listview_output.3 index dbeab53e..b29ea7de 100644 --- a/test/listview_output.3 +++ b/test/listview_output.3 @@ -4,7 +4,7 @@ CSI Use alternate screen buffer CSI set scrolling region 1-24 S -1 ┋ ┋ A └ normal -CSI Replace mode +CSI Reset Replace mode CSI Erase all S 1 ┋orld! x┋ A └┛ alt @@ -52,12 +52,13 @@ S 22 ┋ A └┛ alt S 23 ┋ x┋ A └┛ alt -S 24 ┋ ┋ +S 24 ┋ x ┋ A ···············································································└ backspace A └┛ alt A ···············································································└ backspace -A ··············································································└ [4h -CSI Replace mode +CSI Set Replace mode +S 24 ┋ ┋ +CSI Reset Replace mode S 24 ┋ ┋ A ···············································································└ carriage-return CSI Erase all diff --git a/test/listview_output.4 b/test/listview_output.4 index 2e8cbe21..8f6c5e74 100644 --- a/test/listview_output.4 +++ b/test/listview_output.4 @@ -4,7 +4,7 @@ CSI Use alternate screen buffer CSI set scrolling region 1-24 S -1 ┋ ┋ A └ normal -CSI Replace mode +CSI Reset Replace mode CSI Erase all S 2 ┋Hello x┋ A └┛ alt @@ -50,12 +50,13 @@ S 22 ┋20 A └┛ alt S 23 ┋21 x┋ A └┛ alt -S 24 ┋22 ┋ +S 24 ┋22 x ┋ A ···············································································└ backspace A └┛ alt A ···············································································└ backspace -A ··············································································└ [4h -CSI Replace mode +CSI Set Replace mode +S 24 ┋ ┋ +CSI Reset Replace mode S 24 ┋ ┋ A ···············································································└ carriage-return CSI Erase all diff --git a/test/listview_output.5 b/test/listview_output.5 index dd0e4d43..021b8d74 100644 --- a/test/listview_output.5 +++ b/test/listview_output.5 @@ -4,7 +4,7 @@ CSI Use alternate screen buffer CSI set scrolling region 1-24 S -1 ┋ ┋ A └ normal -CSI Replace mode +CSI Reset Replace mode CSI Erase all S 2 ┋Hello x┋ A └┛ alt diff --git a/test/listview_output.6 b/test/listview_output.6 index a353b1de..f5765d5b 100644 --- a/test/listview_output.6 +++ b/test/listview_output.6 @@ -4,7 +4,7 @@ CSI Use alternate screen buffer CSI set scrolling region 1-24 S -1 ┋ ┋ A └ normal -CSI Replace mode +CSI Reset Replace mode CSI Erase all S 2 ┋World! x┋ A └┛ alt diff --git a/test/mvwattrline_output.0 b/test/mvwattrline_output.0 index e91cc643..608ba64a 100644 --- a/test/mvwattrline_output.0 +++ b/test/mvwattrline_output.0 @@ -4,7 +4,7 @@ CSI Use alternate screen buffer CSI set scrolling region 1-24 S -1 ┋ ┋ A └ normal -CSI Replace mode +CSI Reset Replace mode S -1 ┋ ┋ A └ normal, normal, normal CSI Erase all diff --git a/test/scripty.cc b/test/scripty.cc index bb552aff..70acaa49 100644 --- a/test/scripty.cc +++ b/test/scripty.cc @@ -291,7 +291,14 @@ static const std::map CSI_TO_DESC = { {"[?1l", "Normal cursor keys"}, {"[?47h", "Use alternate screen buffer"}, {"[?47l", "Use normal screen buffer"}, - {"[4l", "Replace mode"}, + {"[2h", "Set Keyboard Action mode"}, + {"[4h", "Set Replace mode"}, + {"[12h", "Set Send/Receive mode"}, + {"[20h", "Set Normal Linefeed mode"}, + {"[2l", "Reset Keyboard Action mode"}, + {"[4l", "Reset Replace mode"}, + {"[12l", "Reset Send/Receive mode"}, + {"[20l", "Reset Normal Linefeed mode"}, {"[2J", "Erase all"}, }; @@ -610,14 +617,18 @@ struct term_machine { if (iter == CSI_TO_DESC.end()) { this->tm_escape_buffer.push_back('\0'); switch (ch) { - case 'C': { + case 'A': { auto amount = this->get_m_params(); int count = 1; if (!amount.empty()) { count = amount[0]; } - this->tm_cursor_x += count; + this->flush_line(); + this->tm_cursor_y -= count; + if (this->tm_cursor_y < 0) { + this->tm_cursor_y = 0; + } break; } case 'B': { @@ -631,6 +642,16 @@ struct term_machine { this->tm_cursor_y += count; break; } + case 'C': { + auto amount = this->get_m_params(); + int count = 1; + + if (!amount.empty()) { + count = amount[0]; + } + this->tm_cursor_x += count; + break; + } case 'J': { auto param = this->get_m_params(); @@ -657,6 +678,28 @@ struct term_machine { } break; } + case 'K': { + auto param = this->get_m_params(); + + this->flush_line(); + + auto region = param.empty() ? 0 : param[0]; + switch (region) { + case 0: + fprintf(scripty_data.sd_from_child, + "CSI Erase to Right\n"); + break; + case 1: + fprintf(scripty_data.sd_from_child, + "CSI Erase to Left\n"); + break; + case 2: + fprintf(scripty_data.sd_from_child, + "CSI Erase All\n"); + break; + } + break; + } case 'H': { auto coords = this->get_m_params(); diff --git a/test/test_sql.sh b/test/test_sql.sh index 3c159771..2020a3a2 100644 --- a/test/test_sql.sh +++ b/test/test_sql.sh @@ -139,6 +139,49 @@ check_output "time_offset in lnav_file table is not working?" <