Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unecessary usage of pager #94

Open
FreddieOliveira opened this issue Aug 19, 2020 · 2 comments
Open

Unecessary usage of pager #94

FreddieOliveira opened this issue Aug 19, 2020 · 2 comments

Comments

@FreddieOliveira
Copy link

Description

Sometimes, even when the command output fits on the screen, it is displayed by the pager.

Steps to reproduce

  1. Open chinook db in litecli and enter the pragma table_info('albums') command

Expected behavior

The output should be displayed without being handled by the pager, since it fits on the screen

Actual behavior

The output is displayed on fullscreen by the pager program

@amjith
Copy link
Member

amjith commented Aug 22, 2020

I'm not able to reproduce this, can you tell me what pager you're using?

You can check the env var $PAGER or $LESS in your terminal.

I presume you're using linux, if you're on windows, you might want to install less.exe and use that as your pager.

@FreddieOliveira
Copy link
Author

FreddieOliveira commented Aug 22, 2020

Hey @amjith, thanks for the response. I'm on Linux using less as pager. What's causing the problem is the fact that this line

if len(line) > size.columns or i > (size.rows - margin):

in the output method is comparing the screen width with each formated line of the output without ripping the formatting of. What I mean is, when calculating the length of a line which has colorful text, it takes the escape sequences as if it was part of the line. For example, the header of the output select * from media_types, is considered to be

'| \x1b[38;5;47;01mMediaTypeId\x1b[39;00m | \x1b[38;5;47;01mName\x1b[39;00m                        |'

instead of simply

| MediaTypeId | Name                        |

To check that, add print(bytearray(line, 'utf-8')) right after the for loop, run the program and run a command with colorful output:

Screenshot_20200822-182246_Termux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants