Giter Club home page Giter Club logo

terminalpager.jl's People

Contributors

bjarthur avatar carstenbauer avatar gregplowman avatar pohzipohzi avatar ronisbr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

terminalpager.jl's Issues

interfacing with `AbbreviatedStackTraces`

AbbreviatedStackTraces.jl is a package which essentially shortens stack traces to "your own" code, relying on the (often correct) assumption that you are doing something wrong, not a bunch of julia internals.

Taking the example from their docs, if I am using AbbreviatedStackTraces and type sum([]), I get an easily readable stack trace:

julia> using AbbreviatedStackTraces
[ Info: Precompiling AbbreviatedStackTraces [ac637c84-cc71-43bf-9c33-c1b4316be3d4]
[ Info: Skipping precompilation since __precompile__(false). Importing AbbreviatedStackTraces [ac637c84-cc71-43bf-9c33-c1b4316be3d4].

julia> sum([])
ERROR: MethodError: no method matching zero(::Type{Any})

Closest candidates are:
  zero(::Type{Union{Missing, T}}) where T
   @ Base missing.jl:105
  zero(::Union{Type{P}, P}) where P<:Period
   @ Dates ~/.julia/juliaup/julia-1.9.3+0.aarch64.apple.darwin14/share/julia/stdlib/v1.9/Dates/src/periods.jl:51
  zero(::FillArrays.Zeros{T, N}) where {T, N}
   @ FillArrays ~/.julia/packages/FillArrays/FwMoZ/src/FillArrays.jl:591
  ...

Stacktrace:
  [1-12] โ‹ฎ internal
       @ Base, Unknown
    [13] sum(a::Vector{Any})
       @ Base ./reducedim.jl:994
    [14] top-level scope
       @ REPL[137]:1
Use `err` to retrieve the full stack trace.

If I am instead in pager> mode (or, indeed, if I am not using AbbreviatedStackTraces) I get a really long error message!

expand really long message!!
pager> sum([])
ERROR: MethodError: no method matching zero(::Type{Any})

Closest candidates are:
  zero(::Type{Union{Missing, T}}) where T
   @ Base missing.jl:105
  zero(::Union{Type{P}, P}) where P<:Period
   @ Dates ~/.julia/juliaup/julia-1.9.3+0.aarch64.apple.darwin14/share/julia/stdlib/v1.9/Dates/src/periods.jl:51
  zero(::FillArrays.Zeros{T, N}) where {T, N}
   @ FillArrays ~/.julia/packages/FillArrays/FwMoZ/src/FillArrays.jl:591
  ...

Stacktrace:
  [1] zero(#unused#::Type{Any})
    @ Base ./missing.jl:106
  [2] reduce_empty(#unused#::typeof(+), #unused#::Type{Any})
    @ Base ./reduce.jl:338
  [3] reduce_empty(#unused#::typeof(Base.add_sum), #unused#::Type{Any})
    @ Base ./reduce.jl:347
  [4] mapreduce_empty(#unused#::typeof(identity), op::Function, T::Type)
    @ Base ./reduce.jl:367
  [5] reduce_empty(op::Base.MappingRF{typeof(identity), typeof(Base.add_sum)}, #unused#::Type{Any})
    @ Base ./reduce.jl:356
  [6] reduce_empty_iter
    @ ./reduce.jl:379 [inlined]
  [7] mapreduce_empty_iter(f::Function, op::Function, itr::Vector{Any}, ItrEltype::Base.HasEltype)
    @ Base ./reduce.jl:375
  [8] _mapreduce(f::typeof(identity), op::typeof(Base.add_sum), #unused#::IndexLinear, A::Vector{Any})
    @ Base ./reduce.jl:427
  [9] _mapreduce_dim
    @ ./reducedim.jl:365 [inlined]
 [10] mapreduce
    @ ./reducedim.jl:357 [inlined]
 [11] _sum
    @ ./reducedim.jl:999 [inlined]
 [12] _sum
    @ ./reducedim.jl:998 [inlined]
 [13] sum(a::Vector{Any})
    @ Base ./reducedim.jl:994
 [14] top-level scope
    @ none:1
 [15] eval
    @ ./boot.jl:370 [inlined]
 [16] _tp_mode_do_cmd(repl::REPL.LineEditREPL, input::String)
    @ TerminalPager ~/.julia/packages/TerminalPager/MpAXn/src/repl.jl:243
 [17] (::TerminalPager.var"#11#14"{REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::IOBuffer, ok::Bool)
    @ TerminalPager ~/.julia/packages/TerminalPager/MpAXn/src/repl.jl:41
 [18] #invokelatest#2
    @ ./essentials.jl:819 [inlined]
 [19] invokelatest
    @ ./essentials.jl:816 [inlined]
 [20] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.9.3+0.aarch64.apple.darwin14/share/julia/stdlib/v1.9/REPL/src/LineEdit.jl:2647
 [21] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL ~/.julia/juliaup/julia-1.9.3+0.aarch64.apple.darwin14/share/julia/stdlib/v1.9/REPL/src/REPL.jl:1300
 [22] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ./task.jl:514

[Feature] Easier `@doc` Macro or Alternative

Hey @ronisbr!

Now that I have started using TerminalPager frequently, I had one feature request/idea that I am not sure how much work would be to do on your end. A big use that I have right now for the package is looking at documentation as it tends to clutter my REPL session. However, with your handy tool and the docs macro, this is no longer a problem!

However, what I was wondering if rather than having to write syntax like this every time:

@doc(println) |> pager

Could you instead make it something more like this:

@doc println

Where the macro implicitly knows to call the pager command? Thanks for the great work! Use it everyday. :)

Pager crashes when searching for non-existent pattern under certain conditions

When searching for a pattern that does not appear in the pager output, after having just searched for a pattern, pager crashes.

To replicate the issue, construct a random matrix and pipe into pager:

rand(100, 100) |> pager

Once in pager mode, search for a pattern that you see (e.g. / 0.7). All instances of that pattern will be highlighted, and something like (match 1 of 1464) 41% will appear on the bottom right. If you hit escape at this point, there is no issue. However, if you search for another pattern and that pattern does not exist (e.g. /.123456), while the search results from the previous search are still shown, pager will crash with the following stacktrace:

ERROR: BoundsError: attempt to access 0-element Vector{Tuple{Int64, Int64, Int64}} at index [1]
Stacktrace:
  [1] getindex
    @ ./array.jl:801 [inlined]
  [2] _move_view_to_match!
    @ ~/.julia/packages/TerminalPager/C06ZN/src/search.jl:109 [inlined]
  [3] _pager_event_process!(pagerd::TerminalPager.Pager)
    @ TerminalPager ~/.julia/packages/TerminalPager/C06ZN/src/pager.jl:313
  [4] _pager!(term::REPL.Terminals.TTYTerminal, str::String; freeze_columns::Int64, freeze_rows::Int64, change_freeze::Bool, hashelp::Bool)
    @ TerminalPager ~/.julia/packages/TerminalPager/C06ZN/src/pager.jl:130
  [5] _pager!
    @ ~/.julia/packages/TerminalPager/C06ZN/src/pager.jl:80 [inlined]
  [6] _pager(str::String; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ TerminalPager ~/.julia/packages/TerminalPager/C06ZN/src/pager.jl:59
  [7] _pager
    @ ~/.julia/packages/TerminalPager/C06ZN/src/pager.jl:53 [inlined]
  [8] #pager#28
    @ ~/.julia/packages/TerminalPager/C06ZN/src/TerminalPager.jl:49 [inlined]
  [9] pager
    @ ~/.julia/packages/TerminalPager/C06ZN/src/TerminalPager.jl:49 [inlined]
 [10] #pager#27
    @ ~/.julia/packages/TerminalPager/C06ZN/src/TerminalPager.jl:46 [inlined]
 [11] pager
    @ ~/.julia/packages/TerminalPager/C06ZN/src/TerminalPager.jl:45 [inlined]
 [12] |>(x::Matrix{Float64}, f::typeof(pager))
    @ Base ./operators.jl:858
 [13] top-level scope
    @ REPL[6]:1 
julia> versioninfo()
Julia Version 1.6.0
Commit f9720dc2eb (2021-03-24 12:55 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: AMD Ryzen 7 PRO 4750U with Radeon Graphics
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, znver2)

[Feature] Vi-Like Key Navigation?

This is AMAZING! I think I will start using this tool in my daily workflow. Great work @ronisbr!

Just a suggestion, but would it be possible to add in vi-like keybinds for navigating? Alongside the arrow keys working, it would be great to have h, j, k, l support and things like Ctrl + d or Ctrl + u for chunked navigation. Is this a good idea or not so much? Happy to look into contributing on that aspect. Thanks!

`pager?>` always pages

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.

LoadError: cannot assign variables in other modules

I'm getting an error when compiling TerminalPager v0.5.0 on Julia v1.6.7.

I think it might be related to resetting Base.stdin in precompilation.jl

[ Info: Precompiling TerminalPager [0c614874-6106-40ed-a7c2-2f1cd0bff883]
ERROR: LoadError: LoadError: cannot assign variables in other modules
Stacktrace:
  [1] setproperty!(x::Module, f::Symbol, v::Base.PipeEndpoint)
    @ Base .\Base.jl:27
  [2] macro expansion
    @ C:\Users\plowman\.julia\packages\TerminalPager\MpAXn\src\precompilation.jl:69 [inlined]
  [3] top-level scope
    @ C:\Users\plowman\.julia\packages\PrecompileTools\kmH5L\src\workloads.jl:140
  [4] include(mod::Module, _path::String)
    @ Base .\Base.jl:384
  [5] include(x::String)
    @ TerminalPager C:\Users\plowman\.julia\packages\TerminalPager\MpAXn\src\TerminalPager.jl:1
  [6] top-level scope
    @ C:\Users\plowman\.julia\packages\TerminalPager\MpAXn\src\TerminalPager.jl:154
  [7] include
    @ .\Base.jl:384 [inlined]
  [8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
    @ Base .\loading.jl:1235
  [9] top-level scope
    @ none:1
 [10] eval
    @ .\boot.jl:360 [inlined]
 [11] eval(x::Expr)
    @ Base.MainInclude .\client.jl:446
 [12] top-level scope
    @ none:1
in expression starting at C:\Users\plowman\.julia\packages\TerminalPager\MpAXn\src\precompilation.jl:12
in expression starting at C:\Users\plowman\.julia\packages\TerminalPager\MpAXn\src\TerminalPager.jl:1
ERROR: Failed to precompile TerminalPager [0c614874-6106-40ed-a7c2-2f1cd0bff883] to C:\Users\plowman\.julia\compiled\v1.6\TerminalPager\jl_873E.tmp.
Stacktrace:
 [1] error(s::String)
   @ Base .\error.jl:33
 [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::Base.TTY, internal_stdout::Base.TTY, ignore_loaded_modules::Bool)
   @ Base .\loading.jl:1385
 [3] compilecache(pkg::Base.PkgId, path::String)
   @ Base .\loading.jl:1329
 [4] _require(pkg::Base.PkgId)
   @ Base .\loading.jl:1043
 [5] require(uuidkey::Base.PkgId)
   @ Base .\loading.jl:936
 [6] require(into::Module, mod::Symbol)
   @ Base .\loading.jl:923

add an option to have custom recipes to pager

This is a general request but what I specifically mean is that if e.g. you do:

DataFrame(rand(100, 100), :auto) |> pager

that it would be possible that recipe would be registered by DataFrames.jl that would by default freeze the "Row" columns and header appropriately. The key thing here is that this recipe would need to be able to properly calculate the number of rows/columns to freeze (currently you have manually count e.g. the width of "Row" column to properly freeze it)

pager?> mode is limited to 80 columns, unlike help?> mode

Using TerminalPager 0.3.1 with Julia 1.8.2, the pager?> mode limits the output to 80 columns, instead of taking the full terminal width as in the built-in help?> mode. See below for an example. Of course, one reason for using a pager is to have less scrollback in one's terminal, so it would be nice for pager?> to give the same behavior in this case.

pager?> run
search: run trunc truncate round rounding RoundUp baltrunc RoundDown RoundToZero

  run(command, args...; wait::Bool = true)


  Run a command object, constructed with backticks (see the Running External
  Programs section in the manual). Throws an error if anything goes wrong,
  including the process exiting with a non-zero status (when wait is true).

  The args... allow you to pass through file descriptors to the command, and
  are ordered like regular unix file descriptors (eg stdin, stdout, stderr,
  FD(3), FD(4)...).

  If wait is false, the process runs asynchronously. You can later wait for it
  and check its exit status by calling success on the returned process object.

  When wait is false, the process' I/O streams are directed to devnull. When
  wait is true, I/O streams are shared with the parent process. Use pipeline
  to control I/O redirection.

help?> run
search: run trunc truncate round rounding RoundUp baltrunc RoundDown RoundToZero RoundingMode RoundNearest

  run(command, args...; wait::Bool = true)


  Run a command object, constructed with backticks (see the Running External Programs section in the manual). Throws
  an error if anything goes wrong, including the process exiting with a non-zero status (when wait is true).

  The args... allow you to pass through file descriptors to the command, and are ordered like regular unix file
  descriptors (eg stdin, stdout, stderr, FD(3), FD(4)...).

  If wait is false, the process runs asynchronously. You can later wait for it and check its exit status by calling
  success on the returned process object.

  When wait is false, the process' I/O streams are directed to devnull. When wait is true, I/O streams are shared

Last line is not showing

Thank you for the great work! ๐Ÿ™Œ๐Ÿฝ

I noticed that the last line is not showing when reaching the end of the rows. Is this expected?

To reproduce:

using DataFrames
df = DataFrame(x = rand(120), y = rand(1:100, 120))
df |> pager

or

data = [rand(120) rand(1:100, 120)]
data |> pager

Support Option key on macOS

Great package!

The help says that ALT + โ†’/โ† can be used to jump to the last/first column. Would be great if the macOS pendant (OPTION key) was also supported, since there is no ALT key on macOS.

@dpr DataFrame vs @dpr CSV.File

Thanks for this long needed feature.

Probably it is my expectations that are at fault here, but I expected to find that if docs were available via 'help?>' then I should be able to swap 'help?>' for '@dpr'. Specifically,

?help> DataFrames # output as expected
@dpr DataFrames # paged as expected

?help> CSV.File # output as expected
However,

julia> @dpr CSV.File 
ERROR: UndefVarError: CSV not defined
Stacktrace:
 [1] top-level scope
   @ ~/.julia/packages/TerminalPager/QD9o8/src/helpers.jl:25

@v1.6) pkg> st TerminalPager
Status ~/.julia/environments/v1.6/Project.toml
[0c614874] TerminalPager v0.2.1

Julia Version 1.6.0
Commit f9720dc2eb (2021-03-24 12:55 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin19.6.0)
CPU: Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, skylake)

Possible to Tag a New Release

Hey @ronisbr !

Would it be possible to tag a new release soon?
Currently, the release does not allow one to do:

julia> @help Module.function

to get the docstrings and returns the error seen in: #17
Thanks!

[FR] Implement keybinding callbacks

I would like to do some other computations when the user moves or triggers other keybindings. Is it possible to expose the pager events so as to customize them?

Use the "alternate screen" to keep the REPL clean

When I use the pager and exit it, whichever part of the paged text was on the screen when I pressed q remains there by itself, making the REPL output look weird and cluttered with this partial output.

It would be nice if TerminalPager used (or allowed as an option) the alternate screen like less does. Then, the pager output is in its own alternate buffer, and exiting the pager leaves us back in the original clean REPL.

This is most useful when using @help, since it's easy to re-access the help text - so the help text being there in REPL output history doesn't serve much purpose.

With pager called directly, eg. function_call() |> pager, it makes more sense to leave it in the output (i.e. not use the alternate screen), since the user might not want to run function_call() again and again.

So a good default for this would be to have it as a default-off option to pager, pager(...; use_alt_screen = false), and then turn it on by default in @help (pager(@doc($f); use_alt_screen = true)).

abbreviated output for DimensionalData

is there a show method or the like that can be defined to customize the output for a specific type to make this work better?

julia> using DimensionalData

julia> A = rand(X(50), Y(10.0:40.0))
50ร—31 DimArray{Float64,2} with dimensions: 
  X,
  Y Sampled{Float64} 10.0:1.0:40.0 ForwardOrdered Regular Points
 10.0         11.0        12.0         13.0         โ€ฆ  38.0        39.0        40.0
  0.414429     0.967962    0.720678     0.31398         0.664142    0.178525    0.198205
  0.451637     0.736537    0.936694     0.370182        0.23804     0.269602    0.80307
  0.84869      0.173599    0.646813     0.769767        0.78232     0.234421    0.492158
  0.782584     0.73037     0.0140345    0.716155        0.0134053   0.762526    0.937726
  0.00782866   0.319108    0.0899623    0.925041    โ€ฆ   0.100216    0.955839    0.0219956
  0.966206     0.0576132   0.889478     0.811982        0.910926    0.732233    0.543933
  0.434441     0.413684    0.825703     0.92534         0.245011    0.532117    0.916558
  0.837677     0.748269    0.00288684   0.788718        0.240337    0.0597967   0.053107
  0.0928123    0.338985    0.770077     0.875858        0.808507    0.449472    0.698103
  0.443271     0.699966    0.390675     0.114863    โ€ฆ   0.509491    0.980215    0.015727
  0.707604     0.761463    0.12522      0.987492        0.180278    0.556036    0.879508
  0.315138     0.146992    0.631747     0.364538        0.701736    0.490354    0.212169
  0.960195     0.319206    0.556295     0.478452        0.853045    0.786151    0.704802
  0.722219     0.891343    0.742402     0.386098        0.710249    0.130277    0.281468
  โ‹ฎ                                                 โ‹ฑ                           โ‹ฎ
  0.453267     0.264981    0.101285     0.100797        0.916495    0.28729     0.0962622
  0.99934      0.385766    0.501177     0.278182        0.931742    0.364607    0.953542
  0.753522     0.228334    0.816532     0.49223         0.84888     0.278374    0.936007
  0.813674     0.846556    0.209538     0.053302    โ€ฆ   0.795106    0.440521    0.674403
  0.907359     0.742182    0.36885      0.67759         0.806291    0.713175    0.487266
  0.381995     0.566324    0.67409      0.0376533       0.232274    0.378529    0.644125
  0.175485     0.598527    0.98843      0.152351        0.688907    0.135789    0.798922
  0.347392     0.743278    0.919895     0.739641        0.670573    0.697128    0.827335
  0.189002     0.142781    0.812652     0.728756    โ€ฆ   0.175437    0.219649    0.0820538
  0.654293     0.322825    0.850235     0.212976        0.660898    0.863237    0.117781
  0.685628     0.535986    0.183944     0.190564        0.180055    0.93551     0.560684
  0.86256      0.474736    0.721193     0.703336        0.10152     0.184241    0.713716
  0.112952     0.509283    0.0895051    0.00164909      0.28468     0.47871     0.818351
  0.0483211    0.663536    0.280515     0.90239     โ€ฆ   0.997375    0.336445    0.64751

julia> using TerminalPager

julia> A |> pager

50ร—31 DimArray{Float64,2} with dimensions: 
  X,
  Y Sampled{Float64} 10.0:1.0:40.0 ForwardOrdered Regular Points
 10.0         11.0       12.0        โ€ฆ  38.0        39.0       40.0
  0.414429     0.967962   0.720678       0.664142    0.178525   0.198205
  0.451637     0.736537   0.936694       0.23804     0.269602   0.80307
  0.84869      0.173599   0.646813       0.78232     0.234421   0.492158
  0.782584     0.73037    0.0140345      0.0134053   0.762526   0.937726
  0.00782866   0.319108   0.0899623  โ€ฆ   0.100216    0.955839   0.0219956
  โ‹ฎ                                  โ‹ฑ                          โ‹ฎ
  0.189002     0.142781   0.812652       0.175437    0.219649   0.0820538
  0.654293     0.322825   0.850235       0.660898    0.863237   0.117781
  0.685628     0.535986   0.183944       0.180055    0.93551    0.560684
  0.86256      0.474736   0.721193   โ€ฆ   0.10152     0.184241   0.713716
  0.112952     0.509283   0.0895051      0.28468     0.47871    0.818351
  0.0483211    0.663536   0.280515       0.997375    0.336445   0.64751
























:                                                            (โ†‘ โ†“ โ† โ†’:move, ?:help, q:quit) 100%

this is on julia v1.10 with DimensionalData v0.25.8 and TerminalPager v0.5.1

Add option to search only one column

It would be very useful for me if I could search for a value, for example 14 in a specific column only, because if I search for it globally I get far too many irrelevant hits.
In my application 14 in the column Flags indicates a CAN bus error frame, but it can also appear (often) in other columns without any special meaning.

Alt-left and Alt-right do not work

On Polish keyboard under Linux Ubuntu Alt-left and Alt-right (:bol and :eol) do not work.
Most likely because Alt-o is รณ in Polish etc. but Alt-left and Alt-right are not getting a special treatment so it should work.

long error messages in `pager>` compared to `julia>`

If I make a simple mistake in julia>, e.g. misspell a variable name, Julia complains very briefly:

julia> myvar
ERROR: UndefVarError: `myvar` not defined

However, if I do this while in pager>, the error message is very long:

pager> myvar
ERROR: UndefVarError: `myvar` not defined
Stacktrace:
 [1] top-level scope
   @ :0
 [2] eval
   @ ./boot.jl:370 [inlined]
 [3] _tp_mode_do_cmd(repl::REPL.LineEditREPL, input::String)
   @ TerminalPager ~/.julia/packages/TerminalPager/MpAXn/src/repl.jl:243
 [4] (::TerminalPager.var"#11#14"{REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::IOBuffer, ok::Bool)
   @ TerminalPager ~/.julia/packages/TerminalPager/MpAXn/src/repl.jl:41
 [5] #invokelatest#2
   @ ./essentials.jl:819 [inlined]
 [6] invokelatest
   @ ./essentials.jl:816 [inlined]
 [7] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
   @ REPL.LineEdit ~/.julia/juliaup/julia-1.9.3+0.aarch64.apple.darwin14/share/julia/stdlib/v1.9/REPL/src/LineEdit.jl:2647
 [8] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
   @ REPL ~/.julia/juliaup/julia-1.9.3+0.aarch64.apple.darwin14/share/julia/stdlib/v1.9/REPL/src/REPL.jl:1300
 [9] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
   @ REPL ./task.jl:514
Details about julia
(@v1.9) pkg> st
Status `~/.julia/environments/v1.9/Project.toml`
  [6e4b80f9] BenchmarkTools v1.3.2
  [89398ba2] LocalRegistry v0.5.5
  [85b6ec6f] MethodAnalysis v0.4.13
  [5fb14364] OhMyREPL v0.5.22
  [295af30f] Revise v3.5.5
  [fd094767] Suppressor v0.2.6
  [0c614874] TerminalPager v0.5.0

julia> versioninfo()
Julia Version 1.9.3
Commit bed2cd540a1 (2023-08-24 14:43 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 8 ร— Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, apple-m1)
  Threads: 1 on 4 virtual cores
Environment:
  JULIA_EDITOR = code

Add optional argument to load only first n lines

As mentioned in #10 it can take a long time to load a large table, and in many cases, I do not actually want to page through thousands of rows.

Would it be ok to add an optional second argument to only load the first n lines?

As example:

julia> m1 = rand(1000, 1000);
julia> d1 = DataFrame(m1, :auto);

Then pager(d1, 100) should conceptually do the same as pager(first(d1,100)) .

For DataFrames the overhead of writing pager(first(d1,100)) rather than pager(d1, 100) is not so big, but for matrices we would need to write pager(m1[1:100,:]):

julia> pager(first(d1,5))
5ร—100 DataFrame
 Row โ”‚ x1        x2        x3        x4        x5         x6         x7        x8        x9        x10       x11       x12
     โ”‚ Float64   Float64   Float64   Float64   Float64    Float64    Float64   Float64   Float64   Float64   Float64   Flo
โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
   1 โ”‚ 0.242587  0.338178  0.175047  0.526432  0.0752374  0.0826068  0.50735   0.488078  0.431373  0.386281  0.50296   0.8
   2 โ”‚ 0.126071  0.481133  0.108992  0.8893    0.519607   0.997476   0.623974  0.779318  0.782236  0.822382  0.74265   0.4
   3 โ”‚ 0.918782  0.170586  0.706512  0.228009  0.770864   0.193122   0.119362  0.331636  0.252595  0.694127  0.269961  0.8
   4 โ”‚ 0.239073  0.339586  0.560449  0.956554  0.572953   0.376078   0.396257  0.412697  0.518571  0.762955  0.789057  0.5
   5 โ”‚ 0.564384  0.618212  0.169127  0.691747  0.627538   0.679062   0.336765  0.76703   0.881205  0.467188  0.164898  0.9

julia> pager(first(m1,5))
5-element Vector{Float64}:
 0.32228426040689684
 0.09436948434039771
 0.01952993269383163
 0.5322686848549102
 0.4830636090242214


julia> pager(m1[1:5,:])
5ร—100 Matrix{Float64}:
 0.322284   0.0706254  0.691225   0.334359   0.605738  0.0657363  0.790047  0.140566  0.736919  0.644921  0.111976  0.5730
 0.0943695  0.964375   0.455835   0.0302767  0.603699  0.820126   0.711371  0.616206  0.968865  0.37598   0.10508   0.7004
 0.0195299  0.0757658  0.74813    0.145286   0.889892  0.448485   0.977724  0.494413  0.679627  0.262876  0.680987  0.3365
 0.532269   0.738045   0.0826661  0.807034   0.215173  0.749381   0.200094  0.130695  0.367826  0.248304  0.317622  0.5663
 0.483064   0.890258   0.587399   0.515627   0.170361  0.68068    0.883226  0.943145  0.487144  0.292369  0.482398  0.1293

We could also consider a third argument to limit the number of columns, but in practice, I find that tables tend to be taller rather than wider.

Just be clear: the use case is to allow the user an easy way to specify that the table is large, and it is ok to only load the first n lines with the limitations that gives. E.g. that searching will only happen in that first part of the table.

Enter key to move down

With less (and partners) one can use the enter key to move down. I realize that I can achieve this with

TerminalPager.set_keybinding("<enter>", :down)

but I would vote for having this as an (additional) default. What do you think?

^ caret as default keybinding for bol

many of the other keybindings are inspired by vi. why then use 0 for bol instead of ^ ?

don't mean to complain, wish i would've found TerminalPager earlier. am loving it!

Work in fixed-height section of the Julia REPL

Don't know if this is even possible with the current setup, but what I like about JuliaLang/julia#38956 based on REPL.TerminalMenus is that all the interactivity works within a "fixed-height section" of the Julia REPL. That is, I can navigate up and down as much as I want and when I quit (q) the documentation bit only has taken so much of my REPL history. TerminalPager on the other hand seems to "reoutput" the relevant part of the docstring over and over again. Hence, if I go up and down multiple times my last line of Julia code is basically lost (the terminal output history is flooded with doctoring information).

show(df) |> pager not working

The following code is not working correctly:

using DataFrames, TerminalPager

arr=Float32[-2.60913f-19, 82.7852, 165.38, 247.703, 329.633, 410.999, 491.576]

df1 = DataFrame(time_rel=[0.1,0.2,0.3,0.4], X = [arr, arr, arr, arr])
show(df1, truncate=100) |> pager

The output is:

nothing


:

Any idea?

new release?

I notice that compat has been updated for latest StringManipulation, but has not been released.
Is it worthwhile to release a new version?

fastdown only shifts by 1 line

on both mac and linux. so it behaves just the same as regular down. similarly for fastup. fast{left,right} work as documented. this is on julia v1.10 and TerminalPager v0.5.1.

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Change freeze corner case errors

steps:

  1. press f
  2. press Enter
  3. press Enter

Result:

Freeze columns: ERROR: MethodError: no method matching isless(::Nothing, ::Int64)
Closest candidates are:
  isless(::Any, ::Missing) at missing.jl:88
  isless(::Missing, ::Any) at missing.jl:87
  isless(::AbstractFloat, ::Real) at operators.jl:169

you need to handle nothing in the input when the user just presses enter (maybe it should be just something(your_var, 0) so that Enter resets freeze to 0?)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.