Title: | Cursor and Terminal Manipulation |
---|---|
Description: | A toolbox for developing applications, games, simulations, or agent-based models in the R terminal. Included functions allow users to move the cursor around the terminal screen, change text colors and attributes, clear the screen, hide and show the cursor, map key presses to functions, draw shapes and curves, among others. Most functionalities require users to be in a terminal (not the R GUI). |
Authors: | Chris Mann |
Maintainer: | Chris Mann <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-10-29 03:15:32 UTC |
Source: | https://github.com/cran/cursr |
Turns off text attributes in the terminal, including bold text, italics, underline, etc.
attr_off(...)
attr_off(...)
... |
characters indicating attributes to turn off. |
Use attr_on
to turn on attributes.
NULL
Other style functions:
attr_on()
,
bg_off()
,
bg_on()
,
color_off()
,
color_pair()
,
fg_off()
,
fg_on()
,
make_bg()
,
make_fg()
,
make_style()
,
reset()
,
style()
cat("hello world!\n") attr_on("bf", "ul") cat("hello world!\n") attr_off("bf") cat("hello world!\n") attr_off() cat("hello world!\n")
cat("hello world!\n") attr_on("bf", "ul") cat("hello world!\n") attr_off("bf") cat("hello world!\n") attr_off() cat("hello world!\n")
Turns on text attributes in terminal, including bold text, italics, underline, etc. Note that not all terminals support each attribute.
attr_on(...)
attr_on(...)
... |
characters indicating attributes to turn on. |
Use attr_off
to turn off the attributes.
NULL
Other style functions:
attr_off()
,
bg_off()
,
bg_on()
,
color_off()
,
color_pair()
,
fg_off()
,
fg_on()
,
make_bg()
,
make_fg()
,
make_style()
,
reset()
,
style()
cat("hello world!\n") attr_on("bf", "ul") cat("hello world!\n") attr_off()
cat("hello world!\n") attr_on("bf", "ul") cat("hello world!\n") attr_off()
Return the background of future terminal text to the default color. Background color is turned on with bg_on
.
bg_off()
bg_off()
NULL
Other style functions:
attr_off()
,
attr_on()
,
bg_on()
,
color_off()
,
color_pair()
,
fg_off()
,
fg_on()
,
make_bg()
,
make_fg()
,
make_style()
,
reset()
,
style()
# Different methods of specifying yellow bg_on("yellow") bg_on("#FFFF00") bg_on(11) bg_on(255, 255, 0) # Turn off color bg_off()
# Different methods of specifying yellow bg_on("yellow") bg_on("#FFFF00") bg_on(11) bg_on(255, 255, 0) # Turn off color bg_off()
Specifies the background color of all future text written in the terminal bg_on
accepts numeric values (RGB or 8-bit color code), hexadecimal characters, or the name of the color. Not all terminals support each possible color.
bg_on(...)
bg_on(...)
... |
character or numeric value |
Background color is turned off with bg_off
.
NULL
Other style functions:
attr_off()
,
attr_on()
,
bg_off()
,
color_off()
,
color_pair()
,
fg_off()
,
fg_on()
,
make_bg()
,
make_fg()
,
make_style()
,
reset()
,
style()
# Different methods of specifying yellow bg_on("yellow") bg_on("#FFFF00") bg_on(11) bg_on(255, 255, 0) # Turn off color bg_off()
# Different methods of specifying yellow bg_on("yellow") bg_on("#FFFF00") bg_on(11) bg_on(255, 255, 0) # Turn off color bg_off()
Draws a box of size dim=c(height, width)
at yx=c(row,col)
.
box_at( yx = c(1, 1), dim = NULL, text = c("|", "|", "-", "-", rep("+", 4)), fg = NA, bg = NA, attr = NA, fill = NA, fill.bg = NA, fill.fg = NA, fill.attr = NA )
box_at( yx = c(1, 1), dim = NULL, text = c("|", "|", "-", "-", rep("+", 4)), fg = NA, bg = NA, attr = NA, fill = NA, fill.bg = NA, fill.fg = NA, fill.attr = NA )
yx |
starting console row and column of top-left corner of box |
dim |
box dimensions in |
text |
repeated character used for box. |
fg |
foreground color. See |
bg |
background color. See |
attr |
border text attributes. See |
fill |
character object to fill box. Only the first character in the first element is used. If |
fill.bg |
background color of the fill character. |
fill.fg |
foreground color of the fill character. |
fill.attr |
text attributes of the fill character. |
NULL
Other drawing functions:
draw_arc()
,
draw_bezier()
,
draw_circle()
,
draw_ellipse()
,
draw_fn()
,
draw_lerp()
,
draw_path()
,
draw_ray()
,
draw_rect()
,
draw_shape()
,
fill_circle()
,
fill_ellipse()
,
fill_rect()
,
fill_shape()
,
grid_at()
,
grid_mat()
,
hline_at()
,
hline()
,
vline_at()
,
vline()
box_at(yx=c(4,4), dim=c(5,10), text="X")
box_at(yx=c(4,4), dim=c(5,10), text="X")
Clear text from the terminal. Passing values "start"
or "end"
allow the user to clear specific portions of the screen relative to the cursor.
clear(x = c("screen", "end", "start"), ...)
clear(x = c("screen", "end", "start"), ...)
x |
character describing console location to clear. The default, |
... |
objects passed to/from methods |
NULL
clear() cat(paste(LETTERS[1:10], collapse="\n")) clear("start") clear("end")
clear() cat(paste(LETTERS[1:10], collapse="\n")) clear("start") clear("end")
Return the background and foreground of future terminal text to the default colors.
color_off()
color_off()
NULL
Other style functions:
attr_off()
,
attr_on()
,
bg_off()
,
bg_on()
,
color_pair()
,
fg_off()
,
fg_on()
,
make_bg()
,
make_fg()
,
make_style()
,
reset()
,
style()
bg_on("red") fg_on("yellow") # Turn off color color_off()
bg_on("red") fg_on("yellow") # Turn off color color_off()
Returns the ANSI codes for the specified colors. color_pair
accepts numeric values (RGB or 8-bit color code), hexadecimal characters, or the name of the color.
color_pair(fg, bg)
color_pair(fg, bg)
fg |
character or numeric value for the foreground color |
bg |
character or numeric value for the background color |
ANSI character string
Other style functions:
attr_off()
,
attr_on()
,
bg_off()
,
bg_on()
,
color_off()
,
fg_off()
,
fg_on()
,
make_bg()
,
make_fg()
,
make_style()
,
reset()
,
style()
# Blue background with white text color_pair("white", "blue") color_pair("#FFFFFF", "#0000FF") color_pair(0, 12) color_pair(c(255, 255, 255), c(0,0,255))
# Blue background with white text color_pair("white", "blue") color_pair("#FFFFFF", "#0000FF") color_pair(0, 12) color_pair(c(255, 255, 255), c(0,0,255))
Calculate the path of an arc within a grid and print to screen.
draw_arc(yx, start, end, r = 1, n = 50, text = "x", ...)
draw_arc(yx, start, end, r = 1, n = 50, text = "x", ...)
yx |
center |
start |
starting angle in radians |
end |
ending angle in radians |
r |
radius of circle |
n |
number of points along curve to calculate |
text |
character value drawn at coordinate |
... |
parameters that are passed to |
NULL
Other drawing functions:
box_at()
,
draw_bezier()
,
draw_circle()
,
draw_ellipse()
,
draw_fn()
,
draw_lerp()
,
draw_path()
,
draw_ray()
,
draw_rect()
,
draw_shape()
,
fill_circle()
,
fill_ellipse()
,
fill_rect()
,
fill_shape()
,
grid_at()
,
grid_mat()
,
hline_at()
,
hline()
,
vline_at()
,
vline()
draw_arc(yx=c(10,10), start=pi/2, end=pi, r=6)
draw_arc(yx=c(10,10), start=pi/2, end=pi, r=6)
Calculate the path of a Bezier Curve with up to two control points in a grid and draw to screen.
draw_bezier(start, end, c1, c2 = NULL, n = 50, text = "x", ...)
draw_bezier(start, end, c1, c2 = NULL, n = 50, text = "x", ...)
start |
starting |
end |
ending |
c1 |
coordinate of first control point |
c2 |
coordinate of second control point |
n |
number of points along curve to calculate |
text |
character value drawn at coordinate |
... |
parameters that are passed to |
NULL
Other drawing functions:
box_at()
,
draw_arc()
,
draw_circle()
,
draw_ellipse()
,
draw_fn()
,
draw_lerp()
,
draw_path()
,
draw_ray()
,
draw_rect()
,
draw_shape()
,
fill_circle()
,
fill_ellipse()
,
fill_rect()
,
fill_shape()
,
grid_at()
,
grid_mat()
,
hline_at()
,
hline()
,
vline_at()
,
vline()
draw_bezier(start=c(10,1), end=c(10,10), c1=c(1, 3))
draw_bezier(start=c(10,1), end=c(10,10), c1=c(1, 3))
Calculate the path of a circle in a grid and draw it to screen.
draw_circle(yx, r = 1, n = 50, text = "x", ...)
draw_circle(yx, r = 1, n = 50, text = "x", ...)
yx |
center |
r |
radius of the circle in grid points |
n |
number of points along curve to calculate |
text |
character value drawn at coordinate |
... |
parameters that are passed to |
NULL
Other drawing functions:
box_at()
,
draw_arc()
,
draw_bezier()
,
draw_ellipse()
,
draw_fn()
,
draw_lerp()
,
draw_path()
,
draw_ray()
,
draw_rect()
,
draw_shape()
,
fill_circle()
,
fill_ellipse()
,
fill_rect()
,
fill_shape()
,
grid_at()
,
grid_mat()
,
hline_at()
,
hline()
,
vline_at()
,
vline()
draw_circle(yx=c(10,10), r=5)
draw_circle(yx=c(10,10), r=5)
Calculate the path of an ellipse within a grid and draw to screen.
draw_ellipse(yx = c(0, 0), rx = 1, ry = 1, n = 50, text = "x", ...)
draw_ellipse(yx = c(0, 0), rx = 1, ry = 1, n = 50, text = "x", ...)
yx |
|
rx |
radius along the x-axis in grid points |
ry |
radius along the y-axis in grid points |
n |
number of points along curve to calculate |
text |
character value drawn at coordinate |
... |
parameters that are passed to |
NULL
Other drawing functions:
box_at()
,
draw_arc()
,
draw_bezier()
,
draw_circle()
,
draw_fn()
,
draw_lerp()
,
draw_path()
,
draw_ray()
,
draw_rect()
,
draw_shape()
,
fill_circle()
,
fill_ellipse()
,
fill_rect()
,
fill_shape()
,
grid_at()
,
grid_mat()
,
hline_at()
,
hline()
,
vline_at()
,
vline()
draw_ellipse(yx=c(10,10), rx=8, ry = 4)
draw_ellipse(yx=c(10,10), rx=8, ry = 4)
Calculate the path within a grid of an user-supplied function and print to screen.
draw_fn(x1, x2, fn, n = 50, text = "x", ...)
draw_fn(x1, x2, fn, n = 50, text = "x", ...)
x1 |
starting column value of the path |
x2 |
ending column value of the path |
fn |
function returning row value for a column input |
n |
number of points along curve to calculate |
text |
character value drawn at coordinate |
... |
parameters that are passed to |
NULL
Other drawing functions:
box_at()
,
draw_arc()
,
draw_bezier()
,
draw_circle()
,
draw_ellipse()
,
draw_lerp()
,
draw_path()
,
draw_ray()
,
draw_rect()
,
draw_shape()
,
fill_circle()
,
fill_ellipse()
,
fill_rect()
,
fill_shape()
,
grid_at()
,
grid_mat()
,
hline_at()
,
hline()
,
vline_at()
,
vline()
draw_fn(x1=1, x2=10, function(x){sqrt(x)} )
draw_fn(x1=1, x2=10, function(x){sqrt(x)} )
Interpolate between two points in a grid and draw to sreen.
draw_lerp(start, end, n = 50, text = "x", ...)
draw_lerp(start, end, n = 50, text = "x", ...)
start |
starting |
end |
ending |
n |
number of points along curve to calculate |
text |
character value drawn at coordinate |
... |
parameters that are passed to |
NULL
Other drawing functions:
box_at()
,
draw_arc()
,
draw_bezier()
,
draw_circle()
,
draw_ellipse()
,
draw_fn()
,
draw_path()
,
draw_ray()
,
draw_rect()
,
draw_shape()
,
fill_circle()
,
fill_ellipse()
,
fill_rect()
,
fill_shape()
,
grid_at()
,
grid_mat()
,
hline_at()
,
hline()
,
vline_at()
,
vline()
draw_lerp(start=c(10,1), end=c(1,3))
draw_lerp(start=c(10,1), end=c(1,3))
Draws text at each supplied coodinate.
draw_path(coord, text = "x", ...)
draw_path(coord, text = "x", ...)
coord |
matrix or list containing |
text |
character value drawn at coordinate |
... |
parameters that are passed to |
NULL
Other drawing functions:
box_at()
,
draw_arc()
,
draw_bezier()
,
draw_circle()
,
draw_ellipse()
,
draw_fn()
,
draw_lerp()
,
draw_ray()
,
draw_rect()
,
draw_shape()
,
fill_circle()
,
fill_ellipse()
,
fill_rect()
,
fill_shape()
,
grid_at()
,
grid_mat()
,
hline_at()
,
hline()
,
vline_at()
,
vline()
c <- path_circle(yx = c(5,5), r=3) draw_path(c, text="0")
c <- path_circle(yx = c(5,5), r=3) draw_path(c, text="0")
Calculate the path of a ray extending and print to screen.
draw_ray(start, end, lim = c(64, 128), n = 200, text = "x", ...)
draw_ray(start, end, lim = c(64, 128), n = 200, text = "x", ...)
start |
start |
end |
either an ending coording, an angle in radians, or a character direction (u, d, l, r, ul, ur, dl, dr) |
lim |
bounding box dimensions used to calculate ray |
n |
number of points along curve to calculate |
text |
character value drawn at coordinate |
... |
parameters that are passed to |
NULL
Other drawing functions:
box_at()
,
draw_arc()
,
draw_bezier()
,
draw_circle()
,
draw_ellipse()
,
draw_fn()
,
draw_lerp()
,
draw_path()
,
draw_rect()
,
draw_shape()
,
fill_circle()
,
fill_ellipse()
,
fill_rect()
,
fill_shape()
,
grid_at()
,
grid_mat()
,
hline_at()
,
hline()
,
vline_at()
,
vline()
draw_ray(start=c(10,10), end=pi/6) draw_ray(start=c(10,10), end=pi/6, lim=c(15,15)) draw_ray(start=c(10,10), end=c(4,2))
draw_ray(start=c(10,10), end=pi/6) draw_ray(start=c(10,10), end=pi/6, lim=c(15,15)) draw_ray(start=c(10,10), end=c(4,2))
Calculate the path of a rectangle in a grid and draw to screen.
draw_rect(yx1, yx2, text = "x", ...)
draw_rect(yx1, yx2, text = "x", ...)
yx1 |
upper-left |
yx2 |
lower-right |
text |
character value drawn at coordinate |
... |
parameters that are passed to |
NULL
Other drawing functions:
box_at()
,
draw_arc()
,
draw_bezier()
,
draw_circle()
,
draw_ellipse()
,
draw_fn()
,
draw_lerp()
,
draw_path()
,
draw_ray()
,
draw_shape()
,
fill_circle()
,
fill_ellipse()
,
fill_rect()
,
fill_shape()
,
grid_at()
,
grid_mat()
,
hline_at()
,
hline()
,
vline_at()
,
vline()
draw_rect(c(5,5), c(9,9))
draw_rect(c(5,5), c(9,9))
Calculate the path of a shape given supplied vertices and draw to screen.
draw_shape(mat, cycle = TRUE, n = 30, text = "x", ...)
draw_shape(mat, cycle = TRUE, n = 30, text = "x", ...)
mat |
an Nx2 matrix of |
cycle |
logical value determining whether to the first and last coordinates |
n |
number of points along each edge to calculate |
text |
character value drawn at coordinate |
... |
parameters that are passed to |
NULL
Other drawing functions:
box_at()
,
draw_arc()
,
draw_bezier()
,
draw_circle()
,
draw_ellipse()
,
draw_fn()
,
draw_lerp()
,
draw_path()
,
draw_ray()
,
draw_rect()
,
fill_circle()
,
fill_ellipse()
,
fill_rect()
,
fill_shape()
,
grid_at()
,
grid_mat()
,
hline_at()
,
hline()
,
vline_at()
,
vline()
# Right Triangle draw_shape(rbind( c(10,1), c(10,10), c(1,1) ), cycle=TRUE)
# Right Triangle draw_shape(rbind( c(10,1), c(10,10), c(1,1) ), cycle=TRUE)
Clear text from the cursor's row . Passing values "start"
and "end"
allow the user to erase specific portions of the row relative to the cursor.
erase(x = c("row", "start", "end"), ...)
erase(x = c("row", "start", "end"), ...)
x |
character describing location to clear. The default, |
... |
objects passed to/from methods |
NULL
cat('hello world!') erase('row')
cat('hello world!') erase('row')
Simple program that asks for a letter and a number and returns another value to screen.
example_luckynumber()
example_luckynumber()
NULL
Return future terminal text to the default color. Foreground color is turned on with fg_on
.
fg_off()
fg_off()
NULL
Other style functions:
attr_off()
,
attr_on()
,
bg_off()
,
bg_on()
,
color_off()
,
color_pair()
,
fg_on()
,
make_bg()
,
make_fg()
,
make_style()
,
reset()
,
style()
# Different methods of specifying red fg_on("red") fg_on("#FF0000") fg_on(1) fg_on(255, 0, 0) # Turn off color fg_off()
# Different methods of specifying red fg_on("red") fg_on("#FF0000") fg_on(1) fg_on(255, 0, 0) # Turn off color fg_off()
Specifies the color of all future text written in the terminal fg_on
accepts numeric values (RGB or 8-bit color code), hexadecimal characters, or the name of the color. Not all terminals support each possible color.
fg_on(...)
fg_on(...)
... |
character or numeric value |
Foreground color is turned off with fg_off
.
NULL
Other style functions:
attr_off()
,
attr_on()
,
bg_off()
,
bg_on()
,
color_off()
,
color_pair()
,
fg_off()
,
make_bg()
,
make_fg()
,
make_style()
,
reset()
,
style()
# Different methods of specifying red fg_on("red") fg_on("#FF0000") fg_on(9) fg_on(255, 0, 0) # Turn off color fg_off()
# Different methods of specifying red fg_on("red") fg_on("#FF0000") fg_on(9) fg_on(255, 0, 0) # Turn off color fg_off()
Calculate the path of a circle in a grid and draw it to screen.
fill_circle(yx, r = 1, n = 50, text = "x", ...)
fill_circle(yx, r = 1, n = 50, text = "x", ...)
yx |
center |
r |
radius of the circle in grid points |
n |
number of points along curve to calculate |
text |
character value drawn at coordinate |
... |
parameters that are passed to |
NULL
Other drawing functions:
box_at()
,
draw_arc()
,
draw_bezier()
,
draw_circle()
,
draw_ellipse()
,
draw_fn()
,
draw_lerp()
,
draw_path()
,
draw_ray()
,
draw_rect()
,
draw_shape()
,
fill_ellipse()
,
fill_rect()
,
fill_shape()
,
grid_at()
,
grid_mat()
,
hline_at()
,
hline()
,
vline_at()
,
vline()
draw_circle(yx=c(10,10), r=5)
draw_circle(yx=c(10,10), r=5)
Calculate the path of an ellipse within a grid and draw to screen.
fill_ellipse(yx = c(0, 0), rx = 1, ry = 1, n = 50, text = "x", ...)
fill_ellipse(yx = c(0, 0), rx = 1, ry = 1, n = 50, text = "x", ...)
yx |
|
rx |
radius along the x-axis in grid points |
ry |
radius along the y-axis in grid points |
n |
number of points along curve to calculate |
text |
character value drawn at coordinate |
... |
parameters that are passed to |
NULL
Other drawing functions:
box_at()
,
draw_arc()
,
draw_bezier()
,
draw_circle()
,
draw_ellipse()
,
draw_fn()
,
draw_lerp()
,
draw_path()
,
draw_ray()
,
draw_rect()
,
draw_shape()
,
fill_circle()
,
fill_rect()
,
fill_shape()
,
grid_at()
,
grid_mat()
,
hline_at()
,
hline()
,
vline_at()
,
vline()
draw_ellipse(yx=c(10,10), rx=8, ry = 4)
draw_ellipse(yx=c(10,10), rx=8, ry = 4)
Calculate the path of a rectangle in a grid and draw to screen.
fill_rect(yx1, yx2, text = "x", ...)
fill_rect(yx1, yx2, text = "x", ...)
yx1 |
upper-left |
yx2 |
lower-right |
text |
character value drawn at coordinate |
... |
parameters that are passed to |
NULL
Other drawing functions:
box_at()
,
draw_arc()
,
draw_bezier()
,
draw_circle()
,
draw_ellipse()
,
draw_fn()
,
draw_lerp()
,
draw_path()
,
draw_ray()
,
draw_rect()
,
draw_shape()
,
fill_circle()
,
fill_ellipse()
,
fill_shape()
,
grid_at()
,
grid_mat()
,
hline_at()
,
hline()
,
vline_at()
,
vline()
draw_rect(c(5,5), c(9,9))
draw_rect(c(5,5), c(9,9))
Calculate the path of a shape given supplied vertices and draw to screen.
fill_shape(mat, cycle = TRUE, n = 30, text = "x", ...)
fill_shape(mat, cycle = TRUE, n = 30, text = "x", ...)
mat |
an Nx2 matrix of |
cycle |
logical value determining whether to the first and last coordinates |
n |
number of points along each edge to calculate |
text |
character value drawn at coordinate |
... |
parameters that are passed to |
NULL
Other drawing functions:
box_at()
,
draw_arc()
,
draw_bezier()
,
draw_circle()
,
draw_ellipse()
,
draw_fn()
,
draw_lerp()
,
draw_path()
,
draw_ray()
,
draw_rect()
,
draw_shape()
,
fill_circle()
,
fill_ellipse()
,
fill_rect()
,
grid_at()
,
grid_mat()
,
hline_at()
,
hline()
,
vline_at()
,
vline()
# Right Triangle fill_shape(rbind( c(10,1), c(10,10), c(1,1) ), cycle=TRUE)
# Right Triangle fill_shape(rbind( c(10,1), c(10,10), c(1,1) ), cycle=TRUE)
Listen for a keypress, then apply keypress to a function or echo it to the terminal screen. The user must be in a terminal to use getkp
; it will not work in RStudio or the R GUI. All actions within R are halted until the keypress is returned.
getkp(fn = list(), echo = FALSE)
getkp(fn = list(), echo = FALSE)
fn |
list of named functions |
echo |
whether the keypress should be echoed to the screen if not found in list |
character naming the key that was pressed (invisibly).
f <- list( 'up' = function(){mv(row=-1)}, 'down' = function(){mv(row=-1)}, 'left' = function(){mv(col=-1)}, 'right' = function(){mv(col=1)} ) ## Not run: getkp(fn=f, echo=FALSE) ## End(Not run)
f <- list( 'up' = function(){mv(row=-1)}, 'down' = function(){mv(row=-1)}, 'left' = function(){mv(col=-1)}, 'right' = function(){mv(col=1)} ) ## Not run: getkp(fn=f, echo=FALSE) ## End(Not run)
Maintain a loop that listens for a keypress, then applies the keypress to a function or echoes it to the terminal screen. The user must be in a terminal to use getkp
; it will not work in RStudio or the R GUI. All actions within R are halted until the keypress is returned.
getkpl(escape = "escape", fn = list(), echo = FALSE)
getkpl(escape = "escape", fn = list(), echo = FALSE)
escape |
vector of character keypresses that escape the loop. The default is "escape" key. |
fn |
list of named functions |
echo |
whether the keypress should be echoed to the screen if not found in list |
NULL
f <- list( 'up' = function(){mv(row=-1)}, 'down' = function(){mv(row=-1)}, 'left' = function(){mv(col=-1)}, 'right' = function(){mv(col=1)} ) ## Not run: getkpl(escape = c("escape", "enter"), fn=f, echo=FALSE) ## End(Not run)
f <- list( 'up' = function(){mv(row=-1)}, 'down' = function(){mv(row=-1)}, 'left' = function(){mv(col=-1)}, 'right' = function(){mv(col=1)} ) ## Not run: getkpl(escape = c("escape", "enter"), fn=f, echo=FALSE) ## End(Not run)
Constructs a grid with given dimension, character values, and step parameter, and prints it to screen
grid_at( yx = c(1, 1), dim = NULL, step = c(2, 2), text = c(".", ".", "+", "|", "|", "-", "-", rep("+", 8)), border = TRUE )
grid_at( yx = c(1, 1), dim = NULL, step = c(2, 2), text = c(".", ".", "+", "|", "|", "-", "-", rep("+", 8)), border = TRUE )
yx |
|
dim |
|
step |
numeric vector describing grid step across |
text |
character vector of values for the grid, in order: horizontal grid line, vertical grid line, grid intersection, left border, right border, top border, bottom border, corners (upper-left, upper-right, lower-left, lower-right), ticks (right, bottom, left, top) |
border |
logical value for whether a border should be included. |
NULL
Other drawing functions:
box_at()
,
draw_arc()
,
draw_bezier()
,
draw_circle()
,
draw_ellipse()
,
draw_fn()
,
draw_lerp()
,
draw_path()
,
draw_ray()
,
draw_rect()
,
draw_shape()
,
fill_circle()
,
fill_ellipse()
,
fill_rect()
,
fill_shape()
,
grid_mat()
,
hline_at()
,
hline()
,
vline_at()
,
vline()
grid_at(yx=c(2,2), dim=c(11,13), step=c(2,4), border=TRUE)
grid_at(yx=c(2,2), dim=c(11,13), step=c(2,4), border=TRUE)
Constructs a grid with provided dimensions (row, col)
, character values for gridlines, and a step parameter noting the number of rows and columns between each gridline.
grid_mat( dim, step = c(2, 2), text = c(".", ".", "+", "|", "|", "-", "-", rep("+", 8)), border = TRUE )
grid_mat( dim, step = c(2, 2), text = c(".", ".", "+", "|", "|", "-", "-", rep("+", 8)), border = TRUE )
dim |
|
step |
numeric vector describing grid step across |
text |
character vector of values for the grid, in order: horizontal grid line, vertical grid line, grid intersection, left border, right border, top border, bottom border, corners (upper-left, upper-right, lower-left, lower-right), ticks (right, bottom, left, top) |
border |
logical value for whether a border should be included. |
row
xcol
matrix
Other drawing functions:
box_at()
,
draw_arc()
,
draw_bezier()
,
draw_circle()
,
draw_ellipse()
,
draw_fn()
,
draw_lerp()
,
draw_path()
,
draw_ray()
,
draw_rect()
,
draw_shape()
,
fill_circle()
,
fill_ellipse()
,
fill_rect()
,
fill_shape()
,
grid_at()
,
hline_at()
,
hline()
,
vline_at()
,
vline()
grid_mat(dim=c(11,13), step=c(2,4), border=TRUE)
grid_mat(dim=c(11,13), step=c(2,4), border=TRUE)
Make the cursor invisible. The cursor can be revealed with show_cursor
hide_cursor()
hide_cursor()
NULL
hide_cursor() cat("\n\nHello World!") show_cursor()
hide_cursor() cat("\n\nHello World!") show_cursor()
Horizontal Line
hline(n, text = "-")
hline(n, text = "-")
n |
integer describing the character length of the line |
text |
character to be repeated |
character string of length n
Other drawing functions:
box_at()
,
draw_arc()
,
draw_bezier()
,
draw_circle()
,
draw_ellipse()
,
draw_fn()
,
draw_lerp()
,
draw_path()
,
draw_ray()
,
draw_rect()
,
draw_shape()
,
fill_circle()
,
fill_ellipse()
,
fill_rect()
,
fill_shape()
,
grid_at()
,
grid_mat()
,
hline_at()
,
vline_at()
,
vline()
hline(10, "*") # ********** hline(5, "$") # $$$$$
hline(10, "*") # ********** hline(5, "$") # $$$$$
Draws a horizontal line of length n
at (row, col)
hline_at(yx, n, text = "-", ...)
hline_at(yx, n, text = "-", ...)
yx |
|
n |
integer describing the character length of the line |
text |
character to be repeated |
... |
parameters that are passed to |
NULL
Other drawing functions:
box_at()
,
draw_arc()
,
draw_bezier()
,
draw_circle()
,
draw_ellipse()
,
draw_fn()
,
draw_lerp()
,
draw_path()
,
draw_ray()
,
draw_rect()
,
draw_shape()
,
fill_circle()
,
fill_ellipse()
,
fill_rect()
,
fill_shape()
,
grid_at()
,
grid_mat()
,
hline()
,
vline_at()
,
vline()
hline_at(c(3,4),6,"-") # print "------" at (3,4)
hline_at(c(3,4),6,"-") # print "------" at (3,4)
Tests whether the session is in terminal and returns TRUE or FALSE. Many of the cursr
functions require being in terminal and will not work with RStudio or the R GUI application.
in.term()
in.term()
logical value; TRUE
or FALSE
in.term()
in.term()
Restore cursor to its previously saved location from save_cursor
.
load_cursor()
load_cursor()
NULL
save_cursor() cat("\n\nHello World!") load_cursor()
save_cursor() cat("\n\nHello World!") load_cursor()
Returns the ANSI code for the specified background color. make_bg
accepts numeric values (RGB or 8-bit color code), hexadecimal characters, or the name of the color.
make_bg(...)
make_bg(...)
... |
character or numeric value |
ANSI character string
Other style functions:
attr_off()
,
attr_on()
,
bg_off()
,
bg_on()
,
color_off()
,
color_pair()
,
fg_off()
,
fg_on()
,
make_fg()
,
make_style()
,
reset()
,
style()
# Different methods of specifying cyan make_bg("cyan") make_bg("#00FFFF") make_bg(14) make_bg(0, 255, 255)
# Different methods of specifying cyan make_bg("cyan") make_bg("#00FFFF") make_bg(14) make_bg(0, 255, 255)
Returns the ANSI code for the specified foreground color. make_fg
accepts numeric values (RGB or 8-bit color code), hexadecimal characters, or the name of the color.
make_fg(...)
make_fg(...)
... |
character or numeric value |
ANSI character string
Other style functions:
attr_off()
,
attr_on()
,
bg_off()
,
bg_on()
,
color_off()
,
color_pair()
,
fg_off()
,
fg_on()
,
make_bg()
,
make_style()
,
reset()
,
style()
# Different methods of specifying red make_fg("red") make_fg("#FF0000") make_fg(9) make_fg(255, 0, 0)
# Different methods of specifying red make_fg("red") make_fg("#FF0000") make_fg(9) make_fg(255, 0, 0)
Returns the ANSI codes for the specified colors and text attributes.
make_style(fg = NA, bg = NA, attr = NA)
make_style(fg = NA, bg = NA, attr = NA)
fg |
character or numeric value for the foreground color. See |
bg |
character or numeric value for the background color. See |
attr |
character vector describing attributes to turn on. See |
ANSI character string
Other style functions:
attr_off()
,
attr_on()
,
bg_off()
,
bg_on()
,
color_off()
,
color_pair()
,
fg_off()
,
fg_on()
,
make_bg()
,
make_fg()
,
reset()
,
style()
cat(make_style(fg="blue", bg=c(192,192,192), attr=c("ul", "st"))) cat("Hello World!\n") reset()
cat(make_style(fg="blue", bg=c(192,192,192), attr=c("ul", "st"))) cat("Hello World!\n") reset()
Move cursor relative to its current position on the screen. Screen coordinates are given by (row, column)
with the position of the screen being (1, 1)
.
mv(row = 0L, col = 0L)
mv(row = 0L, col = 0L)
row |
number of rows in which to move the cursor. Positive values move the cursor down; negative values move the cursor up. If |
col |
number of columns in which to move the cursor. Positive values move the cursor forward; negative values move the cursor backwards. |
The user must be in a terminal to use the functionality; it will not work in RStudio or the R GUI.
NULL
mv_to
to move to a specific location on the screen.
Other moving functions:
mv_col()
,
mv_row()
,
mv_to()
# move the cursor down one and forward two mv(1, 2) # Alternatively, you can specify the coordinates as a single vector. loc <- c(1, 2) mv(loc) # to move to the left one unit (only works if the current column is > 1) mv(, -1)
# move the cursor down one and forward two mv(1, 2) # Alternatively, you can specify the coordinates as a single vector. loc <- c(1, 2) mv(loc) # to move to the left one unit (only works if the current column is > 1) mv(, -1)
Move the cursor to the specified column, while maintaining the same row.
mv_col(n = 1L)
mv_col(n = 1L)
n |
positive integer specifying the column |
The user must be in a terminal to use the functionality; it will not work in RStudio or the R GUI.
NULL
Other moving functions:
mv_row()
,
mv_to()
,
mv()
# Position cursor at the beginning of the row mv_col(1) # Move cursor to the 10th column in the row mv_col(10)
# Position cursor at the beginning of the row mv_col(1) # Move cursor to the 10th column in the row mv_col(10)
Moves cursor to the beginning of the row relative to its current location.
mv_row(n = 1L)
mv_row(n = 1L)
n |
number of rows to move. Positive values indicate the next rows; negative values indicate the previous rows |
The user must be in a terminal to use the functionality; it will not work in RStudio or the R GUI.
NULL
Other moving functions:
mv_col()
,
mv_to()
,
mv()
# move the cursor to the beginning of the previous line mv_row(-1)
# move the cursor to the beginning of the previous line mv_row(-1)
Move cursor relative to its current position on the screen. Screen coordinates are given by (row, column)
with the position of the screen being (1, 1)
.
mv_to(row = 1L, col = 1L)
mv_to(row = 1L, col = 1L)
row |
positive integer specifying the console row. If |
col |
positive integer specifying the console column. |
The user must be in a terminal to use the functionality; it will not work in RStudio or the R GUI.
NULL
mv
to move relative to the current location on the screen.
Other moving functions:
mv_col()
,
mv_row()
,
mv()
# move the cursor to the 2nd row, 4th column mv_to(2, 4) # alternatively, you can specify the coordinates as a vector. loc <- c(2, 4) mv_to(loc)
# move the cursor to the 2nd row, 4th column mv_to(2, 4) # alternatively, you can specify the coordinates as a vector. loc <- c(2, 4) mv_to(loc)
Calculate the path of an arc within a grid.
path_arc(yx, start, end, r = 1, n = 50)
path_arc(yx, start, end, r = 1, n = 50)
yx |
center |
start |
starting angle in radians |
end |
ending angle in radians |
r |
radius of circle |
n |
number of points along curve to calculate |
Nx2 matrix of (row, column)
coordinates
Other path-fitting functions:
path_bezier()
,
path_circle()
,
path_ellipse()
,
path_fill()
,
path_fn()
,
path_intersection()
,
path_lerp()
,
path_ray()
,
path_rect()
,
path_shape()
path_arc(yx=c(10,10), start=pi/2, end=pi, r=6)
path_arc(yx=c(10,10), start=pi/2, end=pi, r=6)
Calculate the path of a Bezier Curve with up to two control points in a grid.
path_bezier(start, end, c1, c2 = NULL, n = 50)
path_bezier(start, end, c1, c2 = NULL, n = 50)
start |
starting |
end |
ending |
c1 |
coordinate of first control point |
c2 |
coordinate of second control point |
n |
number of points along curve to calculate |
Nx2 matrix of (row, column)
coordinates
Other path-fitting functions:
path_arc()
,
path_circle()
,
path_ellipse()
,
path_fill()
,
path_fn()
,
path_intersection()
,
path_lerp()
,
path_ray()
,
path_rect()
,
path_shape()
path_bezier(start=c(10,1), end=c(10,10), c1=c(1, 3))
path_bezier(start=c(10,1), end=c(10,10), c1=c(1, 3))
Calculate the path of a circle in a grid.
path_circle(yx, r = 1, n = 50)
path_circle(yx, r = 1, n = 50)
yx |
center |
r |
radius of the circle in grid points |
n |
number of points along curve to calculate |
Nx2 matrix of (row, column)
coordinates
Other path-fitting functions:
path_arc()
,
path_bezier()
,
path_ellipse()
,
path_fill()
,
path_fn()
,
path_intersection()
,
path_lerp()
,
path_ray()
,
path_rect()
,
path_shape()
path_circle(yx=c(10,10), r=5)
path_circle(yx=c(10,10), r=5)
Calculate the path of an ellipse within a grid.
path_ellipse(yx = c(0, 0), rx = 1, ry = 1, n = 50)
path_ellipse(yx = c(0, 0), rx = 1, ry = 1, n = 50)
yx |
|
rx |
radius along the x-axis in grid points |
ry |
radius along the y-axis in grid points |
n |
number of points along curve to calculate |
Nx2 matrix of (row, column)
coordinates
Other path-fitting functions:
path_arc()
,
path_bezier()
,
path_circle()
,
path_fill()
,
path_fn()
,
path_intersection()
,
path_lerp()
,
path_ray()
,
path_rect()
,
path_shape()
path_ellipse(yx=c(10,10), rx=8, ry = 4)
path_ellipse(yx=c(10,10), rx=8, ry = 4)
Calculate the coordinates of all points inside of a path.
path_fill(mat)
path_fill(mat)
mat |
Nx2 matrix of |
Nx2 matrix of (row, column)
coordinates
Other path-fitting functions:
path_arc()
,
path_bezier()
,
path_circle()
,
path_ellipse()
,
path_fn()
,
path_intersection()
,
path_lerp()
,
path_ray()
,
path_rect()
,
path_shape()
c0 <- path_circle(c(10,10), r=5) path_fill(c0)
c0 <- path_circle(c(10,10), r=5) path_fill(c0)
Calculate the path within a grid of an user-supplied function.
path_fn(x1, x2, fn, n = 50)
path_fn(x1, x2, fn, n = 50)
x1 |
starting column value of the path |
x2 |
ending column value of the path |
fn |
function returning row value for a column input |
n |
number of points along curve to calculate |
Nx2 matrix of (row, column)
coordinates
Other path-fitting functions:
path_arc()
,
path_bezier()
,
path_circle()
,
path_ellipse()
,
path_fill()
,
path_intersection()
,
path_lerp()
,
path_ray()
,
path_rect()
,
path_shape()
path_fn(x1=1, x2=10, function(x){sqrt(x)} )
path_fn(x1=1, x2=10, function(x){sqrt(x)} )
Calculate the points of intersection between two paths.
path_intersection(path)
path_intersection(path)
path |
list containing two coordinate |
Nx2 matrix of (row, column)
coordinates
Other path-fitting functions:
path_arc()
,
path_bezier()
,
path_circle()
,
path_ellipse()
,
path_fill()
,
path_fn()
,
path_lerp()
,
path_ray()
,
path_rect()
,
path_shape()
c1 <- path_circle(c(4,4), r=3) c2 <- path_circle(c(6,6), r=3) path_intersection(list(c1, c2))
c1 <- path_circle(c(4,4), r=3) c2 <- path_circle(c(6,6), r=3) path_intersection(list(c1, c2))
Interpolate between two points in a grid.
path_lerp(start, end, n = 50)
path_lerp(start, end, n = 50)
start |
starting |
end |
ending |
n |
number of points along curve to calculate |
Nx2 matrix of (row, column)
coordinates
Other path-fitting functions:
path_arc()
,
path_bezier()
,
path_circle()
,
path_ellipse()
,
path_fill()
,
path_fn()
,
path_intersection()
,
path_ray()
,
path_rect()
,
path_shape()
path_lerp(start=c(10,1), end=c(1,3))
path_lerp(start=c(10,1), end=c(1,3))
Calculate the path of a ray extending
path_ray(start, end, lim = c(64, 128), n = 200)
path_ray(start, end, lim = c(64, 128), n = 200)
start |
start |
end |
either an ending coording, an angle in radians, or a character direction (u, d, l, r, ul, ur, dl, dr) |
lim |
bounding box dimensions used to calculate ray |
n |
number of points along curve to calculate |
Nx2 matrix of (row, column)
coordinates
Other path-fitting functions:
path_arc()
,
path_bezier()
,
path_circle()
,
path_ellipse()
,
path_fill()
,
path_fn()
,
path_intersection()
,
path_lerp()
,
path_rect()
,
path_shape()
path_ray(start=c(10,10), end=pi/6) path_ray(start=c(10,10), end=pi/6, lim=c(15,15)) path_ray(start=c(10,10), end=c(4,2))
path_ray(start=c(10,10), end=pi/6) path_ray(start=c(10,10), end=pi/6, lim=c(15,15)) path_ray(start=c(10,10), end=c(4,2))
Calculate the path of a rectangle in a grid.
path_rect(yx1, yx2)
path_rect(yx1, yx2)
yx1 |
upper-left |
yx2 |
lower-right |
Nx2 matrix of (row, column)
coordinates
Other path-fitting functions:
path_arc()
,
path_bezier()
,
path_circle()
,
path_ellipse()
,
path_fill()
,
path_fn()
,
path_intersection()
,
path_lerp()
,
path_ray()
,
path_shape()
path_rect(c(5,5), c(9,9))
path_rect(c(5,5), c(9,9))
Calculate the path of a shape given supplied vertices.
path_shape(mat, cycle = TRUE, n = 30)
path_shape(mat, cycle = TRUE, n = 30)
mat |
an Nx2 matrix of |
cycle |
logical value determining whether to the first and last coordinates |
n |
number of points along each edge to calculate |
Nx2 matrix of (row, column)
coordinates
Other path-fitting functions:
path_arc()
,
path_bezier()
,
path_circle()
,
path_ellipse()
,
path_fill()
,
path_fn()
,
path_intersection()
,
path_lerp()
,
path_ray()
,
path_rect()
# Right Triangle path_shape(rbind( c(10,1), c(10,10), c(1,1) ), cycle=TRUE)
# Right Triangle path_shape(rbind( c(10,1), c(10,10), c(1,1) ), cycle=TRUE)
Repeat a character n
times and concatenate into a single value.
repch(x, n)
repch(x, n)
x |
character to be repeated |
n |
number of times to be repeated |
character vector
repch("abc", 5)
repch("abc", 5)
Turns off all text attributes and colors in the terminal.
reset()
reset()
NULL
Other style functions:
attr_off()
,
attr_on()
,
bg_off()
,
bg_on()
,
color_off()
,
color_pair()
,
fg_off()
,
fg_on()
,
make_bg()
,
make_fg()
,
make_style()
,
style()
attr_on("ul") fg_on("red") bg_on(c(10,60,205)) cat("Hello World!\n") reset() cat("Hello World!\n")
attr_on("ul") fg_on("red") bg_on(c(10,60,205)) cat("Hello World!\n") reset() cat("Hello World!\n")
Save the position of the cursor so that the position can be restored for later with load_cursor
.
save_cursor()
save_cursor()
NULL
save_cursor() cat("\n\nHello World!") load_cursor()
save_cursor() cat("\n\nHello World!") load_cursor()
Reveal the cursor after it has been hidden by hide_cursor
.
show_cursor()
show_cursor()
NULL
hide_cursor() cat("\n\nHello World!") show_cursor()
hide_cursor() cat("\n\nHello World!") show_cursor()
Add color and other text attributes to a character vector. Attributes can be seen after text is passed to cat
, though it may only show up in a terminal. Note that terminal attributes and colors are automatically reset to default after text is printed.
style(x, fg = NA, bg = NA, attr = NA)
style(x, fg = NA, bg = NA, attr = NA)
x |
character vector to be styled |
fg |
character or numeric value for the foreground color. See |
bg |
character or numeric value for the background color. See |
attr |
character vector describing attributes to turn on. See |
character vector
Other style functions:
attr_off()
,
attr_on()
,
bg_off()
,
bg_on()
,
color_off()
,
color_pair()
,
fg_off()
,
fg_on()
,
make_bg()
,
make_fg()
,
make_style()
,
reset()
x <- style("Hello World!\n", fg="blue", bg=c(192,192,192), attr=c("ul", "st")) cat(paste(x, "It is nice to meet you!"))
x <- style("Hello World!\n", fg="blue", bg=c(192,192,192), attr=c("ul", "st")) cat(paste(x, "It is nice to meet you!"))
A named list containing the unicode character for various box drawing, mathematical, currency, astrological, and other symbols.
Sym
Sym
A named list of characters
Function determines the size of the terminal in number of rows and columns. The value may not be accurate in RStudio or the R GUI.
term_dim()
term_dim()
numeric vector (# of rows, # of columns)
term_dim()
term_dim()
Vertical Line
vline(n, text = "|")
vline(n, text = "|")
n |
integer describing the character length of the line |
text |
character to be repeated |
character string of length n
, separated by "\n"
Other drawing functions:
box_at()
,
draw_arc()
,
draw_bezier()
,
draw_circle()
,
draw_ellipse()
,
draw_fn()
,
draw_lerp()
,
draw_path()
,
draw_ray()
,
draw_rect()
,
draw_shape()
,
fill_circle()
,
fill_ellipse()
,
fill_rect()
,
fill_shape()
,
grid_at()
,
grid_mat()
,
hline_at()
,
hline()
,
vline_at()
vline(4, "*") # "*\n*\n*\n*"
vline(4, "*") # "*\n*\n*\n*"
Draws a vertical line of length n
at (row, col)
vline_at(yx, n, text = "|", ...)
vline_at(yx, n, text = "|", ...)
yx |
|
n |
integer describing the character length of the line |
text |
character to be repeated |
... |
parameters that are passed to |
NULL
Other drawing functions:
box_at()
,
draw_arc()
,
draw_bezier()
,
draw_circle()
,
draw_ellipse()
,
draw_fn()
,
draw_lerp()
,
draw_path()
,
draw_ray()
,
draw_rect()
,
draw_shape()
,
fill_circle()
,
fill_ellipse()
,
fill_rect()
,
fill_shape()
,
grid_at()
,
grid_mat()
,
hline_at()
,
hline()
,
vline()
vline_at(c(3,4),6,"|") # print "|" at (3,4), ..., (8,4)
vline_at(c(3,4),6,"|") # print "|" at (3,4), ..., (8,4)
Writes a string of characters to the terminal at the current cursor position. wr
accepts text colors and attributes, but these are reset to default afterwards if used.
wr(text, fg = NA, bg = NA, attr = NA)
wr(text, fg = NA, bg = NA, attr = NA)
text |
string to be printed to the Console |
fg |
foreground color. See |
bg |
background color. See |
attr |
character attribute. See |
NULL
Other writing functions:
wrat()
,
wrch()
,
wrkpl()
,
wrkp()
mv_to(5,4) wrch("h") wrch("e", fg="red") wr("llo World")
mv_to(5,4) wrch("h") wrch("e", fg="red") wr("llo World")
Function to be used at the end of a terminal function. It resets the colors and attributes to their default values, clears the screen, and reveals the cursor.
wrapup()
wrapup()
NULL
Move cursor to specified location in the terminal screen, then print the supplied text. This function will only work in terminal, not the RStudio Console or R GUI.
wrat(yx, text, ...)
wrat(yx, text, ...)
yx |
numeric vector specifying the |
text |
text to be written at |
... |
colors and attributes added to text. See |
The coordinates are given in matrix notation: (row, column)
, with the top-left corner of the screen being (1,1)
.
NULL
Other writing functions:
wrch()
,
wrkpl()
,
wrkp()
,
wr()
wrat(c(10,6), "CURSR") wrat(c(4,1), "Hello World!", fg="red", attr=c("bf", "ul")) mat <- rbind(c(5,2), c(10,5), c(1,19)) wrat(mat, "HI", fg="yellow")
wrat(c(10,6), "CURSR") wrat(c(4,1), "Hello World!", fg="red", attr=c("bf", "ul")) mat <- rbind(c(5,2), c(10,5), c(1,19)) wrat(mat, "HI", fg="yellow")
Writes a single character to the terminal at the current cursor position. wr
accepts text colors and attributes, but these are reset to default afterwards if used.
wrch(chr, fg = NA, bg = NA, attr = NA)
wrch(chr, fg = NA, bg = NA, attr = NA)
chr |
character to be printed to the Console |
fg |
foreground color. See |
bg |
background color. See |
attr |
character attribute. See |
NULL
Other writing functions:
wrat()
,
wrkpl()
,
wrkp()
,
wr()
mv_to(5,4) wrch("h") wrch("e", fg="red") wr("llo World")
mv_to(5,4) wrch("h") wrch("e", fg="red") wr("llo World")
Move cursor to specified location in the terminal screen, then print the supplied character. This function will only work in terminal, not the RStudio Console or R GUI.
wrchat(row, col, chr, ...)
wrchat(row, col, chr, ...)
row |
row in which character is printed. If length of |
col |
column in which character is printed |
chr |
character to be printed to the Console |
... |
parameters that are passed to |
The coordinates are given in matrix notation: (row, column)
, with the top-left corner of the screen being (1,1)
.
NULL
wrchat(5, 4, "h")
wrchat(5, 4, "h")
Detect keypress and print it to the terminal screen, while invisibly returning the keypress. The user can specify which characters to ignore, and can also map keys to a list of functions. Any keypress mapped to a function will not be echoed to the screen.
wrkp(ignore = "escape", fn = list(), ...)
wrkp(ignore = "escape", fn = list(), ...)
ignore |
vector of keypresses to ignore. |
fn |
list of functions, named by key, to be called when key is pressed. |
... |
parameters that are passed to |
NULL
Other writing functions:
wrat()
,
wrch()
,
wrkpl()
,
wr()
## Not run: wrkp( ignore="escape", fn = list( enter = function(){mv_row(1)}, left = function(){mv(0, -1)}, right = function(){mv(0, 1)}, up = function(){mv(-1,0)}, down = function(){mv(1,0)}, space = function(){cat(" ")} ) ) ## End(Not run)
## Not run: wrkp( ignore="escape", fn = list( enter = function(){mv_row(1)}, left = function(){mv(0, -1)}, right = function(){mv(0, 1)}, up = function(){mv(-1,0)}, down = function(){mv(1,0)}, space = function(){cat(" ")} ) ) ## End(Not run)
Detect keypress and print it to the terminal screen, while invisibly returning the keypress. The user can specify which characters to ignore, and can also map keys to a list of functions. Any keypress mapped to a function will not be echoed to the screen.
wrkpl(escape = c("escape"), ignore = NA_character_, fn = list(), ...)
wrkpl(escape = c("escape"), ignore = NA_character_, fn = list(), ...)
escape |
vector of keypresses to escape the loop. |
ignore |
vector of keypresses to ignore. |
fn |
list of functions, named by key, to be called when key is pressed. |
... |
parameters that are passed to |
NULL
Other writing functions:
wrat()
,
wrch()
,
wrkp()
,
wr()
## Not run: wrkpl( escape = "escape", fn = list( enter = function(){mv_row(1)}, left = function(){mv(0, -1)}, right = function(){mv(0, 1)}, up = function(){mv(-1,0)}, down = function(){mv(1,0)}, space = function(){cat(" ")} ) ) ## End(Not run)
## Not run: wrkpl( escape = "escape", fn = list( enter = function(){mv_row(1)}, left = function(){mv(0, -1)}, right = function(){mv(0, 1)}, up = function(){mv(-1,0)}, down = function(){mv(1,0)}, space = function(){cat(" ")} ) ) ## End(Not run)