Skip to content

Commit

Permalink
Make menu() and debugger() work again
Browse files Browse the repository at this point in the history
  • Loading branch information
melff committed Dec 15, 2024
1 parent 71faf22 commit 1aa93a3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
5 changes: 3 additions & 2 deletions pkg/R/kernel.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ Kernel <- R6Class("Kernel",
stderr = private$handle_r_stderr,
msg = self$r_session_msg,
readline = private$r_get_input,
browser = private$r_get_input
browser = private$r_get_input,
menu = private$r_get_input
))
# log_out(self$r_session, use.print = TRUE)
},
Expand Down Expand Up @@ -793,7 +794,7 @@ Kernel <- R6Class("Kernel",
self$r_session$run_cmd("RKernel::install_cell_hooks()")
self$r_session$run_cmd("RKernel::install_save_q()")
self$r_session$run_cmd("RKernel::install_readline()")
self$r_session$run_cmd("RKernel::install_menu()")
# self$r_session$run_cmd("RKernel::install_menu()")
self$r_session$run_cmd("RKernel::set_help_displayed")
self$r_session$run_cmd("RKernel::install_httpd_handlers()")
# self$r_session$run_cmd("options(error = function()print(traceback()))")
Expand Down
21 changes: 13 additions & 8 deletions pkg/R/session.R
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,19 @@ RKernelSession <- R6Class("RKernelSession",
self$callbacks$stdout(resp$stdout)
}
next_line <- TRUE
# } else if (endsWith(resp$stdout, self$menu_prompt)) {
# # log_out("Found menu prompt")
# # resp$stdout <- remove_suffix(resp$stdout, self$menu_prompt)
# if (is.function(self$callbacks$menu)) {
# inp <- self$callbacks$menu(resp$stdout)
# force_drop_echo <- TRUE
# self$send_input(inp)
# } else self$send_input("")
} else if (endsWith(resp$stdout, self$menu_prompt)) {
# log_out("Found menu prompt")
# log_out(self$callbacks, use.str = TRUE)
resp$stdout <- remove_suffix(resp$stdout, self$menu_prompt)
if (is.function(self$callbacks$menu)) {
# log_out("Calling menu callback")
inp <- self$callbacks$menu(resp$stdout)
force_drop_echo <- TRUE
self$send_input(inp)
} else {
# log_out("No menu callback available")
self$interrupt()
}
} else if (endsWith(resp$stdout, self$readline_prompt)) {
# log_out("Found readline prompt")
resp$stdout <- remove_suffix(resp$stdout, self$readline_prompt)
Expand Down

0 comments on commit 1aa93a3

Please sign in to comment.