Movatterモバイル変換


[0]ホーム

URL:


Type:Package
Title:Ace Editor Bindings for Shiny
Version:0.4.4
Date:2025-2-2
Description:Ace editor bindings to enable a rich text editing environment within Shiny.
License:MIT + file LICENSE
Depends:R (≥ 3.3.0)
Imports:shiny (≥ 1.0.5), jsonlite, utils, tools
Suggests:testthat (≥ 2.0.0), dplyr (≥ 0.8.3)
BugReports:https://github.com/trestletech/shinyAce/issues
Encoding:UTF-8
RoxygenNote:7.3.2
Language:en-US
NeedsCompilation:no
Packaged:2025-02-02 22:59:22 UTC; vnijs
Author:Vincent Nijs [aut, cre], Forest Fang [aut], Trestle Technology, LLC [aut], Jeff Allen [aut], Institut de Radioprotection et de Surete Nucleaire [cph], Ajax.org B.V. [ctb, cph] (Ace)
Maintainer:Vincent Nijs <radiant@rady.ucsd.edu>
Repository:CRAN
Date/Publication:2025-02-03 00:20:02 UTC

Regular expression for matching the function name in a completion line in themiddle of a function call

Description

Regular expression for matching the function name in a completion line in themiddle of a function call

Usage

.fname_regex

Format

An object of classcharacter of length 1.


Get namespace to get access to unexported functions, namelyRdTags

Description

Get namespace to get access to unexported functions, namelyRdTags

Usage

.tools

Format

An object of classenvironment of length 792.


Get namespace to get access to unexported functions, namely.getHelpFile.assignLinebuffer.assignEnd.guessTokenFromLine.completeToken

Description

Get namespace to get access to unexported functions, namely.getHelpFile.assignLinebuffer.assignEnd.guessTokenFromLine.completeToken

Usage

.utils

Format

An object of classenvironment of length 576.


Enable Error Annotations for an Ace Code Input

Description

This function dynamically evaluate R for syntax errors using theparse function.

Usage

aceAnnotate(inputId, session = shiny::getDefaultReactiveDomain())

Arguments

inputId

The id of the input object

session

Thesession object passed to function given toshinyServer

Details

You can implement your own code completer by observing modification events toinput$<editorId>_shinyAce_annotationTrigger where <editorId> is theaceEditor id. This input is only used for triggering completion andwill contain a random number. However, you can accesssession$input[[inputId]] to get the input text for parsing.

Value

An observer reference class object that is responsible for offeringcode annotations. SeeobserveEvent for more details.You can usesuspend ordestroy to pause to stop dynamic codecompletion.

The observer reference object will send a custom shiny message usingsession$sendCustomMessage to the annotations endpoint containinga json list of annotation metadata objects. The json list should havea structure akin to:

  [    {       row:  <int: row of annotation reference>,       col:  <int: column of annotation reference>,       type: <str: "error", "alert" or "flash">,       html: <str: html of annotation hover div, used by default over text>,       text: <num: text of annotation hover div>,    }  ]

Enable Code Completion for an Ace Code Input

Description

This function dynamically auto complete R code pieces using built-infunctionsutils:::.assignLinebuffer,utils:::.assignEnd,utils:::.guessTokenFromLine andutils:::.completeToken.

Usage

aceAutocomplete(inputId, session = shiny::getDefaultReactiveDomain())

Arguments

inputId

The id of the input object

session

Thesession object passed to function given to shinyServer

Details

You can implement your own code completer by listening toinput$<editorId>_shinyAce_hintwhere <editorId> is theaceEditor id. The input contains

Value

An observer reference class object that is responsible for offeringcode completion. Seeobserve for more details. You canusesuspend ordestroy to pause to stop dynamic codecompletion.

The observer reference object will send a custom shiny message usingsession$sendCustomMessage to the codeCompletions endpoint containinga json list of completion item metadata objects. The json list should havea structure akin to:

  [    {       value:        <str: value to be inserted upon completion (e.g. "print()")>,       caption:      <str: value to be displayed (e.g. "print() # prints text")>,       score:        <num: score to pass to ace editor for sorting>,       meta:         <str: meta text on right of completion>       r_symbol:     <str: symbol name of completion item>,       r_envir_name: <str: name of the environment from which the symbol is referenced>,       r_help_type:  <str: a datatype for dispatching help documentation function>,       completer:    <str: used for dispatching default insertMatch functions>,    }  ]

Render Ace

Description

Render an Ace editor on an application page.

Usage

aceEditor(  outputId,  value,  mode,  theme,  vimKeyBinding = FALSE,  readOnly = FALSE,  height = "400px",  fontSize = 12,  debounce = 1000,  wordWrap = FALSE,  showLineNumbers = TRUE,  highlightActiveLine = TRUE,  selectionId = NULL,  cursorId = NULL,  hotkeys = NULL,  code_hotkeys = NULL,  autoComplete = c("disabled", "enabled", "live"),  autoCompleters = c("snippet", "text", "keyword"),  autoCompleteList = NULL,  tabSize = 4,  useSoftTabs = TRUE,  showInvisibles = FALSE,  setBehavioursEnabled = TRUE,  showPrintMargin = TRUE,  autoScrollEditorIntoView = FALSE,  maxLines = NULL,  minLines = NULL,  placeholder = NULL)

Arguments

outputId

The ID associated with this element

value

The initial text to be contained in the editor.

mode

The Acemode to be used by the editor. Themodein Ace is often the programming or markup language that you're using anddetermines things like syntax highlighting and code folding. Use thegetAceModes function to enumerate all the modes available.

theme

The Acetheme to be used by the editor. Thethemein Ace determines the styling and coloring of the editor. UsegetAceThemes to enumerate all the themes available.

vimKeyBinding

If set toTRUE, Ace will enable vim-keybindings.Default value isFALSE.

readOnly

If set toTRUE, Ace will disable client-side editing.IfFALSE (the default), it will enable editing.

height

A number (which will be interpreted as a number of pixels) orany valid CSS dimension (such as "50%", "200px", or"auto").

fontSize

Defines the font size (in px) used in the editor and shouldbe an integer. The default is 12.

debounce

The number of milliseconds to debounce the input. This willcause the client to withhold update notifications until the user hasstopped typing for this amount of time. If 0, the server will be notifiedof every keystroke as it happens.

wordWrap

If set toTRUE, Ace will enable word wrapping.Default value isFALSE.

showLineNumbers

If set toTRUE, Ace will show line numbers.

highlightActiveLine

If set toTRUE, Ace will highlight the activeline.

selectionId

The ID associated with a change of selected text

cursorId

The ID associated with a cursor change.

hotkeys

A list whose names are ID names and whose elements are theshortcuts of keys. Shortcuts can either be a simple string or a list withelements 'win' and 'mac' that that specifies different shortcuts for win andmac (see example 05).

code_hotkeys

A nested list. The first element indicates the code type (e.g., "r")The second element is a list whose names are ID names and whose elements are theshortcuts of keys (seehotkeys)

autoComplete

Enable/Disable auto code completion. Must be one of the following:

"disabled"

Disable Code Autocomplete

"enabled"

Enable Basic Code Autocomplete. Autocomplete can betriggered using Ctrl-Space, Ctrl-Shift-Space, or Alt-Space.

"live"

Enable Live Code Autocomplete. In addition to BasicAutocomplete, it will automatically trigger at each key stroke.

By default, only local completer is used where all aforementioned code pieceswill be considered as candidates. UseautoCompleteList for staticcompletions andaceAutocomplete for dynamic R code completions.

autoCompleters

Character vector of completers to enable. If set toNULL,all completers will be disabled. Select one or more of "snippet", "text", "static","keyword", and "rlang" to control which completers to use. Default option is touse the "snippet", "text", and "keyword" autocompleters

autoCompleteList

A named list that contains static code completionscandidates. This can be especially useful for Non-Standard Evaluation (NSE)functions such as those indplyr andggvis. Each element in listshould be a character array whose words will be listed under the element key.For example, to suggests column names frommtcars andairquality,you can uselist(mtcars = colnames(mtcars), airquality = colnames(airquality)).

tabSize

Set tab size. Default value is 4

useSoftTabs

Replace tabs by spaces. Default value is TRUE

showInvisibles

Show invisible characters (e.g., spaces, tabs, newline characters).Default value is FALSE

setBehavioursEnabled

Determines if the auto-pairing of special characters, likequotation marks, parenthesis, or brackets should be enabled. Default value is TRUE.

showPrintMargin

Show print margin. Default value is True

autoScrollEditorIntoView

If TRUE, expands the size of the editor window as new lines are added

maxLines

Maximum number of lines the editor window will expand to when autoScrollEditorIntoView is TRUE

minLines

Minimum number of lines in the editor window when autoScrollEditorIntoView is TRUE

placeholder

A string to use a placeholder when the editor has no content

Author(s)

Jeff Allenjeff@trestletech.com

Examples

## Not run: aceEditor(  outputId = "myEditor",  value = "Initial text for editor here",  mode = "r",  theme = "ambiance")aceEditor(  outputId = "myCodeEditor",  value = "# Enter code",  mode = "r",  hotkeys = list(    helpKey = "F1",    runKey = list(      win = "Ctrl-R|Ctrl-Shift-Enter",      mac = "CMD-ENTER|CMD-SHIFT-ENTER"    )  ),  wordWrap = TRUE, debounce = 10)aceEditor(  outputId = "mySmartEditor",  value = "plot(wt ~ mpg, data = mtcars)",  mode = "r",  autoComplete = "live",  autoCompleteList = list(mtcars = colnames(mtcars)))## End(Not run)

Enable Completion Tooltips for an Ace Code Input

Description

This function uses the completion item object to retrieve tooltip informationby parsing Rhelp documentation and rendering to html.

Usage

aceTooltip(inputId, session = shiny::getDefaultReactiveDomain())

Arguments

inputId

The id of the input object

session

Thesession object passed to function given toshinyServer

Details

You can implement your own tooltips by observing modification events toinput$<editorId>_shinyAce_tooltipItem where <editorId> is theaceEditor id. This input contains the object passed to codeCompletionfor this item. See the help foraceAutocomplete for details onthe fields of the completion item object.

Value

An observer reference class object that is responsible for offeringcompletion tooltips. Seeobserve for more details. Youcan usesuspend ordestroy to pause to stop dynamic codecompletion.

The observer reference object will send a custom shiny message usingsession$sendCustomMessage to the docTooltip endpoint containing ajson list of completion item metadata objects. The json list should have astructure akin to one of:

A text object

  <str: text to display for tooltip>

An object containing adocHTML property

  {     docHTML: <str: html to display for tooltip div, used if available>,  }

An object containing adocText property

  {     docText: <str: text to display for tooltip div>  }

Build the fields used to make an html tooltip

Description

Build the fields used to make an html tooltip

Usage

build_tooltip_fields(v)

Arguments

v

Autocomplete metadata values used for building tooltip info

Value

a list with html-formatted character values "title" and "body


Get available modes

Description

Gets all of the availablemodes available in the installed versionof shinyAce. Modes are often the programming or markup language which willbe used in the editor and determine things like syntax highlighting andcode folding.

Usage

getAceModes()

Author(s)

Jeff Allenjeff@trestletech.com


Get available themes

Description

Gets all of the availablethemes available in the installed versionof shinyAce. Themes determine the styling and colors used in the editor.

Usage

getAceThemes()

Author(s)

Jeff Allenjeff@trestletech.com


Retrieve argument documentation from help document

Description

Retrieve argument documentation from help document

Usage

get_arg_help(..., args = character())

Arguments

...

arguments passed to get_help_file

args

function arguments names to get documentation for

Value

A character vector of help

Examples

shinyAce:::get_arg_help("match", package = "base", args = c("table", "nomatch"))

Retrieve description section from help document

Description

Retrieve description section from help document

Usage

get_desc_help(...)

Arguments

...

arguments passed to get_help_file

Value

a character value representing the description section of a helpdocument, rendered as HTML

Examples

shinyAce:::get_desc_help("match", package = "base")

Retrieve an Rd object of a help query

Description

Safely return NULL if an error is encountered.

Usage

get_help_file(...)

Arguments

...

arguments passed toutils::help

Value

the Rd object returned from utils:::getHelpFile


Retrieve usage section from help document

Description

Retrieve usage section from help document

Usage

get_usage_help(...)

Arguments

...

arguments passed to get_help_file

Value

a character value representing the usage section of a helpdocument, rendered as HTML

Examples

shinyAce:::get_usage_help("match", package = "base")

Check if vector is empty

Description

Check if vector is empty

Usage

is.empty(x)

Arguments

x

vector

Examples

is.empty(NULL)is.empty(NA)is.empty(c())is.empty("")is.empty(" ")is.empty(c(" ", " "))is.empty(list())is.empty(list(a = "", b = ""))

Character value to use for object meta field

Description

Character value to use for object meta field

Usage

meta_obj()

Character value to use for package meta field

Description

Character value to use for package meta field

Usage

meta_pkg()

R completions when cursor is within a function call

Description

R completions when cursor is within a function call

Usage

r_completions_function_call_metadata(fname, completions)

Arguments

fname

the function name for which the function call specificcompletion metadata should be constructed

completions

a character vector of completions. These will serve as thefoundation for building added R-specific metadata


R completions for general case

Description

R completions for general case

Usage

r_completions_general_metadata(completions)

Arguments

completions

a character vector of completions. These will serve as thefoundation for building added R-specific metadata


Return completions for a given line of text

Description

Return completions for a given line of text

Usage

r_completions_metadata(line)

Arguments

line

the text up until the cursor in the line for autocompletion


Convert an Rd object to HTML

Description

Convert an Rd object to HTML

Usage

rd_2_html(...)

Arguments

...

additional parameters to pass toparse_Rd whenRd is a filename.

Value

a character value of Rd content rendered as HTML


Retrieve regular expression named capture groups as a list

Description

Retrieve regular expression named capture groups as a list

Usage

re_capture(x, re, ...)

Arguments

x

a character string to capture from

re

the regular expression to use

...

additional arguments passed toregexpr

Value

a named list of matches

Examples

shinyAce:::re_capture("ak09j b", "(?<num>\\d+)(?<alpha>[a-zA-Z]+)", perl = TRUE)

Options available for shinyAce

Description

shinyAce.debug

Logical value to enable or disable debugging messagesbeing printed to console. default behavior equivalent toFALSE.


Function for handling optional debugging messages

Description

Function for handling optional debugging messages

Usage

shinyAce_debug(...)

Arguments

...

zero or more objects which can be coerced to character(and which are pasted together with no separator) or (formessage only) a single condition object.


A helper for formatting a tooltip entry

Description

A helper for formatting a tooltip entry

Usage

tooltip_html(title = "", body = "")

Arguments

title

a character value to use as the title

body

an html block to embed as the body of the tooltip


Update Ace Editor

Description

Update the styling or mode of an aceEditor component.

Usage

updateAceEditor(  session,  editorId,  value,  theme,  readOnly,  mode,  fontSize,  showLineNumbers,  wordWrap,  useSoftTabs,  tabSize,  showInvisibles,  showPrintMargin,  border = c("normal", "alert", "flash"),  autoComplete = c("disabled", "enabled", "live"),  autoCompleters = c("snippet", "text", "keyword", "static", "rlang"),  autoCompleteList = NULL)

Arguments

session

The Shiny session to whom the editor belongs

editorId

The ID associated with this element

value

The initial text to be contained in the editor.

theme

The Acetheme to be used by the editor. Thethemein Ace determines the styling and coloring of the editor. UsegetAceThemes to enumerate all the themes available.

readOnly

If set toTRUE, Ace will disable client-side editing.IfFALSE (the default), it will enable editing.

mode

The Acemode to be used by the editor. Themodein Ace is often the programming or markup language that you're using anddetermines things like syntax highlighting and code folding. Use thegetAceModes function to enumerate all the modes available.

fontSize

If set, will update the font size (in px) used in the editor.Should be an integer.

showLineNumbers

If set toTRUE, Ace will show line numbers.

wordWrap

If set toTRUE, Ace will enable word wrapping.Default value isFALSE.

useSoftTabs

Replace tabs by spaces. Default value is TRUE

tabSize

Set tab size. Default value is 4

showInvisibles

Show invisible characters (e.g., spaces, tabs, newline characters).Default value is FALSE

showPrintMargin

Show print margin. Default value is True

border

Set theborder 'normal', 'alert', or 'flash'.

autoComplete

Enable/Disable code completion. SeeaceEditorfor details.

autoCompleters

Character vector of completers to enable. If set toNULL,all completers will be disabled.

autoCompleteList

If set toNULL, existing static completionslist will be unset. SeeaceEditor for details.

Author(s)

Jeff Allenjeff@trestletech.com

Examples

## Not run:  shinyServer(function(input, output, session) {   observe({     updateAceEditor(session, "myEditor", "Updated text for editor here",       mode = "r", theme = "ambiance")   }) }## End(Not run)

[8]ページ先頭

©2009-2025 Movatter.jp