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

Some styles cause shell styles to break #211

Closed dark-panda closed 1 year ago

dark-panda commented 1 year ago

Styles 17, 18, 19, 20, and 21 cause shell styles to sort of carry on their styling even after the pspg process exits. In my shell, I have the ls command aliased to ls --color=auto, and after using pspg with any of these themes, the colours for my shell persist even after pspg exits.

Here's how my shell should look:

Screen Shot 2022-11-08 at 11 13 35 AM

Here's how it looks when you use any of the affected styles, with only the colours varying between styles:

Screen Shot 2022-11-08 at 11 13 50 AM

The colours on the directories for instance are incorrect after running the pspg command with style 17.

okbob commented 1 year ago

What is your platform? What version of ncurses do you use? I cannot to reproduce on my FC36.

Can you check the commit https://github.com/okbob/pspg/commit/f9ff69f0160a1bc16da8dcb9be59ddc6096d855c ?

dark-panda commented 1 year ago

Platform: macOS 12.6 Shell: zsh 5.9 Terminal: iterm2 3.4.16 ncurses version: 6.3

The issue still appears with this commit. I've poked around a bit though, and it appears to be connected with calls to deftheme_rgb, as commenting out the code in that function specifically appears to work, at least in the sense that the issue itself no longer persists, but obviously the theming no longe works.

okbob commented 1 year ago

Please can you try this workaround - https://github.com/okbob/pspg/commit/70d3f388f08fd034e2e8fb5633508b42ba449d0f ?

What is an output, when you run pspg (with this commit) with an argument --version ?

Unfortunately, In terminals I cannot to save current state of colours and I cannot to revert to some state. I don't have macos, so I a not able to reproduce this issue. You can try to use an option --on-exit-reset too, Maybe it can help.

okbob commented 1 year ago

please, can you check last workaround?

dark-panda commented 1 year ago

@okbob Still appears to have the issue. The --on-exit-reset option does indeed clear up the issue, however.

okbob commented 1 year ago

út 22. 11. 2022 v 16:55 odesílatel J @.***> napsal:

@okbob https://github.com/okbob Still appears to have the issue. The --on-exit-reset option does indeed clear up the issue, however.

Unfortunately, I cannot fix it (it is out of my possibilities when reset colors and init colors didn't help) - there is something wrong between your terminal and ncurses. Theoretically the terminal should be returned to initial state after the correct ncurses library ending, but I know about some problems on BSD and maybe macOS has some issues too. Only one known workaround is sending a reset sequence.

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

dark-panda commented 1 year ago

@okbob that --on-exit-reset option works just fine so I'll be using that moving forward, thanks.

okbob commented 1 year ago

@dark-panda I implemented new option --on-exit-sgr0. Can you check it (without --on-exit-reset)? It is in master branch.