okbob / pspg

Unix pager (with very rich functionality) designed for work with tables. Designed for PostgreSQL, but MySQL is supported too. Works well with pgcli too. Can be used as CSV or TSV viewer too. It supports searching, selecting rows, columns, or block and export selected area to clipboard.
BSD 2-Clause "Simplified" License
2.43k stars 85 forks source link

ESC-q broken on MacOS #204

Closed hunsakerbn closed 2 years ago

hunsakerbn commented 2 years ago

On MacOS the ALT/OPTION key used with another keyboard key sends unicode characters rather than ESC-. For example I have to explicitly hit ESC-q to 'quit and print raw (unformatted) content' as ALT-q sends 'œ'.

When I upgraded to the latest version, this broke unless I can manage to hit ESC-q really really fast. Apparently the 2 second timeout for this to happen is no longer working.

I used the following attached patch (there's probably a better way) to fix the problem: inputs.c.patch.txt

I install/upgrade pspg via homebrew.

okbob commented 2 years ago

What version of pspg do you use? I check the master branch, and there the 2seconds limit is broken.

hunsakerbn commented 2 years ago

% pspg --version
pspg-5.5.5 with readline (version: 0x0801) with integrated menu ncurses version: 6.3, patch: 20211021 ncurses with wide char support ncurses widechar num: 0 wchar_t width: 4, max: 2147483647 with postgres client integration with kqueue support

I install and update via 'hombrew' on MacOS.

% sw_vers
ProductName: macOS ProductVersion: 12.4 BuildVersion: 21F79

okbob commented 2 years ago

I don't understand why you changed expression nced->keycode == PSPG_NOTASSIGNED_CODE to nced->keycode == -1. It looks like some different behavior of macos :-(. Please, can you test commit 1e695721e516bac19a03511c35804e5668106f12 with option --log=file.txt Some like ./pspg -f tests/pg_class.txt --log=log.txt. When you press ESC, then there should be line in log like unexpected error ESC N str. Please, can me send the number and string?

hunsakerbn commented 2 years ago

Here is the log output:

Mon Aug 1 09:11:51 2022 [18322] started Mon Aug 1 09:11:51 2022 [18322] with utf8 support Mon Aug 1 09:11:51 2022 [18322] esc delay = -1 Mon Aug 1 09:11:51 2022 [18322] DataDesc is initialized Mon Aug 1 09:11:51 2022 [18322] next row will be data row Mon Aug 1 09:11:51 2022 [18322] next row will be desc row Mon Aug 1 09:11:51 2022 [18322] read rows 347 Mon Aug 1 09:11:51 2022 [18322] read input 347 rows Mon Aug 1 09:11:51 2022 [18322] terminal size by TIOCGWINSZ rows: 56, cols: 97 Mon Aug 1 09:11:51 2022 [18322] ncurses started Mon Aug 1 09:11:51 2022 [18322] kmous=\E[M, TERM=xterm-kitty Mon Aug 1 09:11:51 2022 [18322] xterm mouse mode 1002 will be used Mon Aug 1 09:11:51 2022 [18322] xterm mouse mode 1002 activated Mon Aug 1 09:11:51 2022 [18322] initial stdscr size - maxy: 56, maxx: 97 Mon Aug 1 09:11:55 2022 [18322] unexpected error ESC: Undefined error: 0 (0) Mon Aug 1 09:12:00 2022 [18322] process command: RawOutputQuit Mon Aug 1 09:12:00 2022 [18322] releasing cmd bar before end Mon Aug 1 09:12:00 2022 [18322] xterm mouse mode 1002 is deactivated Mon Aug 1 09:12:00 2022 [18322] ncurses ended Mon Aug 1 09:12:00 2022 [18322] correct quit

okbob commented 2 years ago

po 1. 8. 2022 v 17:17 odesílatel Bruce Hunsaker @.***> napsal:

Here is the log output:

Mon Aug 1 09:11:51 2022 [18322] started Mon Aug 1 09:11:51 2022 [18322] with utf8 support Mon Aug 1 09:11:51 2022 [18322] esc delay = -1 Mon Aug 1 09:11:51 2022 [18322] DataDesc is initialized Mon Aug 1 09:11:51 2022 [18322] next row will be data row Mon Aug 1 09:11:51 2022 [18322] next row will be desc row Mon Aug 1 09:11:51 2022 [18322] read rows 347 Mon Aug 1 09:11:51 2022 [18322] read input 347 rows Mon Aug 1 09:11:51 2022 [18322] terminal size by TIOCGWINSZ rows: 56, cols: 97 Mon Aug 1 09:11:51 2022 [18322] ncurses started Mon Aug 1 09:11:51 2022 [18322] kmous=\E[M, TERM=xterm-kitty Mon Aug 1 09:11:51 2022 [18322] xterm mouse mode 1002 will be used Mon Aug 1 09:11:51 2022 [18322] xterm mouse mode 1002 activated Mon Aug 1 09:11:51 2022 [18322] initial stdscr size - maxy: 56, maxx: 97 Mon Aug 1 09:11:55 2022 [18322] unexpected error ESC: Undefined error: 0 (0) Mon Aug 1 09:12:00 2022 [18322] process command: RawOutputQuit Mon Aug 1 09:12:00 2022 [18322] releasing cmd bar before end Mon Aug 1 09:12:00 2022 [18322] xterm mouse mode 1002 is deactivated Mon Aug 1 09:12:00 2022 [18322] ncurses ended Mon Aug 1 09:12:00 2022 [18322] correct quit

It is strange - get_wch fails, but errno is 0.

Reply to this email directly, view it on GitHub https://github.com/okbob/pspg/issues/204#issuecomment-1201340273, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEFO47QTJHUNV3WDZWGB2TVW7TARANCNFSM54WUQM4A . You are receiving this because you commented.Message ID: @.***>

okbob commented 2 years ago

please, can you check last commit?

hunsakerbn commented 2 years ago

Latest commit fixes the problem. It seems like the ESC delay is more than 2 seconds, perhaps infinite? (esc delay = -1). I waited about 10 seconds between hitting escape and 'q' and still got 'RawOutputQuit'.

Testing with './pspg -f tests/pg_class.txt --log=log.txt --esc-delay=2000' works with a 2 second delay.

okbob commented 1 year ago

Hi

út 26. 7. 2022 v 18:54 odesílatel Bruce Hunsaker @.***> napsal:

On MacOS the ALT/OPTION key used with another keyboard key sends unicode characters rather than ESC-. For example I have to explicitly hit ESC-q to 'quit and print raw (unformatted) content' as ALT-q sends 'œ'.

When I upgraded to the latest version, this broke unless I can manage to hit ESC-q really really fast. Apparently the 2 second timeout for this to happen is no longer working.

It looks strange, because when I test this issue on my linux, it looks like the limit 2 second doesn't work - and its ESC keys can be checked without limit.

I used the following attached patch (there's probably a better way) to fix the problem: inputs.c.patch.txt https://github.com/okbob/pspg/files/9191810/inputs.c.patch.txt

— Reply to this email directly, view it on GitHub https://github.com/okbob/pspg/issues/204, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEFO45YMMN3MVEPFUQVHVLVWAJ5NANCNFSM54WUQM4A . You are receiving this because you are subscribed to this thread.Message ID: @.***>

okbob commented 1 year ago

po 1. 8. 2022 v 21:55 odesílatel Bruce Hunsaker @.***> napsal:

Latest commit fixes the problem. It seems like the ESC delay is more than 2 seconds, perhaps infinite? (esc delay = -1).

default is infinity, but you can redefine

Due to this error, on Linux, the infinity was default for probably more than one year and nobody sent a bug report.

I waited about 10 seconds between hitting escape and 'q' and still got 'RawOutputQuit'.

Testing with './pspg -f tests/pg_class.txt --log=log.txt --esc-delay=2000' works with a 2 second delay.

yes

Regards

Pavel

— Reply to this email directly, view it on GitHub https://github.com/okbob/pspg/issues/204#issuecomment-1201647247, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEFO42MYDGSMET5KV2YYQDVXATSJANCNFSM54WUQM4A . You are receiving this because you commented.Message ID: @.***>