groff-commit
[Top][All Lists]
Advanced

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

[Groff-commit] groff/src/devices/grotty tty.cpp


From: Werner LEMBERG
Subject: [Groff-commit] groff/src/devices/grotty tty.cpp
Date: Mon, 28 Mar 2005 04:13:41 -0500

CVSROOT:        /cvsroot/groff
Module name:    groff
Branch:         
Changes by:     Werner LEMBERG <address@hidden> 05/03/28 09:13:41

Modified files:
        src/devices/grotty: tty.cpp 

Log message:
        * src/devices/grotty/tty.cpp (glyph): Add width.
        (tty_printer::make_underline, tty_printer::make_bold,
        tty_printer::add_character): Add parameter to pass character width.
        Update all callers.
        (tty_printer::end_page): Increase hpos by actual character width.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/groff/groff/src/devices/grotty/tty.cpp.diff?tr1=1.10&tr2=1.11&r1=text&r2=text

Patches:
Index: groff/src/devices/grotty/tty.cpp
diff -u groff/src/devices/grotty/tty.cpp:1.10 
groff/src/devices/grotty/tty.cpp:1.11
--- groff/src/devices/grotty/tty.cpp:1.10       Sat Oct 30 11:11:00 2004
+++ groff/src/devices/grotty/tty.cpp    Mon Mar 28 09:13:41 2005
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-/* Copyright (C) 1989-2000, 2001, 2002, 2003, 2004
+/* Copyright (C) 1989-2000, 2001, 2002, 2003, 2004, 2005
    Free Software Foundation, Inc.
      Written by James Clark (address@hidden)
 
@@ -93,7 +93,7 @@
 #define SGR_REVERSE CSI "7m"
 #define SGR_NO_REVERSE CSI "27m"
 // many terminals can't handle `CSI 39 m' and `CSI 49 m' to reset
-// the foreground and bachground color, respectively; thus we use
+// the foreground and background color, respectively; we thus use
 // `CSI 0 m' exclusively
 #define SGR_DEFAULT CSI "0m"
 
@@ -155,6 +155,7 @@
   static glyph *free_list;
 public:
   glyph *next;
+  int w;
   int hpos;
   unsigned int code;
   unsigned char mode;
@@ -204,10 +205,10 @@
   int is_bold;
   int cu_flag;
   PTABLE(schar) tty_colors;
-  void make_underline();
-  void make_bold(unsigned int);
+  void make_underline(int);
+  void make_bold(unsigned int, int);
   schar color_to_idx(color *col);
-  void add_char(unsigned int, int, int, color *, color *, unsigned char);
+  void add_char(unsigned int, int, int, int, color *, color *, unsigned char);
   char *make_rgb_string(unsigned int, unsigned int, unsigned int);
   int tty_color(unsigned int, unsigned int, unsigned int, schar *,
                schar = DEFAULT_COLOR_IDX);
@@ -299,11 +300,18 @@
   a_delete lines;
 }
 
-void tty_printer::make_underline()
+void tty_printer::make_underline(int w)
 {
   if (old_drawing_scheme) {
-    putchar('_');
-    putchar('\b');
+    if (!w)
+      warning("can't underline zero-width character");
+    else {
+      int n = w / font::hor;
+      for (int i = 0; i < n; i++)
+       putchar('_');
+      for (int i = 0; i < n; i++)
+       putchar('\b');
+    }
   }
   else {
     if (!is_underline) {
@@ -318,11 +326,17 @@
   }
 }
 
-void tty_printer::make_bold(unsigned int c)
+void tty_printer::make_bold(unsigned int c, int w)
 {
   if (old_drawing_scheme) {
-    put_char(c);
-    putchar('\b');
+    if (!w)
+      warning("can't print zero-width character in bold");
+    else {
+      int n = w / font::hor;
+      put_char(c);
+      for (int i = 0; i < n; i++)
+       putchar('\b');
+    }
   }
   else {
     if (!is_bold)
@@ -349,15 +363,15 @@
 void tty_printer::set_char(int i, font *f, const environment *env,
                           int w, const char *)
 {
-  if (w != font::hor)
-    fatal("width of character not equal to horizontal resolution");
-  add_char(f->get_code(i),
+  if (w % font::hor != 0)
+    fatal("width of character not a multiple of horizontal resolution");
+  add_char(f->get_code(i), w,
           env->hpos, env->vpos,
           env->col, env->fill,
           ((tty_font *)f)->get_mode());
 }
 
-void tty_printer::add_char(unsigned int c,
+void tty_printer::add_char(unsigned int c, int w,
                           int h, int v,
                           color *fore, color *back,
                           unsigned char mode)
@@ -398,6 +412,7 @@
     cached_vpos = vpos;
   }
   glyph *g = new glyph;
+  g->w = w;
   g->hpos = hpos;
   g->code = c;
   g->fore_color_idx = color_to_idx(fore);
@@ -421,7 +436,8 @@
 void tty_printer::special(char *arg, const environment *env, char type)
 {
   if (type == 'u') {
-    add_char(*arg - '0', env->hpos, env->vpos, env->col, env->fill, CU_MODE);
+    add_char(*arg - '0', 0, env->hpos, env->vpos, env->col, env->fill,
+            CU_MODE);
     return;
   }
   if (type != 'p')
@@ -460,12 +476,12 @@
 
 void tty_printer::change_color(const environment * const env)
 {
-  add_char(0, env->hpos, env->vpos, env->col, env->fill, COLOR_CHANGE);
+  add_char(0, 0, env->hpos, env->vpos, env->col, env->fill, COLOR_CHANGE);
 }
 
 void tty_printer::change_fill_color(const environment * const env)
 {
-  add_char(0, env->hpos, env->vpos, env->col, env->fill, COLOR_CHANGE);
+  add_char(0, 0, env->hpos, env->vpos, env->col, env->fill, COLOR_CHANGE);
 }
 
 void tty_printer::draw(int code, int *p, int np, const environment *env)
@@ -485,20 +501,20 @@
       len = -len;
     }
     if (len >= 0 && len <= font::vert)
-      add_char(vline_char, env->hpos, v, env->col, env->fill,
+      add_char(vline_char, font::hor, env->hpos, v, env->col, env->fill,
               VDRAW_MODE|START_LINE|END_LINE);
     else {
-      add_char(vline_char, env->hpos, v, env->col, env->fill,
+      add_char(vline_char, font::hor, env->hpos, v, env->col, env->fill,
               VDRAW_MODE|START_LINE);
       len -= font::vert;
       v += font::vert;
       while (len > 0) {
-       add_char(vline_char, env->hpos, v, env->col, env->fill,
+       add_char(vline_char, font::hor, env->hpos, v, env->col, env->fill,
                 VDRAW_MODE|START_LINE|END_LINE);
        len -= font::vert;
        v += font::vert;
       }
-      add_char(vline_char, env->hpos, v, env->col, env->fill,
+      add_char(vline_char, font::hor, env->hpos, v, env->col, env->fill,
               VDRAW_MODE|END_LINE);
     }
   }
@@ -511,20 +527,20 @@
       len = -len;
     }
     if (len >= 0 && len <= font::hor)
-      add_char(hline_char, h, env->vpos, env->col, env->fill,
+      add_char(hline_char, font::hor, h, env->vpos, env->col, env->fill,
               HDRAW_MODE|START_LINE|END_LINE);
     else {
-      add_char(hline_char, h, env->vpos, env->col, env->fill,
+      add_char(hline_char, font::hor, h, env->vpos, env->col, env->fill,
               HDRAW_MODE|START_LINE);
       len -= font::hor;
       h += font::hor;
       while (len > 0) {
-       add_char(hline_char, h, env->vpos, env->col, env->fill,
+       add_char(hline_char, font::hor, h, env->vpos, env->col, env->fill,
                 HDRAW_MODE|START_LINE|END_LINE);
        len -= font::hor;
        h += font::hor;
       }
-      add_char(hline_char, h, env->vpos, env->col, env->fill,
+      add_char(hline_char, font::hor, h, env->vpos, env->col, env->fill,
               HDRAW_MODE|END_LINE);
     }
   }
@@ -676,7 +692,7 @@
            if (next_tab_pos > p->hpos)
              break;
            if (cu_flag)
-             make_underline();
+             make_underline(p->w);
            else if (!old_drawing_scheme && is_underline) {
              if (italic_flag)
                putstring(SGR_NO_ITALIC);
@@ -692,7 +708,7 @@
        }
        for (; hpos < p->hpos; hpos++) {
          if (cu_flag)
-           make_underline();
+           make_underline(p->w);
          else if (!old_drawing_scheme && is_underline) {
            if (italic_flag)
              putstring(SGR_NO_ITALIC);
@@ -720,7 +736,7 @@
        continue;
       }
       if (p->mode & UNDERLINE_MODE)
-       make_underline();
+       make_underline(p->w);
       else if (!old_drawing_scheme && is_underline) {
        if (italic_flag)
          putstring(SGR_NO_ITALIC);
@@ -731,7 +747,7 @@
        is_underline = 0;
       }
       if (p->mode & BOLD_MODE)
-       make_bold(p->code);
+       make_bold(p->code, p->w);
       else if (!old_drawing_scheme && is_bold) {
        putstring(SGR_NO_BOLD);
        is_bold = 0;
@@ -747,7 +763,7 @@
        }
       }
       put_char(p->code);
-      hpos++;
+      hpos += p->w / font::hor;
     }
     if (!old_drawing_scheme
        && (is_bold || is_underline




reply via email to

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