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

make runcode work with shinyAce editor #93

Closed
shabbychef opened this issue Nov 5, 2016 · 3 comments
Closed

make runcode work with shinyAce editor #93

shabbychef opened this issue Nov 5, 2016 · 3 comments

Comments

@shabbychef
Copy link
Contributor

The shinyAce package provides the Ace editor within shiny pages. This feels like a more comfortable environment for writing R code for execution. (I do this for debugging shiny apps.)

@daattali
Copy link
Owner

daattali commented Nov 5, 2016

I will try add it when I have time before the next release, but I'll also
happily accept PRs


R-Shiny Consultant
http://deanattali.com/shiny

On 4 November 2016 at 23:48, Steven Pav [email protected] wrote:

The shinyAce package provides the Ace editor within shiny pages. This
feels like a more comfortable environment for writing R code for execution.
(I do this for debugging shiny apps.)


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#93, or mute the thread
https://github.com/notifications/unsubscribe-auth/AA6IFENQP852OZxBDIeAZR3cV5mDfVi1ks5q6_yfgaJpZM4KqKPU
.

@shabbychef
Copy link
Contributor Author

I am not sure how runCode works, but here is the snippets I used for my debugging window. In ui.R:

library(shinyAce)


aceEditor("debug_ace_in", mode='r', value="lb <- rnorm(16);head(lb)",
                vimKeyBinding=TRUE,
                theme="github", fontSize=16, height="500px",
                hotkeys=list(runKey="F8|F9|F2|Ctrl-R")),
verbatimTextOutput('debug_ace_stdin'),
verbatimTextOutput('debug_ace_stdout')

And in server.R:

library(shinyAce)


vals <- reactiveValues(ace_stdout = "")
observe({
  input$runKey
  isolate(vals$ace_stdin <- eval(input$debug_ace_in))
  isolate(vals$ace_stdout <- eval(parse(text=vals$ace_stdin)))
})
output$debug_ace_stdin <- renderText({
  retv <- paste0(vals$ace_stdin)
  retv 
})
output$debug_ace_stdout <- renderText({
  retv <- paste0(vals$ace_stdout)
  retv 
})

Again, there is probably a better implementation in runCode.

My defaults for the ace editor here allow one to use F9 as a 'run' key, like I do in Conque in vim, which is a whole other story.

@daattali
Copy link
Owner

daattali commented Nov 5, 2016

I believe the only thing that needs to be done is add a case to the if statement inside runcodeUI. Currently there's an if statement that checks if to add a textInput or a textAreaInput, and it'll be a one liner to support shinyAce I think https://github.com/daattali/shinyjs/blob/master/R/runcode.R#L60-L69 (I'm putting this out there so anyone else can also take a look)

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

2 participants