]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
roberts faxcover patch - Robert Colquhoun(rjc@trump.net.au)
authorRobert Colquhoun <rjc@trump.net.au>
Thu, 7 Jan 1999 07:01:03 +0000 (07:01 +0000)
committerRobert Colquhoun <rjc@trump.net.au>
Thu, 7 Jan 1999 07:01:03 +0000 (07:01 +0000)
Fixes the comments field on faxcover page(some work still needs to
be done on this so that the commentsX params work as well)

faxcover/faxcover.c++
faxcover/faxcover.ps

index f45fcc64808d8b058665d68a70ec1d61f3fb7250..b5540cf11fd5b780387e3cccc5c95ba9edc4ea1b 100644 (file)
@@ -194,37 +194,37 @@ faxCoverApp::usage()
 
 const char* faxCoverApp::prologue = "\
 /wordbreak ( ) def\n\
-/BreakIntoLines\n\
-{ /proc exch def\n\
-  /linewidth exch def\n\
-  /textstring exch def\n\
-  /breakwidth wordbreak stringwidth pop def\n\
-  /curwidth 0 def\n\
-  /lastwordbreak 0 def\n\
-  /startchar 0 def\n\
-  /restoftext textstring def\n\
-  { restoftext wordbreak search\n\
-    { /nextword exch def pop\n\
-      /restoftext exch def\n\
-      /wordwidth nextword stringwidth pop def\n\
-      curwidth wordwidth add linewidth gt\n\
-      { textstring startchar\n\
-       lastwordbreak startchar sub\n\
-       getinterval proc\n\
-       /startchar lastwordbreak def\n\
-       /curwidth wordwidth breakwidth add def }\n\
-      { /curwidth curwidth wordwidth add\n\
-       breakwidth add def\n\
-      } ifelse\n\
-      /lastwordbreak lastwordbreak\n\
-      nextword length add 1 add def\n\
-    }\n\
-    { pop exit }\n\
-    ifelse\n\
-  } loop\n\
-  /lastchar textstring length def\n\
-  textstring startchar lastchar startchar sub\n\
-  getinterval proc\n\
+/linebreak (\\n) def\n\
+/doLine {\n\
+% <line> <width> <height> <x> <y> doLine <width> <height> <x> <y>\n\
+    2 copy moveto 5 -1 roll\n\
+    wordbreak\n\
+    {\n\
+        search {\n\
+            dup stringwidth pop currentpoint pop add 7 index 6 index add gt {\n\
+                6 3 roll 2 index sub 2 copy moveto 6 3 roll\n\
+            } if\n\
+            show wordbreak show\n\
+        }{\n\
+            dup stringwidth pop currentpoint pop add 5 index 4 index add gt {\n\
+                3 1 roll 3 index sub 2 copy moveto 3 -1 roll\n\
+            } if\n\
+            show exit\n\
+        } ifelse\n\
+    } loop\n\
+    2 index sub 2 copy moveto\n\
+} def\n\
+/BreakIntoLines {\n\
+% <width> <height> <x> <y> <text> BreakIntoLines\n\
+    linebreak\n\
+    {\n\
+         search {\n\
+             7 3 roll doLine 6 -2 roll\n\
+         }{\n\
+             5 1 roll doLine exit\n\
+         } ifelse\n\
+    } loop\n\
+    pop pop pop pop\n\
 } def\n\
 ";
 
@@ -332,39 +332,15 @@ void
 faxCoverApp::emitCommentDefs()
 {
     /*
-     * Break comment string into multiple lines (if needed).
+     * Fix up new line characters.
      */
-    coverDef("comments", comments);
-    int line = 1;
-    while (comments.length() > 0) {
-       // strip leading white space
-       while (comments.length() > 0 && isspace(comments[0]))
-           comments.remove(0);
-       int len = fxmin(comments.length(), (u_int) 35);
-       if (len == 35 && !isspace(comments[len-1])) {// break on word boundary
-           int l = len-1;
-           for (; l > 1 && !isspace(comments[l-1]); l--)
-               ;
-           if (l > 0)
-               len = l;
-           // otherwise, break in the middle of this really long word
-       }
-      int tot = comments.length();
-      u_int crlf = comments.find(0, "\\n", (u_int) 0);
-      if ( crlf < comments.length() && crlf < len ) {
-              len = crlf;
-      }
-       fxStr num(line, "%u");
-       coverDef("comments" | num, comments.cut(0,len));
-      if ( crlf < tot && comments.length() >= 2 ) {
-              comments.cut(0, 2);
-      }
-       line++;
-    }
-    for (; line < maxcomments; line++) {
-       fxStr num(line, "%u");
-       coverDef("comments" | num, "");
+    u_int crlf = comments.find(0, "\\n", (u_int) 0);
+    while ( crlf < comments.length()) {
+        comments.remove(crlf, 2);
+        comments.insert('\n', crlf);
+        crlf = comments.find(0, "\\n", (u_int) 0);
     }
+    coverDef("comments", comments);
 }
 
 void
index 1c3564c7501eb06ca12f61b6f0ef79d4fdd42739..e8a80b6bca1ae51c1ff75262bd70fda38fa2a30b 100644 (file)
@@ -267,7 +267,7 @@ drawtext
 /rule (_______________________________) def
 /y 189 def /x 141.336 def
 y -29 73 { x exch M rule S } for
-comments rule stringwidth pop { x y M S /y y 29 sub def } BreakIntoLines
+rule stringwidth pop 29 x y comments BreakIntoLines
 grestore
 grestore
 showpage