]> mj.ucw.cz Git - paperjam.git/commitdiff
Modulo: "half" switch
authorMartin Mares <mj@ucw.cz>
Wed, 4 Apr 2018 11:29:34 +0000 (13:29 +0200)
committerMartin Mares <mj@ucw.cz>
Wed, 4 Apr 2018 11:29:34 +0000 (13:29 +0200)
TODO
cmds.cc

diff --git a/TODO b/TODO
index 8d36b9c466921a209f62fbdbd6778770d4d578e2..c958ad4daa0f9a434f85c36a707fb88e58c08a2f 100644 (file)
--- a/TODO
+++ b/TODO
@@ -39,8 +39,8 @@ cropmarks
        len=5mm         # Cross arm length
        dist=5mm        # Distance from border
 
-book
-       signature=<n>
+book
+|      signature=<n>
 
 # Crop to image box
 crop
@@ -52,8 +52,8 @@ duplex
 
 | merge
 
-modulo
-       half
+modulo
+|      half
 
 | # Add an empty page after the current one
 | add-blank
diff --git a/cmds.cc b/cmds.cc
index a0e0548eb3fb1ec3d5d814b7b464eeecfb7cb012..b12595e8b5822743da0a3362a80e9a1e7632f734 100644 (file)
--- a/cmds.cc
+++ b/cmds.cc
@@ -459,12 +459,14 @@ vector<page *> apply_cmd::process(vector<page *> &pages)
 class modulo_cmd : public cmd_exec {
   pipeline *pipe;
   int n;
+  bool half;
 public:
   modulo_cmd(cmd *c)
     {
       n = c->arg("n")->as_int(0);
       if (n <= 0)
        die("Modulo must have n > 0");
+      half = c->arg("half")->as_int(0);
       pipe = c->pipe;
     }
   vector<page *> process(vector<page *> &pages) override;
@@ -474,8 +476,9 @@ vector<page *> modulo_cmd::process(vector<page *> &pages)
 {
   vector<page *> out;
   int tuples = ((int) pages.size() + n - 1) / n;
+  int use_tuples = half ? tuples/2 : tuples;
 
-  for (int tuple=0; tuple < tuples; tuple++)
+  for (int tuple=0; tuple < use_tuples; tuple++)
     {
       debug("# Tuple %d", tuple);
       debug_indent += 4;
@@ -517,6 +520,7 @@ vector<page *> modulo_cmd::process(vector<page *> &pages)
 
 static const arg_def modulo_args[] = {
   { "n",       AT_INT | AT_MANDATORY | AT_POSITIONAL },
+  { "half",    AT_SWITCH },
   { NULL,      0 }
 };