Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support in custom REPL modes #332

Open
ronisbr opened this issue Sep 23, 2023 · 2 comments
Open

Support in custom REPL modes #332

ronisbr opened this issue Sep 23, 2023 · 2 comments

Comments

@ronisbr
Copy link

ronisbr commented Sep 23, 2023

Hi @KristofferC !

I have a package (TerminalPager.jl) that defines a custom REPL mode to show large outputs inside a pager. When I enable OhMyREPL.jl, the highlight only works when I type certain characters. For example, if I type function in normal REPL, it gets highlighted immediately:

Captura de Tela 2023-09-23 às 13 51 38

However, if I enter my custom mode, this does not happen:

Captura de Tela 2023-09-23 às 13 52 47

The only way to make the line highlighted is if I type backspace, enter, or move the cursor using the left/right keys (at least it was what I found):

Captura de Tela 2023-09-23 às 13 53 19

It seems that I need to call some function to refresh the line at each character. Maybe I can add OhMyREPL as extension for TerminalPager.jl, but I just do not know what should I do. Can you help me?

@ronisbr
Copy link
Author

ronisbr commented Oct 6, 2023

Bump!

@ronisbr
Copy link
Author

ronisbr commented Oct 10, 2023

I think I solved this problem by adding this keymap:

    # For every typed character, we insert it and update the line. This approach is
    # necessary to make OhMyREPL.jl works in TerminalPager.jl.
    line_update_keymap = Dict{Any, Any}(
        "*" => function(s, data, c)
            LineEdit.edit_insert(s, c)
            LineEdit.refresh_line(s)
        end
    )

    tp_mode_keymaps = Dict{Any, Any}[
        line_update_keymap,
        mk,
        prefix_keymap,
        skeymap,
        help_mode_transition_keymap,
        LineEdit.history_keymap,
        LineEdit.default_keymap,
        LineEdit.escape_defaults,
    ]

    tp_mode.keymap_dict = LineEdit.keymap(tp_mode_keymaps)

But I am not sure if this is the correct approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant