-
Notifications
You must be signed in to change notification settings - Fork 103
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
Feature request: Button to send to console or to source #133
Comments
Thank you for the suggestion! Btw, your OpenIntro IMS1 book is the one I tend to recommend the most on the topic! For now you can achieve this if instead of using the chat app you use the "ChatGPT in source" addin with a text selection. This works in both source and console, but is clearly not that nice to iterate for progressive better output as in the chat app. For the developers: The To console and To source buttons might be possible if the background job process can talk to |
An update on this. It is still not possible to send text to console or source when a background job has access to a pointer to the global environment, because a background job is actually a different system process. However, I can think of three alternatives: Access the R processSomehow, be able to run code in the same process of the RStudio IDE's R session. The Use a lower level Rstudio API
.rs.addApiFunction("selectionSet", function(value = NULL, id = NULL)
{
# collapse value into single string
value <- paste(value, collapse = "\n")
# create data payload
payload <- list(
value = .rs.scalar(value),
doc_id = .rs.scalar(id)
)
# create request
request <- .rs.api.createRequest(
type = .rs.api.eventTypes$TYPE_SET_EDITOR_SELECTION,
sync = TRUE,
target = .rs.api.eventTargets$TYPE_ACTIVE_WINDOW,
payload = payload
)
# fire away
.rs.api.sendRequest(request)
}) Which is itself a wrapper on a C++ function... Which might be another wrapper... But in the end, we will get to the point where we will find an API that can receive requests (hopefully without authentication), and we could be able to handle that. Escape RRstudio is built with Electron.js, and in the end is just a custom browser application. I assume we can take advantage of that and target a) an Electron API, or b) target element id. Something really funny happens when you open Rstudio -> Help -> Diagnostics -> Toggle Developer Tools, and run the following in the console: document.getElementsByClassName("ace_cursor")[0].innerText = "test" Or ... maybe we should just block the interactive R session? 🤣 |
The RStudio History pane has two buttons: To Console and To Source.
I wonder if these could be implemented instead of or in addition to the Copy button in gptstudio, so instead of copy-paste, one can easily send the code over.
An alternative or additional functionality could be what happens in the RStudio Help pane, where you can highlight a piece of code and Command+Return to send it to the Console.
The text was updated successfully, but these errors were encountered: