[ANN] Announcing TerminalPager.jl

To echo what @giordano said,

I would encourage using the word pager instead of less, since this isn’t actually using less and the less name is an obscure Unix joke (a backwards version of more) unfamiliar to some programmers.

5 Likes

not gonna lie, my heart raced when I causally clicked on this post and saw my name.

This looks great! thanks for all the work on PrettyTables and this!

4 Likes

Yes, you are right. Maybe crop = :pager then.

Tried in Win10 REPL terminal but do not manage to step-out by 10 columns when using SHIFT + left/right arrows.

IMHO and if it is not asking too much :slight_smile: , this pager would be even more useful if the row numbers and column numbers would always show up (like the freeze function in MS Excel).

2 Likes

Thanks for your feedback! And sorry for not referencing you properly, I did not find your name in the list here on Discourse :slight_smile:

1 Like

This is difficult because it depends on the type of data you are printing.

1 Like

Though I would say = TerminalPager.pager or = TerminalPager.Pager is better than = :pager – functions (or objects) are better than symbols. Because then you don’t need a case analysis inside, you can just call whatever function was handed to you.

I mean, this would be inside PrettyTables. You have an option crop = :none, crop = :vertical, crop = :horizontal, crop = :both, and I would like to add crop = :pager.

1 Like

The crop parameter seems like it really wants to be a function object (\text{terminal size}, \text{string}) \to \text{string}, which seems different from what this pager is doing.

1 Like

No, it is just an option to switch between cropping mechanism in pretty_table. It cannot be an external function due to performance. PrettyTables avoid rendering lines and columns that won’t be shown.

I haven’t benchmarked it so I’ll pipe down :slight_smile:

1 Like

would it make sense to have this as default for Julia doc strings in REPL? I find long docstring is hard to read sometimes, also FYI IPython has this as builtin feature I think.

5 Likes

It makes sense! However, to make this available in Julia by default, we need a lot of tests! I count on the community to help me stabilize everything and find bugs :slight_smile:

Question: pager seems not an usual word. I think we can export it so that people can use it more easily (typing less):

julia> @doc(pretty_tables) |> pager

What do you think?

6 Likes

Any way to change the keybindings? My terminal emulator steals all Shift + arrows sequences, so I can’t ever move quicker than one column/row at the time

3 Likes

One thing that would be really nice would be to show the column names when scrolling down through a large table. I guess you could do that if there was an easy way to freeze the first few rows of output (for a prettytables printout of a dataframe, it would be 4?)

2 Likes

This is one of those packages where I think to myself, “This is such a genius idea! Why isn’t this already in base?” :smiley:

Kudos on a great package - looking forward to using it!

4 Likes

So this is glorious. Far exceeded my expectation that someone wrote a hook between a pager and a terminal window. I mean… I’d be happy to have either, but seeing this - it’s very useful.

Edit - if you don’t know what a pager is ask a parent or google.

1 Like

There was this recently merged PR which has some overlap with this package https://github.com/JuliaLang/julia/pull/38956 (though horizontal scrolling might not be in its scope; but display of long documentation certainly could be).

3 Likes

Unfortunately they are hard-coded in this version, but it can be easily done. I will think about a good way to make this configurable.

Hum, it is very easy to freeze lines and columns when printing. In fact, this would also solve the request of @rafael.guerra. However, the user would need to select how many lines and columns they want to freeze, it cannot be automatically inferred. I will try to do that :slight_smile:

Thank you very much :slight_smile: !

Thanks! Yeah, I am afraid I am from this generation that actually knows what a pager is… I am becoming somewhat old I think :smiley:

Nice! I did not know about that, thanks for pointing this out.

2 Likes