rstudioapi/0000755000176200001440000000000013617370242012442 5ustar liggesusersrstudioapi/NAMESPACE0000644000176200001440000000565413617331207013671 0ustar liggesusers# Generated by roxygen2: do not edit by hand S3method(as.document_position,default) S3method(as.document_position,document_position) S3method(as.document_range,default) S3method(as.document_range,document_range) S3method(format,document_position) S3method(format,document_range) S3method(primary_selection,document_context) S3method(primary_selection,document_selection) S3method(print,document_context) S3method(print,document_position) S3method(print,document_range) S3method(print,document_selection) export(addTheme) export(applyTheme) export(as.document_position) export(as.document_range) export(askForPassword) export(askForSecret) export(bugReport) export(buildToolsCheck) export(buildToolsExec) export(buildToolsInstall) export(callFun) export(convertTheme) export(createProjectTemplate) export(dictionariesPath) export(documentClose) export(documentNew) export(documentSave) export(documentSaveAll) export(document_position) export(document_range) export(executeCommand) export(findFun) export(getActiveDocumentContext) export(getActiveProject) export(getConsoleEditorContext) export(getPersistentValue) export(getRStudioPackageDependencies) export(getSourceEditorContext) export(getThemeInfo) export(getThemes) export(getVersion) export(hasColorConsole) export(hasFun) export(highlightUi) export(initializeProject) export(insertText) export(is.document_position) export(is.document_range) export(isAvailable) export(jobAdd) export(jobAddOutput) export(jobAddProgress) export(jobRemove) export(jobRunScript) export(jobSetProgress) export(jobSetState) export(jobSetStatus) export(launcherAvailable) export(launcherConfig) export(launcherContainer) export(launcherControlJob) export(launcherGetInfo) export(launcherGetJob) export(launcherGetJobs) export(launcherHostMount) export(launcherNfsMount) export(launcherPlacementConstraint) export(launcherResourceLimit) export(launcherSubmitJob) export(launcherSubmitR) export(modifyRange) export(navigateToFile) export(openProject) export(previewRd) export(previewSql) export(primary_selection) export(readPreference) export(readRStudioPreference) export(removeTheme) export(restartSession) export(savePlotAsImage) export(selectDirectory) export(selectFile) export(sendToConsole) export(setCursorPosition) export(setDocumentContents) export(setPersistentValue) export(setSelectionRanges) export(showDialog) export(showPrompt) export(showQuestion) export(sourceMarkers) export(systemUsername) export(terminalActivate) export(terminalBuffer) export(terminalBusy) export(terminalClear) export(terminalContext) export(terminalCreate) export(terminalExecute) export(terminalExitCode) export(terminalKill) export(terminalList) export(terminalRunning) export(terminalSend) export(terminalVisible) export(translateLocalUrl) export(updateDialog) export(userDictionariesPath) export(userIdentity) export(verifyAvailable) export(versionInfo) export(viewer) export(writePreference) export(writeRStudioPreference) importFrom(utils,capture.output) rstudioapi/LICENSE0000644000176200001440000000004513535525640013451 0ustar liggesusersYEAR: 2015 COPYRIGHT HOLDER: RStudio rstudioapi/man/0000755000176200001440000000000013617331207013213 5ustar liggesusersrstudioapi/man/launcherSubmitJob.Rd0000644000176200001440000000645413574017651017141 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/launcher-functions.R \name{launcherSubmitJob} \alias{launcherSubmitJob} \title{Submit a Launcher Job} \usage{ launcherSubmitJob( name, cluster = "Local", tags = NULL, command = NULL, exe = NULL, args = NULL, environment = NULL, stdin = NULL, stdoutFile = NULL, stderrFile = NULL, workingDirectory = NULL, host = NULL, container = NULL, exposedPorts = NULL, mounts = NULL, placementConstraints = NULL, resourceLimits = NULL, queues = NULL, config = NULL, user = Sys.getenv("USER"), applyConfigSettings = TRUE ) } \arguments{ \item{name}{A descriptive name to assign to the job.} \item{cluster}{The name of the cluster this job should be submitted to.} \item{tags}{A set of user-defined tags, used for searching and querying jobs.} \item{command}{The command to run within the job. This is executed via the system shell. Only one of command or exe should be specified.} \item{exe}{The (fully pathed) executable to run within the job. Only one of \code{command} or \code{exe} should be specified.} \item{args}{An array of arguments to pass to the command / executable.} \item{environment}{A list of environment variables to be set for processes launched with this job.} \item{stdin}{Data to be written to stdin when the job process is launched.} \item{stdoutFile}{The file used for the job's generated standard output. Not all launcher plugins support this parameter.} \item{stderrFile}{The file used for the job's generated standard error. Not all launcher plugins support this parameter.} \item{workingDirectory}{The working directory to be used by the command / executable associated with this job.} \item{host}{The host that the job is running on, or the desired host during job submission.} \item{container}{The container to be used for launched jobs.} \item{exposedPorts}{The ports that are exposed by services running on a container. Only applicable to systems that support containers.} \item{mounts}{A list of mount points. See \code{\link[=launcherHostMount]{launcherHostMount()}} and \code{\link[=launcherNfsMount]{launcherNfsMount()}} for more information.} \item{placementConstraints}{A list of placement constraints. See \code{\link[=launcherPlacementConstraint]{launcherPlacementConstraint()}} for more information.} \item{resourceLimits}{A list of resource limits. See \code{\link[=launcherResourceLimit]{launcherResourceLimit()}} for more information.} \item{queues}{A list of available submission queues for the cluster. Only applicable to batch systems like LSF.} \item{config}{A list of cluster-specific configuration options. See \code{\link[=launcherConfig]{launcherConfig()}} for more information.} \item{user}{The user-name of the job owner.} \item{applyConfigSettings}{Apply server-configured mounts, exposedPorts, and environment, in addition to any specified in this call.} } \description{ Submit a launcher job. See https://docs.rstudio.com/job-launcher/latest/index.html for more information. } \seealso{ Other job submission: \code{\link{launcherConfig}()}, \code{\link{launcherContainer}()}, \code{\link{launcherHostMount}()}, \code{\link{launcherNfsMount}()}, \code{\link{launcherPlacementConstraint}()}, \code{\link{launcherResourceLimit}()}, \code{\link{launcherSubmitR}()} } \concept{job submission} rstudioapi/man/terminalExecute.Rd0000644000176200001440000000212613574017651016647 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/terminal.R \name{terminalExecute} \alias{terminalExecute} \title{Execute Command} \usage{ terminalExecute(command, workingDir = NULL, env = character(), show = TRUE) } \arguments{ \item{command}{System command to be invoked, as a character string.} \item{workingDir}{Working directory for command} \item{env}{Vector of name=value strings to set environment variables} \item{show}{If FALSE, terminal won't be brought to front} } \value{ The terminal identifier as a character vector (\code{NULL} if unable to create the terminal). } \description{ Execute a command, showing results in the terminal pane. } \note{ The \code{terminalExecute} function was added in version 1.1.350 of RStudio. } \examples{ \dontrun{ termId <- rstudioapi::terminalExecute( command = 'echo $HELLO && echo $WORLD', workingDir = '/usr/local', env = c('HELLO=WORLD', 'WORLD=EARTH'), show = FALSE) while (is.null(rstudioapi::terminalExitCode(termId))) { Sys.sleep(0.1) } result <- terminalBuffer(termId) terminalKill(termId) print(result) } } rstudioapi/man/terminalExitCode.Rd0000644000176200001440000000120513535525640016745 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/terminal.R \name{terminalExitCode} \alias{terminalExitCode} \title{Terminal Exit Code} \usage{ terminalExitCode(id) } \arguments{ \item{id}{The terminal id. The \code{id} is obtained from \code{\link{terminalList}()}, \code{\link{terminalVisible}()}, ,\code{\link{terminalCreate}()}, or \code{\link{terminalExecute}()}.} } \value{ The exit code as an integer vector, or NULL if process still running. } \description{ Get exit code of terminal process, or NULL if still running. } \note{ The \code{terminalExitCode} function was added in version 1.1.350 of RStudio. } rstudioapi/man/sourceMarkers.Rd0000644000176200001440000000311013535525640016327 0ustar liggesusers\name{sourceMarkers} \alias{sourceMarkers} \title{ Display Source Markers } \description{ Display user navigable source markers in a pane within RStudio } \note{ The \code{sourceMarkers} function was added in version 0.99.225 of RStudio. } \usage{ sourceMarkers(name, markers, basePath = NULL, autoSelect = c("none", "first", "error")) } \arguments{ \item{name}{Name of marker set (will replace any markers of the same name previously shown)} \item{markers}{List or data frame containing source markers (see below for details on how to specify markers)} \item{basePath}{Optional. If all source files are within a base path then specifying that path here will result in file names being displayed as relative paths. Note that in this case markers still need to specify source file names as full paths.} \item{autoSelect}{Optional. Automatically select and drive focus to either the first marker or the first marker that is an error.} } \details{ The \code{markers} argument can contains either a list of marker lists or a data frame with the appropriate marker columns. The fields in a marker are as follows (all are required): \tabular{ll}{ \code{type} \tab Marker type ("error", "warning", "info", "style", or "usage")\cr \code{file} \tab Path to source file\cr \code{line} \tab Line number witin source file \cr \code{column} \tab Column number within line\cr \code{message} \tab Short descriptive message\cr } Note that if the \code{message} field is of class "html" (i.e. \code{inherits(message, "html") == TRUE}) then it's contents will be treated as HTML. } rstudioapi/man/getRStudioPackageDependencies.Rd0000644000176200001440000000163713574017621021370 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/dependencies.R \name{getRStudioPackageDependencies} \alias{getRStudioPackageDependencies} \title{Get RStudio Package Dependencies} \usage{ getRStudioPackageDependencies() } \value{ A data frame containing a row per R package. } \description{ Gets a list of the all the R packages that RStudio depends on in some way. } \details{ The data frame of package dependencies contains the following columns: \describe{ \item{name}{The name of the R package.} \item{version}{The required minimum version of the R package.} \item{location}{Where RStudio expects the package to be, \code{cran} for a CRAN-like repository or \code{embedded} for development packages embedded in RStudio itself.} \item{source}{Whether the package should be installed from source.} } } \note{ The \code{getRStudioPackageDependencies} function was introduced in RStudio 1.3.525. } rstudioapi/man/launcherHostMount.Rd0000644000176200001440000000173013574017651017173 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/launcher-functions.R \name{launcherHostMount} \alias{launcherHostMount} \title{Define a Launcher Host Mount} \usage{ launcherHostMount(path, mountPath, readOnly = TRUE) } \arguments{ \item{path}{The host path to be mounted.} \item{mountPath}{The destination path for the mount in the container.} \item{readOnly}{Boolean; should the path be mounted read-only?} } \description{ Define a launcher host mount, suitable for use with the \code{mounts} argument to \code{\link[=launcherSubmitJob]{launcherSubmitJob()}}. This can be used to mount a path from the host into the generated container. } \seealso{ Other job submission: \code{\link{launcherConfig}()}, \code{\link{launcherContainer}()}, \code{\link{launcherNfsMount}()}, \code{\link{launcherPlacementConstraint}()}, \code{\link{launcherResourceLimit}()}, \code{\link{launcherSubmitJob}()}, \code{\link{launcherSubmitR}()} } \concept{job submission} rstudioapi/man/jobAdd.Rd0000644000176200001440000000371013574017651014674 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/jobs.R \name{jobAdd} \alias{jobAdd} \title{Add a Job} \usage{ jobAdd( name, status = "", progressUnits = 0L, actions = NULL, running = FALSE, autoRemove = TRUE, show = TRUE ) } \arguments{ \item{name}{The job's name.} \item{status}{The initial status text for the job; optional.} \item{progressUnits}{The integer number of units of work in the job; for example, \code{100L} if the job's progress is expressed in percentages. Use \code{0L} if the number of units of work is unknown.} \item{actions}{A list of actions that can be performed on the job (see Actions).} \item{running}{Whether the job is currently running.} \item{autoRemove}{Whether to remove the job from the Jobs pane when it's complete.} \item{show}{Whether to show the job in the Jobs pane.} } \value{ An ID representing the newly added job, used as a handle to provide further updates of the job's status. } \description{ Inform RStudio's Jobs pane that a job has been added. } \section{Actions}{ The \code{actions} parameter is a named list of functions that the user can invoke on the job; for example: \code{actions = list(stop = function(id) { ... })}. The function will be passed a parameter named \code{id} with the job ID that invoked it. There are two special action names: \describe{ \item{stop}{If there is an action named \code{stop}, then the job will have a Stop button in in the Jobs pane, and pressing that button will invoke the \code{stop} action.} \item{info}{If there is an action named \code{info}, then the job will have an informational link in the Jobs pane rather than an output display, and clicking the link will invoke the \code{info} action.} } } \seealso{ Other jobs: \code{\link{jobAddOutput}()}, \code{\link{jobAddProgress}()}, \code{\link{jobRemove}()}, \code{\link{jobRunScript}()}, \code{\link{jobSetProgress}()}, \code{\link{jobSetState}()}, \code{\link{jobSetStatus}()} } \concept{jobs} rstudioapi/man/previewRd.Rd0000644000176200001440000000066113535525640015461 0ustar liggesusers\name{previewRd} \alias{previewRd} \title{ Preview an Rd topic in the Help pane } \description{ Preview an Rd topic in the Help pane } \note{ The \code{previewRd} function was added in version 0.98.191 of RStudio. } \usage{ previewRd(rdFile) } \arguments{ \item{rdFile}{Single element character vector containing the name of the Rd file to be displayed} } \examples{ \dontrun{ rstudioapi::previewRd("~/MyPackage/man/foo.Rd") } }rstudioapi/man/hasFun.Rd0000644000176200001440000000152513535525640014736 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/code.R \name{hasFun} \alias{hasFun} \alias{findFun} \title{Exists/get for RStudio functions} \usage{ hasFun(name, version_needed = NULL, ...) findFun(name, version_needed = NULL, ...) } \arguments{ \item{name}{name of object to look for} \item{version_needed}{An optional version specification. If supplied, ensures that RStudio is at least that version. This is useful if function behavior has changed over time.} \item{...}{other arguments passed on to \code{\link[base]{exists}} and \code{\link[base]{get}}} } \description{ These are specialized versions of \code{\link[base]{get}} and \code{\link[base]{exists}} that look in the rstudio package namespace. If RStudio is not running, \code{hasFun} will return \code{FALSE}. } \examples{ rstudioapi::hasFun("viewer") } rstudioapi/man/jobSetState.Rd0000644000176200001440000000165513574017651015746 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/jobs.R \name{jobSetState} \alias{jobSetState} \title{Set Job State} \usage{ jobSetState( job, state = c("idle", "running", "succeeded", "cancelled", "failed") ) } \arguments{ \item{job}{The ID of the job on which to change state.} \item{state}{The new job state.} } \description{ Changes the state of a job. } \section{States}{ The following states are supported: \describe{ \item{idle}{The job is waiting to run.} \item{running}{The job is actively running.} \item{succeeded}{The job has finished successfully.} \item{cancelled}{The job was cancelled.} \item{failed}{The job finished but did not succeed.} } } \seealso{ Other jobs: \code{\link{jobAddOutput}()}, \code{\link{jobAddProgress}()}, \code{\link{jobAdd}()}, \code{\link{jobRemove}()}, \code{\link{jobRunScript}()}, \code{\link{jobSetProgress}()}, \code{\link{jobSetStatus}()} } \concept{jobs} rstudioapi/man/sendToConsole.Rd0000644000176200001440000000141713535525640016271 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/stubs.R \name{sendToConsole} \alias{sendToConsole} \title{Send Code to the R Console} \usage{ sendToConsole(code, execute = TRUE, echo = TRUE, focus = TRUE) } \arguments{ \item{code}{Character vector containing code to be executed.} \item{execute}{Boolean; execute the code immediately or just enter the text into the console?} \item{echo}{Boolean; echo the \R code in the console as it's executed?} \item{focus}{Boolean; focus the \R console after sending code?} } \description{ Send code to the R console and optionally execute it. } \note{ The \code{sendToConsole} function was added in version 0.99.787 of RStudio. } \examples{ \dontrun{ rstudioapi::sendToConsole(".Platform", execute = TRUE) } } rstudioapi/man/document_range.Rd0000644000176200001440000000157313535525640016507 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/document-methods.R \name{document_range} \alias{document_range} \alias{is.document_range} \alias{as.document_range} \title{Create a Range} \usage{ document_range(start, end = NULL) is.document_range(x) as.document_range(x) } \arguments{ \item{start}{A \code{\link{document_position}} indicating the start of the range.} \item{end}{A \code{\link{document_position}} indicating the end of the range.} \item{x}{An object coercable to \code{document_range}.} } \value{ An \R \code{list} with class \code{document_range} and fields: \tabular{ll}{ \code{start:}\tab The start position.\cr \code{end:}\tab The end position.\cr } } \description{ A \code{document_range} is a pair of \code{\link{document_position}} objects, with each position indicating the \code{start} and \code{end} of the range, respectively. } rstudioapi/man/showDialog.Rd0000644000176200001440000000135413535525640015612 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/dialogs.R \name{showDialog} \alias{showDialog} \title{Show Dialog Box} \usage{ showDialog(title, message, url = "") } \arguments{ \item{title}{The title to display in the dialog box.} \item{message}{A character vector with the contents to display in the main dialog area. Contents can contain the following HTML tags: "p", "em", "strong", "b" and "i".} \item{url}{An optional url to display under the \code{message}.} } \description{ Shows a dialog box with a given title and contents. } \details{ \preformatted{ showDialog("A dialog", "Showing bold text in the message.") } } \note{ The \code{showDialog} function was added in version 1.1.67 of RStudio. } rstudioapi/man/launcherContainer.Rd0000644000176200001440000000175213574017651017161 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/launcher-functions.R \name{launcherContainer} \alias{launcherContainer} \title{Define a Launcher Container} \usage{ launcherContainer(image, runAsUserId = NULL, runAsGroupId = NULL) } \arguments{ \item{image}{The container image to use.} \item{runAsUserId}{The user id to run as within the container. Defaults to the container-specified user.} \item{runAsGroupId}{The group id to run as within the container. Defaults to the container-specified group.} } \description{ Define a launcher container, suitable for use with the \code{container} argument to \code{\link[=launcherSubmitJob]{launcherSubmitJob()}}. } \seealso{ Other job submission: \code{\link{launcherConfig}()}, \code{\link{launcherHostMount}()}, \code{\link{launcherNfsMount}()}, \code{\link{launcherPlacementConstraint}()}, \code{\link{launcherResourceLimit}()}, \code{\link{launcherSubmitJob}()}, \code{\link{launcherSubmitR}()} } \concept{job submission} rstudioapi/man/jobSetProgress.Rd0000644000176200001440000000115513574017651016465 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/jobs.R \name{jobSetProgress} \alias{jobSetProgress} \title{Set Job Progress} \usage{ jobSetProgress(job, units) } \arguments{ \item{job}{The ID of the job to set progress for.} \item{units}{The integer number of total units of work completed so far.} } \description{ Updates the progress for a job. } \seealso{ Other jobs: \code{\link{jobAddOutput}()}, \code{\link{jobAddProgress}()}, \code{\link{jobAdd}()}, \code{\link{jobRemove}()}, \code{\link{jobRunScript}()}, \code{\link{jobSetState}()}, \code{\link{jobSetStatus}()} } \concept{jobs} rstudioapi/man/readRStudioPreference.Rd0000644000176200001440000000212713535525640017735 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/prefs.R \name{readRStudioPreference} \alias{readRStudioPreference} \title{Read RStudio Preference} \usage{ readRStudioPreference(name, default) } \arguments{ \item{name}{The name of the preference.} \item{default}{The default value of the preference, returned if the preference is not found.} } \description{ Reads an internal RStudio IDE preference for the current user. } \details{ RStudio IDE internal preferences include the values displayed in RStudio's Global Options dialog as well as a number of additional settings. } \note{ The \code{readRStudioPreference} function was added in version 1.3.387 of RStudio. } \examples{ \dontrun{ # Get indentation settings spaces <- rstudioapi::readRStudioPreference("num_spaces_for_tab", FALSE) message("Using ", spaces, " per tab.") } } \seealso{ \code{\link{readPreference}}, which can be used to read arbitrary user (non-RStudio) preferences set with \code{\link{writePreference}}. \code{link{writeRStudioPreference}}, which can be used to write internal RStudio IDE preferences. } rstudioapi/man/userIdentity.Rd0000644000176200001440000000037413617331207016176 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/user.R \name{userIdentity} \alias{userIdentity} \title{Get User Identity} \usage{ userIdentity() } \description{ Returns the identity (displayed name) of the current user. } rstudioapi/man/rstudio-editors.Rd0000644000176200001440000000217613535525640016655 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/document-api.R \name{rstudio-editors} \alias{rstudio-editors} \alias{getActiveDocumentContext} \alias{getSourceEditorContext} \alias{getConsoleEditorContext} \title{Retrieve Information about an RStudio Editor} \usage{ getActiveDocumentContext() getSourceEditorContext() getConsoleEditorContext() } \value{ A \code{list} with elements: \tabular{ll}{ \code{id} \tab The document ID.\cr \code{path} \tab The path to the document on disk.\cr \code{contents} \tab The contents of the document.\cr \code{selection} \tab A \code{list} of selections. See \bold{Details} for more information.\cr } } \description{ Returns information about an RStudio editor. } \details{ The \code{selection} field returned is a list of document selection objects. A document selection is just a pairing of a document \code{range}, and the \code{text} within that range. } \note{ The \code{getActiveDocumentContext} function was added with version 0.99.796 of RStudio, while the \code{getSourceEditorContext} and the \code{getConsoleEditorContext} functions were added with version 0.99.1111. } rstudioapi/man/bugReport.Rd0000644000176200001440000000056513535525640015466 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/bug-report.R \name{bugReport} \alias{bugReport} \title{File an RStudio Bug Report} \usage{ bugReport() } \description{ A utility function to assist with the filing of an RStudio bug report. This function will pre-populate a template with information useful in understanding your reported bug. } rstudioapi/man/getThemes.Rd0000644000176200001440000000051713535525640015437 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/themes.R \name{getThemes} \alias{getThemes} \title{Get Theme List} \usage{ getThemes() } \description{ Retrieves a list of the names of all the editor themes installed for RStudio. } \note{ The \code{getThemes} function was introduced in RStudio 1.2.879. } rstudioapi/man/convertTheme.Rd0000644000176200001440000000355613574017651016164 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/themes.R \name{convertTheme} \alias{convertTheme} \title{Convert a tmTheme to an RStudio Theme} \usage{ convertTheme( themePath, add = TRUE, outputLocation = NULL, apply = FALSE, force = FALSE, globally = FALSE ) } \arguments{ \item{themePath}{A full or relative path to the \code{tmTheme} file to be converted.} \item{add}{Whether to add the newly converted theme to RStudio. Setting this to true will have the same impact as running \code{{ rstudioapi::convertTheme(, outputLocation = ); rstudioapi::addTheme() }}.\cr Default: \code{TRUE}.} \item{outputLocation}{A full or relative path where a copy of the converted theme will be saved. If this value is \code{NULL}, no copy will be saved.\cr Default: \code{NULL}.} \item{apply}{Whether to immediately apply the newly added theme. This paramater cannot be set to \code{TRUE} if \code{add} is set to \code{FALSE}. Setting this and \code{add} to \code{TRUE} has the same impact as running \code{{ rstudioapi::convertTheme(, outputLocation = ); rstudioapi::addTheme(); rstudioapi::applyTheme() }}.\cr Default: \code{FALSE}.} \item{force}{Whether to force the operation and overwrite an existing file with the same name.\cr Default: \code{FALSE}.} \item{globally}{Whether to install this theme for the current user or all users. If set to \code{TRUE} this will attempt to install the theme for all users, which may require administrator privileges. Only applies when \code{add} is \code{TRUE}. \cr Default: \code{FALSE}.} } \description{ Converts a \code{tmTheme} to an \code{rstheme} and optionally adds and applies it to RStudio and returns the name of the theme. } \note{ The \code{convertTheme} function was introduced in RStudio 1.2.879. } rstudioapi/man/createProjectTemplate.Rd0000644000176200001440000000317513574017651020004 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/templates.R \name{createProjectTemplate} \alias{createProjectTemplate} \title{Create a Project Template} \usage{ createProjectTemplate( package = ".", binding, title, subtitle = paste("Create a new", title), caption = paste("Create", title), icon = NULL, open_files = NULL, overwrite = FALSE, edit = TRUE ) } \arguments{ \item{package}{The path to an \R package sources.} \item{binding}{The \R skeleton function to associate with this project template. This is the name of the function that will be used to initialize the project.} \item{title}{The title to be shown within the \strong{New Project...} wizard.} \item{subtitle}{(optional) The subtitle to be shown within the \strong{New Project...} wizard.} \item{caption}{(optional) The caption to be shown on the landing page for this template.} \item{icon}{(optional) The path to an icon, on disk, to be used in the dialog. Must be an \code{.png} of size less than 64KB.} \item{open_files}{(optional) Files that should be opened by RStudio when the project is generated. Shell-style globs can be used to indicate when multiple files matching some pattern should be opened -- for example, OpenFiles: R/*.R would indicate that RStudio should open all .R files within the R folder of the generated project.} \item{overwrite}{Boolean; overwrite a pre-existing template file if one exists?} \item{edit}{Boolean; open the file for editting after creation?} } \description{ Create a project template. See \url{https://rstudio.github.io/rstudio-extensions/rstudio_project_templates.html} for more information. } rstudioapi/man/getActiveProject.Rd0000644000176200001440000000075413535525640016757 0ustar liggesusers\name{getActiveProject} \alias{getActiveProject} \title{ Path to Active RStudio Project } \description{ Returns the path to the currently active RStudio project. } \note{ The \code{getActiveProject} function was added in version 0.99.854 of RStudio. } \usage{ getActiveProject() } \value{ Returns a single element character vector with the path of the currently active RStudio project. Returns \code{NULL} if no project is active. } \examples{ \dontrun{ rstudioapi::getActiveProject() } } rstudioapi/man/writeRStudioPreference.Rd0000644000176200001440000000222613535525640020154 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/prefs.R \name{writeRStudioPreference} \alias{writeRStudioPreference} \title{Write RStudio Preference} \usage{ writeRStudioPreference(name, value) } \arguments{ \item{name}{The name of the preference.} \item{value}{The value of the preference.} } \description{ Writes an internal RStudio IDE preference for the current user. } \details{ RStudio IDE internal preferences include the values displayed in RStudio's Global Options dialog as well as a number of additional settings. Set them carefully; inappropriate values can cause unexpected behavior. See the RStudio Server Professional Administration Guide appendix for your version of RStudio for a full list of preference names and values. } \note{ The \code{writeRStudioPreference} function was added in version 1.3.387 of RStudio. } \examples{ \dontrun{ # Hide RStudio's toolbar. rstudioapi::writeRStudioPreference("toolbar_visible", FALSE) } } \seealso{ \code{\link{writePreference}}, which can be used to store arbitrary user (non-RStudio) preferences. \code{\link{readRStudioPreference}}, which reads internal RStudio IDE preferences. } rstudioapi/man/versionInfo.Rd0000644000176200001440000000203513535525640016010 0ustar liggesusers\name{versionInfo} \alias{versionInfo} \title{ RStudio Version Information } \description{ Provides information about the currently running version of RStudio, including it's specific version number and whether it is running in desktop or server mode. } \note{ The \code{versionInfo} function was added in version 0.97.124 of RStudio. } \usage{ versionInfo() } \value{ Returns a list with the following elements: \tabular{ll}{ \code{version} \tab A package version object that can be used in comparisons. This is the same value which would be returned from \code{packageVersion("rstudio")} \cr \code{mode} \tab Current program mode (either "desktop" or "server")\cr \code{citation} \tab An object inheriting from class \code{bibentry}\cr } } \examples{ \dontrun{ require(rstudioapi) ver <- versionInfo() # Test specific version constraint if (ver$version >= "0.97") { # do some 0.97 dependent stuff } # Check current mode desktopMode <- ver$mode == "desktop" serverMode <- ver$mode == "server" # Get the citation ver$citation } } rstudioapi/man/addTheme.Rd0000644000176200001440000000212413535525640015221 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/themes.R \name{addTheme} \alias{addTheme} \title{Add a Custom Editor Theme} \usage{ addTheme(themePath, apply = FALSE, force = FALSE, globally = FALSE) } \arguments{ \item{themePath}{A full or relative path or URL to an \code{rstheme} or \code{tmtheme} to be added.} \item{apply}{Whether to immediately apply the newly added theme. Setting this to \code{TRUE} has the same impact as running \code{{ rstudioapi::addTheme(); rstudioapi::applyTheme() }}.\cr Default: \code{FALSE}.} \item{force}{Whether to force the operation and overwrite an existing file with the same name.\cr Default: \code{FALSE}.} \item{globally}{Whether to install this theme for the current user or all users. If set to \code{TRUE} this will attempt to install the theme for all users, which may require administrator privileges.\cr Default: \code{FALSE}.} } \description{ Adds a custom editor theme to RStudio and returns the name of the newly added theme. } \note{ The \code{addTheme} function was introduced in RStudio 1.2.879. } rstudioapi/man/build-tools.Rd0000644000176200001440000000265313574017651015753 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/build-tools.R \name{build-tools} \alias{build-tools} \alias{buildToolsCheck} \alias{buildToolsInstall} \alias{buildToolsExec} \title{Build Tools} \usage{ buildToolsCheck() buildToolsInstall(action) buildToolsExec(expr) } \arguments{ \item{action}{The action (as a string) being taken that will require installation of build tools.} \item{expr}{An \R expression (unquoted) to be executed with build tools available and on the \code{PATH}.} } \description{ Check, install, and use build tools as required. } \details{ These functions are intended to be used together -- one should first check whether build tools are available, and when not, prompt for installation. For example:\if{html}{\out{
}}\preformatted{compile_model <- function(...) \{ if (rstudioapi::isAvailable()) \{ if (!rstudioapi::buildToolsCheck()) rstudioapi::buildToolsInstall("Model compilation") rstudioapi::buildToolsExec(\{ # code requiring build tools here \}) \} \} }\if{html}{\out{
}} The \code{action} parameter is used to communicate (with a prompt) the operation being performed that requires build tool installation. Setting it to \code{NULL} or the empty string will suppress that prompt. } \note{ The \code{buildToolsCheck()}, \code{buildToolsInstall()}, and \code{buildToolsExec()} functions were added with version 1.2.962 of RStudio. } rstudioapi/man/terminalBuffer.Rd0000644000176200001440000000130113535525640016447 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/terminal.R \name{terminalBuffer} \alias{terminalBuffer} \title{Get Terminal Buffer} \usage{ terminalBuffer(id, stripAnsi = TRUE) } \arguments{ \item{id}{The terminal id. The \code{id} is obtained from \code{\link{terminalList}()}, \code{\link{terminalVisible}()}, \code{\link{terminalCreate}()}, or \code{\link{terminalExecute}()}.} \item{stripAnsi}{If FALSE, don't strip out Ansi escape sequences before returning terminal buffer.} } \value{ The terminal contents, one line per row. } \description{ Returns contents of a terminal buffer. } \note{ The \code{terminalBuffer} function was added in version 1.1.350 of RStudio. } rstudioapi/man/callFun.Rd0000644000176200001440000000107713535525640015100 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/code.R \name{callFun} \alias{callFun} \title{Call an RStudio API function} \usage{ callFun(fname, ...) } \arguments{ \item{fname}{name of the RStudio function to call.} \item{...}{Other arguments passed on to the function} } \description{ This function will return an error if RStudio is not running, or the function is not available. If you want to fall back to different behavior, use \code{\link{hasFun}}. } \examples{ if (rstudioapi::isAvailable()) { rstudioapi::callFun("versionInfo") } } rstudioapi/man/getVersion.Rd0000644000176200001440000000074413535525640015641 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/code.R \name{getVersion} \alias{getVersion} \title{Return the current version of the RStudio API} \usage{ getVersion() } \value{ A \code{\link{numeric_version}} which you can compare to a string and get correct results. } \description{ Return the current version of the RStudio API } \examples{ \dontrun{ if (rstudioapi::getVersion() < "0.98.100") { message("Your version of RStudio is quite old") } } } rstudioapi/man/jobAddProgress.Rd0000644000176200001440000000116213574017651016420 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/jobs.R \name{jobAddProgress} \alias{jobAddProgress} \title{Add Job Progress} \usage{ jobAddProgress(job, units) } \arguments{ \item{job}{The ID of the job to update progress for.} \item{units}{The integer number of new progress units completed.} } \description{ Adds incremental progress units to a job. } \seealso{ Other jobs: \code{\link{jobAddOutput}()}, \code{\link{jobAdd}()}, \code{\link{jobRemove}()}, \code{\link{jobRunScript}()}, \code{\link{jobSetProgress}()}, \code{\link{jobSetState}()}, \code{\link{jobSetStatus}()} } \concept{jobs} rstudioapi/man/viewer.Rd0000644000176200001440000000744313535525640015020 0ustar liggesusers\name{viewer} \alias{viewer} \title{ View local web content within RStudio } \description{ View local web content within RStudio. Content can be served from static files in the R session temporary directory or can be a \link[shiny:shiny-package]{Shiny}, \link[Rook:Rook-package]{Rook}, \link[opencpu:opencpu]{OpenCPU}, or any other type of localhost web application. } \usage{ viewer(url, height = NULL) } \arguments{ \item{url}{Application URL. This can be either a localhost URL or a path to a file within the R session temporary directory (i.e. a path returned by \code{\link[base:tempfile]{tempfile}}). } \item{height}{Desired height. Specifies a desired height for the Viewer pane (the default is \code{NULL} which makes no change to the height of the pane). This value can be numeric or the string \code{"maximize"} in which case the Viewer will expand to fill all vertical space. See details below for a discussion of constraints imposed on the height. } } \details{ RStudio also sets the global \code{viewer} option to the \code{rstudioapi::viewer} function so that it can be invoked in a front-end independent manner. Applications are displayed within the Viewer pane. The application URL must either be served from localhost or be a path to a file within the R session temporary directory. If the URL doesn't conform to these requirements it is displayed within a standard browser window. The \code{height} parameter specifies a desired height, however it's possible the Viewer pane will end up smaller if the request can't be fulfilled (RStudio ensures that the pane paired with the Viewer maintains a minimum height). A height of 400 pixels or lower is likely to succeed in a large proportion of configurations. A very large height (e.g. 2000 pixels) will allocate the maximum allowable space for the Viewer (while still preserving some view of the pane above or below it). The value \code{"maximize"} will force the Viewer to full height. Note that this value should only be specified in cases where maximum vertical space is essential, as it will result in one of the user's other panes being hidden. } \note{ The \code{viewer} function was added in version 0.98.423 of RStudio. The ability to specify \code{maximize} for the \code{height} parameter was introduced in version 0.99.1001 of RStudio. } \section{Viewer Detection}{ When a page is displayed within the Viewer it's possible that the user will choose to pop it out into a standalone browser window. When rendering inside a standard browser you may want to make different choices about how content is laid out or scaled. Web pages can detect that they are running inside the Viewer pane by looking for the \code{viewer_pane} query parameter, which is automatically injected into URLs when they are shown in the Viewer. For example, the following URL: \preformatted{ http://localhost:8100 } When rendered in the Viewer pane is transformed to: \preformatted{ http://localhost:8100?viewer_pane=1 } To provide a good user experience it's strongly recommended that callers take advantage of this to automatically scale their content to the current size of the Viewer pane. For example, re-rendering a JavaScript plot with new dimensions when the size of the pane changes. } \examples{ \dontrun{ # run an application inside the IDE rstudioapi::viewer("http://localhost:8100") # run an application and request a height of 500 pixels rstudioapi::viewer("http://localhost:8100", height = 500) # probe for viewer option then fall back to browseURL viewer <- getOption("viewer") if (!is.null(viewer)) viewer("http://localhost:8100") else utils::browseURL("http://localhost:8100") # generate a temporary html file and display it dir <- tempfile() dir.create(dir) htmlFile <- file.path(dir, "index.html") # (code to write some content to the file) rstudioapi::viewer(htmlFile) } }rstudioapi/man/jobRunScript.Rd0000644000176200001440000000246513574017651016143 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/jobs.R \name{jobRunScript} \alias{jobRunScript} \title{Run R Script As Job} \usage{ jobRunScript( path, name = NULL, encoding = "unknown", workingDir = NULL, importEnv = FALSE, exportEnv = "" ) } \arguments{ \item{path}{The path to the R script to be run.} \item{name}{A name for the background job. When \code{NULL} (the default), the filename of the script is used as the job name.} \item{encoding}{The text encoding of the script, if known.} \item{workingDir}{The working directory in which to run the job. When \code{NULL} (the default), the parent directory of the R script is used.} \item{importEnv}{Whether to import the global environment into the job.} \item{exportEnv}{The name of the environment in which to export the R objects created by the job. Use \code{""} (the default) to skip export, \code{"R_GlobalEnv"}` to export to the global environment, or the name of an environment object to create an object with that name.} } \description{ Starts an R script as a background job. } \seealso{ Other jobs: \code{\link{jobAddOutput}()}, \code{\link{jobAddProgress}()}, \code{\link{jobAdd}()}, \code{\link{jobRemove}()}, \code{\link{jobSetProgress}()}, \code{\link{jobSetState}()}, \code{\link{jobSetStatus}()} } \concept{jobs} rstudioapi/man/showQuestion.Rd0000644000176200001440000000130013535525640016211 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/dialogs.R \name{showQuestion} \alias{showQuestion} \title{Show Question Dialog Box} \usage{ showQuestion(title, message, ok = NULL, cancel = NULL) } \arguments{ \item{title}{The title to display in the dialog box.} \item{message}{A character vector with the contents to display in the main dialog area.} \item{ok}{And optional character vector that overrides the caption for the OK button.} \item{cancel}{An optional character vector that overrides the caption for the Cancel button.} } \description{ Shows a dialog box asking a question. } \note{ The \code{showQuestion} function was added in version 1.1.67 of RStudio. } rstudioapi/man/askForPassword.Rd0000644000176200001440000000117413535525640016462 0ustar liggesusers\name{askForPassword} \alias{askForPassword} \title{ Ask the user for a password interactively } \description{ Ask the user for a password interactively. } \note{ The \code{askForPassword} function was added in version 0.99.853 of RStudio. } \usage{ askForPassword(prompt) } \arguments{ \item{prompt}{Single element character vector containing the prompt to be displayed} } \details{ RStudio also sets the global \code{askpass} option to the \code{rstudioapi::askForPassword} function so that it can be invoked in a front-end independent manner. } \examples{ \dontrun{ rstudioapi::askForPassword("Please enter your password") } } rstudioapi/man/navigateToFile.Rd0000644000176200001440000000220413535525640016406 0ustar liggesusers\name{navigateToFile} \alias{navigateToFile} \title{ Navigate to File } \description{ Open a file in RStudio, optionally at a specified location. } \note{ The \code{navigateToFile} function was added in version 0.99.719 of RStudio. } \usage{ navigateToFile(file, line = -1L, column = -1L) } \arguments{ \item{file}{Path to the file to open)} \item{line}{Optional; integer specifying the line number on which to place the cursor} \item{column}{Optional; integer specifying the column number on which to place the cursor} } \details{ The \code{navigateToFile} opens a file in RStudio. If the file is already open, its tab or window is activated. Once the file is open, the cursor is moved to the specified location. If the \code{line} and \code{column} arguments are both equal to \code{-1L} (the default), then the cursor position in the document that is opened will be preserved. Note that if your intent is to navigate to a particular function within a file, you can also cause RStudio to navigate there by invoking \code{\link[utils]{View}} on the function, which has the advantage of falling back on deparsing if the file is not available. } rstudioapi/man/previewSql.Rd0000644000176200001440000000124013535525640015645 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/preview.R \name{previewSql} \alias{previewSql} \title{Preview SQL statement} \usage{ previewSql(conn, statement, ...) } \arguments{ \item{conn}{The 'DBI' connection to be used to execute this statement.} \item{statement}{The SQL statement to execute. Either a path to a file containing a SQL statement or the SQL statement itself.} \item{...}{Additional arguments to be used in \code{dbGetQuery()}.} } \description{ Makes use of 'DBI' and \code{dbGetQuery()} to preview a SQL statement for a given 'DBI' connection. } \note{ The \code{previewSql} function was introduced in RStudio 1.2.600 } rstudioapi/man/jobRemove.Rd0000644000176200001440000000101213574017651015432 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/jobs.R \name{jobRemove} \alias{jobRemove} \title{Remove a Job} \usage{ jobRemove(job) } \arguments{ \item{job}{The ID of the job to remove.} } \description{ Remove a job from RStudio's Jobs pane. } \seealso{ Other jobs: \code{\link{jobAddOutput}()}, \code{\link{jobAddProgress}()}, \code{\link{jobAdd}()}, \code{\link{jobRunScript}()}, \code{\link{jobSetProgress}()}, \code{\link{jobSetState}()}, \code{\link{jobSetStatus}()} } \concept{jobs} rstudioapi/man/removeTheme.Rd0000644000176200001440000000061113535525640015765 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/themes.R \name{removeTheme} \alias{removeTheme} \title{Remove a custom theme from RStudio.} \usage{ removeTheme(name) } \arguments{ \item{name}{The unique name of the theme to remove.} } \description{ Remove a custom theme from RStudio. } \note{ The \code{removeTheme} function was introduced in RStudio 1.2.879. } rstudioapi/man/rstudio-documents.Rd0000644000176200001440000001025313574017651017201 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/document-api.R \name{rstudio-documents} \alias{rstudio-documents} \alias{insertText} \alias{modifyRange} \alias{setDocumentContents} \alias{setCursorPosition} \alias{setSelectionRanges} \alias{documentSave} \alias{documentSaveAll} \alias{documentNew} \alias{documentClose} \title{Interact with Documents open in RStudio} \usage{ insertText(location, text, id = NULL) modifyRange(location, text, id = NULL) setDocumentContents(text, id = NULL) setCursorPosition(position, id = NULL) setSelectionRanges(ranges, id = NULL) documentSave(id = NULL) documentSaveAll() documentNew( text, type = c("r", "rmarkdown", "sql"), position = document_position(0, 0), execute = FALSE ) documentClose(id = NULL, save = TRUE) } \arguments{ \item{location}{An object specifying the positions, or ranges, wherein text should be inserted. See \bold{Details} for more information.} \item{text}{A character vector, indicating what text should be inserted at each aforementioned range. This should either be length one (in which case, this text is applied to each range specified); otherwise, it should be the same length as the \code{ranges} list.} \item{id}{The document id. When \code{NULL} or blank, the mutation will apply to the currently open, or last focused, RStudio document. Use the \code{id} returned from \code{\link{getActiveDocumentContext}()} to ensure that the operation is applied on the intended document.} \item{position}{The cursor position, typically created through \code{\link{document_position}()}.} \item{ranges}{A list of one or more ranges, typically created through \code{\link{document_range}()}.} \item{type}{The type of document to be created.} \item{execute}{Should the code be executed after the document is created?} \item{save}{Whether to commit unsaved changes to the document before closing it.} } \description{ Use these functions to interact with documents open in RStudio. Creates a new document in RStudio Closes a document currently open in RStudio. } \details{ \code{location} should be a (list of) \code{\link{document_position}} or \code{\link{document_range}} object(s), or numeric vectors coercable to such objects. To operate on the current selection in a document, call \code{insertText()} with only a text argument, e.g. \preformatted{ insertText("# Hello\\n") insertText(text = "# Hello\\n") } Otherwise, specify a (list of) positions or ranges, as in: \preformatted{ # insert text at the start of the document insertText(c(1, 1), "# Hello\\n") # insert text at the end of the document insertText(Inf, "# Hello\\n") # comment out the first 5 rows pos <- Map(c, 1:5, 1) insertText(pos, "# ") # uncomment the first 5 rows, undoing the previous action rng <- Map(c, Map(c, 1:5, 1), Map(c, 1:5, 3)) modifyRange(rng, "") } \code{modifyRange} is a synonym for \code{insertText}, but makes its intent clearer when working with ranges, as performing text insertion with a range will replace the text previously existing in that range with new text. For clarity, prefer using \code{insertText} when working with \code{\link{document_position}}s, and \code{modifyRange} when working with \code{\link{document_range}}s. \code{documentClose} accepts an ID of an open document rather than a path. You can get the ID of an open document from the \code{getSourceEditorContext} function, among others. Closing is always done non-interactively; that is, no prompts are given to the user. If the user has made changes to the document but not saved them, then the \code{save} parameter governs the behavior: when \code{TRUE}, unsaved changes are committed, and when \code{FALSE} they are discarded. } \note{ The \code{insertText}, \code{modifyRange} and \code{setDocumentContents} functions were added with version 0.99.796 of RStudio. The \code{setCursorPosition} and \code{setSelectionRanges} functions were added with version 0.99.1111 of RStudio. The \code{documentSave} and \code{documentSaveAll} functions were added with version 1.1.287 of RStudio. The \code{documentNew} function was introduced in RStudio 1.2.640 The \code{documentClose} function was introduced in RStudio 1.2.1255 } rstudioapi/man/readPreference.Rd0000644000176200001440000000146413535525640016426 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/prefs.R \name{readPreference} \alias{readPreference} \title{Read Preference} \usage{ readPreference(name, default) } \arguments{ \item{name}{The name of the preference.} \item{default}{The default value to use when the preference is not available.} } \description{ Reads a user preference, useful to remember preferences across different R sessions for the same user. } \details{ User preferences can have arbitrary names and values. You must write the preference with \code{\link{writePreference}} before it can be read (otherwise its default value will be returned). } \note{ The \code{readPreference} function was added in version 1.1.67 of RStudio. } \seealso{ \code{\link{readRStudioPreference}}, which reads RStudio IDE preferences. } rstudioapi/man/launcherConfig.Rd0000644000176200001440000000152413574017651016441 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/launcher-functions.R \name{launcherConfig} \alias{launcherConfig} \title{Define a Launcher Configuration} \usage{ launcherConfig(name, value = NULL) } \arguments{ \item{name}{The name of the launcher configuration.} \item{value}{The configuration value. Must either be an integer, float, or string.} } \description{ Define a launcher configuration, suitable for use with the \code{config} argument to \code{\link[=launcherSubmitJob]{launcherSubmitJob()}}. } \seealso{ Other job submission: \code{\link{launcherContainer}()}, \code{\link{launcherHostMount}()}, \code{\link{launcherNfsMount}()}, \code{\link{launcherPlacementConstraint}()}, \code{\link{launcherResourceLimit}()}, \code{\link{launcherSubmitJob}()}, \code{\link{launcherSubmitR}()} } \concept{job submission} rstudioapi/man/primary_selection.Rd0000644000176200001440000000120313535525640017233 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/document-methods.R \name{primary_selection} \alias{primary_selection} \title{Extract the Primary Selection} \usage{ primary_selection(x, ...) } \arguments{ \item{x}{A document context, or a selection.} \item{...}{Optional arguments (currently ignored).} } \description{ By default, functions returning a document context will return a list of selections, including both the 'primary' selection and also 'other' selections (e.g. to handle the case where a user might have multiple cursors active). Use \code{primary_selection()} to extract the primary selection. } rstudioapi/man/terminalList.Rd0000644000176200001440000000064013535525640016156 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/terminal.R \name{terminalList} \alias{terminalList} \title{Get All Terminal Ids} \usage{ terminalList() } \value{ The terminal identifiers as a character vector. } \description{ Return a character vector containing all the current terminal identifiers. } \note{ The \code{terminalList} function was added in version 1.1.350 of RStudio. } rstudioapi/man/savePlotAsImage.Rd0000644000176200001440000000121013574017651016526 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/stubs.R \name{savePlotAsImage} \alias{savePlotAsImage} \title{Save Active RStudio Plot as an Image} \usage{ savePlotAsImage( file, format = c("png", "jpeg", "bmp", "tiff", "emf", "svg", "eps"), width, height ) } \arguments{ \item{file}{Target filename} \item{format}{Image format ("png", "jpeg", "bmp", "tiff", "emf", "svg", or "eps")} \item{width}{Image width in pixels} \item{height}{Image height in pixels} } \description{ Save the currnently active RStudio as an image file. } \note{ The \code{savePlotAsImage} function was introduced in RStudio 1.1.57 } rstudioapi/man/figures/0000755000176200001440000000000013575747142014673 5ustar liggesusersrstudioapi/man/figures/logo.png0000644000176200001440000005242413535525640016341 0ustar liggesusersPNG  IHDRqsBIT|d pHYs+tEXtSoftwarewww.inkscape.org< IDATxu|g3qw#@Z~r'\׻(TNn!@<ij>?R !f'Ƽ_/`>ߝ<Nl8f,IA51Vx P>1K&H:3xԼ~ʒKETw" u$_\VIA[0EQEtxBx 0 kiƪK*NEaTwhf1Coy ڃ($Y-lSi%TwPt D FxvM ʨ"`LXgk-,IAx1w?WEITw-i|VxRc{3jGK"nH~ܲ?/ rZj, =ŎXjzJOZ2& $J롊l(Joq0$$cZXW$(pݺ)jj"nL\fYhM +icSoVo>atF5I`NpTTM&,4]_JKIm-3uSP"nc kT9D+a)*.%*2?難xo6j߾Z#9x=[x UmŨE!f6p4=S3,MS"/-ԳCyzXSfۨ"nmƭ%4*HI#(eB'dbvHҋET-D ]N;=\'X+dkhpjc+p3D)c 4WХ탋剼@e5PE`&I^Df`x}\1Ԇ:+ixeryIP*H*72&B`vZ۹ ؕ"z-dh1d>;iJvK$Dpl'/q ZcYc!-$̓yݰ U-eB_AiFhul=E:^/ j~_fV)aۅ*`do] g.,ޥ%zʪeR'Izƴ~jȣg"OC5"\1ƃZv١4'z>ߠ*3õ[xH y*b[nŃa]hٕ#[dk3~!<( Q(o;lϘylD;Swإ`ú!;1V ՊO"#oA(XVZF`Ŋ,߫|d =\4yK 8إ}FLl1퀎-ߪEp72Obx}2{5WoCu]M9$ʚ*B$$PQSouD)wtLU8ZZ /$EH} \t*VĆKf"Ho #W/qVĤXwV$ICtIJPtzA*ɧtK+8Y|qG*wHp))I9`lYsl.snv?hVOA26Yr k%:V}u`v"(9$~[$28(RZypF|}}o||55[@ZZ}'_PXP\;pPT^!銈\ZGk'V48"nAdO^f&-uJ8r8fXŏwd2y(ťDFҽ{W֛5=~S:t!228Z$B=dpv/!5DP%㠆+{x#<[>DPz>rک!*GA|̜1iyv)bØ`^ T&-y-k'WѾD}IGE牼ЉBۉA֥3<}/fkIS" ,z!.AtioTyɟI|nXנ/,.J;l1'g\UU7'^YgUVkpIR"=_o W"ҙhAZAe=x]D^\g GRVS`{*cFIʛ!R]yy*O>v'::ƽ͆<֮YMTX g @>r!+dW4x>x?C$>G>#w>DGGZ233ٲy1܆{ʴW >D|vQx*>{ۜ yԓ_.?$IxGwq{@pN ׏Mf'9ݸ39?MNrr 2,_&ip3| ¢i`0pF N'B\!IO<6~ͬY7ѳgOd:DQIo}0<|GaO8[̤Iͤ)"ܵ%'(n @(i`_R&kkhSn̶wٛ>.#9@?9M#u<5Â58W&spz`a쒅Q9Q3-5[:! Y܄MH0f1&bv﬋pB:m:zFn "\:!.gVVUQRR֢DMq,+ZVҁ?V$I*er ,!**㹧vŘ ׵>A ea4]&Ö֞ ^$dզi.D%'Fjj1|0ϜqyS%sL8޽epE\\w?Q8ŗ_}O] VfeI=k| Çhd_UUk9u$ 2ݻ7xqxNX,XNjׇ믿^N\oX1-ۏ tolmQk#!>nQzΓG=(\-]Ӻic*09MZ ٸ{UD%3iԗ8u?˟]v5!Æ)"3l2+(~%T_TÚU?Sg21exofg{^^^G~E{3f8**XxC9l$%nf\:+6-[_7ngdVTO>ﺑn\D$\=3$>*3NIxa> Ty۫Vb/+1o:SiM׽eą%:ǃNo>w9[°aemM~)}~0яAX2kSpͱ|R.4i#F%:=z5ˆ Tw|B"=U\A.`0ғ{1w^=gAJҧ^@$bCcX`˶Fx|1ˎi;A޹vc'ri|*% yݱnfҔڵ6fJ";BBzӍ@??##kx/Nռ ŠoT]S'r @p2f?Lwn3Q;!Pk#ȯMfYq*I_ /nzBiXnf _e2 ,|cXt$АjMwm6+*a ӿ|ݿoGp0"[n<69OggTegȐ?pzPU[ũB HwF޽@~jZW^,ucucG9]UM||bFEF`0+>u 8{=ӳgw ʊm\;dfhyK@WZkzcqǹ@v16HBx>F*++9 _Ah|GT,xؒH-%-DǍysCieE%\s^;s }MևUfkXmMhH0_w9_~ qQg#8~}:3W`z.zUtns Wy;w q%nƱS/kz4v'g֝d23pxFњt:7r ӽKW.KK;d_p &z4/Ilu+ya?У{WEU|ң{}%=eXm 6M@jj*wh䒉cdbw愇rٌIgWƪ[ޣ**MqqiKNFJG]xρ,;̆J[Ю>NxDaǎcmtJ[gmm-.Ag8$HOKQEa"h4f{aNdu:vCVjm֢S-V+:7s0kZ,V(( 1LͿjkk pIsbu;Fli *Mqq6EEE$'==9ElչLbUGˠijǠ'FsXHN;.Kp88tk߹9El: V$;;ۭ۷ĸh%+"N;. ÷j ,gՑv ~Vu".0hZՑ#3ڗeY7sŴq{:*SV+Z6/r{nb˜ltIđ#Gڿ;O7 TE=,V+Ka}TTV 4{ ΰZmhdqEE%?cXVcy$;Z99'i2rNHMMኙ jzKh4Gaq|-UյQZzȈyf&Xgض}7klOgMжDlxwJ:zĥl~XƉܓ\yr,׸kb^/   7x}r4g~>=3pl;'O'DX?zħ\=Yw_Vx9(6^|-~)} @ΰl޼')%enןh4v֫II&5+~F_ z q Jyc1w΍4y3(utFrt2s>l oVlټaiGHh"Vd(ַb"޻I ^iuĆưo!O?-gw^ <]xHz<,X͙HM{%0Y IDATu&5?8/^2\hZNԩ[b M47b[ڌ6>ߧU[5ɤґ"j&VQiM:iFVtZ_#qAQ)8~fs~";w5qaq>*o }&stt4&fӶ^P5"lM1ӿn̛"ѣeY9Ggūpy.y-+2FbNϙw>_!t;ȏ?|ރټt̝u$zl)pnv \wXZ|yLݨ:Vyk>tgDPP!o""Ӧ.p8Z'pAs:Q8o|µNqAf̸rVSs:'ʃeyW7nڷ(̼ >r{dj-զouJ[eĢ}_ Qgm`` &LW?j$vInzRr2oM)El&t[~ }6`С ^=z N3g6LY:6ujk'vӶ 0jޟC;W0}eƈ̙s(x S2*@@}(MYʦuTNsxl%큪ZL:1!!!Lk謓XV{"rNЭ[6Ig钜ҬZ~ 7?kZN*b#q{ڱ]tUUU|ݷdffئ.lھşm2~ή}YLx[ZΉ+>Fzee% ukm'>p0;QZZNBB,F!""\,VZ;;~ݴC`XHIId1b2 lhqq16>yw\Kp?Knk׮n#8ѵuu_crƈ! ʌaTUUZUUE".**ᗍ[=EXX0ӳE̝Ͽ MY;lݾ[>=96ͼ۬]G >~{7q?__Yyg uk jZħNsog&FX^xmLfl!2r]9ȡMrۭv ou{Jˏj"ý/bA߼%(&ݒ(,/n$IWHMVq8坛KFd1QVq&?#6:(=Z$IYG =6bh^znݺp7W?3{:Ir0Ihh\=c" =vnns%χ@6+A},u뢈}NKDyE% Ă pםiRVoC.I<=n==Es0zN, U(vVx@*8Cuu5A͟ʡ{ca2 ޠq獗pZu^Mج&MA`a9 |}>`kp8MF~a41*0t\se\utJJN*[cK㣩uΚGnT63{(w&˗?߃ƃА` +UUU% "a"`n 0zvÙ8zVyFſU(--mվ%IbL8zjߞVSTU)t:tmfUnn.L5,Odzf Yfj4xꁛ[ϖꖈ#jK:IީYL&,^3bkq \5}<_xy$IXKΉ|3 ok#šR["xPp*k8u믾d¨LxQX(Gx=͜xsYV-\HIIy3W#ènZӊ8(Пr>#lBNN٬Y>篏֦7]/׍$|gn(w#$ػJJ]mˍ:tS6=Cxh076nضyF=^ )>MKF10OɛNe@n+yV_:!lٺ-[5ZɢC0]2[͌Mk_TRU]Ogjj1*怣2g:H NV8UQN&VQPPEQEQEQEQEQEQEQEQEQEQEQEi5mW-ڴK[~.Css"Kس uu&8~cG@]ݴe˖^G=iQc0? **gNgZBkjdj6oNUu5 1)'Y⧟RXT($'q5\]3TVTw8p0V`LȰ![rH[5k7p#}ʙݪ)mY]qj;]= o6[oa7A>LNO[w")n[+=㻓қ8KXr5Ç R4'p~~~MCj\W4hY.@?W Cͷ?0>]z;Aa:>l6૯~$%*)IJ+VЧO_/C>HL-[G{eJEĆƐw2Uf䈡h%cuR]_PĆ } !!^'51|BߜoIOKt":Q `p|f"n][M?SUQï*w]o[ @EtZIщŧǥĄFN 0@oDAAb}ge > zzcҕfgu9HUu5q\zX(AVQVB80#HjivNs"V.UT:8UT:8UT:8UT:8UT:8UT:8jUN·ܶrKj%B=sj ; <> ZZ-z~:9Lo߄Bg2p(ޑCa ܊VzQN_6dJcxdYy퇭Z>\ۺc* ]`c "mQpTDsW p:6D~IOy(_g@#JV[Ш4tGߺK VhpX֣,?:Ҷ) Cm|^oW/o(16:'UCZ78кӞŸ.bכU K\;]U̼TLqocڀֽ/dtZb+^ldcAY +, :+ Uޡ-c+j}$4RWwrEB1>DRNT R<}r1Ca@I@ bC$E_OV& r[V_(j'88^"Z6dj1^?b"1Gf7lpt㫭Glx g|Eg>zxygq'gX|:;Q6F7ta! _e1 sZFi)VbCg؜؞)\1$۴xmG5V7~0$ƌv%5jؔ%'O2鼯壇~vfcbo{;韮kV7Lg!6FBL)1JzrJz[*]E5S"w|`t;XϹf |U>9pRߏPL?G~Lɍ[U:< ێ5&u-:ҳ ?p><مoI~c iU}ZVӒ#.pQCuؔaSt`?.~^5F8y䗋|!`wo3#ƹr1u7Śb48|iw,|bp)s2 <>OUvhc>CkhIYϦl }nfgu-s)#Ӂ=.D6-M_j٘FKt<)QooX\c6"ZKmZ^E96//\26d]nBg5CmĆHzD݅h_~U_!~N$9"T18uq[Ǵü_tN ^nafen ڵZ_t7cl<8aΓz|5\pH}lF^F"%"N4|Cn2P/@x{~ZWU:_hvMq^1GwNDc<>~U2Q&+,ۭe> DϮ173 NnPU&qqՖ 6++i(rU |^˜ Z kTQĉ 1k \aǰ&jU7/5[=ŕ/I i&}NdWۧt: H|q^q,ީ)h \^q#KggЈ#gqPß>54+?+y+hŐטva1kb.-s~֒bw2~-2[hhT9Nun8;sm)A.U5p1Ѭ"0;ӽ \n{]ZU.Lghۢ]X:-\>A=Һ\C;R <;jWWSawwW~Ǜq-~?&aG5kkA>8ua+LlqVUnii7J{.Ӟ OM:ϥQυ2*MPpڽ\l^Vsv(,zj_5.& \ؗ;]3qo]'\ts&3b "4b}Dwf{r$a;N}sozOG^%؅~ws1 +9ilϳʉˊZ{[= .=>[#?{-!DlwL};+u;7>ZB\El> 54r\hN<񥁣Ev,ym׹-(υFv1Yj~ڮLpJ1pGr.AAu-"Pb栳bp🕺gŕ1\ԑ_^{DŅzZܠWfM\exoO>i_2EujD'MrLǛĔ~gcz8Wϫ]ɍ#ByIDATq>gvL-|1g/xvO4x .خe =cԚa 윞bծ],qV|[9z-8x>HU:_cNS"<<^;8vm%2LIP{:K'wm)~]f`)(X{@#bsMɛ6/aS40e_>zVh5δ̜+ jD}Yg3}yZ\: J\+6FǦZydjiyTNv1k\LW 5\z9x6snrktӬy&xck0!mЂ =ڈb{\$`\nkK N-f"8JOp&#Ae↋ ?teoWXri\om7p8+_|>f.j"}FmSjCUox[3a0v,+w7O)vwIh: -GDՈ'.>6tDCveJ{5<%R^#o|u w0ݥH,G;k(ЊzZNT:9Jt4 ie Nէ`zI?Y*~F EJƆHn-dvTÉ :HP?>tu4nr{:%Pi?)1\!*!I፽opu8O I'GÚ"'OX=cLh {sEj̍cHG~ 9%"o-ױbD~̲M H"wOغ,**nќ&`/6jeGJIY4Bk6ü ᨏמs~)hY"ɲn7j[/Am/.q>MRQQiȶc"׽ó . fI3vN>}-. `֧-cc<5ý 7XSAVi`wz"D1_]`N]g^i ITnwVE|vsb I{5\wWd X2$asdeyf.g;Lø1=.I< gW\YV-OͰ?IUʅz3tx$κ+ʛ{{nM00fvfJvLqu|գ*Iy-XGN;=:l6Zsl'&J NQƇjtwɒD.8 >fΘHnCCCƭ%<i$$ W1OEqPK591B$9^Kzr XjKCfhdO^f&-FU:&G^ZO!Bw~Ȁ_U ?gT]ƖR87RU9\ry9 ivN=<^T/k/ӻwR'B;vi_FA!EY{Ujǐc;YӴ*A>?y>$v`/+Jxo!~_>I|{7)IۚȾ3q8̸:-DA>QQS… ٺv7j93 蓂EizջQe@6`F'v$B]cG'3s"Yո}6NC߆#BO{*PᎢ^DMHJ>ޒ<盙6k K)t~mI}CP;6Oүorv{p++5uLżYX_QQ?n>Ih_d]Իt;mٳ 4z|L~A]Tԫٳf2erVS,)a y[:*?ֽßwbQfUylees}LTcYʕ iip)j*+BJ~]&q8 <N{ΐ`WK lh=fF$ +-8oUyNʣA-&m1Z4 q+Ι[\G8D!;;l4j΢%ޝ[tZDh-lr+-`UjNΏo!va(SMrM~WԈ)F;!nYy@jT{a*;b߮c:LM7b.ĭ(Z\v78"o>R}i]AqHVM0F!xK/E(b;-B{hte+&G5[Jw2=f$qVl3e(.TѤ{hUԊ_cqTeA\_õqI^x4ӓ*lBGv!=9+qb26쉖Ke\?S6ϗ%VB0p !otadf|4TkV'\ijST n#p(҈x֗X!n6 K(rY-. [C"!Ş9z-1!nUy+Z*['Xzػf$E:>-S_h'.)#E(zf[p(HRTAU.}J=:ĭ8b p;|kr=e7ìʿA[S)rSyi SyNU}rBT1ay(lPP q'ĺxi>*RgL{m>=Q4 3w T1.yǍ7q)F AbB"FJʿIYTs OXU qWGyRqSgذῘ:X,7`'gq5d.5PE(k iǥs}!IFai+Z#ʳ :pA lB]X8}+w8pu`mZEu N/>o>an^ߪX؇ Pa(gyYp]هE9AZ17QcǎjmeW\]θqc">wk"1 =Erkǘ>\U;T2#K%XPDJ,ȷqT 3"CADؔxq:<s޾j( 0BD&1CaMy| .Ş]b}9}3(ɉL?OOG(%jzm멊QD$<.4_IyъQ!6PGh>_< ge`M-GHxE(HhTc 3F8dQʣf}V2)ˀz(a(`M5}-b22f̭cQYR'̙?B?SDl*݋(9kRʵ8-u*av<''?k-4.?lF揺L ߏ.X!c˞h}U.Gjۤ8& qxgLE01Cٚ)`FLE01C,WӳBF居 !O=ץLB q<]ylV=u>]Lt q0uǰ% tW2 .1nf&zb8q>R0S"Vyo5/}0Ciu"֫8™o0ZюNIENDB`rstudioapi/man/figures/logo.svg0000644000176200001440000007420513575747142016364 0ustar liggesusers image/svg+xml rstudioapi rstudioapi/man/writePreference.Rd0000644000176200001440000000111613535525640016637 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/prefs.R \name{writePreference} \alias{writePreference} \title{Write Preference} \usage{ writePreference(name, value) } \arguments{ \item{name}{The name of the preference.} \item{value}{The value of the preference.} } \description{ Writes a user preference, useful to remember preferences across different R sessions for the same user. } \note{ The \code{writePreference} function was added in version 1.1.67 of RStudio. } \seealso{ \code{\link{writeRStudioPreference}}, which changes RStudio IDE preferences. } rstudioapi/man/projects.Rd0000644000176200001440000000216213535525640015341 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/stubs.R \name{projects} \alias{projects} \alias{openProject} \alias{initializeProject} \title{Open a Project in RStudio} \usage{ openProject(path = NULL, newSession = FALSE) initializeProject(path = getwd()) } \arguments{ \item{path}{Either the path to an existing \code{.Rproj} file, or a path to a directory in which a new project should be initialized and opened.} \item{newSession}{Boolean; should the project be opened in a new session, or should the current RStudio session switch to that project? Note that \code{TRUE} values are only supported with RStudio Desktop and RStudio Server Pro.} } \description{ Initialize and open RStudio projects. } \details{ Calling \code{openProject()} without arguments effectively re-opens the currently open project in RStudio. When switching projects, users will be prompted to save any unsaved files; alternatively, you can explicitly save any open documents using \code{\link{documentSaveAll}()}. } \note{ The \code{openProject} and \code{initializeProject} functions were added in version 1.1.287 of RStudio. } rstudioapi/man/getThemeInfo.Rd0000644000176200001440000000166613535525640016076 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/themes.R \name{getThemeInfo} \alias{getThemeInfo} \title{Retrieve Themes} \usage{ getThemeInfo() } \description{ Retrieves a list with information about the current color theme used by RStudio. } \details{ A list is returned with the following elements: \describe{ \item{editor}{The name of the current editor theme, such as \code{Textmate}.} \item{global}{The name of the current global theme. One of \code{Modern}, \code{Classic}, or \code{Sky}.} \item{dark}{\code{TRUE} if the editor theme is dark, \code{FALSE} otherwise.} \item{foreground}{The current editor theme's default text foreground color, formatted as a CSS-compatible color string, such as \code{rgb(1, 22, 39)}. Supported since RStudio 1.2.1214.} \item{background}{The current editor theme's default text background color, formatted as a CSS-compatible color string. Supported since RStudio 1.2.1214.} } } rstudioapi/man/launcherSubmitR.Rd0000644000176200001440000000223113574017651016615 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/launcher-functions.R \name{launcherSubmitR} \alias{launcherSubmitR} \title{Execute an R Script as a Launcher Job} \usage{ launcherSubmitR(script, cluster = "Local", container = NULL) } \arguments{ \item{script}{Fully qualified path of R script. Must be a path that is available in the job container (if using containerized job cluster such as Kubernetes).} \item{cluster}{The name of the cluster this job should be submitted to.} \item{container}{The container to be used for launched jobs.} } \description{ Convenience function for running an R script as a launcher job using whichever R is found on the path in the launcher cluster. } \details{ See \code{\link[=launcherSubmitJob]{launcherSubmitJob()}} for running jobs with full control over command, environment, and so forth. } \seealso{ Other job submission: \code{\link{launcherConfig}()}, \code{\link{launcherContainer}()}, \code{\link{launcherHostMount}()}, \code{\link{launcherNfsMount}()}, \code{\link{launcherPlacementConstraint}()}, \code{\link{launcherResourceLimit}()}, \code{\link{launcherSubmitJob}()} } \concept{job submission} rstudioapi/man/highlightUi.Rd0000644000176200001440000000334113605427107015752 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/highlight-ui.R \name{highlightUi} \alias{highlightUi} \title{Highlight UI Elements within the RStudio IDE} \usage{ highlightUi(queries) } \arguments{ \item{queries}{A list of "query" objects. Each query should be a list with entries \code{"query"} and \code{"parent"}. See \strong{Queries} for more details.} } \description{ This function can be used to highlight UI elements within the RStudio IDE. UI elements can be selected using query selectors; most commonly, one should choose to highlight elements based on their IDs when available. } \details{ The tool at:\preformatted{Help -> Diagnostics -> Show DOM Elements } can be useful for identifying the classes and IDs assigned to the different elements within RStudio. } \note{ The \code{executeCommand} function was introduced in RStudio 1.3.658. } \section{Queries}{ Elements are selected using the same queries as through the web \code{querySelectorAll()} API. See \url{https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll} for more details. For example, to highlight the Save icon within the Source pane, one might use:\preformatted{rstudioapi::highlightUi("#rstudio_tb_savesourcedoc") } In some cases, multiple UI elements need to be highlighted -- e.g. if you want to highlight both a menu button, and a menu item within the menu displayed after the button is pressed. We'll use the Environment Pane's Import Dataset button as an example. To highlight the \verb{From Text (readr)} command, you might use:\preformatted{rstudioapi::highlightUi( list( list(query = "#rstudio_mb_import_dataset", parent = 0L), list(query = "#rstudio_label_from_text_readr_command", parent = 1L) ) ) } } rstudioapi/man/askForSecret.Rd0000644000176200001440000000124113574017651016101 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/dialogs.R \name{askForSecret} \alias{askForSecret} \title{Show Prompt for Secret Dialog} \usage{ askForSecret( name, message = paste(name, ":", sep = ""), title = paste(name, "Secret") ) } \arguments{ \item{name}{The name of the secret.} \item{message}{A character vector with the contents to display in the main dialog area.} \item{title}{The title to display in the dialog box.} } \description{ Shows a dialog box asking for a secret with support to remember such secret using the 'keyring' package. } \note{ The \code{askForSecret} function was added in version 1.1.419 of RStudio. } rstudioapi/man/terminalSend.Rd0000644000176200001440000000130113574017651016130 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/terminal.R \name{terminalSend} \alias{terminalSend} \title{Send Text to a Terminal} \usage{ terminalSend(id, text) } \arguments{ \item{id}{The terminal id. The \code{id} is obtained from \code{\link{terminalList}()}, \code{\link{terminalVisible}()}, \code{\link{terminalCreate}()}, or \code{\link{terminalExecute}()}.} \item{text}{Character vector containing text to be inserted.} } \description{ Send text to an existing terminal. } \note{ The \code{terminalSend} function was added in version 1.1.350 of RStudio. } \examples{ \dontrun{ termId <- rstudioapi::terminalCreate() rstudioapi::terminalSend(termId, 'ls -l\n') } } rstudioapi/man/applyTheme.Rd0000644000176200001440000000061413535525640015620 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/themes.R \name{applyTheme} \alias{applyTheme} \title{Apply an Editor Theme to RStudio} \usage{ applyTheme(name) } \arguments{ \item{name}{The unique name of the theme to apply.} } \description{ Applies the specified editor theme to RStudio. } \note{ The \code{applyTheme} function was introduced in RStudio 1.2.879. } rstudioapi/man/file-dialogs.Rd0000644000176200001440000000270413574017651016052 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/stubs.R \name{file-dialogs} \alias{file-dialogs} \alias{selectFile} \alias{selectDirectory} \title{Select a File / Folder} \usage{ selectFile( caption = "Select File", label = "Select", path = getActiveProject(), filter = "All Files (*)", existing = TRUE ) selectDirectory( caption = "Select Directory", label = "Select", path = getActiveProject() ) } \arguments{ \item{caption}{The window title.} \item{label}{The label to use for the 'Accept' / 'OK' button.} \item{path}{The initial working directory, from which the file dialog should begin browsing. Defaults to the current RStudio project directory.} \item{filter}{A glob filter, to be used when attempting to open a file with a particular extension. For example, to scope the dialog to \R files, one could use \code{R Files (*.R)} here.} \item{existing}{Boolean; should the file dialog limit itself to existing files on the filesystem, or allow the user to select the path to a new file?} } \description{ Prompt the user for the path to a file or folder, using the system file dialogs with RStudio Desktop, and RStudio's own web dialogs with RStudio Server. } \details{ When the selected file resolves within the user's home directory, RStudio will return an aliased path -- that is, prefixed with \code{~/}. } \note{ The \code{selectFile} and \code{selectDirectory} functions were added in version 1.1.287 of RStudio. } rstudioapi/man/terminalActivate.Rd0000644000176200001440000000207513574017651017010 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/terminal.R \name{terminalActivate} \alias{terminalActivate} \title{Activate Terminal} \usage{ terminalActivate(id = NULL, show = TRUE) } \arguments{ \item{id}{The terminal id. The \code{id} is obtained from \code{\link{terminalList}()}, \code{\link{terminalVisible}()}, \code{\link{terminalCreate}()}, or \code{\link{terminalExecute}()}. If NULL, the terminal tab will be selected but no specific terminal will be chosen.} \item{show}{If TRUE, bring the terminal to front in RStudio.} } \description{ Ensure terminal is running and optionally bring to front in RStudio. } \note{ The \code{terminalActivate} function was added in version 1.1.350 of RStudio. } \examples{ \dontrun{ # create a hidden terminal and run a lengthy command termId = rstudioapi::terminalCreate(show = FALSE) rstudioapi::terminalSend(termId, "sleep 5\n") # wait until a busy terminal is finished while (rstudioapi::terminalBusy(termId)) { Sys.sleep(0.1) } print("Terminal available")#' rstudioapi::terminalActivate(termId) } } rstudioapi/man/showPrompt.Rd0000644000176200001440000000112713535525640015672 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/dialogs.R \name{showPrompt} \alias{showPrompt} \title{Show Prompt Dialog Box} \usage{ showPrompt(title, message, default = NULL) } \arguments{ \item{title}{The title to display in the dialog box.} \item{message}{A character vector with the contents to display in the main dialog area.} \item{default}{An optional character vector that fills the prompt field with a default value.} } \description{ Shows a dialog box with a prompt field. } \note{ The \code{showPrompt} function was added in version 1.1.67 of RStudio. } rstudioapi/man/hasColorConsole.Rd0000644000176200001440000000077213535525640016612 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/stubs.R \name{hasColorConsole} \alias{hasColorConsole} \title{Check if Console Supports ANSI Color Escapes} \usage{ hasColorConsole() } \value{ a boolean } \description{ Check if Console Supports ANSI Color Escapes } \note{ The \code{hasColorConsole} function was added in version 1.1.216 of RStudio. } \examples{ \dontrun{ if (rstudioapi::hasColorConsole()) { message("RStudio console supports ANSI color sequences.") } } } rstudioapi/man/launcherResourceLimit.Rd0000644000176200001440000000205513574017651020022 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/launcher-functions.R \name{launcherResourceLimit} \alias{launcherResourceLimit} \title{Define a Launcher Resource Limit} \usage{ launcherResourceLimit(type, value) } \arguments{ \item{type}{The resource limit type. Must be one of cpuCount, cpuFrequency, cpuSet, cpuTime, memory, memorySwap. Different launcher plugins may support different subsets of these resource limit types; please consult the plugin documentation to learn which limits are supported.} \item{value}{The formatted value of the requested limit.} } \description{ Define a launcher resource limit, suitable for use with the \code{resourceLimits} argument to \code{\link[=launcherSubmitJob]{launcherSubmitJob()}}. } \seealso{ Other job submission: \code{\link{launcherConfig}()}, \code{\link{launcherContainer}()}, \code{\link{launcherHostMount}()}, \code{\link{launcherNfsMount}()}, \code{\link{launcherPlacementConstraint}()}, \code{\link{launcherSubmitJob}()}, \code{\link{launcherSubmitR}()} } \concept{job submission} rstudioapi/man/launcherNfsMount.Rd0000644000176200001440000000205213574017651017002 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/launcher-functions.R \name{launcherNfsMount} \alias{launcherNfsMount} \title{Define a Launcher NFS Mount} \usage{ launcherNfsMount(host, path, mountPath, readOnly = TRUE) } \arguments{ \item{host}{The host name, or IP address, of the NFS server.} \item{path}{The NFS path to be mounted.} \item{mountPath}{The destination path for the mount in the container.} \item{readOnly}{Boolean; should the path be mounted read-only?} } \description{ Define a launcher NFS mount, suitable for use with the \code{mounts} argument to \code{\link[=launcherSubmitJob]{launcherSubmitJob()}}. This can be used to mount a path from a networked filesystem into a newly generated container. } \seealso{ Other job submission: \code{\link{launcherConfig}()}, \code{\link{launcherContainer}()}, \code{\link{launcherHostMount}()}, \code{\link{launcherPlacementConstraint}()}, \code{\link{launcherResourceLimit}()}, \code{\link{launcherSubmitJob}()}, \code{\link{launcherSubmitR}()} } \concept{job submission} rstudioapi/man/updateDialog.Rd0000644000176200001440000000117013535525640016110 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/dialogs.R \name{updateDialog} \alias{updateDialog} \title{Updates a Dialog Box} \usage{ updateDialog(...) } \arguments{ \item{...}{Named parameters and values to update a dialog box.} } \description{ Updates specific properties from the current dialog box. } \details{ Currently, the only dialog with support for this action is the New Connection dialog in which the code preview can be updated through this API. \preformatted{ updateDialog(code = "con <- NULL") } } \note{ The \code{updateDialog} function was added in version 1.1.67 of RStudio. } rstudioapi/man/terminalCreate.Rd0000644000176200001440000000250713535525640016452 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/terminal.R \name{terminalCreate} \alias{terminalCreate} \title{Create a Terminal} \usage{ terminalCreate(caption = NULL, show = TRUE, shellType = NULL) } \arguments{ \item{caption}{The desired terminal caption. When \code{NULL} or blank, the terminal caption will be chosen by the system.} \item{show}{If \code{FALSE}, terminal won't be brought to front.} \item{shellType}{Shell type for the terminal: NULL or "default" to use the shell selected in Global Options. For Microsoft Windows, alternatives are "win-cmd" for 64-bit Command Prompt, "win-ps" for 64-bit PowerShell, "win-git-bash" for Git Bash, or "win-wsl-bash" for Bash on Windows Subsystem for Linux. On Linux, Mac, and RStudio Server "custom" will use the custom terminal defined in Global Options. If the requested shell type is not available, the default shell will be used, instead.} } \value{ The terminal identifier as a character vector (\code{NULL} if unable to create the terminal or the given terminal caption is already in use). } \description{ Create a new Terminal. } \note{ The \code{terminalCreate} function was added in version 1.1.350 of RStudio and the ability to specify shellType was added in version 1.2.696. } \examples{ \dontrun{ termId <- rstudioapi::terminalCreate('My Terminal') } } rstudioapi/man/terminalKill.Rd0000644000176200001440000000100713535525640016134 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/terminal.R \name{terminalKill} \alias{terminalKill} \title{Kill Terminal} \usage{ terminalKill(id) } \arguments{ \item{id}{The terminal id. The \code{id} is obtained from \code{\link{terminalList}()}, \code{\link{terminalVisible}()}, \code{\link{terminalCreate}()}, or \code{\link{terminalExecute}()}.} } \description{ Kill processes and close a terminal. } \note{ The \code{terminalKill} function was added in version 1.1.350 of RStudio. } rstudioapi/man/terminalClear.Rd0000644000176200001440000000126413574017651016275 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/terminal.R \name{terminalClear} \alias{terminalClear} \title{Clear Terminal Buffer} \usage{ terminalClear(id) } \arguments{ \item{id}{The terminal id. The \code{id} is obtained from \code{\link{terminalList}()}, \code{\link{terminalVisible}()}, \code{\link{terminalCreate}()}, or \code{\link{terminalExecute}()}.} } \description{ Clears the buffer for specified terminal. } \note{ The \code{terminalClear} function was added in version 1.1.350 of RStudio. } \examples{ \dontrun{ termId <- rstudioapi::terminalCreate() rstudioapi::terminalSend(termId, 'ls -l\n') Sys.sleep(3) rstudioapi::terminalClear(termId) } } rstudioapi/man/systemUsername.Rd0000644000176200001440000000037213617331207016530 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/user.R \name{systemUsername} \alias{systemUsername} \title{Get System Username} \usage{ systemUsername() } \description{ Returns the system username of the current user. } rstudioapi/man/persistent-values.Rd0000644000176200001440000000133113535525640017202 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/stubs.R \name{persistent-values} \alias{persistent-values} \alias{setPersistentValue} \alias{getPersistentValue} \title{Persistent Keys and Values} \usage{ setPersistentValue(name, value) getPersistentValue(name) } \arguments{ \item{name}{Key name} \item{value}{Key value} } \value{ The stored value as a character vector (\code{NULL} if no value of the specified name is available). } \description{ Store persistent keys and values. Storage is per-project, if there is no project currently active then a global store is used. } \note{ The \code{setPersistentValue} and \code{getPersistentValue} functions were added in version 1.1.57 of RStudio. } rstudioapi/man/isAvailable.Rd0000644000176200001440000000161313542731513015720 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/code.R \name{isAvailable} \alias{isAvailable} \alias{verifyAvailable} \title{Check if RStudio is running.} \usage{ isAvailable(version_needed = NULL, child_ok = FALSE) verifyAvailable(version_needed = NULL) } \arguments{ \item{version_needed}{An optional version specification. If supplied, ensures that RStudio is at least that version.} \item{child_ok}{Boolean; check if the current R process is a child process of the main RStudio session? This can be useful for e.g. RStudio Jobs, where you'd like to communicate back with the main R session from a child process through \code{rstudioapi}.} } \value{ \code{isAvailable} a boolean; \code{verifyAvailable} an error message if RStudio is not running } \description{ Check if RStudio is running. } \examples{ rstudioapi::isAvailable() \dontrun{rstudioapi::verifyAvailable()} } rstudioapi/man/terminalBusy.Rd0000644000176200001440000000153013574017651016165 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/terminal.R \name{terminalBusy} \alias{terminalBusy} \title{Is Terminal Busy} \usage{ terminalBusy(id) } \arguments{ \item{id}{The terminal id. The \code{id} is obtained from \code{\link{terminalList}()}, \code{\link{terminalVisible}()}, \code{\link{terminalCreate}()}, or \code{\link{terminalExecute}()}.} } \value{ a boolean } \description{ Are terminals reporting that they are busy? } \note{ The \code{terminalBusy} function was added in version 1.1.350 of RStudio. } \examples{ \dontrun{ # create a hidden terminal and run a lengthy command termId <- rstudioapi::terminalCreate(show = FALSE) rstudioapi::terminalSend(termId, "sleep 5\n") # wait until a busy terminal is finished while (rstudioapi::terminalBusy(termId)) { Sys.sleep(0.1) } print("Terminal available") } } rstudioapi/man/jobSetStatus.Rd0000644000176200001440000000111713574017651016142 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/jobs.R \name{jobSetStatus} \alias{jobSetStatus} \title{Set Job Status} \usage{ jobSetStatus(job, status) } \arguments{ \item{job}{The ID of the job to update.} \item{status}{Text describing job's new status.} } \description{ Update a job's informational status text. } \seealso{ Other jobs: \code{\link{jobAddOutput}()}, \code{\link{jobAddProgress}()}, \code{\link{jobAdd}()}, \code{\link{jobRemove}()}, \code{\link{jobRunScript}()}, \code{\link{jobSetProgress}()}, \code{\link{jobSetState}()} } \concept{jobs} rstudioapi/man/launcherPlacementConstraint.Rd0000644000176200001440000000170013574017651021205 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/launcher-functions.R \name{launcherPlacementConstraint} \alias{launcherPlacementConstraint} \title{Define a Launcher Placement Constraint} \usage{ launcherPlacementConstraint(name, value = NULL) } \arguments{ \item{name}{The name of this placement constraint.} \item{value}{The value of the constraint. A job will only be placed on a requested node if the requested placement constraint is present.} } \description{ Define a launcher placement constraint, suitable for use with the \code{placementConstraints} argument to \code{\link[=launcherSubmitJob]{launcherSubmitJob()}}. } \seealso{ Other job submission: \code{\link{launcherConfig}()}, \code{\link{launcherContainer}()}, \code{\link{launcherHostMount}()}, \code{\link{launcherNfsMount}()}, \code{\link{launcherResourceLimit}()}, \code{\link{launcherSubmitJob}()}, \code{\link{launcherSubmitR}()} } \concept{job submission} rstudioapi/man/jobAddOutput.Rd0000644000176200001440000000122413574017651016113 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/jobs.R \name{jobAddOutput} \alias{jobAddOutput} \title{Add Job Output} \usage{ jobAddOutput(job, output, error = FALSE) } \arguments{ \item{job}{The ID of the job that has emitted text.} \item{output}{The text output emitted by the job.} \item{error}{Whether the output represents an error.} } \description{ Adds text output to a job. } \seealso{ Other jobs: \code{\link{jobAddProgress}()}, \code{\link{jobAdd}()}, \code{\link{jobRemove}()}, \code{\link{jobRunScript}()}, \code{\link{jobSetProgress}()}, \code{\link{jobSetState}()}, \code{\link{jobSetStatus}()} } \concept{jobs} rstudioapi/man/executeCommand.Rd0000644000176200001440000000204313535525640016447 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/commands.R \name{executeCommand} \alias{executeCommand} \title{Execute Command} \usage{ executeCommand(commandId, quiet = FALSE) } \arguments{ \item{commandId}{The ID of the command to execute.} \item{quiet}{Whether to show an error if the command does not exist.} } \description{ Executes an arbitrary RStudio command. } \details{ Most menu commands and many buttons in RStudio can be invoked from the API using this method. The \code{quiet} command governs the behavior of the function when the command does not exist. By default, an error is shown if you attempt to invoke a non-existent command. You should set this to \code{TRUE} when invoking a command that may not be available if you don't want your users to see an error. The command is run asynchronously, so no status is returned. See the RStudio Server Professional Administration Guide appendix for a list of supported command IDs. } \note{ The \code{executeCommand} function was introduced in RStudio 1.2.1261. } rstudioapi/man/terminalContext.Rd0000644000176200001440000000263113535525640016671 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/terminal.R \name{terminalContext} \alias{terminalContext} \title{Retrieve Information about RStudio Terminals} \usage{ terminalContext(id) } \arguments{ \item{id}{The terminal id. The \code{id} is obtained from \code{\link{terminalList}()}, \code{\link{terminalVisible}()}, \code{\link{terminalCreate}()}, or \code{\link{terminalExecute}()}.} } \value{ A \code{list} with elements: \tabular{ll}{ \code{handle} \tab the internal handle\cr \code{caption} \tab caption\cr \code{title} \tab title set by the shell\cr \code{working_dir} \tab working directory\cr \code{shell} \tab shell type\cr \code{running} \tab is terminal process executing\cr \code{busy} \tab is terminal running a program\cr \code{exit_code} \tab process exit code or NULL\cr \code{connection} \tab websockets or rpc\cr \code{sequence} \tab creation sequence\cr \code{lines} \tab lines of text in terminal buffer\cr \code{cols} \tab columns in terminal\cr \code{rows} \tab rows in terminal\cr \code{pid} \tab process id of terminal shell\cr \code{full_screen} \tab full screen program running\cr } } \description{ Returns information about RStudio terminal instances. } \note{ The \code{terminalContext} function was added in version 1.1.350 of RStudio. } \examples{ \dontrun{ termId <- rstudioapi::terminalCreate("example", show = FALSE) View(rstudioapi::terminalContext(termId)) } } rstudioapi/man/launcherControlJob.Rd0000644000176200001440000000124013574017651017302 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/launcher-functions.R \name{launcherControlJob} \alias{launcherControlJob} \title{Interact with (Control) a Job} \usage{ launcherControlJob( jobId, operation = c("suspend", "resume", "stop", "kill", "cancel") ) } \arguments{ \item{jobId}{The job id.} \item{operation}{The operation to execute. The operation should be one of \code{c("suspend", "resume", "stop", "kill", "cancel")}. Note that different launcher plugins support different subsets of these operations -- consult your launcher plugin documentation to see which operations are supported.} } \description{ Interact with a job. } rstudioapi/man/dictionaries.Rd0000644000176200001440000000155513535525640016172 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/dictionaries.R \name{dictionaries} \alias{dictionaries} \alias{dictionariesPath} \alias{userDictionariesPath} \title{Interact with RStudio's Dictionaries} \usage{ dictionariesPath() userDictionariesPath() } \description{ Interact with the \href{https://hunspell.github.io/}{hunspell} dictionaries used by RStudio for spell checking. } \details{ \code{dictionariesPath()} gives a path to the dictionaries installed and distributed with RStudio. \code{userDictionariesPath()} gives the path where users can provide their own custom \code{hunspell} dictionaries. See: \url{https://support.rstudio.com/hc/en-us/articles/200551916-Spelling-Dictionaries} for more information. } \note{ The \code{dictionariesPath()} and \code{userDictionariesPath()} functions were introduced with RStudio 1.2.1202. } rstudioapi/man/terminalRunning.Rd0000644000176200001440000000216513574017651016670 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/terminal.R \name{terminalRunning} \alias{terminalRunning} \title{Is Terminal Running} \usage{ terminalRunning(id) } \arguments{ \item{id}{The terminal id. The \code{id} is obtained from \code{\link{terminalList}()}, \code{\link{terminalVisible}()}, \code{\link{terminalCreate}()}, or \code{\link{terminalExecute}()}.} } \value{ a boolean } \description{ Does a terminal have a process associated with it? If the R session is restarted after a terminal has been created, the terminal will not restart its shell until it is displayed either via the user interface, or via \code{\link{terminalActivate}()}. } \note{ The \code{terminalRunning} function was added in version 1.1.350 of RStudio. } \examples{ \dontrun{ # termId has a handle to a previously created terminal # make sure it is still running before we send it a command if (!rstudioapi::terminalRunning(termId)) { rstudioapi::terminalActivate(termId)) # wait for it to start while (!rstudioapi::terminalRunning(termId)) { Sys.sleep(0.1) } terminalSend(termId, "echo Hello\n") } } } rstudioapi/man/launcher.Rd0000644000176200001440000000245213574017651015314 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/launcher-functions.R \name{launcher} \alias{launcher} \alias{launcherGetInfo} \alias{launcherAvailable} \alias{launcherGetJobs} \title{Retrieve Launcher Information} \usage{ launcherGetInfo() launcherAvailable() launcherGetJobs( statuses = NULL, fields = NULL, tags = NULL, includeSessions = FALSE ) } \arguments{ \item{statuses}{Return only jobs whose status matches one of \code{statuses}. Valid statuses are: Pending, Running, Suspended, Failed, Finished, Killed, Canceled. When \code{NULL}, all jobs are returned.} \item{fields}{Return a subset of fields associated with each job object. When \code{NULL}, all fields associated with a particular job are returned.} \item{tags}{An optional set of tags. Only jobs that have been assigned one of these requested tags will be returned.} \item{includeSessions}{Boolean; include jobs which are also operating as RStudio R sessions?} } \description{ Retrieve information about the launcher, as well as the different clusters that the launcher has been configured to use. Check if the RStudio launcher is available and configured to support 'ad-hoc' jobs; that is, jobs normally launched by the user through the RStudio IDE's user interface. Retrieve information on launcher jobs. } rstudioapi/man/restartSession.Rd0000644000176200001440000000064613535525640016545 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/stubs.R \name{restartSession} \alias{restartSession} \title{Restart the R Session} \usage{ restartSession(command = "") } \arguments{ \item{command}{An \R command (as a string) to be run after restarting \R.} } \description{ Restart the RStudio \R session. } \note{ The \code{restartSession} function was added in version 1.1.281 of RStudio. } rstudioapi/man/document_position.Rd0000644000176200001440000000123213535525640017247 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/document-methods.R \name{document_position} \alias{document_position} \alias{is.document_position} \alias{as.document_position} \title{Create a Document Position} \usage{ document_position(row, column) is.document_position(x) as.document_position(x) } \arguments{ \item{row}{The row (using 1-based indexing).} \item{column}{The column (using 1-based indexing).} \item{x}{An object coercable to \code{document_position}.} } \description{ Creates a \code{document_position}, which can be used to indicate e.g. the row + column location of the cursor in a document. } \concept{location} rstudioapi/man/launcherGetJob.Rd0000644000176200001440000000051313535525640016402 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/launcher-functions.R \name{launcherGetJob} \alias{launcherGetJob} \title{Retrieve Job Information} \usage{ launcherGetJob(jobId) } \arguments{ \item{jobId}{The id of a launcher job.} } \description{ Retrieve information on a job with id \code{jobId}. } rstudioapi/man/translateLocalUrl.Rd0000644000176200001440000000176013535525640017146 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/urls.R \name{translateLocalUrl} \alias{translateLocalUrl} \title{Translate Local URL} \usage{ translateLocalUrl(url, absolute = FALSE) } \arguments{ \item{url}{The fully qualified URL to translate; for example, \code{http://localhost:1234/service/page.html}.} \item{absolute}{Whether to return a relative path URL (the default) or an absolute URL.} } \value{ The translated URL. } \description{ Translates a local URL into an externally accessible URL on RStudio Server. } \details{ On RStudio Server, URLs which refer to the local host network address (such as \code{http://localhost:1234/} and \code{http://127.0.0.1:5678/}) must be translated in order to be externally accessible from a browser. This method performs the required translation, and returns the translated URL, which RStudio Server uses to proxy HTTP requests. Returns an unmodified URL on RStudio Desktop, and when the URL does not refer to a local address. } rstudioapi/man/terminalVisible.Rd0000644000176200001440000000057213535525640016644 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/terminal.R \name{terminalVisible} \alias{terminalVisible} \title{Get Visible Terminal} \usage{ terminalVisible() } \value{ Terminal identifier selected in the client, if any. } \description{ Get Visible Terminal } \note{ The \code{terminalVisible} function was added in version 1.1.350 of RStudio. } rstudioapi/DESCRIPTION0000644000176200001440000000205613617370242014153 0ustar liggesusersPackage: rstudioapi Title: Safely Access the RStudio API Description: Access the RStudio API (if available) and provide informative error messages when it's not. Version: 0.11 Authors@R: c( person("Kevin", "Ushey", role = c("aut", "cre"), email = "kevin@rstudio.com"), person("JJ", "Allaire", role = c("aut"), email = "jj@rstudio.com"), person("Hadley", "Wickham", role = c("aut"), email = "hadley@rstudio.com"), person("Gary", "Ritchie", role = c("aut"), email = "gary@rstudio.com"), person(family = "RStudio", role = "cph") ) Maintainer: Kevin Ushey License: MIT + file LICENSE URL: https://github.com/rstudio/rstudioapi BugReports: https://github.com/rstudio/rstudioapi/issues RoxygenNote: 7.0.2 Suggests: testthat, knitr, rmarkdown, clipr VignetteBuilder: knitr Encoding: UTF-8 NeedsCompilation: no Packaged: 2020-02-07 18:58:10 UTC; kevinushey Author: Kevin Ushey [aut, cre], JJ Allaire [aut], Hadley Wickham [aut], Gary Ritchie [aut], RStudio [cph] Repository: CRAN Date/Publication: 2020-02-07 23:20:02 UTC rstudioapi/build/0000755000176200001440000000000013617331501013534 5ustar liggesusersrstudioapi/build/vignette.rds0000644000176200001440000000055413617331501016077 0ustar liggesusersRMO1-`0R 1&8xmjvM tnt^_7/BHD^D1l+0=XwI9,k;][2MrdQfIX*g4/>,~ ֶN\*UXSp&3A*ĮTDExxNSc]ɥfD0a@PknCˊB(x` <~k\l;_ٍ3FmQ]8V7~pn~i7cscc! ^7A%'ݒ~ۊҌYȃ7K)rstudioapi/vignettes/0000755000176200001440000000000013617331502014446 5ustar liggesusersrstudioapi/vignettes/terminal.Rmd0000644000176200001440000001116513535525640016740 0ustar liggesusers--- title: "Interacting with Terminals" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Interacting with Terminals} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include=FALSE} knitr::opts_chunk$set(eval = FALSE) ``` The `rstudioapi` package provides a collection of functions that can be used to interact with the [RStudio terminal tab](https://support.rstudio.com/hc/en-us/articles/115010737148-Using-the-RStudio-Terminal). There are two primary approaches to using these functions. 1. Use `terminalExecute()` to run a specific process with the output shown in a new terminal buffer, without blocking the current R session. 2. Create, query, and manipulate interactive terminals. This might be used to develop custom terminal behavior via an [RStudio addin](https://rstudio.github.io/rstudioaddins/). ## TerminalExecute Scenario ```{r} # Start a command with results displayed in a terminal buffer termId <- rstudioapi::terminalExecute("ping rstudio.com") # If viewing the result in the terminal buffer is sufficient, # then no need to do anything else. The command will continue # running and displaying its results without blocking the R session. # To obtain the results programmatically, wait for it to finish. while (is.null(rstudioapi::terminalExitCode(termId))) { Sys.sleep(0.1) } result <- rstudioapi::terminalBuffer(termId) # Delete the buffer and close the session in the IDE rstudioapi::terminalKill(termId) ``` ## Interative Terminal Scenario Several concepts are important to understand to make full use of these functions. ### Terminal Identifier Each terminal session has a unique **terminal identifier**, a required argument for most of the functions. A terminal identifier is generated and returned when a terminal is created via `terminalCreate()` or `terminalExecute()`, and identifiers of existing terminals can be obtained via `terminalList()` or `terminalVisible()`. ### Terminal Session A **terminal session** is an instance of a terminal that can be displayed in the RStudio terminal tab. A terminal session consists of: * a unique terminal identifier * a unique caption shown in the RStudio terminal dropdown (e.g. "Terminal 1") * a shell process (e.g. bash) running as a child process of the R session * zero or more processes running as children of the shell (e.g. commands) * an xterm-compatible terminal emulator in the terminal tab * a buffer of output shown in the terminal emulator (can be cleared via `terminalClear()`) ### Busy Terminal A terminal session with child processes running (excluding the shell), is considered **busy** and this is reflected in the IDE UI and can be queried with `terminalBusy()`. ### Terminal States In the most common situation, a terminal session has all the above features; however, it is possible for terminals to be in other states. **No shell process or child processes**: This happens if the associated R session has been closed (or suspended in the case of an inactive RStudio Server session). The `terminalRunning()` function returns `TRUE` if a terminal is in this state. If a terminal is not running, it can be started via interacting with it in the RStudio IDE, or via `terminalActivate()`. ```{r} # start an interactive terminal using the shell selected in # RStudio global options myTerm <- rstudioapi::terminalCreate() # .... # sometime later # .... if (!rstudioapi::terminalRunning(myTerm)) { # start the terminal shell back up, but don't bring to front rstudioapi::terminalActivate(myTerm, show = FALSE) # wait for it to start while (!rstudioapi::terminalRunning(myTerm)) { Sys.sleep(0.1) } # send a new command rstudioapi::terminalSend(myTerm, "echo Hello\n") } ``` **Running but not loaded in the IDE**: On RStudio Server, the web browser can be closed but the R session and any associated terminal sessions keep running. If the web browser is reconnected, each terminal will be redisplayed in the IDE when it is selected. The `rstudioapi` functions may be used on a terminal in this state; for example, the buffer may still be fetched with `terminalBuffer()` even if the terminal isn't loaded in the IDE (so long as the R session is still alive). **Terminated but still visible**: Normally the terminal emulator for a given terminal session will close when the shell exits. If the option **Close Terminal When Shell Exits** is turned off, then the terminal buffer will remain loaded in the RStudio IDE until closed by the user or `terminalKill()`. Terminals started with `terminalExecute()` will always remain loaded when they finish running. To test a terminal for this state, `terminalExitCode()` will return a non-NULL value. rstudioapi/vignettes/r-session.Rmd0000644000176200001440000000264513535525640017052 0ustar liggesusers--- title: "Interacting with the R Session" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Interact with the R Session} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include=FALSE} knitr::opts_chunk$set(eval = FALSE) ``` ## Session Interaction The `rstudioapi` package allows you to interact with the running R session in a couple useful ways: you can send code to the R console, or restart the R session. ```{r} # restart R, then run some code after rstudioapi::restartSession(command = "print('Welcome back!')") # send some code to the console and execute it immediately rstudioapi::sendToConsole("1 + 1", execute = TRUE) ``` ## Running at Startup Typically, code that you want to run at the start of an R session is placed into an `.Rprofile` file (see [Initialization at the Start of a Session](https://stat.ethz.ch/R-manual/R-devel/library/base/html/Startup.html) for details). However, RStudio's API hooks are not available until RStudio has fully started up, so most `rstudioapi` methods will not work inside `.Rprofile`. If you want to invoke `rstudioapi` methods on session startup, use the `rstudio.sessionInit` hook. For example, to print the RStudio version to the R console when the session begins: ```{r} setHook("rstudio.sessionInit", function(newSession) { if (newSession) message("Welcome to RStudio ", rstudioapi::getVersion()) }, action = "append") ``` rstudioapi/vignettes/dialogs.Rmd0000644000176200001440000000316613535525640016551 0ustar liggesusers--- title: "File Dialogs" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{File Dialogs} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include=FALSE} knitr::opts_chunk$set(eval = FALSE) ``` Using the `rstudioapi` package, you can request input from the user with various dialogs. The `selectFile()` and `selectDirectory()` APIs allow you to request the name of an existing or non-existing path on the system. ```{r} # request the path to an existing .csv file on disk path <- rstudioapi::selectFile(caption = "Select CSV File", filter = "CSV Files (*.csv)", existing = TRUE) # now, you could read the data using e.g. 'readr::read_csv()' data <- readr::read_csv(path) # request a file path (e.g. where you would like to save a new file) target <- rstudioapi::selectFile(caption = "Save File", label = "Save", existing = FALSE) # save data to the path provided by the user saveRDS(data, file = target) ``` Use `rstudioapi::askForPassword()` to request a password, or other credentials, from a user. ```{r} token <- rstudioapi::askForPassword( prompt = "Please provide your GitHub access token." ) ``` Use `rstudioapi::showDialog()` to display an informative dialog to the user. This dialog is used to report some kind of status or information to the user; it does not request any input. ```{r} rstudioapi::showDialog(title = "Hello, world!", message = "You're awesome!", url = "http://www.example.com") ``` rstudioapi/vignettes/introduction.Rmd0000644000176200001440000000140113535525640017636 0ustar liggesusers--- title: "Introduction to rstudioapi" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Introduction to rstudioapi} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- The `rstudioapi` package provides an interface for interacting with the RStudio IDE with R code. Using `rstudioapi`, you can: - Examine, manipulate, and save the contents of documents currently open in RStudio, - Create, open, or re-open RStudio projects, - Prompt the user with different kinds of dialogs (e.g. for selecting a file or folder, or requesting a password from the user), - Interact with RStudio terminals, - Interact with the R session associated with the current RStudio instance. Please see the other articles for more detailed information. rstudioapi/vignettes/projects.Rmd0000644000176200001440000000120213535525640016745 0ustar liggesusers--- title: "Interacting with RStudio Projects" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Interacting with RStudio Projects} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include=FALSE} knitr::opts_chunk$set(eval = FALSE) ``` Users can create and open RStudio projects using the `rstudioapi` package. ```{r} # open a project in another directory rstudioapi::openProject("~/projects/t-sne-gene-expression-2017") # re-open the current project rstudioapi::openProject() # initialize an RStudio project (without opening it) rstudioapi::initializeProject("~/scratch/testbed") ``` rstudioapi/vignettes/document-manipulation.Rmd0000644000176200001440000000407413535525640021442 0ustar liggesusers--- title: "Document Manipulation" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Document Manipulation} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup} knitr::opts_chunk$set(eval = FALSE) ``` The `rstudioapi` package provides a small family of functions that can be used to interact with documents open in an RStudio session. For example, the following code could be used to insert a 'last modified' comment at the start of a document: ```{r} # construct the text to be inserted fmt <- "# This document was last modified on %s.\n" text <- sprintf(fmt, Sys.Date()) # specify a range where this text should be inserted; here, # we use the first line; that is, the 'range' between the start # of the first row, and the start of the second row range <- rstudioapi::document_range(c(1, 0), c(2, 0)) rstudioapi::insertText(range, text) ``` By default, these APIs target the editor instance either currently focused by the user, or when no such editor is currently focused, the last focused editor. If you need to target a specific editor instance (for example, you want to write code that inserts text into the console), you can use `getConsoleEditorContext()` to get the `id` for the console editor: ```{r} # get console editor id context <- rstudioapi::getConsoleEditorContext() id <- context$id # send some R code to the console rstudioapi::insertText(text = "print(1 + 1)", id = id) # see also: `getActiveEditorContext()`, `getSourceEditorContext()` ``` You can also modify the cursor position through the use of the `setCursorPosition()` and `setSelectionRanges()` APIs. ```{r} # put the cursor at the end of the document -- note that here, # `Inf` is automatically truncated to the actual length of the # document rstudioapi::setCursorPosition(Inf) # select the first 10 even lines in the document ranges <- lapply(seq(2, by = 2, length.out = 10), function(start) { rstudioapi::document_range( c(start, 0), c(start, Inf) ) }) rstudioapi::setSelectionRanges(ranges) ``` See the `?"rstudio-documents"` help page for more details. rstudioapi/R/0000755000176200001440000000000013617331207012641 5ustar liggesusersrstudioapi/R/dialogs.R0000644000176200001440000000610713535525640014417 0ustar liggesusers#' Show Dialog Box #' #' Shows a dialog box with a given title and contents. #' #' @param title The title to display in the dialog box. #' #' @param message A character vector with the contents to display in #' the main dialog area. Contents can contain the following HTML tags: #' "p", "em", "strong", "b" and "i". #' #' @param url An optional url to display under the \code{message}. #' #' @details #' #' \preformatted{ #' showDialog("A dialog", "Showing bold text in the message.") #' } #' #' @note The \code{showDialog} function was added in version 1.1.67 of RStudio. #' #' @export showDialog <- function(title, message, url = "") { callFun("showDialog", title, message, url) } #' Updates a Dialog Box #' #' Updates specific properties from the current dialog box. #' #' @param ... Named parameters and values to update a dialog box. #' #' @details #' #' Currently, the only dialog with support for this action is the #' New Connection dialog in which the code preview can be #' updated through this API. #' #' \preformatted{ #' updateDialog(code = "con <- NULL") #' } #' #' @note The \code{updateDialog} function was added in version 1.1.67 of RStudio. #' #' @export updateDialog <- function(...) { callFun("updateDialog", ...) } #' Show Prompt Dialog Box #' #' Shows a dialog box with a prompt field. #' #' @param title The title to display in the dialog box. #' #' @param message A character vector with the contents to display in #' the main dialog area. #' #' @param default An optional character vector that fills the prompt field #' with a default value. #' #' @note The \code{showPrompt} function was added in version 1.1.67 of RStudio. #' #' @export showPrompt <- function(title, message, default = NULL) { callFun("showPrompt", title, message, default) } #' Show Question Dialog Box #' #' Shows a dialog box asking a question. #' #' @param title The title to display in the dialog box. #' #' @param message A character vector with the contents to display in #' the main dialog area. #' #' @param ok And optional character vector that overrides the caption for #' the OK button. #' #' @param cancel An optional character vector that overrides the caption for #' the Cancel button. #' #' @note The \code{showQuestion} function was added in version 1.1.67 of RStudio. #' #' @export showQuestion <- function(title, message, ok = NULL, cancel = NULL) { callFun("showQuestion", title, message, ok, cancel) } #' Show Prompt for Secret Dialog #' #' Shows a dialog box asking for a secret with support to remember such secret #' using the 'keyring' package. #' #' @param name The name of the secret. #' #' @param message A character vector with the contents to display in #' the main dialog area. #' #' @param title The title to display in the dialog box. #' #' @note The \code{askForSecret} function was added in version 1.1.419 of RStudio. #' #' @export askForSecret <- function( name, message = paste(name, ":", sep = ""), title = paste(name, "Secret")) { if (hasFun("askForSecret")) { callFun("askForSecret", name, title, message) } else { askForPassword(message) } } rstudioapi/R/stubs.R0000644000176200001440000001523513550767570014146 0ustar liggesusers #' @export versionInfo <- function() { callFun("versionInfo") } #' @export previewRd <- function(rdFile) { callFun("previewRd", rdFile) } #' @export viewer <- function(url, height = NULL) { callFun("viewer", url, height = height) } #' @export sourceMarkers <- function(name, markers, basePath = NULL, autoSelect = c("none", "first", "error")) { callFun("sourceMarkers", name, markers, basePath, autoSelect) } #' @export navigateToFile <- function(file, line = -1L, column = -1L) { callFun("navigateToFile", file, as.integer(line), as.integer(column)) } #' @export askForPassword <- function(prompt = "Please enter your password") { callFun("askForPassword", prompt) } #' Get Path to Active RStudio Project #' @export getActiveProject <- function() { path <- callFun("getActiveProject") # path is NULL iff there is no open project if (is.null(path)) return(path) # ... otherwise path is UTF-8 encoded Encoding(path) <- "UTF-8" path } #' Save Active RStudio Plot as an Image #' #' Save the currnently active RStudio as an image file. #' #' @param file Target filename #' @param format Image format ("png", "jpeg", "bmp", "tiff", "emf", "svg", or "eps") #' @param height Image height in pixels #' @param width Image width in pixels #' #' @note The \code{savePlotAsImage} function was introduced in RStudio 1.1.57 #' #' @export savePlotAsImage <- function(file, format = c("png", "jpeg", "bmp", "tiff", "emf", "svg", "eps"), width, height) { format <- match.arg(format) callFun("savePlotAsImage", file, format, width, height) } #' Send Code to the R Console #' #' Send code to the R console and optionally execute it. #' #' @param code Character vector containing code to be executed. #' @param execute Boolean; execute the code immediately or just enter the text #' into the console? #' @param echo Boolean; echo the \R code in the console as it's executed? #' @param focus Boolean; focus the \R console after sending code? #' #' @note The \code{sendToConsole} function was added in version 0.99.787 of RStudio. #' #' @examples #' \dontrun{ #' rstudioapi::sendToConsole(".Platform", execute = TRUE) #' } #' #' @export sendToConsole <- function(code, execute = TRUE, echo = TRUE, focus = TRUE) { callFun("sendToConsole", code = code, echo = echo, execute = execute, focus = focus) } #' Persistent Keys and Values #' #' Store persistent keys and values. Storage is per-project, if there is #' no project currently active then a global store is used. #' #' @param name Key name #' @param value Key value #' @return The stored value as a character vector (\code{NULL} if no value #' of the specified name is available). #' #' @note The \code{setPersistentValue} and \code{getPersistentValue} functions #' were added in version 1.1.57 of RStudio. #' #' @name persistent-values #' @export setPersistentValue <- function(name, value) { callFun("setPersistentValue", name, value) } #' @rdname persistent-values #' @export getPersistentValue <- function(name) { callFun("getPersistentValue", name) } #' Check if Console Supports ANSI Color Escapes #' #' @return a boolean #' #' @examples #' \dontrun{ #' if (rstudioapi::hasColorConsole()) { #' message("RStudio console supports ANSI color sequences.") #' } #' } #' #' @note The \code{hasColorConsole} function was added in version 1.1.216 #' of RStudio. #' #' @export hasColorConsole <- function() { callFun("getConsoleHasColor") } #' Restart the R Session #' #' Restart the RStudio \R session. #' #' @param command An \R command (as a string) to be run #' after restarting \R. #' #' @note The \code{restartSession} function was added in version 1.1.281 #' of RStudio. #' #' @export restartSession <- function(command = "") { callFun("restartSession", command) } #' Select a File / Folder #' #' Prompt the user for the path to a file or folder, using the system #' file dialogs with RStudio Desktop, and RStudio's own web dialogs #' with RStudio Server. #' #' When the selected file resolves within the user's home directory, #' RStudio will return an aliased path -- that is, prefixed with \code{~/}. #' #' @param caption The window title. #' @param label The label to use for the 'Accept' / 'OK' button. #' @param path The initial working directory, from which the file dialog #' should begin browsing. Defaults to the current RStudio #' project directory. #' @param filter A glob filter, to be used when attempting to open a file with a #' particular extension. For example, to scope the dialog to \R files, one could use #' \code{R Files (*.R)} here. #' @param existing Boolean; should the file dialog limit itself to existing #' files on the filesystem, or allow the user to select the path to a new file? #' #' @note The \code{selectFile} and \code{selectDirectory} functions were #' added in version 1.1.287 of RStudio. #' #' @name file-dialogs NULL #' @name file-dialogs #' @export selectFile <- function(caption = "Select File", label = "Select", path = getActiveProject(), filter = "All Files (*)", existing = TRUE) { out <- callFun("selectFile", caption, label, path, filter, existing) Encoding(out) <- "UTF-8" out } #' @name file-dialogs #' @export selectDirectory <- function(caption = "Select Directory", label = "Select", path = getActiveProject()) { callFun("selectDirectory", caption, label, path) } #' Open a Project in RStudio #' #' Initialize and open RStudio projects. #' #' Calling \code{openProject()} without arguments effectively re-opens the #' currently open project in RStudio. When switching projects, users will #' be prompted to save any unsaved files; alternatively, you can explicitly #' save any open documents using \code{\link{documentSaveAll}()}. #' #' @param path Either the path to an existing \code{.Rproj} file, or a path #' to a directory in which a new project should be initialized and opened. #' @param newSession Boolean; should the project be opened in a new session, #' or should the current RStudio session switch to that project? Note that #' \code{TRUE} values are only supported with RStudio Desktop and RStudio #' Server Pro. #' #' @note The \code{openProject} and \code{initializeProject} functions were #' added in version 1.1.287 of RStudio. #' #' @name projects NULL #' @name projects #' @export openProject <- function(path = NULL, newSession = FALSE) { callFun("openProject", path, newSession) } #' @name projects #' @export initializeProject <- function(path = getwd()) { callFun("initializeProject", path) } rstudioapi/R/user.R0000644000176200001440000000047013617331207013743 0ustar liggesusers#' Get User Identity #' #' Returns the identity (displayed name) of the current user. #' #' @export userIdentity <- function() { callFun("userIdentity") } #' Get System Username #' #' Returns the system username of the current user. #' #' @export systemUsername <- function() { callFun("systemUsername") } rstudioapi/R/utils.R0000644000176200001440000000047513574020603014127 0ustar liggesusers `%||%` <- function(x, y) { if (is.null(x)) y else x } renderTemplate <- function(template, data) { rendered <- template for (i in seq_along(data)) { key <- names(data)[[i]] val <- data[[i]] fkey <- sprintf("${%s}", key) rendered <- gsub(fkey, val, rendered, fixed = TRUE) } rendered } rstudioapi/R/urls.R0000644000176200001440000000171413535525640013761 0ustar liggesusers#' Translate Local URL #' #' Translates a local URL into an externally accessible URL on RStudio Server. #' #' @param url The fully qualified URL to translate; for example, #' \code{http://localhost:1234/service/page.html}. #' @param absolute Whether to return a relative path URL (the default) or an #' absolute URL. #' @return The translated URL. #' #' @details #' #' On RStudio Server, URLs which refer to the local host network address (such #' as \code{http://localhost:1234/} and \code{http://127.0.0.1:5678/}) must be #' translated in order to be externally accessible from a browser. This method #' performs the required translation, and returns the translated URL, which #' RStudio Server uses to proxy HTTP requests. #' #' Returns an unmodified URL on RStudio Desktop, and when the URL does not refer #' to a local address. #' #' @export translateLocalUrl <- function(url, absolute = FALSE) { callFun("translateLocalUrl", url = url, absolute = absolute) } rstudioapi/R/preview.R0000644000176200001440000000115513535525640014454 0ustar liggesusers#' Preview SQL statement #' #' Makes use of 'DBI' and \code{dbGetQuery()} to preview a SQL statement #' for a given 'DBI' connection. #' #' @param conn The 'DBI' connection to be used to execute this statement. #' @param statement The SQL statement to execute. Either a path to a #' file containing a SQL statement or the SQL statement itself. #' @param ... Additional arguments to be used in \code{dbGetQuery()}. #' #' @note The \code{previewSql} function was introduced in RStudio 1.2.600 #' #' @export previewSql <- function(conn, statement, ...) { callFun("previewSql", conn = conn, statement = statement, ...) } rstudioapi/R/commands.R0000644000176200001440000000200413535525640014566 0ustar liggesusers#' Execute Command #' #' Executes an arbitrary RStudio command. #' #' @param commandId The ID of the command to execute. #' @param quiet Whether to show an error if the command does not exist. #' #' @details #' #' Most menu commands and many buttons in RStudio can be invoked from the API #' using this method. #' #' The \code{quiet} command governs the behavior of the function when the #' command does not exist. By default, an error is shown if you attempt to #' invoke a non-existent command. You should set this to `TRUE` when invoking #' a command that may not be available if you don't want your users to see an #' error. #' #' The command is run asynchronously, so no status is returned. #' #' See the RStudio Server Professional Administration Guide appendix for a list #' of supported command IDs. #' #' @note The \code{executeCommand} function was introduced in RStudio 1.2.1261. #' #' @export executeCommand <- function(commandId, quiet = FALSE) { callFun("executeCommand", commandId = commandId, quiet = quiet) } rstudioapi/R/terminal.R0000644000176200001440000002447313535525640014616 0ustar liggesusers #' Send Text to a Terminal #' #' Send text to an existing terminal. #' #' @param id The terminal id. The \code{id} is obtained from #' \code{\link{terminalList}()}, \code{\link{terminalVisible}()}, #' \code{\link{terminalCreate}()}, or \code{\link{terminalExecute}()}. #' @param text Character vector containing text to be inserted. #' #' @note The \code{terminalSend} function was added in version 1.1.350 of RStudio. #' #' @examples #' \dontrun{ #' termId <- rstudioapi::terminalCreate() #' rstudioapi::terminalSend(termId, 'ls -l\n') #' } #' #' @export terminalSend <- function(id, text) { callFun("terminalSend", id, text) } #' Clear Terminal Buffer #' #' Clears the buffer for specified terminal. #' #' @param id The terminal id. The \code{id} is obtained from #' \code{\link{terminalList}()}, \code{\link{terminalVisible}()}, #' \code{\link{terminalCreate}()}, or \code{\link{terminalExecute}()}. #' #' @note The \code{terminalClear} function was added in version 1.1.350 of RStudio. #' #' @examples #' \dontrun{ #' termId <- rstudioapi::terminalCreate() #' rstudioapi::terminalSend(termId, 'ls -l\n') #' Sys.sleep(3) #' rstudioapi::terminalClear(termId) #' } #' #' @export terminalClear <- function(id) { callFun("terminalClear", id) } #' Create a Terminal #' #' Create a new Terminal. #' #' @param caption The desired terminal caption. When \code{NULL} or blank, #' the terminal caption will be chosen by the system. #' @param show If \code{FALSE}, terminal won't be brought to front. #' @param shellType Shell type for the terminal: NULL or "default" to use the #' shell selected in Global Options. For Microsoft Windows, alternatives #' are "win-cmd" for 64-bit Command Prompt, "win-ps" for 64-bit PowerShell, #' "win-git-bash" for Git Bash, or "win-wsl-bash" for Bash on Windows Subsystem #' for Linux. On Linux, Mac, and RStudio Server "custom" will use the custom #' terminal defined in Global Options. If the requested shell type is not #' available, the default shell will be used, instead. #' #' @return The terminal identifier as a character vector (\code{NULL} if #' unable to create the terminal or the given terminal caption is already #' in use). #' #' @note The \code{terminalCreate} function was added in version 1.1.350 of RStudio #' and the ability to specify shellType was added in version 1.2.696. #' #' @examples #' \dontrun{ #' termId <- rstudioapi::terminalCreate('My Terminal') #' } #' #' @export terminalCreate <- function(caption = NULL, show = TRUE, shellType = NULL) { if (rstudioapi::getVersion() < "1.2.696") { if (!is.null(shellType)) { warning('shellType parameter ignored: not supported in this version of RStudio') } callFun("terminalCreate", caption, show) } else { callFun("terminalCreate", caption, show, shellType) } } #' Is Terminal Busy #' #' Are terminals reporting that they are busy? #' #' @param id The terminal id. The \code{id} is obtained from #' \code{\link{terminalList}()}, \code{\link{terminalVisible}()}, #' \code{\link{terminalCreate}()}, or \code{\link{terminalExecute}()}. #' #' @return a boolean #' #' @note The \code{terminalBusy} function was added in version 1.1.350 of RStudio. #' #' @examples #' \dontrun{ #' # create a hidden terminal and run a lengthy command #' termId <- rstudioapi::terminalCreate(show = FALSE) #' rstudioapi::terminalSend(termId, "sleep 5\n") #' #' # wait until a busy terminal is finished #' while (rstudioapi::terminalBusy(termId)) { #' Sys.sleep(0.1) #' } #' print("Terminal available") #' } #' @export terminalBusy <- function(id) { callFun("terminalBusy", id) } #' Is Terminal Running #' #' Does a terminal have a process associated with it? If the R session is #' restarted after a terminal has been created, the terminal will not #' restart its shell until it is displayed either via the user #' interface, or via \code{\link{terminalActivate}()}. #' #' @param id The terminal id. The \code{id} is obtained from #' \code{\link{terminalList}()}, \code{\link{terminalVisible}()}, #' \code{\link{terminalCreate}()}, or \code{\link{terminalExecute}()}. #' #' @return a boolean #' #' @note The \code{terminalRunning} function was added in version 1.1.350 of RStudio. #' #' @examples #' \dontrun{ #' # termId has a handle to a previously created terminal #' # make sure it is still running before we send it a command #' if (!rstudioapi::terminalRunning(termId)) { #' rstudioapi::terminalActivate(termId)) #' #' # wait for it to start #' while (!rstudioapi::terminalRunning(termId)) { #' Sys.sleep(0.1) #' } #' #' terminalSend(termId, "echo Hello\n") #' } #' } #' @export terminalRunning <- function(id) { callFun("terminalRunning", id) } #' Get All Terminal Ids #' #' Return a character vector containing all the current terminal identifiers. #' #' @return The terminal identifiers as a character vector. #' #' @note The \code{terminalList} function was added in version 1.1.350 of RStudio. #' #' @export terminalList <- function() { callFun("terminalList") } #' Retrieve Information about RStudio Terminals #' #' Returns information about RStudio terminal instances. #' #' @param id The terminal id. The \code{id} is obtained from #' \code{\link{terminalList}()}, \code{\link{terminalVisible}()}, #' \code{\link{terminalCreate}()}, or \code{\link{terminalExecute}()}. #' #' @return A \code{list} with elements: #' \tabular{ll}{ #' \code{handle} \tab the internal handle\cr #' \code{caption} \tab caption\cr #' \code{title} \tab title set by the shell\cr #' \code{working_dir} \tab working directory\cr #' \code{shell} \tab shell type\cr #' \code{running} \tab is terminal process executing\cr #' \code{busy} \tab is terminal running a program\cr #' \code{exit_code} \tab process exit code or NULL\cr #' \code{connection} \tab websockets or rpc\cr #' \code{sequence} \tab creation sequence\cr #' \code{lines} \tab lines of text in terminal buffer\cr #' \code{cols} \tab columns in terminal\cr #' \code{rows} \tab rows in terminal\cr #' \code{pid} \tab process id of terminal shell\cr #' \code{full_screen} \tab full screen program running\cr #' } #' #' @note The \code{terminalContext} function was added in version 1.1.350 of RStudio. #' #' @examples #' \dontrun{ #' termId <- rstudioapi::terminalCreate("example", show = FALSE) #' View(rstudioapi::terminalContext(termId)) #' #' } #' #' @export terminalContext <- function(id) { callFun("terminalContext", id) } #' Activate Terminal #' #' Ensure terminal is running and optionally bring to front in RStudio. #' #' @param id The terminal id. The \code{id} is obtained from #' \code{\link{terminalList}()}, \code{\link{terminalVisible}()}, #' \code{\link{terminalCreate}()}, or \code{\link{terminalExecute}()}. #' If NULL, the terminal tab will be selected but no specific terminal #' will be chosen. #' @param show If TRUE, bring the terminal to front in RStudio. #' #' @note The \code{terminalActivate} function was added in version 1.1.350 of RStudio. #' #' @examples #' \dontrun{ #' # create a hidden terminal and run a lengthy command #' termId = rstudioapi::terminalCreate(show = FALSE) #' rstudioapi::terminalSend(termId, "sleep 5\n") #' #' # wait until a busy terminal is finished #' while (rstudioapi::terminalBusy(termId)) { #' Sys.sleep(0.1) #' } #' print("Terminal available")#' #' #' rstudioapi::terminalActivate(termId) #' } #' #' @export terminalActivate <- function(id = NULL, show = TRUE) { callFun("terminalActivate", id, show) } #' Get Terminal Buffer #' #' Returns contents of a terminal buffer. #' #' @param id The terminal id. The \code{id} is obtained from #' \code{\link{terminalList}()}, \code{\link{terminalVisible}()}, #' \code{\link{terminalCreate}()}, or \code{\link{terminalExecute}()}. #' @param stripAnsi If FALSE, don't strip out Ansi escape sequences before returning #' terminal buffer. #' #' @return The terminal contents, one line per row. #' #' @note The \code{terminalBuffer} function was added in version 1.1.350 of RStudio. #' #' @export terminalBuffer <- function(id, stripAnsi = TRUE) { callFun("terminalBuffer", id, stripAnsi) } #' Kill Terminal #' #' Kill processes and close a terminal. #' #' @param id The terminal id. The \code{id} is obtained from #' \code{\link{terminalList}()}, \code{\link{terminalVisible}()}, #' \code{\link{terminalCreate}()}, or \code{\link{terminalExecute}()}. #' #' @note The \code{terminalKill} function was added in version 1.1.350 of RStudio. #' #' @export terminalKill<- function(id) { callFun("terminalKill", id) } #' Get Visible Terminal #' #' @return Terminal identifier selected in the client, if any. #' #' @note The \code{terminalVisible} function was added in version 1.1.350 of RStudio. #' #' @export terminalVisible <- function() { callFun("terminalVisible") } #' Execute Command #' #' Execute a command, showing results in the terminal pane. #' #' @param command System command to be invoked, as a character string. #' @param workingDir Working directory for command #' @param env Vector of name=value strings to set environment variables #' @param show If FALSE, terminal won't be brought to front #' #' @return The terminal identifier as a character vector (\code{NULL} if #' unable to create the terminal). #' #' @note The \code{terminalExecute} function was added in version 1.1.350 of RStudio. #' #' @examples #' \dontrun{ #' termId <- rstudioapi::terminalExecute( #' command = 'echo $HELLO && echo $WORLD', #' workingDir = '/usr/local', #' env = c('HELLO=WORLD', 'WORLD=EARTH'), #' show = FALSE) #' #' while (is.null(rstudioapi::terminalExitCode(termId))) { #' Sys.sleep(0.1) #' } #' #' result <- terminalBuffer(termId) #' terminalKill(termId) #' print(result) #' } #' #' @export terminalExecute <- function(command, workingDir = NULL, env = character(), show = TRUE) { callFun("terminalExecute", command, workingDir, env, show) } #' Terminal Exit Code #' #' Get exit code of terminal process, or NULL if still running. #' #' @param id The terminal id. The \code{id} is obtained from #' \code{\link{terminalList}()}, \code{\link{terminalVisible}()}, #' ,\code{\link{terminalCreate}()}, or \code{\link{terminalExecute}()}. #' #' @return The exit code as an integer vector, or NULL if process still running. #' #' @note The \code{terminalExitCode} function was added in version 1.1.350 of RStudio. #' #' @export terminalExitCode <- function(id) { callFun("terminalExitCode", id) } rstudioapi/R/document-api.R0000644000176200001440000001451713535525640015366 0ustar liggesusers#' Interact with Documents open in RStudio #' #' Use these functions to interact with documents open in RStudio. #' #' @param location An object specifying the positions, or ranges, wherein #' text should be inserted. See \bold{Details} for more information. #' #' @param text A character vector, indicating what text should be #' inserted at each aforementioned range. This should either #' be length one (in which case, this text is applied to each #' range specified); otherwise, it should be the same length #' as the \code{ranges} list. #' #' @param id The document id. When \code{NULL} or blank, #' the mutation will apply to the currently open, or last #' focused, RStudio document. Use the \code{id} returned #' from \code{\link{getActiveDocumentContext}()} to ensure #' that the operation is applied on the intended document. #' #' @param position The cursor position, typically created through #' \code{\link{document_position}()}. #' #' @param ranges A list of one or more ranges, typically created #' through \code{\link{document_range}()}. #' #' @param type The type of document to be created. #' #' @param execute Should the code be executed after the document #' is created? #' #' @details #' #' \code{location} should be a (list of) \code{\link{document_position}} or #' \code{\link{document_range}} object(s), or numeric vectors coercable to #' such objects. #' #' To operate on the current selection in a document, call \code{insertText()} #' with only a text argument, e.g. #' #' \preformatted{ #' insertText("# Hello\\n") #' insertText(text = "# Hello\\n") #' } #' #' Otherwise, specify a (list of) positions or ranges, as in: #' #' \preformatted{ #' # insert text at the start of the document #' insertText(c(1, 1), "# Hello\\n") #' #' # insert text at the end of the document #' insertText(Inf, "# Hello\\n") #' #' # comment out the first 5 rows #' pos <- Map(c, 1:5, 1) #' insertText(pos, "# ") #' #' # uncomment the first 5 rows, undoing the previous action #' rng <- Map(c, Map(c, 1:5, 1), Map(c, 1:5, 3)) #' modifyRange(rng, "") #' } #' #' \code{modifyRange} is a synonym for \code{insertText}, but makes its intent #' clearer when working with ranges, as performing text insertion with a range #' will replace the text previously existing in that range with new text. For #' clarity, prefer using \code{insertText} when working with #' \code{\link{document_position}}s, and \code{modifyRange} when working with #' \code{\link{document_range}}s. #' #' @note #' The \code{insertText}, \code{modifyRange} and \code{setDocumentContents} #' functions were added with version 0.99.796 of RStudio. #' #' The \code{setCursorPosition} and \code{setSelectionRanges} functions were #' added with version 0.99.1111 of RStudio. #' #' The \code{documentSave} and \code{documentSaveAll} functions were added #' with version 1.1.287 of RStudio. #' #' @name rstudio-documents NULL #' @name rstudio-documents #' @export insertText <- function(location, text, id = NULL) { callFun("insertText", location, text, id) } #' @name rstudio-documents #' @export modifyRange <- insertText #' @name rstudio-documents #' @export setDocumentContents <- function(text, id = NULL) { location <- document_range( document_position(1, 1), document_position(Inf, 1) ) insertText(location, text, id) } #' @name rstudio-documents #' @export setCursorPosition <- function(position, id = NULL) { callFun("setSelectionRanges", position, id) } #' @name rstudio-documents #' @export setSelectionRanges <- function(ranges, id = NULL) { callFun("setSelectionRanges", ranges, id) } #' @name rstudio-documents #' @export documentSave <- function(id = NULL) { callFun("documentSave", id) } #' @name rstudio-documents #' @export documentSaveAll <- function() { callFun("documentSaveAll") } #' Retrieve Information about an RStudio Editor #' #' Returns information about an RStudio editor. #' #' The \code{selection} field returned is a list of document selection objects. #' A document selection is just a pairing of a document \code{range}, and the #' \code{text} within that range. #' #' @note #' The \code{getActiveDocumentContext} function was added with version 0.99.796 #' of RStudio, while the \code{getSourceEditorContext} and the \code{getConsoleEditorContext} #' functions were added with version 0.99.1111. #' #' @return A \code{list} with elements: #' \tabular{ll}{ #' \code{id} \tab The document ID.\cr #' \code{path} \tab The path to the document on disk.\cr #' \code{contents} \tab The contents of the document.\cr #' \code{selection} \tab A \code{list} of selections. See \bold{Details} for more information.\cr #' } #' #' @rdname rstudio-editors #' @name rstudio-editors #' @export getActiveDocumentContext <- function() { getDocumentContext("getActiveDocumentContext") } #' @name rstudio-editors #' @export getSourceEditorContext <- function() { getDocumentContext("getSourceEditorContext") } #' @name rstudio-editors #' @export getConsoleEditorContext <- function() { getDocumentContext("getConsoleEditorContext") } #' Create a New Document #' #' Creates a new document in RStudio #' #' @note The \code{documentNew} function was introduced in RStudio 1.2.640 #' #' @name rstudio-documents #' @export documentNew <- function( text, type = c("r", "rmarkdown", "sql"), position = document_position(0,0), execute = FALSE) { type <- match.arg(as.character(type), choices = c("r", "rmarkdown", "sql")) callFun("documentNew", type, text, position[1], position[2], execute) } #' Close a Document #' #' Closes a document currently open in RStudio. #' #' @param save Whether to commit unsaved changes to the document before closing it. #' #' @note The \code{documentClose} function was introduced in RStudio 1.2.1255 #' #' @details #' #' \code{documentClose} accepts an ID of an open document rather than a path. #' You can get the ID of an open document from the #' \code{getSourceEditorContext} function, among others. #' #' Closing is always done non-interactively; that is, no prompts are given to #' the user. If the user has made changes to the document but not saved them, #' then the \code{save} parameter governs the behavior: when \code{TRUE}, #' unsaved changes are committed, and when \code{FALSE} they are discarded. #' #' @name rstudio-documents #' @export documentClose <- function(id = NULL, save = TRUE) { callFun("documentClose", id, save) } rstudioapi/R/launcher-functions.R0000644000176200001440000003072713575747142016620 0ustar liggesusers#' Retrieve Launcher Information #' #' Retrieve information about the launcher, as well as the different clusters #' that the launcher has been configured to use. #' #' @name launcher #' @export launcherGetInfo <- function() { callLauncherFun("launcher.getInfo") } #' Check if Launcher is Available #' #' Check if the RStudio launcher is available and configured to support #' 'ad-hoc' jobs; that is, jobs normally launched by the user through #' the RStudio IDE's user interface. #' #' @name launcher #' @export launcherAvailable <- function() { callLauncherFun("launcher.jobsFeatureAvailable") } #' Retrieve Job Information #' #' Retrieve information on launcher jobs. #' #' @param statuses Return only jobs whose status matches one of `statuses`. #' Valid statuses are: Pending, Running, Suspended, Failed, Finished, Killed, #' Canceled. When `NULL`, all jobs are returned. #' #' @param fields Return a subset of fields associated with each job object. #' When `NULL`, all fields associated with a particular job are returned. #' #' @param includeSessions Boolean; include jobs which are also operating #' as RStudio R sessions? #' #' @param tags An optional set of tags. Only jobs that have been assigned one #' of these requested tags will be returned. #' #' @name launcher #' @export launcherGetJobs <- function(statuses = NULL, fields = NULL, tags = NULL, includeSessions = FALSE) { callLauncherFun("launcher.getJobs", statuses = statuses, fields = fields, tags = tags, includeSessions = includeSessions) } #' Retrieve Job Information #' #' Retrieve information on a job with id `jobId`. #' #' @param jobId The id of a launcher job. #' #' @export launcherGetJob <- function(jobId) { callLauncherFun("launcher.getJob", jobId = jobId) } #' Define a Launcher Configuration #' #' Define a launcher configuration, suitable for use with the `config` argument #' to [launcherSubmitJob()]. #' #' @param name The name of the launcher configuration. #' @param value The configuration value. Must either be an integer, float, or string. #' #' @family job submission #' @export launcherConfig <- function(name, value = NULL) { valueType <- if (is.integer(value)) "int" else if (is.double(value)) "float" else if (is.character(value)) "string" value <- format(value) callLauncherFun("launcher.newConfig", name = name, value = value, valueType = valueType) } #' Define a Launcher Container #' #' Define a launcher container, suitable for use with the `container` argument #' to [launcherSubmitJob()]. #' #' @param image The container image to use. #' @param runAsUserId The user id to run as within the container. Defaults #' to the container-specified user. #' @param runAsGroupId The group id to run as within the container. Defaults #' to the container-specified group. #' #' @family job submission #' @export launcherContainer <- function(image, runAsUserId = NULL, runAsGroupId = NULL) { callLauncherFun("launcher.newContainer", image = image, runAsUserId = runAsUserId, runAsGroupId = runAsGroupId) } #' Define a Launcher Placement Constraint #' #' Define a launcher placement constraint, suitable for use with the #' `placementConstraints` argument to [launcherSubmitJob()]. #' #' @param name The name of this placement constraint. #' @param value The value of the constraint. A job will only be placed on a #' requested node if the requested placement constraint is present. #' #' @family job submission #' @export launcherPlacementConstraint <- function(name, value = NULL) { callLauncherFun("launcher.newPlacementConstraint", name = name, value = value) } #' Define a Launcher Resource Limit #' #' Define a launcher resource limit, suitable for use with the `resourceLimits` #' argument to [launcherSubmitJob()]. #' #' @param type The resource limit type. Must be one of cpuCount, cpuFrequency, #' cpuSet, cpuTime, memory, memorySwap. Different launcher plugins may support #' different subsets of these resource limit types; please consult the plugin #' documentation to learn which limits are supported. #' @param value The formatted value of the requested limit. #' #' @family job submission #' @export launcherResourceLimit <- function(type, value) { callLauncherFun("launcher.newResourceLimit", type = type, value = value) } #' Define a Launcher Host Mount #' #' Define a launcher host mount, suitable for use with the `mounts` argument #' to [launcherSubmitJob()]. This can be used to mount a path from the host #' into the generated container. #' #' @param path The host path to be mounted. #' @param mountPath The destination path for the mount in the container. #' @param readOnly Boolean; should the path be mounted read-only? #' #' @family job submission #' @export launcherHostMount <- function(path, mountPath, readOnly = TRUE) { callLauncherFun("launcher.newHostMount", path = path, mountPath = mountPath, readOnly = readOnly) } #' Define a Launcher NFS Mount #' #' Define a launcher NFS mount, suitable for use with the `mounts` argument #' to [launcherSubmitJob()]. This can be used to mount a path from a #' networked filesystem into a newly generated container. #' #' @param host The host name, or IP address, of the NFS server. #' @param path The NFS path to be mounted. #' @param mountPath The destination path for the mount in the container. #' @param readOnly Boolean; should the path be mounted read-only? #' #' @family job submission #' @export launcherNfsMount <- function(host, path, mountPath, readOnly = TRUE) { callLauncherFun("launcher.newNfsMount", host = host, path = path, mountPath = mountPath, readOnly = readOnly) } #' Submit a Launcher Job #' #' Submit a launcher job. See https://docs.rstudio.com/job-launcher/latest/index.html #' for more information. #' #' @param name A descriptive name to assign to the job. #' @param cluster The name of the cluster this job should be submitted to. #' @param tags A set of user-defined tags, used for searching and querying #' jobs. #' #' @param command The command to run within the job. This is executed via the #' system shell. Only one of command or exe should be specified. #' @param exe The (fully pathed) executable to run within the job. Only one of #' `command` or `exe` should be specified. #' @param args An array of arguments to pass to the command / executable. #' @param environment A list of environment variables to be set for processes #' launched with this job. #' @param stdin Data to be written to stdin when the job process is launched. #' @param stdoutFile The file used for the job's generated standard output. Not #' all launcher plugins support this parameter. #' @param stderrFile The file used for the job's generated standard error. Not #' all launcher plugins support this parameter. #' @param workingDirectory The working directory to be used by the command / #' executable associated with this job. #' #' @param host The host that the job is running on, or the desired host during #' job submission. #' @param container The container to be used for launched jobs. #' @param exposedPorts The ports that are exposed by services running on a #' container. Only applicable to systems that support containers. #' @param mounts A list of mount points. See [launcherHostMount()] and #' [launcherNfsMount()] for more information. #' @param placementConstraints A list of placement constraints. See #' [launcherPlacementConstraint()] for more information. #' @param resourceLimits A list of resource limits. See [launcherResourceLimit()] #' for more information. #' @param queues A list of available submission queues for the cluster. Only #' applicable to batch systems like LSF. #' #' @param config A list of cluster-specific configuration options. See #' [launcherConfig()] for more information. #' @param user The user-name of the job owner. #' #' @param applyConfigSettings Apply server-configured mounts, exposedPorts, and #' environment, in addition to any specified in this call. #' #' @family job submission #' @export launcherSubmitJob <- function(name, cluster = "Local", tags = NULL, command = NULL, exe = NULL, args = NULL, environment = NULL, stdin = NULL, stdoutFile = NULL, stderrFile = NULL, workingDirectory = NULL, host = NULL, container = NULL, exposedPorts = NULL, mounts = NULL, placementConstraints = NULL, resourceLimits = NULL, queues = NULL, config = NULL, user = Sys.getenv("USER"), applyConfigSettings = TRUE) { callLauncherFun("launcher.submitJob", args = args, cluster = cluster, command = command, config = config, container = container, environment = environment, exe = exe, exposedPorts = exposedPorts, host = host, mounts = mounts, name = name, placementConstraints = placementConstraints, queues = queues, resourceLimits = resourceLimits, stderrFile = stderrFile, stdin = stdin, stdoutFile = stdoutFile, tags = tags, user = user, workingDirectory = workingDirectory, applyConfigSettings = applyConfigSettings) } #' Execute an R Script as a Launcher Job #' #' Convenience function for running an R script as a launcher job using whichever #' R is found on the path in the launcher cluster. #' #' See [launcherSubmitJob()] for running jobs with full control over command, #' environment, and so forth. #' #' @param script Fully qualified path of R script. Must be a path that is #' available in the job container (if using containerized job cluster such as Kubernetes). #' @param cluster The name of the cluster this job should be submitted to. #' @param container The container to be used for launched jobs. #' #' @family job submission #' @export launcherSubmitR <- function(script, cluster = "Local", container = NULL) { # don't proactively check for existence of the script; possible the supplied # path only resolves correctly in the job cluster scriptPath <- path.expand(script) scriptFile <- basename(scriptPath) scriptArg <- paste("-f", scriptPath) jobTag <- paste("rstudio-r-script-job", scriptFile, sep = ":") callLauncherFun("launcher.submitJob", args = c("--slave", "--no-save", "--no-restore", scriptArg), cluster = cluster, command = "R", container = container, name = scriptFile, tags = c(jobTag), applyConfigSettings = TRUE) } #' Interact with (Control) a Job #' #' Interact with a job. #' #' @param jobId The job id. #' @param operation The operation to execute. The operation should be one of #' `c("suspend", "resume", "stop", "kill", "cancel")`. Note that different #' launcher plugins support different subsets of these operations -- consult #' your launcher plugin documentation to see which operations are supported. #' #' @export launcherControlJob <- function(jobId, operation = c("suspend", "resume", "stop", "kill", "cancel")) { callLauncherFun("launcher.controlJob", jobId = jobId, operation = operation) } rstudioapi/R/jobs.R0000644000176200001440000001300513542731511013717 0ustar liggesusers #' Add a Job #' #' Inform RStudio's Jobs pane that a job has been added. #' #' @param name The job's name. #' @param status The initial status text for the job; optional. #' @param progressUnits The integer number of units of work in the job; for example, \code{100L} #' if the job's progress is expressed in percentages. Use \code{0L} if the number of units of #' work is unknown. #' @param actions A list of actions that can be performed on the job (see Actions). #' @param running Whether the job is currently running. #' @param autoRemove Whether to remove the job from the Jobs pane when it's complete. #' @param show Whether to show the job in the Jobs pane. #' @return An ID representing the newly added job, used as a handle to provide #' further updates of the job's status. #' #' @section Actions: #' The \code{actions} parameter is a named list of functions that the user can invoke on the job; #' for example: \code{actions = list(stop = function(id) { ... })}. The function will be passed a #' parameter named \code{id} with the job ID that invoked it. #' #' There are two special action names: #' \describe{ #' \item{stop}{If there is an action named \code{stop}, then the job will #' have a Stop button in in the Jobs pane, and pressing that button will invoke #' the \code{stop} action.} #' \item{info}{If there is an action named \code{info}, then the job will #' have an informational link in the Jobs pane rather than an output #' display, and clicking the link will invoke the \code{info} action.} #' } #' #' @family jobs #' @export jobAdd <- function(name, status = "", progressUnits = 0L, actions = NULL, running = FALSE, autoRemove = TRUE, show = TRUE) { callFun("addJob", name = name, status = status, progressUnits = progressUnits, actions = actions, running = running, autoRemove = autoRemove, show = show) } #' Remove a Job #' #' Remove a job from RStudio's Jobs pane. #' #' @param job The ID of the job to remove. #' #' @family jobs #' @export jobRemove <- function(job) { callFun("removeJob", job = job) } #' Set Job Progress #' #' Updates the progress for a job. #' #' @param job The ID of the job to set progress for. #' @param units The integer number of total units of work completed so far. #' #' @family jobs #' @export jobSetProgress <- function(job, units) { callFun("setJobProgress", job = job, units = units) } #' Add Job Progress #' #' Adds incremental progress units to a job. #' #' @param job The ID of the job to update progress for. #' @param units The integer number of new progress units completed. #' #' @family jobs #' @export jobAddProgress <- function(job, units) { callFun("addJobProgress", job = job, units = units) } #' Set Job Status #' #' Update a job's informational status text. #' #' @param job The ID of the job to update. #' @param status Text describing job's new status. #' #' @family jobs #' @export jobSetStatus <- function(job, status) { callFun("setJobStatus", job = job, status = status) } #' Set Job State #' #' Changes the state of a job. #' #' @param job The ID of the job on which to change state. #' @param state The new job state. #' #' @section States: #' #' The following states are supported: #' \describe{ #' \item{idle}{The job is waiting to run.} #' \item{running}{The job is actively running.} #' \item{succeeded}{The job has finished successfully.} #' \item{cancelled}{The job was cancelled.} #' \item{failed}{The job finished but did not succeed.} #' } #' #' @family jobs #' @export jobSetState <- function(job, state = c("idle", "running", "succeeded", "cancelled", "failed")) { callFun("setJobState", job = job, state = state) } #' Add Job Output #' #' Adds text output to a job. #' #' @param job The ID of the job that has emitted text. #' @param output The text output emitted by the job. #' @param error Whether the output represents an error. #' #' @family jobs #' @export jobAddOutput <- function(job, output, error = FALSE) { callFun("addJobOutput", job = job, output = output, error = error) } #' Run R Script As Job #' #' Starts an R script as a background job. #' #' @param path The path to the R script to be run. #' @param name A name for the background job. When \code{NULL} (the default), the filename of the #' script is used as the job name. #' @param encoding The text encoding of the script, if known. #' @param workingDir The working directory in which to run the job. When \code{NULL} (the default), #' the parent directory of the R script is used. #' @param importEnv Whether to import the global environment into the job. #' @param exportEnv The name of the environment in which to export the R objects created by the #' job. Use \code{""} (the default) to skip export, \code{"R_GlobalEnv"}` to export to the #' global environment, or the name of an environment object to create an object with that name. #' #' @family jobs #' @export #' #' #' jobRunScript <- function(path, name = NULL, encoding = "unknown", workingDir = NULL, importEnv = FALSE, exportEnv = "") { path <- normalizePath(path, winslash = "/", mustWork = TRUE) callFun("runScriptJob", path = path, name = name, encoding = encoding, workingDir = workingDir, importEnv = importEnv, exportEnv = exportEnv) } rstudioapi/R/document-methods.R0000644000176200001440000001237413535525640016257 0ustar liggesusers#' Create a Document Position #' #' Creates a \code{document_position}, which can be used to indicate e.g. the #' row + column location of the cursor in a document. #' #' @param x An object coercable to \code{document_position}. #' @param row The row (using 1-based indexing). #' @param column The column (using 1-based indexing). #' #' @name document_position #' #' @export #' @family location document_position <- function(row, column) { structure(c(row = as.numeric(row), column = as.numeric(column)), class = "document_position") } #' @rdname document_position #' @export is.document_position <- function(x) { inherits(x, "document_position") } #' @name document_position #' @export as.document_position <- function(x) { UseMethod("as.document_position") } #' @export as.document_position.document_position <- function(x) { x } #' @export as.document_position.default <- function(x) { if (length(x) != 2 || !is.numeric(x)) stop("'x' should be a numeric vector of length 2", call. = FALSE) document_position(row = x[[1]], column = x[[2]]) } #' @export format.document_position <- function(x, ...) { paste("[", paste(x, collapse = ", "), "]", sep = "") } #' @export print.document_position <- function(x, ...) { cat("Document Position: ", format(x), "\n", sep = "") } #' Create a Range #' #' A \code{document_range} is a pair of \code{\link{document_position}} objects, #' with each position indicating the \code{start} and \code{end} of the range, #' respectively. #' #' @param x An object coercable to \code{document_range}. #' @param start A \code{\link{document_position}} indicating the start of the #' range. #' @param end A \code{\link{document_position}} indicating the end of the range. #' #' @return An \R \code{list} with class \code{document_range} and fields: #' #' \tabular{ll}{ #' \code{start:}\tab The start position.\cr #' \code{end:}\tab The end position.\cr #' } #' #' @name document_range #' #' @export document_range <- function(start, end = NULL) { # Allow users to write e.g. 'document_range(c(1, 2, 3, 4))'; # ie, ignore using the 'end' argument if (is.null(end)) { if (length(start) != 4 || !is.numeric(start)) stop("invalid range specification", call. = FALSE) end <- start[3:4] start <- start[1:2] } structure(list(start = as.document_position(start), end = as.document_position(end)), class = "document_range") } #' @name document_range #' @export is.document_range <- function(x) { inherits(x, "document_range") } #' @name document_range #' @export as.document_range <- function(x) { UseMethod("as.document_range") } #' @export as.document_range.document_range <- function(x) { x } #' @export as.document_range.default <- function(x) { document_range(x) } #' @export format.document_range <- function(x, ...) { startPos <- as.document_position(x$start) endPos <- as.document_position(x$end) paste(format(startPos, ...), "--", format(endPos, ...)) } #' @export print.document_range <- function(x, ...) { cat("Document Range:", "\n- Start: ", format(x$start), "\n- End: ", format(x$end), "\n", sep = "") } as.document_selection <- function(x) { invalidMsg <- "'x' should be a list of {range, text} pairs" if (!is.list(x)) stop(invalidMsg, call. = FALSE) result <- lapply(x, function(el) { named <- all(c("range", "text") %in% names(el)) if (!named) stop(invalidMsg, call. = FALSE) Encoding(el$text) <- "UTF-8" list( range = as.document_range(el$range), text = el$text ) }) structure(result, class = "document_selection") } formatSelection <- function(x) { vapply(x, FUN.VALUE = character(1), function(el) { rng <- format(el$range) txt <- formatText(el$text) paste(rng, ": '", txt, "'", sep = "") }) } #' @export print.document_selection <- function(x, ...) { cat("Document Selection:", sep = "") formatted <- formatSelection(x) lapply(formatted, function(el) { cat("\n- ", el, sep = "") }) cat("\n", sep = "") } #' @export print.document_context <- function(x, ...) { cat("Document Context: ", "\n- id: '", x$id, "'", "\n- path: '", x$path, "'", "\n- contents: <", length(x$contents), " rows>", "\n", sep = "") print(x$selection) } #' Extract the Primary Selection #' #' By default, functions returning a document context will #' return a list of selections, including both the 'primary' #' selection and also 'other' selections (e.g. to handle the #' case where a user might have multiple cursors active). #' Use \code{primary_selection()} to extract the primary #' selection. #' #' @param x A document context, or a selection. #' @param ... Optional arguments (currently ignored). #' #' @export primary_selection <- function(x, ...) { UseMethod("primary_selection") } #' @export primary_selection.document_context <- function(x, ...) { primary_selection(x$selection) } #' @export primary_selection.document_selection <- function(x, ...) { x[[1]] } getDocumentContext <- function(fn) { context <- callFun(fn) if (is.null(context)) return(NULL) Encoding(context$path) <- "UTF-8" Encoding(context$contents) <- "UTF-8" context$selection <- as.document_selection(context$selection) structure(context, class = "document_context") } rstudioapi/R/misc.R0000644000176200001440000000031013535525640013716 0ustar liggesusers#' @importFrom utils capture.output formatText <- function(text, n = 20L, truncated = "<...>") { result <- if (nchar(text) < n) text else paste(text, truncated) encodeString(result) } rstudioapi/R/launcher.R0000644000176200001440000000135713535525640014600 0ustar liggesusers callLauncherFun <- function(fname, ...) { verifyAvailable() if (hasFun(fname)) return(callFun(fname, ...)) if (!exists("RStudio.Version", envir = globalenv())) stop("RStudio is not available.", call. = FALSE) RStudio.Version <- get("RStudio.Version", envir = globalenv()) version <- RStudio.Version() if (is.null(version$edition)) { fmt <- "Launcher API '%s' is not available in the open-source edition of RStudio." stop(sprintf(fmt, fname)) } if (identical(version$mode, "desktop")) { fmt <- "Launcher API '%s' is not yet available in the Desktop edition of RStudio." stop(sprintf(fmt, fname)) } fmt <- "Launcher API '%s' is not available in this version of RStudio." stop(sprintf(fmt, fname)) } rstudioapi/R/prefs.R0000644000176200001440000000665513535525640014124 0ustar liggesusers #' Read Preference #' #' Reads a user preference, useful to remember preferences across different R #' sessions for the same user. #' #' @param name The name of the preference. #' #' @param default The default value to use when the preference is not available. #' #' @seealso \code{\link{readRStudioPreference}}, which reads RStudio IDE #' preferences. #' #' @details User preferences can have arbitrary names and values. You must write #' the preference with \code{\link{writePreference}} before it can be read #' (otherwise its default value will be returned). #' #' @note The \code{readPreference} function was added in version 1.1.67 of #' RStudio. #' #' @export readPreference <- function(name, default) { callFun("readPreference", name, default) } #' Write Preference #' #' Writes a user preference, useful to remember preferences across different R #' sessions for the same user. #' #' @param name The name of the preference. #' #' @param value The value of the preference. #' #' @note The \code{writePreference} function was added in version 1.1.67 of #' RStudio. #' #' @seealso \code{\link{writeRStudioPreference}}, which changes RStudio IDE #' preferences. #' #' @export writePreference <- function(name, value) { callFun("writePreference", name, value) } #' Write RStudio Preference #' #' Writes an internal RStudio IDE preference for the current user. #' #' @param name The name of the preference. #' #' @param value The value of the preference. #' #' @details RStudio IDE internal preferences include the values displayed in #' RStudio's Global Options dialog as well as a number of additional settings. #' Set them carefully; inappropriate values can cause unexpected behavior. See #' the RStudio Server Professional Administration Guide appendix for your #' version of RStudio for a full list of preference names and values. #' #' @seealso \code{\link{writePreference}}, which can be used to store arbitrary #' user (non-RStudio) preferences. #' #' \code{\link{readRStudioPreference}}, which reads internal RStudio IDE #' preferences. #' #' @note The \code{writeRStudioPreference} function was added in version 1.3.387 #' of RStudio. #' #' @examples #' \dontrun{ #' # Hide RStudio's toolbar. #' rstudioapi::writeRStudioPreference("toolbar_visible", FALSE) #' } #' #' @export writeRStudioPreference <- function(name, value) { callFun("writeRStudioPreference", name, value) } #' Read RStudio Preference #' #' Reads an internal RStudio IDE preference for the current user. #' #' @param name The name of the preference. #' #' @param default The default value of the preference, returned if the #' preference is not found. #' #' @details RStudio IDE internal preferences include the values displayed in #' RStudio's Global Options dialog as well as a number of additional settings. #' #' @seealso \code{\link{readPreference}}, which can be used to read arbitrary #' user (non-RStudio) preferences set with \code{\link{writePreference}}. #' #' \code{link{writeRStudioPreference}}, which can be used to write internal #' RStudio IDE preferences. #' #' @note The \code{readRStudioPreference} function was added in version 1.3.387 #' of RStudio. #' #' @examples #' \dontrun{ #' # Get indentation settings #' spaces <- rstudioapi::readRStudioPreference("num_spaces_for_tab", FALSE) #' message("Using ", spaces, " per tab.") #' } #' #' @export readRStudioPreference <- function(name, default) { callFun("readRStudioPreference", name, default) } rstudioapi/R/bug-report.R0000644000176200001440000000334613535525640015065 0ustar liggesusers #' File an RStudio Bug Report #' #' A utility function to assist with the filing of an RStudio bug report. #' This function will pre-populate a template with information useful in #' understanding your reported bug. #' #' #' @export bugReport <- function() { verifyAvailable() rstudioInfo <- versionInfo() rstudioVersion <- format(rstudioInfo$version) rstudioEdition <- sprintf( "%s [%s]", if (rstudioInfo$mode == "desktop") "Desktop" else "Server", if (is.null(rstudioInfo$edition)) "Open Source" else toupper(rstudioInfo$edition) ) rInfo <- utils::sessionInfo() rVersion <- rInfo$R.version$version.string rVersion <- sub("^R version", "", rVersion, fixed = TRUE) osVersion <- rInfo$running templateFile <- system.file("resources/bug-report.md", package = "rstudioapi") template <- readLines(templateFile) rendered <- renderTemplate(template, list( RSTUDIO_VERSION = rstudioVersion, RSTUDIO_EDITION = rstudioEdition, OS_VERSION = osVersion, R_VERSION = rVersion )) if (rstudioInfo$mode == "desktop" && requireNamespace("clipr", quietly = TRUE)) { clipr::write_clip(rendered) writeLines("* The bug report template has been written to the clipboard.") writeLines("* Please paste the clipboard contents into the issue comment section,") writeLines("* and then fill out the rest of the issue details.") } else { header <- "" text <- c(header, rendered) file <- tempfile("rstudio-bug-report-", fileext = ".html") on.exit(unlink(file), add = TRUE) writeLines(text, con = file) utils::file.edit(file) } url <- "https://github.com/rstudio/rstudio/issues/new" utils::browseURL(url) } rstudioapi/R/dependencies.R0000644000176200001440000000153113574017621015415 0ustar liggesusers#' Get RStudio Package Dependencies #' #' Gets a list of the all the R packages that RStudio depends on in some way. #' #' @return A data frame containing a row per R package. #' #' @details The data frame of package dependencies contains the following #' columns: \describe{ #' \item{name}{The name of the R package.} #' \item{version}{The required minimum version of the R package.} #' \item{location}{Where RStudio expects the package to be, \code{cran} for #' a CRAN-like repository or \code{embedded} for development packages #' embedded in RStudio itself.} #' \item{source}{Whether the package should be installed from source.} #' } #' #' @note The \code{getRStudioPackageDependencies} function was introduced in #' RStudio 1.3.525. #' #' @export getRStudioPackageDependencies <- function() { callFun("getPackageDependencies") } rstudioapi/R/dictionaries.R0000644000176200001440000000152613535525640015452 0ustar liggesusers #' Interact with RStudio's Dictionaries #' #' Interact with the [hunspell](https://hunspell.github.io/) dictionaries #' used by RStudio for spell checking. #' #' `dictionariesPath()` gives a path to the dictionaries installed and #' distributed with RStudio. #' #' `userDictionariesPath()` gives the path where users can provide their #' own custom `hunspell` dictionaries. See: #' #' \url{https://support.rstudio.com/hc/en-us/articles/200551916-Spelling-Dictionaries} #' #' for more information. #' #' @note The `dictionariesPath()` and `userDictionariesPath()` functions were #' introduced with RStudio 1.2.1202. #' #' @name dictionaries NULL #' @name dictionaries #' @export dictionariesPath <- function() { callFun("dictionariesPath") } #' @name dictionaries #' @export userDictionariesPath <- function() { callFun("userDictionariesPath") } rstudioapi/R/build-tools.R0000644000176200001440000000267513535525640015240 0ustar liggesusers#' Build Tools #' #' Check, install, and use build tools as required. #' #' These functions are intended to be used together -- one should #' first check whether build tools are available, and when not, #' prompt for installation. For example: #' #' ```R #' compile_model <- function(...) { #' #' if (rstudioapi::isAvailable()) { #' #' if (!rstudioapi::buildToolsCheck()) #' rstudioapi::buildToolsInstall("Model compilation") #' #' rstudioapi::buildToolsExec({ #' # code requiring build tools here #' }) #' #' } #' } #' ``` #' #' The `action` parameter is used to communicate (with a prompt) the operation #' being performed that requires build tool installation. Setting it to `NULL` #' or the empty string will suppress that prompt. #' #' @param action The action (as a string) being taken that will require #' installation of build tools. #' #' @param expr An \R expression (unquoted) to be executed with build tools #' available and on the `PATH`. #' #' @note The `buildToolsCheck()`, `buildToolsInstall()`, and `buildToolsExec()` #' functions were added with version 1.2.962 of RStudio. #' #' @name build-tools NULL #' @name build-tools #' @export buildToolsCheck <- function() { callFun("buildToolsCheck") } #' @name build-tools #' @export buildToolsInstall <- function(action) { callFun("buildToolsInstall", action) } #' @name build-tools #' @export buildToolsExec <- function(expr) { callFun("buildToolsExec", expr) } rstudioapi/R/tutorial.R0000644000176200001440000000012413617331207014624 0ustar liggesusers tutorialLaunchBrowser <- function(url) { callFun("tutorialLaunchBrowser", url) } rstudioapi/R/highlight-ui.R0000644000176200001440000000376113574521743015365 0ustar liggesusers #' Highlight UI Elements within the RStudio IDE #' #' This function can be used to highlight UI elements within the RStudio IDE. #' UI elements can be selected using query selectors; most commonly, one should #' choose to highlight elements based on their IDs when available. #' #' The tool at: #' #' ``` #' Help -> Diagnostics -> Show DOM Elements #' ``` #' #' can be useful for identifying the classes and IDs assigned to the different #' elements within RStudio. #' #' @section Queries: #' #' Elements are selected using the same queries as through the web #' `querySelectorAll()` API. See #' for more details. #' #' For example, to highlight the Save icon within the Source pane, one might #' use: #' #' ``` #' rstudioapi::highlightUi("#rstudio_tb_savesourcedoc") #' ``` #' #' In some cases, multiple UI elements need to be highlighted -- e.g. if #' you want to highlight both a menu button, and a menu item within the #' menu displayed after the button is pressed. We'll use the Environment Pane's #' Import Dataset button as an example. To highlight the `From Text (readr)` #' command, you might use: #' #' ``` #' rstudioapi::highlightUi( #' list( #' list(query = "#rstudio_mb_import_dataset", parent = 0L), #' list(query = "#rstudio_label_from_text_readr_command", parent = 1L) #' ) #' ) #' ``` #' #' @note The \code{executeCommand} function was introduced in RStudio 1.3.658. #' #' @param queries A list of "query" objects. Each query should be a list with #' entries `"query"` and `"parent"`. See **Queries** for more details. #' #' @export highlightUi <- function(queries) { queries <- lapply(queries, function(data) { if (is.character(data)) data <- list(query = data, parent = 0L) if (is.null(data$query)) stop("missing 'query' in highlight request") data$highlight <- as.integer(data$highlight %||% 0) data }) invisible(callFun("highlightUi", queries)) } rstudioapi/R/themes.R0000644000176200001440000001430313535525640014257 0ustar liggesusers#' Retrieve Themes #' #' Retrieves a list with information about the current color theme used by RStudio. #' #' @details A list is returned with the following elements: #' \describe{ #' \item{editor}{The name of the current editor theme, such as \code{Textmate}.} #' \item{global}{The name of the current global theme. One of \code{Modern}, \code{Classic}, or #' \code{Sky}.} #' \item{dark}{\code{TRUE} if the editor theme is dark, \code{FALSE} otherwise.} #' \item{foreground}{The current editor theme's default text foreground color, formatted as a #' CSS-compatible color string, such as \code{rgb(1, 22, 39)}. Supported since RStudio 1.2.1214.} #' \item{background}{The current editor theme's default text background color, formatted as a #' CSS-compatible color string. Supported since RStudio 1.2.1214.} #' } #' #' @export getThemeInfo <- function() { callFun("getThemeInfo") } #' Add a Custom Editor Theme #' #' Adds a custom editor theme to RStudio and returns the name of the newly added theme. #' #' @param themePath A full or relative path or URL to an \code{rstheme} or \code{tmtheme} to be #' added. #' @param apply Whether to immediately apply the newly added theme. Setting this to #' \code{TRUE} has the same impact as running #' \code{{ rstudioapi::addTheme(); rstudioapi::applyTheme() }}.\cr #' Default: \code{FALSE}. #' @param force Whether to force the operation and overwrite an existing file with the same #' name.\cr #' Default: \code{FALSE}. #' @param globally Whether to install this theme for the current user or all users. If set to #' \code{TRUE} this will attempt to install the theme for all users, which may #' require administrator privileges.\cr #' Default: \code{FALSE}. #' #' @note The \code{addTheme} function was introduced in RStudio 1.2.879. #' #' @export addTheme <- function(themePath, apply = FALSE, force = FALSE, globally = FALSE) { path <- themePath # Ensure path looks like something we can use ext <- tolower(tools::file_ext(path)) if (!identical(ext, "rstheme") && !identical(ext, "tmtheme")) { stop("Invalid path ", path, ". ", "Please supply a path or URL to an .rstheme or .tmtheme file to add.") } # If the path appears to be a URL, download it. if (grepl("^https?:", themePath)) { # Give the downloaded filename the same name and extension as the original. path <- file.path(tempdir(), utils::URLdecode(basename(themePath))) if (file.exists(path)) { # It's unlikely that the theme file will exist in the temp dir, but move it out # of the way if it does. unlink(path) } # Perform the download utils::download.file(themePath, path) } if (identical(ext, "tmtheme")) { # needs conversion first convertTheme(path, add = TRUE, apply = apply, force = force, globally = globally) } else if (identical(ext, "rstheme")) { # no conversion necessary callFun("addTheme", path, apply, force, globally) } } #' Apply an Editor Theme to RStudio #' #' Applies the specified editor theme to RStudio. #' #' @param name The unique name of the theme to apply. #' #' @note The \code{applyTheme} function was introduced in RStudio 1.2.879. #' #' @export applyTheme <- function(name) { callFun("applyTheme", name) } #' Convert a tmTheme to an RStudio Theme #' #' Converts a \code{tmTheme} to an \code{rstheme} and optionally adds and applies it to RStudio and returns the #' name of the theme. #' #' @param themePath A full or relative path to the \code{tmTheme} file to be converted. #' @param add Whether to add the newly converted theme to RStudio. Setting this to true #' will have the same impact as running \code{{ rstudioapi::convertTheme(, outputLocation = ); rstudioapi::addTheme() }}.\cr #' Default: \code{TRUE}. #' @param outputLocation A full or relative path where a copy of the converted theme will be saved. #' If this value is \code{NULL}, no copy will be saved.\cr #' Default: \code{NULL}. #' @param apply Whether to immediately apply the newly added theme. This paramater cannot be set to #' \code{TRUE} if \code{add} is set to \code{FALSE}. Setting this and \code{add} #' to \code{TRUE} has the same impact as running #' \code{{ rstudioapi::convertTheme(, outputLocation = ); rstudioapi::addTheme(); rstudioapi::applyTheme() }}.\cr #' Default: \code{FALSE}. #' @param force Whether to force the operation and overwrite an existing file with the same #' name.\cr #' Default: \code{FALSE}. #' @param globally Whether to install this theme for the current user or all users. If set to #' \code{TRUE} this will attempt to install the theme for all users, which may #' require administrator privileges. Only applies when \code{add} is \code{TRUE}. \cr #' Default: \code{FALSE}. #' #' @note The \code{convertTheme} function was introduced in RStudio 1.2.879. #' #' @export convertTheme <- function(themePath, add = TRUE, outputLocation = NULL, apply = FALSE, force = FALSE, globally = FALSE) { callFun("convertTheme", themePath, add, outputLocation, apply, force, globally) } #' Get Theme List #' #' Retrieves a list of the names of all the editor themes installed for RStudio. #' #' @note The \code{getThemes} function was introduced in RStudio 1.2.879. #' #' @export getThemes <- function() { callFun("getThemes") } #' Remove a custom theme from RStudio. #' #' @param name The unique name of the theme to remove. #' #' @note The \code{removeTheme} function was introduced in RStudio 1.2.879. #' #' @export removeTheme <- function(name) { callFun("removeTheme", name) } rstudioapi/R/remote.R0000644000176200001440000000320013542731513014253 0ustar liggesusers isChildProcess <- function() { !is.na(Sys.getenv("RSTUDIOAPI_IPC_REQUESTS_FILE", unset = NA)) } callRemote <- function(call, frame) { # check for active request / response request <- Sys.getenv("RSTUDIOAPI_IPC_REQUESTS_FILE", unset = NA) response <- Sys.getenv("RSTUDIOAPI_IPC_RESPONSE_FILE", unset = NA) secret <- Sys.getenv("RSTUDIOAPI_IPC_SHARED_SECRET", unset = NA) if (is.na(request) || is.na(response) || is.na(secret)) stop("internal error: callFunRemote() called without remote connection") attr(call, "srcref") <- NULL # ensure rstudioapi functions get appropriate prefix if (is.name(call[[1L]])) call[[1L]] <- call("::", as.name("rstudioapi"), call[[1L]]) # ensure arguments are evaluated before sending request for (i in seq_along(call)[-1L]) call[[i]] <- eval(call[[i]], envir = frame) # write to tempfile and rename, to ensure atomicity data <- list(secret = secret, call = call) tmp <- tempfile(tmpdir = dirname(request)) saveRDS(data, file = tmp) file.rename(tmp, request) # loop until response is ready (poll) # in theory we'd just do a blocking read but there isn't really a good # way to do this in a cross-platform way without additional dependencies now <- Sys.time() repeat { # check for response if (file.exists(response)) break # check for lack of response diff <- difftime(Sys.time(), now, units = "secs") if (diff > 10) stop("RStudio did not respond to rstudioapi IPC request") # wait a bit Sys.sleep(0.1) } # read response response <- readRDS(response) if (inherits(response, "error")) stop(response) response } rstudioapi/R/templates.R0000644000176200001440000000636413535525640015000 0ustar liggesusers#' Create a Project Template #' #' Create a project template. See #' \url{https://rstudio.github.io/rstudio-extensions/rstudio_project_templates.html} #' for more information. #' #' @param package The path to an \R package sources. #' @param binding The \R skeleton function to associate with this project #' template. This is the name of the function that will be used to initialize #' the project. #' @param title The title to be shown within the \strong{New Project...} wizard. #' @param subtitle (optional) The subtitle to be shown within the \strong{New Project...} wizard. #' @param caption (optional) The caption to be shown on the landing page for this template. #' @param icon (optional) The path to an icon, on disk, to be used in the dialog. Must be an #' \code{.png} of size less than 64KB. #' @param open_files (optional) Files that should be opened by RStudio when the project is #' generated. Shell-style globs can be used to indicate when multiple files #' matching some pattern should be opened -- for example, OpenFiles: R/*.R #' would indicate that RStudio should open all .R files within the R folder of #' the generated project. #' @param overwrite Boolean; overwrite a pre-existing template file if one exists? #' @param edit Boolean; open the file for editting after creation? #' @export createProjectTemplate <- function(package = ".", binding, title, subtitle = paste("Create a new", title), caption = paste("Create", title), icon = NULL, open_files = NULL, overwrite = FALSE, edit = TRUE) { package <- normalizePath(package, winslash = "/", mustWork = TRUE) # construct metadata metadata <- list( Binding = binding, Title = title, Subtitle = subtitle, Caption = caption, Icon = icon, OpenFiles = open_files ) # drop nulls metadata <- metadata[vapply(metadata, Negate(is.null), FUN.VALUE = logical(1))] # create templates directory templates_dir <- file.path(package, "inst/rstudio/templates/project") if (!file.exists(templates_dir)) if (!dir.create(templates_dir, recursive = TRUE)) stop(sprintf("failed to create '%s' directory", templates_dir)) # construct DCF metadata contents dcf <- paste(names(metadata), ": ", metadata, sep = "") # add header linking to online documentation header <- c( "# This file provides the metadata necessary for RStudio to", "# use the '%s()' function when initializing a project. See", "# the documentation online at: ", "#", "# https://rstudio.github.io/rstudio-extensions/rstudio_project_templates.html", "#", "# for more details.", "" ) header <- sprintf(header, binding) dcf <- c(header, dcf) # construct path to file name <- gsub("[^a-zA-Z0-9_.]", "_", binding) path <- file.path(templates_dir, paste(name, "dcf", sep = ".")) if (file.exists(path) && !overwrite) stop(sprintf("a skeleton function already exists at path '%s'", path)) # write out writeLines(dcf, con = path) if (edit) utils::file.edit(path) TRUE } rstudioapi/R/code.R0000644000176200001440000000761013542731513013703 0ustar liggesusers#' Check if RStudio is running. #' #' @param version_needed An optional version specification. If supplied, #' ensures that RStudio is at least that version. #' #' @param child_ok Boolean; check if the current R process is a child #' process of the main RStudio session? This can be useful for e.g. RStudio #' Jobs, where you'd like to communicate back with the main R session from #' a child process through `rstudioapi`. #' #' @return \code{isAvailable} a boolean; \code{verifyAvailable} an error message #' if RStudio is not running #' #' @export #' @examples #' rstudioapi::isAvailable() #' \dontrun{rstudioapi::verifyAvailable()} isAvailable <- function(version_needed = NULL, child_ok = FALSE) { if (child_ok && isChildProcess()) return(callRemote(sys.call(), parent.frame())) identical(.Platform$GUI, "RStudio") && version_ok(version_needed) } version_ok <- function(version = NULL) { if (is.null(version)) return(TRUE) getVersion() >= version } #' @rdname isAvailable #' @export verifyAvailable <- function(version_needed = NULL) { if (!isAvailable()) stop("RStudio not running", call. = FALSE) if (!version_ok(version_needed)) { stop("Need at least version ", version_needed, " of RStudio. ", "Currently running ", getVersion(), call. = FALSE) } invisible(TRUE) } #' Return the current version of the RStudio API #' #' @return A \code{\link{numeric_version}} which you can compare to a string #' and get correct results. #' @export #' @examples #' \dontrun{ #' if (rstudioapi::getVersion() < "0.98.100") { #' message("Your version of RStudio is quite old") #' } #' } getVersion <- function() { verifyAvailable() callFun("versionInfo")$version } #' Call an RStudio API function #' #' This function will return an error if RStudio is not running, or the #' function is not available. If you want to fall back to different #' behavior, use \code{\link{hasFun}}. #' #' @param fname name of the RStudio function to call. #' @param ... Other arguments passed on to the function #' @export #' @examples #' if (rstudioapi::isAvailable()) { #' rstudioapi::callFun("versionInfo") #' } callFun <- function(fname, ...) { if (isChildProcess()) return(callRemote(sys.call(), parent.frame())) verifyAvailable() if (usingTools()) found <- exists(toolsName(fname), envir = toolsEnv(), mode = "function") else found <- exists(fname, envir = asNamespace("rstudio"), mode = "function") if (!found) stop("Function ", fname, " not found in RStudio", call. = FALSE) f <- findFun(fname, mode = "function") f(...) } #' Exists/get for RStudio functions #' #' These are specialized versions of \code{\link[base]{get}} and #' \code{\link[base]{exists}} that look in the rstudio package namespace. #' If RStudio is not running, \code{hasFun} will return \code{FALSE}. #' #' @param name name of object to look for #' @param ... other arguments passed on to \code{\link[base]{exists}} and #' \code{\link[base]{get}} #' @param version_needed An optional version specification. If supplied, #' ensures that RStudio is at least that version. This is useful if #' function behavior has changed over time. #' @export #' @examples #' rstudioapi::hasFun("viewer") hasFun <- function(name, version_needed = NULL, ...) { if (!isAvailable(version_needed)) return(FALSE) if (usingTools()) exists(toolsName(name), toolsEnv(), ...) else exists(name, envir = asNamespace("rstudio"), ...) } #' @export #' @rdname hasFun findFun <- function(name, version_needed = NULL, ...) { verifyAvailable(version_needed) if (usingTools()) get(toolsName(name), toolsEnv(), ...) else get(name, envir = asNamespace("rstudio"), ...) } usingTools <- function() { exists(toolsName("versionInfo"), envir = toolsEnv()) } toolsName <- function(name) { paste(".rs.api.", name, sep="") } toolsEnv <- function() { as.environment(match("tools:rstudio", search())) } rstudioapi/NEWS.md0000644000176200001440000000556113617331257013552 0ustar liggesusers # rstudioapi 0.11 * `rstudioapi::launcherResourceLimit()` now properly delegates the type and memory arguments. (#164) * `rstudioapi` gains the function `highlightUi()`, used to highlight UI elements in newer versions of RStudio. * Paths returned from `selectFile()` are now properly marked with UTF-8 encoding. * It is now possible for `rstudioapi` to communicate with a parent RStudio session, for R sessions launched as RStudio jobs. Use `rstudioapi::isAvailable(child_ok = TRUE)` to assert that it's okay to check that `rstudioapi` is available and is running within an RStudio job. * Added `bugReport()`, a helper function for reporting RStudio bugs on the GitHub issue tracker with an issue template pre-populated with some helpful diagnostic information. * Added `userIdentity` and `systemUsername`, used to retrieve information about the current user. # rstudioapi 0.10 * Added the parameters `echo` and `focus` to `sendToConsole()`. # rstudioapi 0.9 * Added functions for displaying jobs in RStudio's Jobs pane: `jobAdd()`, `jobRemove()`, etc. * Added `translateLocalUrl()`, for translating localhost URLs to externally addressable ones on RStudio Server. # rstudioapi 0.8 * Added functions for installing + using build tools: `buildToolsCheck()`, `buildToolsInstall()`, `buildToolsExec()` * Added functions for installing + using themes: `addTheme()`, `applyTheme()`, `convertTheme()`, `getThemes()`, `getThemeInfo()`. * Added `previewSql()`, for previewing output from executing a SQL query. * Added `askForSecret()`, for prompting the user to enter a password or otherwise privileged information. * Fixed an issue where `getActiveProject()` failed for non-ASCII paths. (#86) # rstudioapi 0.7 * Added methods for prompting the user for file paths: `selectFile()`, `selectDirectory()`. * `askForPassword()` gains a default prompt (#41) * Add `createProjectTemplate()` function * Add `setPersistentValue()` / `getPersistentValue()` functions * Add methods for interacting with Terminal tab: `terminalActivate()`, `terminalClear()`, `terminalCreate()`, `terminalList()`, `terminalBuffer()`, `terminalContext()`, `terminalVisible()`, `terminalBusy()`, `terminalRunning()`, `terminalKill()`, `terminalSend()`, `terminalExecute()`, and `terminalExitCode()`. # rstudioapi 0.6 * Add sendToConsole function * Add APIs for setting cursor position in document # rstudioapi 0.5 * Add askForPassword function * Add getActiveProject function # rstudioapi 0.4 * Add API methods for interacting with a document open in RStudio: 'insertText()', 'modifyRange()' and 'getActiveDocumentContext()'. # rstudioapi 0.3 * Add stub and documentation for sourceMarker function # rstudioapi 0.2 * Compatibility with calling conventions for RStudio v0.99 * Stubs and documentation for versionInfo, previewRd, and viewer functions # rstudioapi 0.1 Initial release to CRAN rstudioapi/MD50000644000176200001440000001641013617370242012754 0ustar liggesusers52c9119f42754fdee3b115afd25a5d86 *DESCRIPTION 2491c4039e00be047cce99c452d3fd00 *LICENSE b756a4c6b03f3db63daa294e56ff1fe7 *NAMESPACE ff4bc51b46abe762be4417055d34e78d *NEWS.md 8079d5d17a7544786ae008beb8bcfeff *R/bug-report.R 55173aca0882afbde1f0255d458bc4d1 *R/build-tools.R c8c3e88180d402f3efbec33ce57d3641 *R/code.R 4a18e62299bb7e705b6909f2105ef27f *R/commands.R cbf2dc8a60ac9c041d46cd2cf3eb616a *R/dependencies.R d3c1b096bce76401a443187c76adc980 *R/dialogs.R d3b7b1360801c205e6217adc8c8a5d3d *R/dictionaries.R 3817651bef22ba2c61d3a60f520802f5 *R/document-api.R 489638fe1f6c67d1afa7a9c983d4e8f7 *R/document-methods.R 54f0340af2a982b8a0b15aa291fc3e63 *R/highlight-ui.R 5584305529c126844bf5630637364535 *R/jobs.R adc717e1855b71b7214350f9160c6c5f *R/launcher-functions.R a6b30acdc0bba6b16108033aee980ba6 *R/launcher.R 627c1993928ca912b11e33ee38fd7e15 *R/misc.R 79eec1cb2c08f7cf08d65c905326b44c *R/prefs.R b993b959fb26173752c62514952af63b *R/preview.R 1ef0b0fa956973a7458b7173a2b50579 *R/remote.R 7e2f7b3a3ffe953516b099bf2eef3bbb *R/stubs.R 4ff4a8ad43716c847b75431bf5917b6d *R/templates.R 3236309e8e13f9de2467556413fc6dc5 *R/terminal.R 2d7e1fbeb173a3802cbb6b8989dafc68 *R/themes.R 803dd0ced443c56b0a3457007b52f89c *R/tutorial.R 590e8d0ab9ee2f18c4a207db7cbd0f98 *R/urls.R e93f0ae783320dd015e29338f7790b57 *R/user.R 1219c514fd50cdd826fe436c25d006e0 *R/utils.R 1915dcc02ca5e391e58789e77a050b7c *build/vignette.rds bd533fab67709a0c98a10338d39ee679 *inst/doc/dialogs.R 01f5841a3d3d9249f0b6509697189d5e *inst/doc/dialogs.Rmd f003379d255b96fd2d4c07603d47a1df *inst/doc/dialogs.html 462250065182d40e516e44efddc7dc36 *inst/doc/document-manipulation.R 0a81e2595fc31915b1c6ec77cdbc8fe2 *inst/doc/document-manipulation.Rmd 19cf19865084ad5cb46964785ed28292 *inst/doc/document-manipulation.html 4eb7f4d912f65f74a951b41ca1ab859d *inst/doc/introduction.Rmd 89487e0b2c5c2ff36d5cc63e5a5938e4 *inst/doc/introduction.html 0ed95f3ce75ac90c6e6948d13c746b8e *inst/doc/projects.R b3f763976fc12d073ef5f4cf610589db *inst/doc/projects.Rmd 19963167fdb87737daad07a0517a8b6d *inst/doc/projects.html 26da07b8e9e5d3e5986c75a8444ca0ca *inst/doc/r-session.R 3d38c4910650dbcb09439a1a17f585ca *inst/doc/r-session.Rmd 478bd7e3b9c8f643986fd2a3b5a2c14e *inst/doc/r-session.html 41a4c559971972d6d9dcd58bfff08ae1 *inst/doc/terminal.R 2ba016fe1aab495668b3409636332aa3 *inst/doc/terminal.Rmd 589529dc848fe9d66fcc114e6c548f9b *inst/doc/terminal.html 5ce8c65f8c31f69388f565ac5489d6fc *inst/resources/bug-report.md d56348eb1de0a1598a08f341e6c77fb7 *man/addTheme.Rd a1cf55bd498336bae467889235fc3a69 *man/applyTheme.Rd 03ae66de60e7f4e1516280cba5e474ec *man/askForPassword.Rd bbb1277f8fdb80c43a8a729a74354724 *man/askForSecret.Rd f61ff76af7670343148eddcfb4322a7c *man/bugReport.Rd 131ed40ec1f2c247de1daca8d61987da *man/build-tools.Rd ca498d6d2888e0fede04ba5b602101f7 *man/callFun.Rd 1e8edeaf164a2cf7eec9e63a14ceed4f *man/convertTheme.Rd b10ea44fcfca221242a2451c2225d09b *man/createProjectTemplate.Rd 21c99823cf7f079015c90598ec9dd0fa *man/dictionaries.Rd d87040340d4b4d6c4dca502b9e3ae9b4 *man/document_position.Rd d1962425c332ad09514f3e37f303ed0f *man/document_range.Rd 55a9095839caec4ff0d1c5c2e11101e0 *man/executeCommand.Rd c47a9b7aac17e65a1cbd34ee82199d2c *man/figures/logo.png df5831ec5c23b263da1bbbf667a9d428 *man/figures/logo.svg f04fbc421ccf0b918695f75f4ae8b055 *man/file-dialogs.Rd d14b51dd251dd29bfaf0331da150e656 *man/getActiveProject.Rd e8613e517f5cc356760d0ce5b644cfbf *man/getRStudioPackageDependencies.Rd 5b4bad70a80db81b876e5f6463d3548a *man/getThemeInfo.Rd 8edc2af0faef24f9a652a86b81b5c24e *man/getThemes.Rd 968062ff97bfc41d78110ff3b10c0a52 *man/getVersion.Rd 3c53d1752a61b88ad8651daa6f819869 *man/hasColorConsole.Rd 8f8b3eccc1a09659f46c4452f3b3c944 *man/hasFun.Rd c7409259025e7b1662bf9905ac73f27e *man/highlightUi.Rd a0211f534c0d88747c7e1ef2d05a2791 *man/isAvailable.Rd eebab5f604b61d1bafe51256d4b9affd *man/jobAdd.Rd acdbf8a0338af356077082b15b355e9d *man/jobAddOutput.Rd 9051b67163d45cfd6e6d9ae6f0577496 *man/jobAddProgress.Rd 93ee60c5b960e68323a23a99fe8e7e0d *man/jobRemove.Rd f31c1e0b8a5838fd0db7ed56287dcfce *man/jobRunScript.Rd 79373cca7a9f0ab6ee23521380c5c8e0 *man/jobSetProgress.Rd d31710ec126547221421e54eb07a0125 *man/jobSetState.Rd 71f57ac475e575fc512b43bc0010d019 *man/jobSetStatus.Rd b592071a8f1e3592bf32b7ea78b17d91 *man/launcher.Rd 567b5f1568782839dd88c77b4f7e241f *man/launcherConfig.Rd cbfb8170d63fdafcd9e5383660223d58 *man/launcherContainer.Rd 6c584fbee9c32f076d3f69c84dba1a3d *man/launcherControlJob.Rd 0f7079f75e81c404d4a205f8fdd89c87 *man/launcherGetJob.Rd 2899e0783ad1e0fe534e3008331e5e4e *man/launcherHostMount.Rd d64526ddc834f20a11bcb341e2daf758 *man/launcherNfsMount.Rd 61c7c1da73b171d190c5046ae513dd1c *man/launcherPlacementConstraint.Rd dbd47c3d189ec8240e737b53ab436749 *man/launcherResourceLimit.Rd 502fcbedcad514c55296af0d2c84acdb *man/launcherSubmitJob.Rd 3829c487cbb06f958ef47c9088ccd1af *man/launcherSubmitR.Rd 86b986e7537985ce69231bf925bbb88c *man/navigateToFile.Rd bc25a20af1d58c6a5be93da3ae89c837 *man/persistent-values.Rd 11afff28da5a838ddfcd210abfc8e144 *man/previewRd.Rd d6ca33cb2ebd43da41a772b02d9aef90 *man/previewSql.Rd 7b821cb2132dcd6c12a9d637b71f4579 *man/primary_selection.Rd eb937360ded93ddcc72db9b05ae249db *man/projects.Rd 52e055edef2180fd4cbe3399c36409f4 *man/readPreference.Rd d0f5111fe66f8a504453fcace0580543 *man/readRStudioPreference.Rd f6fdc4654fd43e7e8051b137a57b9920 *man/removeTheme.Rd 3df25a8da801d52209245fcab3971490 *man/restartSession.Rd 91076970b25002beb22f48a5bd28e613 *man/rstudio-documents.Rd 45f4ac0bee6c6b5b45094fbaf38fffc8 *man/rstudio-editors.Rd 81d600f00e10340d25838b6aad201435 *man/savePlotAsImage.Rd e0a004d52100469f3b9e8434c682f59c *man/sendToConsole.Rd e029ea8323236e891e2633f14cfe8fdd *man/showDialog.Rd 19c83a2f89748a964b29c28811d8f152 *man/showPrompt.Rd 5d93ce0c1c220e766829593935f80145 *man/showQuestion.Rd 0d5ed2c1fbd1d32f3d1c67bdd21d9c8a *man/sourceMarkers.Rd c64d52cabb74dc47ddb6f03a7aa42dd7 *man/systemUsername.Rd 4fd7953dfeab6e22aae3c56f8a4a7809 *man/terminalActivate.Rd 3c6a4f340b0b363511497f473d36eaa8 *man/terminalBuffer.Rd c008a5884aabb312c7a43d9a351b3653 *man/terminalBusy.Rd 88d13e99eeae07e762c21ab64c19adb5 *man/terminalClear.Rd d952a8fab9e2e89a80d61ae82693bf55 *man/terminalContext.Rd 87954224f9cff66b9677f8b5df31ba7f *man/terminalCreate.Rd 6fadb83e4c436541196b6c699d692d24 *man/terminalExecute.Rd 58186f9255226b2e33ff2459a489b453 *man/terminalExitCode.Rd ce1abbd7856353cb9212f71e2c74088c *man/terminalKill.Rd 35606fc8b8e6c7c12a4c1fbb4681b799 *man/terminalList.Rd 07878b215a21b075d1cb6dbebb40ad32 *man/terminalRunning.Rd a52daec78ac24d663227ed446a4d182f *man/terminalSend.Rd 44a2b40ffbf8ee37c0f8297f2f25b1e3 *man/terminalVisible.Rd 9be38b177d3343a46b6c805a66de5594 *man/translateLocalUrl.Rd 9bd0485e13b003db97e8bbc0cc7a3e30 *man/updateDialog.Rd 838bfa3b11a19467a2f607749c532105 *man/userIdentity.Rd 81a78e563475ba823e5bc21d7eef55ed *man/versionInfo.Rd 94dbccd5ee33fca7d9601a03622990d4 *man/viewer.Rd 54f1ec85c00d8a6421e5d6fc1cf6f810 *man/writePreference.Rd 48621778ea8d4a52679b916559945e1e *man/writeRStudioPreference.Rd 01f5841a3d3d9249f0b6509697189d5e *vignettes/dialogs.Rmd 0a81e2595fc31915b1c6ec77cdbc8fe2 *vignettes/document-manipulation.Rmd 4eb7f4d912f65f74a951b41ca1ab859d *vignettes/introduction.Rmd b3f763976fc12d073ef5f4cf610589db *vignettes/projects.Rmd 3d38c4910650dbcb09439a1a17f585ca *vignettes/r-session.Rmd 2ba016fe1aab495668b3409636332aa3 *vignettes/terminal.Rmd rstudioapi/inst/0000755000176200001440000000000013617331501013412 5ustar liggesusersrstudioapi/inst/doc/0000755000176200001440000000000013617331501014157 5ustar liggesusersrstudioapi/inst/doc/terminal.Rmd0000644000176200001440000001116513535525640016452 0ustar liggesusers--- title: "Interacting with Terminals" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Interacting with Terminals} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include=FALSE} knitr::opts_chunk$set(eval = FALSE) ``` The `rstudioapi` package provides a collection of functions that can be used to interact with the [RStudio terminal tab](https://support.rstudio.com/hc/en-us/articles/115010737148-Using-the-RStudio-Terminal). There are two primary approaches to using these functions. 1. Use `terminalExecute()` to run a specific process with the output shown in a new terminal buffer, without blocking the current R session. 2. Create, query, and manipulate interactive terminals. This might be used to develop custom terminal behavior via an [RStudio addin](https://rstudio.github.io/rstudioaddins/). ## TerminalExecute Scenario ```{r} # Start a command with results displayed in a terminal buffer termId <- rstudioapi::terminalExecute("ping rstudio.com") # If viewing the result in the terminal buffer is sufficient, # then no need to do anything else. The command will continue # running and displaying its results without blocking the R session. # To obtain the results programmatically, wait for it to finish. while (is.null(rstudioapi::terminalExitCode(termId))) { Sys.sleep(0.1) } result <- rstudioapi::terminalBuffer(termId) # Delete the buffer and close the session in the IDE rstudioapi::terminalKill(termId) ``` ## Interative Terminal Scenario Several concepts are important to understand to make full use of these functions. ### Terminal Identifier Each terminal session has a unique **terminal identifier**, a required argument for most of the functions. A terminal identifier is generated and returned when a terminal is created via `terminalCreate()` or `terminalExecute()`, and identifiers of existing terminals can be obtained via `terminalList()` or `terminalVisible()`. ### Terminal Session A **terminal session** is an instance of a terminal that can be displayed in the RStudio terminal tab. A terminal session consists of: * a unique terminal identifier * a unique caption shown in the RStudio terminal dropdown (e.g. "Terminal 1") * a shell process (e.g. bash) running as a child process of the R session * zero or more processes running as children of the shell (e.g. commands) * an xterm-compatible terminal emulator in the terminal tab * a buffer of output shown in the terminal emulator (can be cleared via `terminalClear()`) ### Busy Terminal A terminal session with child processes running (excluding the shell), is considered **busy** and this is reflected in the IDE UI and can be queried with `terminalBusy()`. ### Terminal States In the most common situation, a terminal session has all the above features; however, it is possible for terminals to be in other states. **No shell process or child processes**: This happens if the associated R session has been closed (or suspended in the case of an inactive RStudio Server session). The `terminalRunning()` function returns `TRUE` if a terminal is in this state. If a terminal is not running, it can be started via interacting with it in the RStudio IDE, or via `terminalActivate()`. ```{r} # start an interactive terminal using the shell selected in # RStudio global options myTerm <- rstudioapi::terminalCreate() # .... # sometime later # .... if (!rstudioapi::terminalRunning(myTerm)) { # start the terminal shell back up, but don't bring to front rstudioapi::terminalActivate(myTerm, show = FALSE) # wait for it to start while (!rstudioapi::terminalRunning(myTerm)) { Sys.sleep(0.1) } # send a new command rstudioapi::terminalSend(myTerm, "echo Hello\n") } ``` **Running but not loaded in the IDE**: On RStudio Server, the web browser can be closed but the R session and any associated terminal sessions keep running. If the web browser is reconnected, each terminal will be redisplayed in the IDE when it is selected. The `rstudioapi` functions may be used on a terminal in this state; for example, the buffer may still be fetched with `terminalBuffer()` even if the terminal isn't loaded in the IDE (so long as the R session is still alive). **Terminated but still visible**: Normally the terminal emulator for a given terminal session will close when the shell exits. If the option **Close Terminal When Shell Exits** is turned off, then the terminal buffer will remain loaded in the RStudio IDE until closed by the user or `terminalKill()`. Terminals started with `terminalExecute()` will always remain loaded when they finish running. To test a terminal for this state, `terminalExitCode()` will return a non-NULL value. rstudioapi/inst/doc/dialogs.R0000644000176200001440000000242113617331500015722 0ustar liggesusers## ----setup, include=FALSE----------------------------------------------------- knitr::opts_chunk$set(eval = FALSE) ## ----------------------------------------------------------------------------- # # request the path to an existing .csv file on disk # path <- rstudioapi::selectFile(caption = "Select CSV File", # filter = "CSV Files (*.csv)", # existing = TRUE) # # # now, you could read the data using e.g. 'readr::read_csv()' # data <- readr::read_csv(path) # # # request a file path (e.g. where you would like to save a new file) # target <- rstudioapi::selectFile(caption = "Save File", # label = "Save", # existing = FALSE) # # # save data to the path provided by the user # saveRDS(data, file = target) ## ----------------------------------------------------------------------------- # token <- rstudioapi::askForPassword( # prompt = "Please provide your GitHub access token." # ) ## ----------------------------------------------------------------------------- # rstudioapi::showDialog(title = "Hello, world!", # message = "You're awesome!", # url = "http://www.example.com") rstudioapi/inst/doc/r-session.R0000644000176200001440000000124413617331501016225 0ustar liggesusers## ----setup, include=FALSE----------------------------------------------------- knitr::opts_chunk$set(eval = FALSE) ## ----------------------------------------------------------------------------- # # restart R, then run some code after # rstudioapi::restartSession(command = "print('Welcome back!')") # # # send some code to the console and execute it immediately # rstudioapi::sendToConsole("1 + 1", execute = TRUE) ## ----------------------------------------------------------------------------- # setHook("rstudio.sessionInit", function(newSession) { # if (newSession) # message("Welcome to RStudio ", rstudioapi::getVersion()) # }, action = "append") rstudioapi/inst/doc/r-session.Rmd0000644000176200001440000000264513535525640016564 0ustar liggesusers--- title: "Interacting with the R Session" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Interact with the R Session} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include=FALSE} knitr::opts_chunk$set(eval = FALSE) ``` ## Session Interaction The `rstudioapi` package allows you to interact with the running R session in a couple useful ways: you can send code to the R console, or restart the R session. ```{r} # restart R, then run some code after rstudioapi::restartSession(command = "print('Welcome back!')") # send some code to the console and execute it immediately rstudioapi::sendToConsole("1 + 1", execute = TRUE) ``` ## Running at Startup Typically, code that you want to run at the start of an R session is placed into an `.Rprofile` file (see [Initialization at the Start of a Session](https://stat.ethz.ch/R-manual/R-devel/library/base/html/Startup.html) for details). However, RStudio's API hooks are not available until RStudio has fully started up, so most `rstudioapi` methods will not work inside `.Rprofile`. If you want to invoke `rstudioapi` methods on session startup, use the `rstudio.sessionInit` hook. For example, to print the RStudio version to the R console when the session begins: ```{r} setHook("rstudio.sessionInit", function(newSession) { if (newSession) message("Welcome to RStudio ", rstudioapi::getVersion()) }, action = "append") ``` rstudioapi/inst/doc/terminal.R0000644000176200001440000000267213617331501016124 0ustar liggesusers## ----setup, include=FALSE----------------------------------------------------- knitr::opts_chunk$set(eval = FALSE) ## ----------------------------------------------------------------------------- # # Start a command with results displayed in a terminal buffer # termId <- rstudioapi::terminalExecute("ping rstudio.com") # # # If viewing the result in the terminal buffer is sufficient, # # then no need to do anything else. The command will continue # # running and displaying its results without blocking the R session. # # # To obtain the results programmatically, wait for it to finish. # while (is.null(rstudioapi::terminalExitCode(termId))) { # Sys.sleep(0.1) # } # # result <- rstudioapi::terminalBuffer(termId) # # # Delete the buffer and close the session in the IDE # rstudioapi::terminalKill(termId) ## ----------------------------------------------------------------------------- # # start an interactive terminal using the shell selected in # # RStudio global options # myTerm <- rstudioapi::terminalCreate() # # # .... # # sometime later # # .... # if (!rstudioapi::terminalRunning(myTerm)) { # # start the terminal shell back up, but don't bring to front # rstudioapi::terminalActivate(myTerm, show = FALSE) # # # wait for it to start # while (!rstudioapi::terminalRunning(myTerm)) { # Sys.sleep(0.1) # } # # # send a new command # rstudioapi::terminalSend(myTerm, "echo Hello\n") # } rstudioapi/inst/doc/document-manipulation.html0000644000176200001440000003252113617331501021364 0ustar liggesusers Document Manipulation

Document Manipulation

knitr::opts_chunk$set(eval = FALSE)

The rstudioapi package provides a small family of functions that can be used to interact with documents open in an RStudio session. For example, the following code could be used to insert a ‘last modified’ comment at the start of a document:

# construct the text to be inserted
fmt <- "# This document was last modified on %s.\n"
text <- sprintf(fmt, Sys.Date())

# specify a range where this text should be inserted; here,
# we use the first line; that is, the 'range' between the start
# of the first row, and the start of the second row
range <- rstudioapi::document_range(c(1, 0), c(2, 0))
rstudioapi::insertText(range, text)

By default, these APIs target the editor instance either currently focused by the user, or when no such editor is currently focused, the last focused editor. If you need to target a specific editor instance (for example, you want to write code that inserts text into the console), you can use getConsoleEditorContext() to get the id for the console editor:

# get console editor id
context <- rstudioapi::getConsoleEditorContext()
id <- context$id

# send some R code to the console
rstudioapi::insertText(text = "print(1 + 1)", id = id)

# see also: `getActiveEditorContext()`, `getSourceEditorContext()`

You can also modify the cursor position through the use of the setCursorPosition() and setSelectionRanges() APIs.

# put the cursor at the end of the document -- note that here,
# `Inf` is automatically truncated to the actual length of the
# document
rstudioapi::setCursorPosition(Inf)

# select the first 10 even lines in the document
ranges <- lapply(seq(2, by = 2, length.out = 10), function(start) {
  rstudioapi::document_range(
    c(start, 0),
    c(start, Inf)
  )
})
rstudioapi::setSelectionRanges(ranges)

See the ?"rstudio-documents" help page for more details.

rstudioapi/inst/doc/dialogs.html0000644000176200001440000002746613617331500016505 0ustar liggesusers File Dialogs

File Dialogs

Using the rstudioapi package, you can request input from the user with various dialogs.

The selectFile() and selectDirectory() APIs allow you to request the name of an existing or non-existing path on the system.

# request the path to an existing .csv file on disk
path <- rstudioapi::selectFile(caption = "Select CSV File",
                               filter = "CSV Files (*.csv)",
                               existing = TRUE)

# now, you could read the data using e.g. 'readr::read_csv()'
data <- readr::read_csv(path)

# request a file path (e.g. where you would like to save a new file)
target <- rstudioapi::selectFile(caption = "Save File",
                                 label = "Save",
                                 existing = FALSE)

# save data to the path provided by the user
saveRDS(data, file = target)

Use rstudioapi::askForPassword() to request a password, or other credentials, from a user.

token <- rstudioapi::askForPassword(
  prompt = "Please provide your GitHub access token."
)

Use rstudioapi::showDialog() to display an informative dialog to the user. This dialog is used to report some kind of status or information to the user; it does not request any input.

rstudioapi::showDialog(title = "Hello, world!",
                       message = "You're <b>awesome!</b>",
                       url = "http://www.example.com")
rstudioapi/inst/doc/projects.html0000644000176200001440000002233413617331501016702 0ustar liggesusers Interacting with RStudio Projects

Interacting with RStudio Projects

Users can create and open RStudio projects using the rstudioapi package.

# open a project in another directory
rstudioapi::openProject("~/projects/t-sne-gene-expression-2017")

# re-open the current project
rstudioapi::openProject()

# initialize an RStudio project (without opening it)
rstudioapi::initializeProject("~/scratch/testbed")
rstudioapi/inst/doc/dialogs.Rmd0000644000176200001440000000316613535525640016263 0ustar liggesusers--- title: "File Dialogs" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{File Dialogs} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include=FALSE} knitr::opts_chunk$set(eval = FALSE) ``` Using the `rstudioapi` package, you can request input from the user with various dialogs. The `selectFile()` and `selectDirectory()` APIs allow you to request the name of an existing or non-existing path on the system. ```{r} # request the path to an existing .csv file on disk path <- rstudioapi::selectFile(caption = "Select CSV File", filter = "CSV Files (*.csv)", existing = TRUE) # now, you could read the data using e.g. 'readr::read_csv()' data <- readr::read_csv(path) # request a file path (e.g. where you would like to save a new file) target <- rstudioapi::selectFile(caption = "Save File", label = "Save", existing = FALSE) # save data to the path provided by the user saveRDS(data, file = target) ``` Use `rstudioapi::askForPassword()` to request a password, or other credentials, from a user. ```{r} token <- rstudioapi::askForPassword( prompt = "Please provide your GitHub access token." ) ``` Use `rstudioapi::showDialog()` to display an informative dialog to the user. This dialog is used to report some kind of status or information to the user; it does not request any input. ```{r} rstudioapi::showDialog(title = "Hello, world!", message = "You're awesome!", url = "http://www.example.com") ``` rstudioapi/inst/doc/introduction.Rmd0000644000176200001440000000140113535525640017350 0ustar liggesusers--- title: "Introduction to rstudioapi" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Introduction to rstudioapi} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- The `rstudioapi` package provides an interface for interacting with the RStudio IDE with R code. Using `rstudioapi`, you can: - Examine, manipulate, and save the contents of documents currently open in RStudio, - Create, open, or re-open RStudio projects, - Prompt the user with different kinds of dialogs (e.g. for selecting a file or folder, or requesting a password from the user), - Interact with RStudio terminals, - Interact with the R session associated with the current RStudio instance. Please see the other articles for more detailed information. rstudioapi/inst/doc/projects.R0000644000176200001440000000075113617331501016136 0ustar liggesusers## ----setup, include=FALSE----------------------------------------------------- knitr::opts_chunk$set(eval = FALSE) ## ----------------------------------------------------------------------------- # # open a project in another directory # rstudioapi::openProject("~/projects/t-sne-gene-expression-2017") # # # re-open the current project # rstudioapi::openProject() # # # initialize an RStudio project (without opening it) # rstudioapi::initializeProject("~/scratch/testbed") rstudioapi/inst/doc/introduction.html0000644000176200001440000001172213617331501017571 0ustar liggesusers Introduction to rstudioapi

Introduction to rstudioapi

The rstudioapi package provides an interface for interacting with the RStudio IDE with R code. Using rstudioapi, you can:

  • Examine, manipulate, and save the contents of documents currently open in RStudio,

  • Create, open, or re-open RStudio projects,

  • Prompt the user with different kinds of dialogs (e.g. for selecting a file or folder, or requesting a password from the user),

  • Interact with RStudio terminals,

  • Interact with the R session associated with the current RStudio instance.

Please see the other articles for more detailed information.

rstudioapi/inst/doc/terminal.html0000644000176200001440000004047613617331501016673 0ustar liggesusers Interacting with Terminals

Interacting with Terminals

The rstudioapi package provides a collection of functions that can be used to interact with the RStudio terminal tab.

There are two primary approaches to using these functions.

  1. Use terminalExecute() to run a specific process with the output shown in a new terminal buffer, without blocking the current R session.

  2. Create, query, and manipulate interactive terminals. This might be used to develop custom terminal behavior via an RStudio addin.

TerminalExecute Scenario

# Start a command with results displayed in a terminal buffer
termId <- rstudioapi::terminalExecute("ping rstudio.com")

# If viewing the result in the terminal buffer is sufficient,
# then no need to do anything else. The command will continue
# running and displaying its results without blocking the R session.

# To obtain the results programmatically, wait for it to finish.
while (is.null(rstudioapi::terminalExitCode(termId))) {
  Sys.sleep(0.1)
}

result <- rstudioapi::terminalBuffer(termId)

# Delete the buffer and close the session in the IDE
rstudioapi::terminalKill(termId)

Interative Terminal Scenario

Several concepts are important to understand to make full use of these functions.

Terminal Identifier

Each terminal session has a unique terminal identifier, a required argument for most of the functions. A terminal identifier is generated and returned when a terminal is created via terminalCreate() or terminalExecute(), and identifiers of existing terminals can be obtained via terminalList() or terminalVisible().

Terminal Session

A terminal session is an instance of a terminal that can be displayed in the RStudio terminal tab. A terminal session consists of:

  • a unique terminal identifier
  • a unique caption shown in the RStudio terminal dropdown (e.g. “Terminal 1”)
  • a shell process (e.g. bash) running as a child process of the R session
  • zero or more processes running as children of the shell (e.g. commands)
  • an xterm-compatible terminal emulator in the terminal tab
  • a buffer of output shown in the terminal emulator (can be cleared via terminalClear())

Busy Terminal

A terminal session with child processes running (excluding the shell), is considered busy and this is reflected in the IDE UI and can be queried with terminalBusy().

Terminal States

In the most common situation, a terminal session has all the above features; however, it is possible for terminals to be in other states.

No shell process or child processes: This happens if the associated R session has been closed (or suspended in the case of an inactive RStudio Server session).

The terminalRunning() function returns TRUE if a terminal is in this state.

If a terminal is not running, it can be started via interacting with it in the RStudio IDE, or via terminalActivate().

# start an interactive terminal using the shell selected in 
# RStudio global options
myTerm <- rstudioapi::terminalCreate()

# ....
# sometime later
# ....
if (!rstudioapi::terminalRunning(myTerm)) {
  # start the terminal shell back up, but don't bring to front
  rstudioapi::terminalActivate(myTerm, show = FALSE)
  
  # wait for it to start
  while (!rstudioapi::terminalRunning(myTerm)) {
    Sys.sleep(0.1)
  }
 
  # send a new command 
  rstudioapi::terminalSend(myTerm, "echo Hello\n") 
}

Running but not loaded in the IDE: On RStudio Server, the web browser can be closed but the R session and any associated terminal sessions keep running. If the web browser is reconnected, each terminal will be redisplayed in the IDE when it is selected. The rstudioapi functions may be used on a terminal in this state; for example, the buffer may still be fetched with terminalBuffer() even if the terminal isn’t loaded in the IDE (so long as the R session is still alive).

Terminated but still visible: Normally the terminal emulator for a given terminal session will close when the shell exits. If the option Close Terminal When Shell Exits is turned off, then the terminal buffer will remain loaded in the RStudio IDE until closed by the user or terminalKill(). Terminals started with terminalExecute() will always remain loaded when they finish running. To test a terminal for this state, terminalExitCode() will return a non-NULL value.

rstudioapi/inst/doc/r-session.html0000644000176200001440000002516513617331501017000 0ustar liggesusers Interacting with the R Session

Interacting with the R Session

Session Interaction

The rstudioapi package allows you to interact with the running R session in a couple useful ways: you can send code to the R console, or restart the R session.

# restart R, then run some code after
rstudioapi::restartSession(command = "print('Welcome back!')")

# send some code to the console and execute it immediately
rstudioapi::sendToConsole("1 + 1", execute = TRUE)

Running at Startup

Typically, code that you want to run at the start of an R session is placed into an .Rprofile file (see Initialization at the Start of a Session for details). However, RStudio’s API hooks are not available until RStudio has fully started up, so most rstudioapi methods will not work inside .Rprofile.

If you want to invoke rstudioapi methods on session startup, use the rstudio.sessionInit hook. For example, to print the RStudio version to the R console when the session begins:

setHook("rstudio.sessionInit", function(newSession) {
  if (newSession)
    message("Welcome to RStudio ", rstudioapi::getVersion())
}, action = "append")
rstudioapi/inst/doc/projects.Rmd0000644000176200001440000000120213535525640016457 0ustar liggesusers--- title: "Interacting with RStudio Projects" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Interacting with RStudio Projects} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include=FALSE} knitr::opts_chunk$set(eval = FALSE) ``` Users can create and open RStudio projects using the `rstudioapi` package. ```{r} # open a project in another directory rstudioapi::openProject("~/projects/t-sne-gene-expression-2017") # re-open the current project rstudioapi::openProject() # initialize an RStudio project (without opening it) rstudioapi::initializeProject("~/scratch/testbed") ``` rstudioapi/inst/doc/document-manipulation.Rmd0000644000176200001440000000407413535525640021154 0ustar liggesusers--- title: "Document Manipulation" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Document Manipulation} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup} knitr::opts_chunk$set(eval = FALSE) ``` The `rstudioapi` package provides a small family of functions that can be used to interact with documents open in an RStudio session. For example, the following code could be used to insert a 'last modified' comment at the start of a document: ```{r} # construct the text to be inserted fmt <- "# This document was last modified on %s.\n" text <- sprintf(fmt, Sys.Date()) # specify a range where this text should be inserted; here, # we use the first line; that is, the 'range' between the start # of the first row, and the start of the second row range <- rstudioapi::document_range(c(1, 0), c(2, 0)) rstudioapi::insertText(range, text) ``` By default, these APIs target the editor instance either currently focused by the user, or when no such editor is currently focused, the last focused editor. If you need to target a specific editor instance (for example, you want to write code that inserts text into the console), you can use `getConsoleEditorContext()` to get the `id` for the console editor: ```{r} # get console editor id context <- rstudioapi::getConsoleEditorContext() id <- context$id # send some R code to the console rstudioapi::insertText(text = "print(1 + 1)", id = id) # see also: `getActiveEditorContext()`, `getSourceEditorContext()` ``` You can also modify the cursor position through the use of the `setCursorPosition()` and `setSelectionRanges()` APIs. ```{r} # put the cursor at the end of the document -- note that here, # `Inf` is automatically truncated to the actual length of the # document rstudioapi::setCursorPosition(Inf) # select the first 10 even lines in the document ranges <- lapply(seq(2, by = 2, length.out = 10), function(start) { rstudioapi::document_range( c(start, 0), c(start, Inf) ) }) rstudioapi::setSelectionRanges(ranges) ``` See the `?"rstudio-documents"` help page for more details. rstudioapi/inst/doc/document-manipulation.R0000644000176200001440000000272313617331500020621 0ustar liggesusers## ----setup-------------------------------------------------------------------- knitr::opts_chunk$set(eval = FALSE) ## ----------------------------------------------------------------------------- # # construct the text to be inserted # fmt <- "# This document was last modified on %s.\n" # text <- sprintf(fmt, Sys.Date()) # # # specify a range where this text should be inserted; here, # # we use the first line; that is, the 'range' between the start # # of the first row, and the start of the second row # range <- rstudioapi::document_range(c(1, 0), c(2, 0)) # rstudioapi::insertText(range, text) ## ----------------------------------------------------------------------------- # # get console editor id # context <- rstudioapi::getConsoleEditorContext() # id <- context$id # # # send some R code to the console # rstudioapi::insertText(text = "print(1 + 1)", id = id) # # # see also: `getActiveEditorContext()`, `getSourceEditorContext()` ## ----------------------------------------------------------------------------- # # put the cursor at the end of the document -- note that here, # # `Inf` is automatically truncated to the actual length of the # # document # rstudioapi::setCursorPosition(Inf) # # # select the first 10 even lines in the document # ranges <- lapply(seq(2, by = 2, length.out = 10), function(start) { # rstudioapi::document_range( # c(start, 0), # c(start, Inf) # ) # }) # rstudioapi::setSelectionRanges(ranges) rstudioapi/inst/resources/0000755000176200001440000000000013535525640015434 5ustar liggesusersrstudioapi/inst/resources/bug-report.md0000644000176200001440000000110413535525640020040 0ustar liggesusers ### System details RStudio Edition : ${RSTUDIO_EDITION} RStudio Version : ${RSTUDIO_VERSION} OS Version : ${OS_VERSION} R Version : ${R_VERSION} ### Steps to reproduce the problem ### Describe the problem in detail ### Describe the behavior you expected