[ANN] TerminalPager v0.1.0

Hi!

Last week, I announced the package TerminalPager.jl here. It is targeting a missing feature that would make analysis of data and documentation reading a little bit easier. If you have to print something on the screen larger than the terminal (a table for example), then it will be cropped. Algorithms to crop tables are very difficult to implement and you will always miss something. Hence, TerminalPager.jl is trying to be an implementation of Linux’s less command inside Julia.

I just released v0.1.0 that is the first “usable” version (it should be available within some minutes). In this new release, we have the following new features:

We can now freeze rows and columns (as requested by @rafael.guerra and @jacobadenbaum). The number of frozen columns and rows can be specified as a keyword when calling pager of by typing f and inputing new values:

Gravação de Tela 2021-04-23 às 21.19.06

There is now a searching mechanism that can be called by typing / (just as in Vim / Neovim, the best editor out there :sweat_smile:). Then, you write a regex and every match will be highlighted. The first one is active, and the active match can be changed using n (forward) or N (backward). When the match is changed, the display moves to show it.

Gravação de Tela 2021-04-23 às 21.20.19

It turns out that the help screen of TerminalPager.jl was not being handle as the input string, leading to the same cropping we want to solve by creating the package :smiley: This is fixed now, help is printed using the same algorithm as the input string:

I defined actions and those actions are related to key codes. Hence, you can change any key code or add new ones using the function set_keybinding.

If you want to try:

julia> ]add TerminalPager

julia> using TerminalPager

julia> rand(100, 100) |> pager

My next step will be creating tests to increase the coverage of the package and the documentation. I appreciate help to find bugs, because there will be a lot :smiley: Notice that this version are not very well debugged to work in edge cases (like, very small screens, with wrong input values, strange ANSI escape sequences, etc.). Hence, expect some problems.

I also was not able to test it in Windows (only Linux and macOS). I appreciate feedback and help here, it will be difficult to make everything run smoothly in different platforms.

48 Likes

Awesome work @Ronis_BR ! Examples like yourself continue to show that the julia community is a great public good :smiley:

1 Like

Thanks for the kind words! The fact that programming in Julia is so enjoyable (you can do a lot with so little effort) helps :smiley:

4 Likes

A few days ago I was considering opening an issue about searching functionalities, but then decided to postpone it to the weekend. I see you’re always one step ahead. This is awesome! I really hope this could become the default pager in the future!

2 Likes

Thanks! :slight_smile: Actually the first thing that came to my mind when creating this package was the search functionality. When I analyze the AOCS telemetry of the satellite Amazonia 1, I get a huge table describing every important event. Hence, to search for a particular thing, I needed to save this table to a file and use Neovim to search. This will save me a lot of time.

Now I need to polish somethings before declaring a “stable” version. When you highlight highlighted text in terminal, there is some intricate things like:

Captura de Tela 2021-04-23 às 22.26.00

I needed to save and track the text highlight before the match and see if I need to apply it again when the match is finished. This gets even more difficult when this is cropped due to the pager view. Conclusion: there is probably countless bugs in the current version :smiley:

EDIT: I could use some help from a bash-expert regarding best practices with those escape sequences.

2 Likes

Ok, it isn’t named “less”, so dissapointed …
:wink:

Of course it’s awesome anyways! Thanks a lot! Incredible fast development, how many people are you?

1 Like

Me too! Unfortunately we were beaten in the name selection :cry:

Thanks! We had a holiday here in Brazil this week that helped a lot :smiley:

1 Like