ronisbr / TerminalPager.jl

Pure Julia implementation of the command less
MIT License
116 stars 8 forks source link

`pager?>` always pages #16

Closed knuesel closed 3 years ago

knuesel commented 3 years ago

Looking at documentation with ? while in pager mode shows a pager screen even if the documentation is short. For example, pager?> sin fills the screen with empty lines at the bottom. I think it would be less disruptive to show short documentation inline, same as when printing small arrays in pager> mode.

ronisbr commented 3 years ago

Hi @knuesel !

Hum, ok! I thought it would be better for help mode to always show the pager. I will modify to have the same behavior of the pager mode.

knuesel commented 3 years ago

Thanks! It's just my opinion, but it seems good to have the same behavior.

ronisbr commented 3 years ago

Hi @knuesel

Sorry for the huge delay! The problem was that I was counting invisible characters like the color escape sequences. I pushed a commit that should address this problem. Can you please test?

knuesel commented 3 years ago

@ronisbr are you sure the invisible characters thing was related to this issue? In any case, the pager?> mode is working as expected now so thanks for that :)

ronisbr commented 3 years ago

Yes, they was! Look the output of the first line of the help for the function sin:

search: \e[0m\e[1ms\e[22m\e[0m\e[1mi\e[22m\e[0m\e[1mn\e[22m \e[0m\e[1ms\e[22m\e[0m\e[1mi\e[22m\e[0m\e[1mn\e[22mh \e[0m\e[1ms\e[22m\e[0m\e[1mi\e[22m\e[0m\e[1mn\e[22md \e[0m\e[1ms\e[22m\e[0m\e[1mi\e[22m\e[0m\e[1mn\e[22mc \e[0m\e[1ms\e[22m\e[0m\e[1mi\e[22m\e[0m\e[1mn\e[22mpi \e[0m\e[1ms\e[22m\e[0m\e[1mi\e[22m\e[0m\e[1mn\e[22mcos \e[0m\e[1ms\e[22m\e[0m\e[1mi\e[22m\e[0m\e[1mn\e[22mcosd \e[0m\e[1ms\e[22m\e[0m\e[1mi\e[22m\e[0m\e[1mn\e[22mcospi a\e[0m\e[1ms\e[22m\e[0m\e[1mi\e[22m\e[0m\e[1mn\e[22m u\e[0m\e[1ms\e[22m\e[0m\e[1mi\e[22m\e[0m\e[1mn\e[22mg i\e[0m\e[1ms\e[22m\e[0m\e[1mi\e[22m\e[0m\e[1mn\e[22mf a\e[0m\e[1ms\e[22m\e[0m\e[1mi\e[22m\e[0m\e[1mn\e[22mh

I was using textwidth to obtain the width and, if it is is larger than the screen, the pager is called. In this case, I was getting 439, meaning that if your display is not 439 characters wide it will always call the pager. We were not seeing this in normal commands because hardly there is this number of invisible characters.