From: Martin Mares Date: Wed, 4 Apr 2018 11:29:34 +0000 (+0200) Subject: Modulo: "half" switch X-Git-Tag: v0.1~22 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=25f568d3a03f22752ea0df18459388104ef54fa4;p=paperjam.git Modulo: "half" switch --- diff --git a/TODO b/TODO index 8d36b9c..c958ad4 100644 --- a/TODO +++ b/TODO @@ -39,8 +39,8 @@ cropmarks len=5mm # Cross arm length dist=5mm # Distance from border -book - signature= +| book +| signature= # 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 a0e0548..b12595e 100644 --- a/cmds.cc +++ b/cmds.cc @@ -459,12 +459,14 @@ vector apply_cmd::process(vector &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 process(vector &pages) override; @@ -474,8 +476,9 @@ vector modulo_cmd::process(vector &pages) { vector 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 modulo_cmd::process(vector &pages) static const arg_def modulo_args[] = { { "n", AT_INT | AT_MANDATORY | AT_POSITIONAL }, + { "half", AT_SWITCH }, { NULL, 0 } };