groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff-commit] groff ChangeLog NEWS src/devices/grotty/grotty....


From: Werner LEMBERG
Subject: [Groff-commit] groff ChangeLog NEWS src/devices/grotty/grotty....
Date: Thu, 29 Jun 2006 08:51:23 +0000

CVSROOT:        /cvsroot/groff
Module name:    groff
Changes by:     Werner LEMBERG <wl>     06/06/29 08:51:23

Modified files:
        .              : ChangeLog NEWS 
        src/devices/grotty: grotty.man tty.cpp 

Log message:
        Add support for \D'p...' to grotty.
        
        * src/devices/grotty/grotty.cpp (tty_printer::draw): Move most of
        its code to...
        (tty_printer::line): This function.
        (tty_printer::draw): Rewritten; just call either draw_line or
        draw_polygon.
        (tty_printer::draw_line, tty_printer::draw_polygon): New functions.
        
        * src/devices/grotty/grotty.man, NEWS: Document it.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/groff/ChangeLog?cvsroot=groff&r1=1.972&r2=1.973
http://cvs.savannah.gnu.org/viewcvs/groff/NEWS?cvsroot=groff&r1=1.215&r2=1.216
http://cvs.savannah.gnu.org/viewcvs/groff/src/devices/grotty/grotty.man?cvsroot=groff&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/groff/src/devices/grotty/tty.cpp?cvsroot=groff&r1=1.17&r2=1.18

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/groff/groff/ChangeLog,v
retrieving revision 1.972
retrieving revision 1.973
diff -u -b -r1.972 -r1.973
--- ChangeLog   27 Jun 2006 17:37:18 -0000      1.972
+++ ChangeLog   29 Jun 2006 08:51:22 -0000      1.973
@@ -1,3 +1,16 @@
+2006-06-28  Werner LEMBERG  <address@hidden>
+
+       Add support for \D'p...' to grotty.
+
+       * src/devices/grotty/grotty.cpp (tty_printer::draw): Move most of
+       its code to...
+       (tty_printer::line): This function.
+       (tty_printer::draw): Rewritten; just call either draw_line or
+       draw_polygon.
+       (tty_printer::draw_line, tty_printer::draw_polygon): New functions.
+
+       * src/devices/grotty/grotty.man, NEWS: Document it.
+
 2006-06-27  Werner LEMBERG  <address@hidden>
 
        * src/preproc/refer/command.h (have_bibliography): New variable
@@ -198,7 +211,7 @@
 
 2006-03-27  Werner LEMBERG  <address@hidden>
 
-       Add two request `.device' and `.devicem' which are equivalent to
+       Add two requests `.device' and `.devicem' which are equivalent to
        `\X' and `\Y', respectively.
 
        * src/roff/troff/input.cpp (device_request, device_macro_request):

Index: NEWS
===================================================================
RCS file: /cvsroot/groff/groff/NEWS,v
retrieving revision 1.215
retrieving revision 1.216
diff -u -b -r1.215 -r1.216
--- NEWS        1 May 2006 08:37:13 -0000       1.215
+++ NEWS        29 Jun 2006 08:51:22 -0000      1.216
@@ -41,6 +41,12 @@
   of x, this is, it rounds towards zero and not towards the next integer
   less than or equal to x.
 
+Grotty
+------
+
+o \D'p...' is now supported if the polygon consists entirely of horizontal
+   and vertical lines.
+
 Afmtodit
 --------
 

Index: src/devices/grotty/grotty.man
===================================================================
RCS file: /cvsroot/groff/groff/src/devices/grotty/grotty.man,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- src/devices/grotty/grotty.man       17 Oct 2005 07:06:42 -0000      1.18
+++ src/devices/grotty/grotty.man       29 Jun 2006 08:51:22 -0000      1.19
@@ -1,5 +1,6 @@
 .ig
-Copyright (C) 1989-2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
+Copyright (C) 1989-2000, 2001, 2002, 2003, 2005, 2006
+  Free Software Foundation, Inc.
 
 Permission is granted to make and distribute verbatim copies of
 this manual provided the copyright notice and this permission notice
@@ -64,10 +65,10 @@
 on EBCDIC based hosts.
 If no files are given,
 .B grotty
-will read the standard input.
+reads the standard input.
 A filename of
 .B \-
-will also cause
+also causes
 .B grotty
 to read the standard input.
 Output is written to the standard output.
@@ -189,11 +190,11 @@
 If the 01 bit in
 .I n
 is set,
-then the font will be treated as an italic font;
+then the font is treated as an italic font;
 if the 02 bit is set,
-then it will be treated as a bold font.
+then it is treated as a bold font.
 The code field in the font description field gives the
-code which will be used to output the character.
+code which is used to output the character.
 This code can also be used in the
 .B \[rs]N
 escape sequence in
@@ -231,7 +232,7 @@
 commands.
 Without this
 .B grotty
-will render
+renders
 .B \[rs]D'l\|.\|.\|.\&'
 commands that have at least one zero argument
 (and so are either horizontal or vertical)
@@ -241,11 +242,17 @@
 and
 .B +
 characters.
+In a similar way,
+.B grotty
+handles
+.B \[rs]D'p\|.\|.\|.\&'
+commands which consist entirely of horizontal and vertical lines.
+.
 .
 .TP
 .B \-f
 Use form feeds in the output.
-A form feed will be output at the end of each page that has no output
+A form feed is output at the end of each page that has no output
 on its last line.
 .
 .TP
@@ -406,7 +413,7 @@
 .LP
 Note that on EBCDIC hosts, only files for the
 .B cp1047
-device will be installed.
+device is installed.
 .
 .
 .

Index: src/devices/grotty/tty.cpp
===================================================================
RCS file: /cvsroot/groff/groff/src/devices/grotty/tty.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- src/devices/grotty/tty.cpp  23 Feb 2006 20:00:47 -0000      1.17
+++ src/devices/grotty/tty.cpp  29 Jun 2006 08:51:23 -0000      1.18
@@ -216,6 +216,9 @@
   char *make_rgb_string(unsigned int, unsigned int, unsigned int);
   int tty_color(unsigned int, unsigned int, unsigned int, schar *,
                schar = DEFAULT_COLOR_IDX);
+  void line(int, int, int, int, color *, color *);
+  void draw_line(int *, int, const environment *);
+  void draw_polygon(int *, int, const environment *);
 public:
   tty_printer(const char *);
   ~tty_printer();
@@ -490,61 +493,110 @@
 
 void tty_printer::draw(int code, int *p, int np, const environment *env)
 {
-  if (code != 'l' || !draw_flag)
+  if (!draw_flag)
     return;
+  if (code == 'l')
+    draw_line(p, np, env);
+  if (code == 'p')
+    draw_polygon(p, np, env);
+}
+
+void tty_printer::draw_polygon(int *p, int np, const environment *env)
+{
+  if (np & 1) {
+    error("even number of arguments required for polygon");
+    return;
+  }
+  if (np == 0) {
+    error("no arguments for polygon");
+    return;
+  }
+  // We only draw polygons which consist entirely of horizontal and
+  // vertical lines.
+  int hpos = 0;
+  int vpos = 0;
+  for (int i = 0; i < np; i += 2) {
+    if (!(p[i] == 0 || p[i + 1] == 0))
+      return;
+    hpos += p[i];
+    vpos += p[i + 1];
+  }
+  if (!(hpos == 0 || vpos == 0))
+    return;
+  int start_hpos = env->hpos;
+  int start_vpos = env->vpos;
+  hpos = start_hpos;
+  vpos = start_vpos;
+  for (int i = 0; i < np; i += 2) {
+    line(hpos, vpos, p[i], p[i + 1], env->col, env->fill);
+    hpos += p[i];
+    vpos += p[i + 1];
+  }
+  line(hpos, vpos, start_hpos - hpos, start_vpos - vpos,
+       env->col, env->fill);
+}
+
+void tty_printer::draw_line(int *p, int np, const environment *env)
+{
   if (np != 2) {
     error("2 arguments required for line");
     return;
   }
-  if (p[0] == 0) {
+  line(env->hpos, env->vpos, p[0], p[1], env->col, env->fill);
+}
+
+void tty_printer::line(int hpos, int vpos, int dx, int dy,
+                      color *col, color *fill)
+{
+  if (dx == 0) {
     // vertical line
-    int v = env->vpos;
-    int len = p[1];
+    int v = vpos;
+    int len = dy;
     if (len < 0) {
       v += len;
       len = -len;
     }
     if (len >= 0 && len <= font::vert)
-      add_char(vline_char, font::hor, env->hpos, v, env->col, env->fill,
+      add_char(vline_char, font::hor, hpos, v, col, fill,
               VDRAW_MODE|START_LINE|END_LINE);
     else {
-      add_char(vline_char, font::hor, env->hpos, v, env->col, env->fill,
+      add_char(vline_char, font::hor, hpos, v, col, fill,
               VDRAW_MODE|START_LINE);
       len -= font::vert;
       v += font::vert;
       while (len > 0) {
-       add_char(vline_char, font::hor, env->hpos, v, env->col, env->fill,
+       add_char(vline_char, font::hor, hpos, v, col, fill,
                 VDRAW_MODE|START_LINE|END_LINE);
        len -= font::vert;
        v += font::vert;
       }
-      add_char(vline_char, font::hor, env->hpos, v, env->col, env->fill,
+      add_char(vline_char, font::hor, hpos, v, col, fill,
               VDRAW_MODE|END_LINE);
     }
   }
-  if (p[1] == 0) {
+  if (dy == 0) {
     // horizontal line
-    int h = env->hpos;
-    int len = p[0];
+    int h = hpos;
+    int len = dx;
     if (len < 0) {
       h += len;
       len = -len;
     }
     if (len >= 0 && len <= font::hor)
-      add_char(hline_char, font::hor, h, env->vpos, env->col, env->fill,
+      add_char(hline_char, font::hor, h, vpos, col, fill,
               HDRAW_MODE|START_LINE|END_LINE);
     else {
-      add_char(hline_char, font::hor, h, env->vpos, env->col, env->fill,
+      add_char(hline_char, font::hor, h, vpos, col, fill,
               HDRAW_MODE|START_LINE);
       len -= font::hor;
       h += font::hor;
       while (len > 0) {
-       add_char(hline_char, font::hor, h, env->vpos, env->col, env->fill,
+       add_char(hline_char, font::hor, h, vpos, col, fill,
                 HDRAW_MODE|START_LINE|END_LINE);
        len -= font::hor;
        h += font::hor;
       }
-      add_char(hline_char, font::hor, h, env->vpos, env->col, env->fill,
+      add_char(hline_char, font::hor, h, vpos, col, fill,
               HDRAW_MODE|END_LINE);
     }
   }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]