[rkward] packages/rkwarddev/R: trying to fix layout problems

m.eik michalke meik.michalke at uni-duesseldorf.de
Mon Nov 9 15:10:40 UTC 2015


Git commit 883683ed7666eacea854addc5af807c90835fe40 by m.eik michalke.
Committed on 09/11/2015 at 15:11.
Pushed by meikm into branch 'master'.

trying to fix layout problems

  - if conditions still have an odd layout in js(), there's always twice as much tabs as there should be.
    this is work in progress

M  +9    -0    packages/rkwarddev/R/js.R
M  +18   -9    packages/rkwarddev/R/rk.paste.JS.graph.R

http://commits.kde.org/rkward/883683ed7666eacea854addc5af807c90835fe40

diff --git a/packages/rkwarddev/R/js.R b/packages/rkwarddev/R/js.R
index 777abba..334230c 100644
--- a/packages/rkwarddev/R/js.R
+++ b/packages/rkwarddev/R/js.R
@@ -81,8 +81,17 @@ js <- function(..., level=2, linebreaks=FALSE){
         if(inherits(this.part, "for")){
           this.part <- replaceJSFor(this.part, level=level)
         } else {}
+        if(identical(this.part[[1]], "rk.comment")){
+          return(rk.paste.JS(eval(this.part), level=level))
+        } else {}
         # replace JS operators
         return(do.call("replaceJSOperators", args=list(this.part)))
+      } else if(is.XiMpLe.node(this.part)){
+        if(XMLName(this.part) == "!--"){
+          return(rk.paste.JS(this.part, level=level))
+        } else {
+          return(this.part)
+        }
       } else {
         return(this.part)
       }
diff --git a/packages/rkwarddev/R/rk.paste.JS.graph.R b/packages/rkwarddev/R/rk.paste.JS.graph.R
index 6a0f024..e2dc3b7 100644
--- a/packages/rkwarddev/R/rk.paste.JS.graph.R
+++ b/packages/rkwarddev/R/rk.paste.JS.graph.R
@@ -80,17 +80,18 @@ rk.paste.JS.graph <- function(..., plotOpts=NULL, printoutObj=NULL, level=2, ind
         } else {
           warning("rk.paste.JS.graph: you're using plot options, but 'printoutObj' is empty, is that intended?")
         },
-        js.po.calculate
+        js.po.calculate,
+        level=level+1
       )
     } else {},
-    level=level, indent.by=indent.by, empty.e=empty.e
+    level=max(0, level-1), indent.by=indent.by, empty.e=empty.e
   )
 
   # graph.on() & begin try()
   js.prnt <- paste(js.prnt, rk.paste.JS(
     ite("full", echo("rk.graph.on()\n")),
     echo("\ttry({\n"),
-    level=level, indent.by=indent.by, empty.e=empty.e
+    level=level+1, indent.by=indent.by, empty.e=empty.e
   ), sep="\n\n")
 
   # plot options: preprocess
@@ -98,17 +99,21 @@ rk.paste.JS.graph <- function(..., plotOpts=NULL, printoutObj=NULL, level=2, ind
     if(!is.null(plotOpts)){
       rk.paste.JS(
         rk.comment("insert any option-setting code that should be run before the actual plotting commands:"),
-        id("\t\tprintIndentedUnlessEmpty(\"", plotOptsIndent, "\", ", js.po.preprocess, ", \"\\n\", \"\");")
+        id(paste0(
+          paste0(rep("\t", level+1),collapse=""),
+          "printIndentedUnlessEmpty(\""), plotOptsIndent, "\", ", js.po.preprocess, ", \"\\n\", \"\");"
+        ),
+        level=level+1
       )
     } else {},
-    level=level, indent.by=indent.by, empty.e=empty.e
+    level=level+1, indent.by=indent.by, empty.e=empty.e
   ), sep="\n\n")
 
   # here comes the plot
   js.prnt <- paste(js.prnt, rk.paste.JS(
     rk.comment("the actual plot:"),
     rk.paste.JS(..., level=level, indent.by=indent.by, empty.e=empty.e),
-    level=level, indent.by=indent.by, empty.e=empty.e
+    level=level+1, indent.by=indent.by, empty.e=empty.e
   ), sep="\n\n")
 
   # plot options: postprocess
@@ -116,17 +121,21 @@ rk.paste.JS.graph <- function(..., plotOpts=NULL, printoutObj=NULL, level=2, ind
     if(!is.null(plotOpts)){
       rk.paste.JS(
         rk.comment("insert any option-setting code that should be run after the actual plot:"),
-        id("\t\tprintIndentedUnlessEmpty(\"", plotOptsIndent, "\", ", js.po.calculate, ", \"\\n\", \"\");")
+        id(paste0(
+          paste0(rep("\t", level+1),collapse=""),
+          "printIndentedUnlessEmpty(\""), plotOptsIndent, "\", ", js.po.calculate, ", \"\\n\", \"\");"
+        ),
+        level=level+1
       )
     } else {},
-    level=level, indent.by=indent.by, empty.e=empty.e
+    level=level+1, indent.by=indent.by, empty.e=empty.e
   ), sep="\n\n")
 
   # end try() & graph.off()
   js.prnt <- paste(js.prnt, rk.paste.JS(
     echo("\n\t})\n"),
     ite("full", echo("rk.graph.off()\n")),
-    level=level, indent.by=indent.by, empty.e=empty.e
+    level=level+1, indent.by=indent.by, empty.e=empty.e
   ), sep="\n\n")
 
   return(js.prnt)



More information about the rkward-tracker mailing list