Robpol86 / terminaltables

Project no longer maintained.
https://github.com/matthewdeanmartin/terminaltables
MIT License
689 stars 69 forks source link

pager support #59

Open anarcat opened 6 years ago

anarcat commented 6 years ago

A bug report (#891381) was filed against the undertime Debian package, which uses this library, because it doesn't support piping the SingleTable through less or similar pagers.

I can confirm that terminaltables seriously garbles the terminal when piped into a pager:

[1015]anarcat@curie:~$ undertime | less 
qqqqqqqk
  EST  
qqqqqqqu
 00:00 
 01:00 
 02:00 
 03:00 
 04:00 
 05:00 
 06:00 
 07:00 
 08:00 
 09:00 
 10:00 
 11:00 
 12:00 
 13:00 
 13:12 
 14:00 
 15:00 
 16:00 
 17:00 
 18:00 
 19:00 
 20:00 
 21:00 
 22:00 
 23:00 
└───────┘
[1016]▒┼▒⎼␌▒├@␌┤⎼␋␊:·$ 

This requires a reset to get fixed.

One suggested fix was to send "proper" unicode or ANSI escape sequences to avoid freaking out pages like less. There are three pending pull requests to implement the former: #42, #47 (which supersedes #42) and #50. I haven't tested if those fix the issue, but it would be great to have a solution for this implemented somehow, so I figured I would document the issue to facilitate the tracking across projects.

anarcat commented 6 years ago

I just noticed that the DoubleTable style outputs unicode in Linux, so I have switched to that now, but maybe the same should be done for the SingleTable style?