Skip to content

Commit

Permalink
Show tab complete hints, if supported (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth authored Oct 18, 2023
1 parent 0d60955 commit f092341
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ function rewrite_with_ANSI(s, cursormove::Bool = false)
LineEdit.write(outbuf, "\e[?25h") # Show the cursor
write(terminal(s), take!(io))
flush(terminal(s))
@static if isdefined(LineEdit, :maybe_show_hint)
stat = state(s)
if stat isa LineEdit.PromptState
LineEdit.maybe_show_hint(stat)
end
end
end


Expand All @@ -87,7 +93,11 @@ function create_keybindings()
else
beep(terminal(s))
end
D["*"] = (s, data, c) -> (LineEdit.edit_insert(buffer(s), c); rewrite_with_ANSI(s))
D["*"] = @static if isdefined(LineEdit, :check_for_hint)
(s, data, c) -> (LineEdit.edit_insert(buffer(s), c); LineEdit.check_for_hint(s); rewrite_with_ANSI(s))
else
(s, data, c) -> (LineEdit.edit_insert(buffer(s), c); rewrite_with_ANSI(s))
end
D["^B"] = (s, data, c) -> (LineEdit.edit_move_left(buffer(s)) ;rewrite_with_ANSI(s))
D["^F"] = (s, data, c) -> (LineEdit.edit_move_right(buffer(s)) ;rewrite_with_ANSI(s))
# Meta B
Expand Down

0 comments on commit f092341

Please sign in to comment.