Skip to content

Commit

Permalink
synchro
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentGuyader committed Jan 23, 2017
1 parent b4b97bd commit 1baa866
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 99 deletions.
18 changes: 9 additions & 9 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Package: littleboxes
Type: Package
Title: RStudio Addin - creates boxed in titles in an Rscript
Version: 0.1.0
Author: Vincent Guyader
Maintainer: Vincent Guyader <[email protected]>
Description: Creates boxed in titles in an Rscript
License: MIT
LazyData: TRUE
Package: littleboxes
Type: Package
Title: RStudio Addin - creates boxed in titles in an Rscript
Version: 0.1.0
Author: Vincent Guyader
Maintainer: Vincent Guyader <[email protected]>
Description: Creates boxed in titles in an Rscript
License: MIT
LazyData: TRUE
42 changes: 21 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 ThinkRstat

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
The MIT License (MIT)
Copyright (c) 2016 ThinkRstat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
128 changes: 64 additions & 64 deletions R/nice.R
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
dd <- function(x) {
if (nchar(x) <= 56) {
base <- (60 - nchar(x) - 2)/2
return(paste(c("#", rep(" ", floor(base)), x, rep(" ",
ceiling(base)), "####"), collapse = ""))
}
s1 <- strsplit(x, " ")[[1]]
c(Recall(paste(s1[1:floor(length(s1)/2)], collapse = " ")), Recall(paste(s1[ceiling(length(s1)/2):length(s1)],
collapse = " ")))
}


toutbeau <- function(x, l = 60) {
# print(x)
x <- gsub("\n", " ", x)
x <- gsub("\t", " ", x)
x <- gsub("^[# ]+", "", x)
x <- gsub("[# =]+$", " ", x)
x <- gsub(" $", " ", x)
res <- paste(rep("#", l), collapse = "")
res <- c(res, paste(c("#", rep(" ", l - 2), "#"), collapse = ""))


res <- c(res, do.call(c, as.list(dd(x))))




res <- c(res, paste(c("#", rep(" ", l - 2), "#"), collapse = ""))
res <- c(res, paste(rep("#", l), collapse = ""))
res <- c(res, "")
res
res <- paste(res, collapse = "\n")
return(res)
}


littleboxes <- function() {
context <- rstudioapi::getActiveDocumentContext()
for (sel in context$selection) {
# print(sel)
if (sel$text != "") {


rstudioapi::modifyRange(sel$range, toutbeau(sel$text),
context$id)
break
} else {

lign <- context$selection[[1]]$range$start[["row"]]
value <- context$contents[lign]
range <- structure(list(start = structure(c(lign,
1), .Names = c("row", "column"), class = "document_position"),
end = structure(c(lign, 77777), .Names = c("row",
"column"), class = "document_position")), .Names = c("start",
"end"), class = "document_range")

if (value != "") {
rstudioapi::modifyRange(range, toutbeau(value),
context$id)
}
}
}
}
dd <- function(x) {
if (nchar(x) <= 56) {
base <- (60 - nchar(x) - 2)/2
return(paste(c("#", rep(" ", floor(base)), x, rep(" ",
ceiling(base)), "####"), collapse = ""))
}
s1 <- strsplit(x, " ")[[1]]
c(Recall(paste(s1[1:floor(length(s1)/2)], collapse = " ")), Recall(paste(s1[ceiling(length(s1)/2):length(s1)],
collapse = " ")))
}


toutbeau <- function(x, l = 60) {
# print(x)
x <- gsub("\n", " ", x)
x <- gsub("\t", " ", x)
x <- gsub("^[# ]+", "", x)
x <- gsub("[# =]+$", " ", x)
x <- gsub(" $", " ", x)
res <- paste(rep("#", l), collapse = "")
res <- c(res, paste(c("#", rep(" ", l - 2), "#"), collapse = ""))


res <- c(res, do.call(c, as.list(dd(x))))




res <- c(res, paste(c("#", rep(" ", l - 2), "#"), collapse = ""))
res <- c(res, paste(rep("#", l), collapse = ""))
res <- c(res, "")
res
res <- paste(res, collapse = "\n")
return(res)
}


littleboxes <- function() {
context <- rstudioapi::getActiveDocumentContext()
for (sel in context$selection) {
# print(sel)
if (sel$text != "") {


rstudioapi::modifyRange(sel$range, toutbeau(sel$text),
context$id)
break
} else {

lign <- context$selection[[1]]$range$start[["row"]]
value <- context$contents[lign]
range <- structure(list(start = structure(c(lign,
1), .Names = c("row", "column"), class = "document_position"),
end = structure(c(lign, 77777), .Names = c("row",
"column"), class = "document_position")), .Names = c("start",
"end"), class = "document_range")

if (value != "") {
rstudioapi::modifyRange(range, toutbeau(value),
context$id)
}
}
}
}
10 changes: 5 additions & 5 deletions inst/rstudio/addins.dcf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Name: Little Boxes
Description: Canned titles in #comments
Binding: littleboxes
Interactive: false
Name: Little Boxes
Description: Canned titles in #comments
Binding: littleboxes
Interactive: false
17 changes: 17 additions & 0 deletions littleboxes.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source

0 comments on commit 1baa866

Please sign in to comment.