[ANN] TerminalPager.jl v0.2.0

Great package. @help alone is worth a lot.

I tried @rafael.guerra example with freeze rows/columns and it did not work for me either.

2 Likes

Thanks!!

Hum, very strange. Can you please try another value like 10?

@Ronis_BR, sorry, misunderstood you on the larger test.
Editing this same post to not overcrowd this thread.

Win10:
Tried a 10 rows x 10 columns freeze and got a table in the REPL that took forever to print the updates and had to kill the REPL.

Linux on Android cellphone:
Tried a 3 rows x 3 columns freeze, and got a few digits of freeze on first column, and 2 rows of freeze at top.

1 Like

I did not understand. Is there a way to post a video or something? Look what I get:

Gravação de Tela 2021-05-23 às 15.13.19

No there is not. TerminalPager.jl does not depend on PrettyTables.

EDIT: By the way, the number in freeze rows and columns are the number of text rows and text columns, and not the number of rows in a matrix, for example.

I just do not have a Windows machine here to test. Maybe we need more tweaking.

The result in Android is expected. Notice that rows and columns are related to text rows and text columns.

OK. I think I understand what I’m supposed to see. freeze would be more useful if it knew about rows and columns. As it is, it is hard to get much out of it with a matrix of floating point numbers without counting the characters.

2 Likes

I don’t know how I did without @help.

Welcome to my startup.jl file.

2 Likes

This feature is mainly designed for packages. For example, in DataFrames, we know the size of the header and the column with the row numbers. Hence, we can call pager with the correct values. It will be extremely difficult to make pager aware of many different types to develop defaults for the freeze parameters.

Nice! I am glad it is being useful :slight_smile:

@Ronis_BR, thanks. Got it now.

The following produced a nice freezing test in both Win10 and linux on Android:

julia> DataFrame(rand(100,100),:auto) |> pager
:f
Freeze rows (0): 4
Freeze columns (0): 6

And then use arrow keys and other keybindings.

NB: it would be helpful to have the package doc that is available at the terminal help, also in the github package documentation.

1 Like

@sijo I just pushed a commit with the REPL modes. @ctkelley if you use a lot @help maybe you will also like!

I really need help to test since it is the first time I created a REPL mode.

After using TerminalPager, we can type | to enter pager mode. I know this can give some problem since | is a valid function, but it is hardly used at the beginning of the command:

(Side note: We already have modes using green, red, and blue. Thus I took magenta :slight_smile:)

In this case, the mode analyze everything that is printed to stdout, including the result of the command. If the output is larger than screen, then the pager is called. Otherwise, it is print normally:

pager> rand(3,3)

pager> rand(100, 100)

In pager mode, you can also type ? to enter in “pager help” mode. In this case, the help of the function is show just like in the mode help?>. The difference is that, if the output does not fit in the screen, the pager is called:

To use this features, we need main branch.

9 Likes

This is what I see.

It is probably a discourse bug, so I wouldn’t worry too much.

That was super quick to create the REPL mode! I think that REPL modes are an underutilised tool in the Julia ecosystem, just my opinion though.

1 Like

That’s very weird… I have no idea why this is happening.

@Ronis_BR, you seem to have provided the wrong picture for the code snippet in your OP. It should have been:

NB: :slight_smile:

But it is exactly what I am seeing in the documentation:

EDIT: Ouch! Never mind, I just noticed that you are mentioning the post here instead of the documentation in Github. Sorry!! @rafael.guerra is 100% right.

2 Likes

@Ronis_BR, yes but not in your OP above?

1 Like

By the way, here is the new REPL mode in action:

https://asciinema.org/a/nuDAsGY2vasRuQboDbBoLctlx

P.S.: How I could live without knowing about Asciinema?! I think the time of my gifs in Discourse has come :smiley:

2 Likes

This is excellent stuff. The REPL mode is perfect to test what should (in my opinion) become the default REPL behavior.

Being used to the less pager, I miss a few shortcuts that I often use for scrolling: space and (Ctrl+)F for one screen forward, (Ctrl+)B for one screen backward, <and>for beginning and end of document (same asgandG` which are already implemented.

One issue I see: it seems the implementation renders the whole data, not just the part necessary to render the screen? It’s fine most of the time but I have problems with very large arrays: On my underpowered laptop, displaying rand(2000, 2000) takes ~13 seconds, and scrolling is laggy (for example, keeping the “right arrow” key pressed for 2 seconds, it starts to scroll slowly and keeps scrolling for a while after I release the key).

A feature request (maybe there already but couldn’t find it): a nice feature of the normal REPL is that when displaying a matrix too large for the screen, the four corners are shown. It doesn’t make sense to do that in pager mode, but it would be nice to have a shortcut like g/G but for the horizontal axis, to quickly check the horizontal end, and come back.

I guess I should start using your issue tracker on GitHub :slight_smile:

Just one question: I want to make this my default. Do you know how I can enable it from the startup.jl?

1 Like

Put this line in your startup.jl

using TerminalPager

That’s it. I’m not clear on what you mean by default however.

1 Like

Thanks!! However we have a long, long way until I am confident to propose to merge it to stdlib :slight_smile:

The space should be working… anyway, it is very easy to change the key bindings, we just need to discuss the best options for everyone. Can you please open an issue listing the key bindings you want to be the default?

It cannot lazy load anything. In fact, it is a major problem that will require a lot of work.

I was discussing in slack with @pdeffebach. It is not feasible to add support for numerous object types inside TerminalPager.jl. What we really need to do is to create some kind of interface just like we have in Tables.jl. Each type must register itself in this interface and provide API functions like render_chunk or something. Hence, the pager can call the chunks separately to lazy load everything.

This lazy load API will require a lot of work…

You can go to the beginning and end of the line by typing 0 and $ just like in Vim. The same functionality is also mapped to ALT + left and ALT + right, but some terminals hijack those keystrokes.

You can load TerminalPager.jl as @ctkelley said, but I have no idea how to change the REPL mode at startup :frowning:

3 Likes