Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FSI and LRO #350

Merged
merged 2 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions R/ctl_colonnade.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ctl_colonnade <- function(x, has_row_id = TRUE, width = NULL, controller = new_t
flat_tiers <- map(flat_tiers, function(.x) c(rowid_formatted, .x))
}

out <- map(flat_tiers, format_colonnade_tier_2)
out <- map(flat_tiers, format_colonnade_tier_2, bidi = get_pillar_option_bidi())

extra_cols <- as.list(x)[seq2(length(pillars) + 1L, nc)]
new_colonnade_body(out, extra_cols = extra_cols)
Expand Down Expand Up @@ -80,14 +80,27 @@ pillar_format_tier <- function(pillars, widths, max_widths) {
})
}

format_colonnade_tier_2 <- function(x) {
"!!!!!DEBUG format_colonnade_tier_2(`v(x)`)"
# Reference: https://www.w3.org/International/questions/qa-bidi-unicode-controls
fsi <- function(x) {
paste0("\u2068", x, "\u2069")
}

lro <- function(x) {
paste0("\u202d", x, "\u202c")
}

format_colonnade_tier_2 <- function(x, bidi = FALSE) {
if (length(x) == 0) {
return(character())
}

exec(paste, !!!x)
if (bidi) {
x <- map(x, fsi)
out <- exec(paste, !!!x)
lro(out)
} else {
exec(paste, !!!x)
}
}

new_colonnade_body <- function(x, extra_cols) {
Expand Down
9 changes: 9 additions & 0 deletions R/options.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,13 @@ pillar_options <- list2(
max_footer_lines = make_option_impl(
getOption("pillar.max_footer_lines", default = 7L)
),
#' - `bidi`: Set to `TRUE` for experimental support for bidirectional scripts.
#' Default: `FALSE`. When this option is set, "left right override"
#' and "first strong isolate"
#' [Unicode controls](https://www.w3.org/International/questions/qa-bidi-unicode-controls)
#' are inserted to ensure that text appears in its intended direction
#' and that the column headings correspond to the correct columns.
bidi = make_option_impl(
getOption("pillar.bidi", default = FALSE)
),
)