-
Notifications
You must be signed in to change notification settings - Fork 0
/
defineSelected.R
43 lines (38 loc) · 1.1 KB
/
defineSelected.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#' Define Selected Text
#'
#' Detects a selected word in an open document. This was tested for Rmarkdown writing, but it can be used for an open document.
#' Using the addin is the most preferred means to call this function, albeit it can be called directly from the console.
#'
#' @return definition of the selected text
#' @examples
#' \dontrun{
#' defineSelected()
#' }
#' @export
#'
#'
defineSelected <-function(){
#fetch selected term
the.selected <- fetchSelectedText()
#if selected term is present and contains alphabets, find definition. else, yell at the user
if(the.selected[1]){
define(the.selected[2])
}
else{
message("No words selected within the current document.")
}
}
#' Define Selected Text
#'
#' Detects a selected word in an open document. This was written for Rmarkdown writing, but it can be used for an open document.
#' Using the addin is the most preferred means to call this function, albeit it can be called directly from the console.
#'
#' @return definition of the selected text
#' @examples
#' \dontrun{
#' defineSel()
#' }
#' @export
#'
#'
defineSel <- defineSelected