diff -Nru pspg-5.5.5/debian/changelog pspg-5.5.6/debian/changelog --- pspg-5.5.5/debian/changelog 2022-07-11 09:55:27.000000000 +0000 +++ pspg-5.5.6/debian/changelog 2022-08-08 17:44:39.000000000 +0000 @@ -1,3 +1,9 @@ +pspg (5.5.6-1) unstable; urgency=medium + + * New upstream version. + + -- Christoph Berg Mon, 08 Aug 2022 19:44:39 +0200 + pspg (5.5.5-1) unstable; urgency=medium * New upstream version. diff -Nru pspg-5.5.5/pspg.spec pspg-5.5.6/pspg.spec --- pspg-5.5.5/pspg.spec 2022-07-06 03:21:38.000000000 +0000 +++ pspg-5.5.6/pspg.spec 2022-08-02 04:10:53.000000000 +0000 @@ -3,7 +3,7 @@ Summary: pspg: a unix pager optimized for psql Name: pspg -Version: 5.5.5 +Version: 5.5.6 Release: 0%{?dist} License: BSD Group: Development/Tools @@ -43,7 +43,10 @@ %{_bindir}/* %changelog -* Tue Nov 2 2021 Pavel Stehule +* Tue Aug 2 2022 Pavel Stehule +- allow to set esc delay interval + +* Tue Nov 2 2021 Pavel Stehule - new visual effects --highlight-odd-rec and --hide-header-line - possibility to read SQLcl (Oracle) tables in ANSICONSOLE format - support streaming mode over files on BSD like systems (kqueue support) diff -Nru pspg-5.5.5/README.md pspg-5.5.6/README.md --- pspg-5.5.5/README.md 2022-07-06 03:21:38.000000000 +0000 +++ pspg-5.5.6/README.md 2022-08-02 04:10:53.000000000 +0000 @@ -57,6 +57,7 @@ -F, --quit-if-one-screen quit if content is one screen --clipboard-app=NUM specify app used by copy to clipboard (1, 2, 3) + --esc-delay=NUM specify escape delay in ms (-1 inf, 0 not used, ) --interactive force interactive mode --ignore_file_suffix don't try to deduce format from file suffix --ni not interactive mode (only for csv and query) @@ -363,13 +364,19 @@ \copy csv | less - ## Ending The pager can be ended by pressing keys q or F10 or Esc 0. With option `--on-sigint-exit` then the pager is closed by pressing keys Ctrl+c or Esc Esc. +## Use Escape, key instead Alt + key + +pspg supports a possibility to use a sequence of keys Esc, key instead an +combination of Alt+key. The interval between pressing Esc and +key is limmited by interval specified by option `esc-delay` or by configuration's +option `esc_delay`. This is max delay time in ms. After this interval, the single pressing Esc +is interpreted as `Escape`. -1 meas unlimited, 0 disables this feature. ## Column search diff -Nru pspg-5.5.5/src/args.c pspg-5.5.6/src/args.c --- pspg-5.5.5/src/args.c 2022-07-06 03:21:38.000000000 +0000 +++ pspg-5.5.6/src/args.c 2022-08-02 04:10:53.000000000 +0000 @@ -109,6 +109,7 @@ {"custom-style-name", required_argument, 0, 49}, {"highlight-odd-rec", no_argument, 0, 50}, {"hide-header-line", no_argument, 0, 51}, + {"esc-delay", required_argument, 0, 52}, {0, 0, 0, 0} }; @@ -313,6 +314,7 @@ fprintf(stdout, " -F, --quit-if-one-screen\n"); fprintf(stdout, " quit if content is one screen\n"); fprintf(stdout, " --clipboard-app=NUM specify app used by copy to clipboard (1, 2, 3)\n"); + fprintf(stdout, " --esc-delay=NUM specify escape delay in ms (-1 inf, 0 not used, )\n"); fprintf(stdout, " --interactive force interactive mode\n"); fprintf(stdout, " --ignore_file_suffix don't try to deduce format from file suffix\n"); fprintf(stdout, " --ni not interactive mode (only for csv and query)\n"); @@ -684,6 +686,9 @@ case 51: opts->hide_header_line = true; break; + case 52: + opts->esc_delay = atoi(optarg); + break; default: { diff -Nru pspg-5.5.5/src/commands.c pspg-5.5.6/src/commands.c --- pspg-5.5.5/src/commands.c 2022-07-06 03:21:38.000000000 +0000 +++ pspg-5.5.6/src/commands.c 2022-08-02 04:10:53.000000000 +0000 @@ -409,7 +409,7 @@ return cmd_ForwardSearch; case '9': return cmd_ShowMenu; - case 27: + case PSPG_ESC_CODE: return cmd_Escape; case '0': return cmd_Quit; diff -Nru pspg-5.5.5/src/config.c pspg-5.5.6/src/config.c --- pspg-5.5.5/src/config.c 2022-07-06 03:21:38.000000000 +0000 +++ pspg-5.5.6/src/config.c 2022-08-02 04:10:53.000000000 +0000 @@ -184,6 +184,10 @@ return false; } + result = fprintf(f, "esc_delay = %d\n", opts->esc_delay); + if (result < 0) + return false; + result = fclose(f); if (result != 0) return false; @@ -339,6 +343,8 @@ is_valid = assign_bool(key, &opts->highlight_odd_rec, bool_val, res); else if (strcmp(key, "hide_header_line") == 0) is_valid = assign_bool(key, &opts->hide_header_line, bool_val, res); + else if (strcmp(key, "esc_delay") == 0) + is_valid = assign_int(key, &opts->esc_delay, int_val, res, -1, INT_MAX); if (!is_valid || res == -1) break; diff -Nru pspg-5.5.5/src/config.h pspg-5.5.6/src/config.h --- pspg-5.5.5/src/config.h 2022-07-06 03:21:38.000000000 +0000 +++ pspg-5.5.6/src/config.h 2022-08-02 04:10:53.000000000 +0000 @@ -97,6 +97,7 @@ char *custom_theme_name; bool highlight_odd_rec; bool hide_header_line; + int esc_delay; } Options; extern bool save_config(char *path, Options *opts); diff -Nru pspg-5.5.5/src/inputs.c pspg-5.5.6/src/inputs.c --- pspg-5.5.5/src/inputs.c 2022-07-06 03:21:38.000000000 +0000 +++ pspg-5.5.6/src/inputs.c 2022-08-02 04:10:53.000000000 +0000 @@ -20,8 +20,6 @@ #include #include -#define PSPG_ESC_DELAY 2000 - #if defined(HAVE_INOTIFY) #include @@ -37,6 +35,8 @@ #include "inputs.h" #include "pspg.h" +#define PSPG_NOTASSIGNED_CODE 0 + static char pathname[MAXPATHLEN] = ""; FILE *f_tty = NULL; /* ncurses input stream */ @@ -68,6 +68,9 @@ static bool close_f_tty = false; static bool close_f_data = false; +int pspg_esc_delay; + + /************************************* * Events processing * @@ -147,6 +150,13 @@ return false; } + /* + * Workaround for issue #204. MacOS returns ERR when there are not + * any other activity after ESC in ESCDELAY limit. + */ + if (nced->keycode == ERR && !first_event && errno == 0) + nced->keycode = PSPG_NOTASSIGNED_CODE; + nced->alt = !first_event; return ok; @@ -336,17 +346,32 @@ { first_event = false; - /* - * own implementation of escape delay. For fast escape - press - * 2x escape. - */ - timeout = PSPG_ESC_DELAY; - goto repeat_reading; + if (pspg_esc_delay != 0) + { + if (pspg_esc_delay > 0) + { + timeout = pspg_esc_delay; + without_timeout = false; + } + else + { + timeout = -1; + without_timeout = true; + } + + goto repeat_reading; + } + else + { + /* esc delay is not wanted */ + nced->keycode = PSPG_ESC_CODE; + return PSPG_NCURSES_EVENT; + } } if (!first_event) { - /* double escpae */ + /* double escape */ if (nced->alt && nced->keycode == PSPG_NOTASSIGNED_CODE) nced->keycode = PSPG_ESC_CODE; else if (nced->keycode != KEY_MOUSE) diff -Nru pspg-5.5.5/src/inputs.h pspg-5.5.6/src/inputs.h --- pspg-5.5.5/src/inputs.h 2022-07-06 03:21:38.000000000 +0000 +++ pspg-5.5.6/src/inputs.h 2022-08-02 04:10:53.000000000 +0000 @@ -68,6 +68,8 @@ extern FILE *f_tty; extern int f_data_opts; +extern int pspg_esc_delay; + extern int get_pspg_event(NCursesEventData *nced, bool only_tty_events, int timeout); extern void unget_pspg_event(NCursesEventData *nced); diff -Nru pspg-5.5.5/src/pspg.c pspg-5.5.6/src/pspg.c --- pspg-5.5.5/src/pspg.c 2022-07-06 03:21:38.000000000 +0000 +++ pspg-5.5.6/src/pspg.c 2022-08-02 04:10:53.000000000 +0000 @@ -1596,7 +1596,7 @@ /* eat escape if pressed here */ if (event == PSPG_NCURSES_EVENT && - !(nced.keycode == 27 && nced.alt)) + !(nced.keycode == PSPG_ESC_CODE && nced.alt)) unget_pspg_event(&nced); } @@ -2614,6 +2614,7 @@ opts.progressive_load_mode = true; opts.highlight_odd_rec = false; opts.hide_header_line = false; + opts.esc_delay = -1; setup_sigsegv_handler(); @@ -2762,6 +2763,9 @@ log_row("started"); log_row("%s utf8 support", use_utf8 ? "with" : "without"); + pspg_esc_delay = opts.esc_delay; + log_row("esc delay = %d", pspg_esc_delay); + if (opts.csv_format || opts.tsv_format || opts.query) result = read_and_format(&opts, &desc, &state); else if (opts.querystream) diff -Nru pspg-5.5.5/src/pspg.h pspg-5.5.6/src/pspg.h --- pspg-5.5.5/src/pspg.h 2022-07-06 03:21:38.000000000 +0000 +++ pspg-5.5.6/src/pspg.h 2022-08-02 04:10:53.000000000 +0000 @@ -35,7 +35,7 @@ #define FILE_TSV 2 #define FILE_MATRIX 3 -#define PSPG_VERSION "5.5.5" +#define PSPG_VERSION "5.5.6" /* GNU Hurd does not define MAXPATHLEN */ #ifndef MAXPATHLEN @@ -473,7 +473,6 @@ * Global constants */ #define PSPG_ESC_CODE 27 -#define PSPG_NOTASSIGNED_CODE 0 /* * Global setting diff -Nru pspg-5.5.5/src/readline.c pspg-5.5.6/src/readline.c --- pspg-5.5.5/src/readline.c 2022-07-06 03:21:38.000000000 +0000 +++ pspg-5.5.6/src/readline.c 2022-08-02 04:10:53.000000000 +0000 @@ -492,7 +492,7 @@ pos -= 1; else if (c == 2 || c == 9) pos += 1; - else if (c == 4 || c == 27) + else if (c == 4 || c == PSPG_ESC_CODE) break; else if (c == 5) { @@ -662,7 +662,7 @@ while (c == ERR || c == 0); /* detect double alts .. escape */ - if (c == 27 && prev_c == 27) + if (c == PSPG_ESC_CODE && prev_c == PSPG_ESC_CODE) { /* * Cannot leave here - readline requires complete ALT pair. @@ -702,7 +702,7 @@ char *ptr = readline_buffer; while (*ptr) - if (*ptr++ == 27) + if (*ptr++ == PSPG_ESC_CODE) { result_is_ok = false; break; diff -Nru pspg-5.5.5/src/string.c pspg-5.5.6/src/string.c --- pspg-5.5.5/src/string.c 2022-07-06 03:21:38.000000000 +0000 +++ pspg-5.5.6/src/string.c 2022-08-02 04:10:53.000000000 +0000 @@ -149,7 +149,7 @@ { const char *haystack_cur, *needle_cur, *needle_prev; int f1 = 0; - bool eq; + bool needle_char_is_upper = false; /* be compiler quiet */ needle_cur = needle; needle_prev = NULL; @@ -157,7 +157,7 @@ while (*needle_cur != '\0') { - bool needle_char_is_upper = false; /* be compiler quiet */ + bool eq; if (*haystack_cur == '\0') return NULL; diff -Nru pspg-5.5.5/src/table.c pspg-5.5.6/src/table.c --- pspg-5.5.5/src/table.c 2022-07-06 03:21:38.000000000 +0000 +++ pspg-5.5.6/src/table.c 2022-08-02 04:10:53.000000000 +0000 @@ -692,7 +692,7 @@ if (!desc->initialized) { - log_row("DataDesc is initialized\n"); + log_row("DataDesc is initialized"); desc->title[0] = '\0'; desc->title_rows = 0; diff -Nru pspg-5.5.5/src/unicode.c pspg-5.5.6/src/unicode.c --- pspg-5.5.5/src/unicode.c 2022-07-06 03:21:38.000000000 +0000 +++ pspg-5.5.6/src/unicode.c 2022-08-02 04:10:53.000000000 +0000 @@ -16,6 +16,8 @@ #include "unicode.h" #include "string.h" +#include "pspg.h" + inline static wchar_t utf8_to_unicode(const unsigned char *c); /* @@ -656,7 +658,8 @@ { const char *haystack_cur, *needle_cur, *needle_prev; int f1 = 0, f2 = 0; - bool eq; + int needle_char_len = 0; + bool needle_char_is_upper = false; needle_cur = needle; needle_prev = NULL; @@ -665,8 +668,7 @@ while (*needle_cur != '\0') { int haystack_char_len; - int needle_char_len = 0; - bool needle_char_is_upper = false; + bool eq; if (*haystack_cur == '\0') return NULL; diff -Nru pspg-5.5.5/ToDo pspg-5.5.6/ToDo --- pspg-5.5.5/ToDo 2022-07-06 03:21:38.000000000 +0000 +++ pspg-5.5.6/ToDo 2022-08-02 04:10:53.000000000 +0000 @@ -6,6 +6,7 @@ Possible ToDo ============= +* fast scrolling - vertical or horizontal scrolling based on table's rows or table's columns * support fetched data - columns width can be different Similar projects