Skip to content

Commit

Permalink
REPL: change ^C to "Clear" input area if not already empty
Browse files Browse the repository at this point in the history
  • Loading branch information
rfourquet committed Dec 9, 2017
1 parent a933979 commit 2f3abe9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
21 changes: 12 additions & 9 deletions base/repl/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2023,16 +2023,19 @@ AnyDict(
"^W" => (s,o...)->edit_werase(s),
# Meta D
"\ed" => (s,o...)->edit_delete_next_word(s),
"^C" => (s,o...)->begin
try # raise the debugger if present
ccall(:jl_raise_debugger, Int, ())
"^C" => function (s,o...)
if isempty(s)
try # raise the debugger if present
ccall(:jl_raise_debugger, Int, ())
end
cancel_beep(s)
refresh_line(s)
print(terminal(s), "^C\n\n")
transition(s, :reset)
refresh_line(s)
else
edit_clear(s)
end
cancel_beep(s)
move_input_end(s)
refresh_line(s)
print(terminal(s), "^C\n\n")
transition(s, :reset)
refresh_line(s)
end,
"^Z" => (s,o...)->(return :suspend),
# Right Arrow
Expand Down
14 changes: 8 additions & 6 deletions base/repl/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -732,12 +732,14 @@ function mode_keymap(julia_prompt::Prompt)
end
end,
"^C" => function (s,o...)
LineEdit.move_input_end(s)
LineEdit.refresh_line(s)
print(LineEdit.terminal(s), "^C\n\n")
transition(s, julia_prompt)
transition(s, :reset)
LineEdit.refresh_line(s)
if isempty(s)
print(LineEdit.terminal(s), "^C\n\n")
transition(s, julia_prompt)
transition(s, :reset)
LineEdit.refresh_line(s)
else
LineEdit.edit_clear(s)
end
end)
end

Expand Down

0 comments on commit 2f3abe9

Please sign in to comment.