Skip to content

Unecessary usage of pager #94

Open

Description

@FreddieOliveira

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

Activity

  1. amjith commented on Aug 22, 2020

    @amjith
    Member

    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.

  2. FreddieOliveira commented on Aug 22, 2020

    @FreddieOliveira
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions