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

Feature Request: Move single column to the left & right #192

Closed muhmud closed 2 years ago

muhmud commented 2 years ago

It would be great to be able to move a single column to the left and right.

I would propose using Ctrl + h / KEY_LEFT and Ctrl + l / KEY_RIGHT for these movements.

okbob commented 2 years ago

po 18. 10. 2021 v 14:54 odesílatel Muhmud Ahmad @.***> napsal:

It would be great to be able to move a single column to the left and right.

I would propose using Ctrl + h / KEY_LEFT and Ctrl + l / KEY_RIGHT for these movements.

Unfortunately, this is not possible. pspg is just a pager - it can draw content, but it cannot switch columns. Anything that can break formatting (table borders) is not possible in pspg.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/okbob/pspg/issues/192, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEFO4Y4UUGES2VQDTVHQITUHQKINANCNFSM5GGSODBQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

muhmud commented 2 years ago

I think maybe I didn't state this clearly: I mean it should move one terminal character to the left & right, regardless of how columns are drawn.

okbob commented 2 years ago

po 18. 10. 2021 v 15:38 odesílatel Muhmud Ahmad @.***> napsal:

I think maybe I didn't state this clearly: I mean it should move one terminal character to the left & right, regardless of how columns are drawn.

I am sorry, I don't understand. Can you draw pictures - before and after operation?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/okbob/pspg/issues/192#issuecomment-945777311, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEFO42ERE3M7WU2IUYYQYTUHQPMNANCNFSM5GGSODBQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

muhmud commented 2 years ago

Sure, can do, however, if you look at the man page for less, it's basically the same functionality as the [-# shift] option with a value of 1, but only applied when the Ctrl key is used.

What I would like is to keep the existing functionality of h and l as it is, but if Ctrl h or Ctrl l is used, then only move by a single column position.

If it still doesn't make sense, please let me know & I'll do an ASCII diagram

muhmud commented 2 years ago

Take a look at the attached file from sqlcmd (MSSQL Server) for an example of where I'm having issues. The last column TABLE_TYPE can be difficult to catch, though it seems better in less.

It would also be great if pspg could somehow clean up the output to remove the wasted space, though I suspect this might be difficult...

mssql.txt

okbob commented 2 years ago

I implemented one char horizontal scrolling controlled by ^left and ^right. I cannot to use ^h and ^l, because ^l is used for different purpose already. See commit 945d783083183f50be47e3c67024a4e7dbc42091

Unfortunately pspg cannot to reformat original document. It is just pager. If your client can print data in csv format, then pspg can read data in csv format and can do internal formatting to table. It was used as workaround for older slow table formatting in pgcli (already fixed), or it is used for sqlite.

muhmud commented 2 years ago

Thanks @okbob , just tried it out & it works great, though only in xterm. I normally use st and none of the Ctrl-based shortcuts work for me. I'll have to try and sit down with it to figure out why, as the reported escape codes are the same in both.

I worked around the formatting issue by preprocessing the output in perl before passing it to pspg, and making it look like it came from postgres, which works pretty well. I didn't know about the CSV functionality, that's pretty useful, thanks for that :+1:

okbob commented 2 years ago

Maybe terminfo for st terminal is not good, or maybe your TERM specification has some issue.

Unfortunately - escape sequences and related codes can be different - pspg uses ncurses terminfo database, and when the configuration of TERM is not correct, or data in terminfo database is not current, then it can be broken.

muhmud commented 2 years ago

Yep, I think it's something like that; we can close this issue now if you like

okbob commented 2 years ago

ok :)