[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 09/28: [troff]: Trivially refactor.
From: |
G. Branden Robinson |
Subject: |
[groff] 09/28: [troff]: Trivially refactor. |
Date: |
Sat, 7 Sep 2024 21:36:46 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit d47b4b6ee4c5c058481839831950bbe7f4741bcc
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Sep 4 05:59:45 2024 -0500
[troff]: Trivially refactor.
...renaming internal symbols matching `glyph_color` to `stroke_color`;
the latter is what our documentation uses, and the glyph color is
applied to things other than glyphs--the outlines of geometric figures.
* src/roff/troff/env.h (class environment): Rename member variables and
functions in declarations.
`glyph_color` -> `stroke_color`
`prev_glyph_color` -> `prev_stroke_color`
`get_glyph_color` -> `get_stroke_color`
`get_prev_glyph_color` -> `get_prev_stroke_color`
`set_glyph_color` -> `set_stroke_color`
* src/roff/troff/env.cpp: Migrate. Update member function definitions
accordingly.
(environment::environment): Update constructors.
(environment::copy): Update back end of `evc` (_not_ a copy
constructor).
(glyph_color_change): Rename this...
(stroke_color_change): ...to this.
(title, environment::get_stroke_color_string): Update accesses to
member variables.
(init_env_requests): Wire up `gcolor` request to
`stroke_color_change()`. Wire up `.m` register to
`get_stroke_color_string()`.
* src/roff/troff/input.h: Migrate declaration.
(do_glyph_color): Rename this...
(do_stroke_color): Rename this...
* src/roff/troff/input.cpp: Migrate.
(do_stroke_color): Use new member function name `set_stroke_color()`.
(token::next): Wire up `\m` escape sequence to `do_stroke_color()`.
(read_drawing_command): Construct node using `get_stroke_color()`.
---
ChangeLog | 40 ++++++++++++++++++++++++++++++++++++
src/libs/libdriver/input.cpp | 2 +-
src/roff/troff/env.cpp | 44 ++++++++++++++++++++--------------------
src/roff/troff/env.h | 12 +++++------
src/roff/troff/input.cpp | 12 +++++------
src/roff/troff/input.h | 2 +-
src/roff/troff/node.cpp | 48 ++++++++++++++++++++++----------------------
src/roff/troff/node.h | 2 +-
8 files changed, 101 insertions(+), 61 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index baadd9031..20c62455b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,43 @@
+2024-09-04 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [troff]: Trivially refactor, renaming internal symbols matching
+ `glyph_color` to `stroke_color`; the latter is what our
+ documentation uses, and the glyph color is applied to things
+ other than glyphs--the outlines of geometric figures.
+
+ * src/roff/troff/env.h (class environment): Rename member
+ variables and functions in declarations.
+ `glyph_color` -> `stroke_color`
+ `prev_glyph_color` -> `prev_stroke_color`
+ `get_glyph_color` -> `get_stroke_color`
+ `get_prev_glyph_color` -> `get_prev_stroke_color`
+ `set_glyph_color` -> `set_stroke_color`
+
+ * src/roff/troff/env.cpp: Migrate. Update member function
+ definitions accordingly.
+ (environment::environment): Update constructors.
+ (environment::copy): Update back end of `evc` (_not_ a copy
+ constructor).
+ (glyph_color_change): Rename this...
+ (stroke_color_change): ...to this.
+ (title, environment::get_stroke_color_string): Update accesses
+ to member variables.
+ (init_env_requests): Wire up `gcolor` request to
+ `stroke_color_change()`. Wire up `.m` register to
+ `get_stroke_color_string()`.
+
+ * src/roff/troff/input.h: Migrate declaration.
+ (do_glyph_color): Rename this...
+ (do_stroke_color): Rename this...
+
+ * src/roff/troff/input.cpp: Migrate.
+ (do_stroke_color): Use new member function name
+ `set_stroke_color()`.
+ (token::next): Wire up `\m` escape sequence to
+ `do_stroke_color()`.
+ (read_drawing_command): Construct node using
+ `get_stroke_color()`.
+
2024-09-04 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/roff/troff/reg.cpp (assign_register_format_request):
diff --git a/src/libs/libdriver/input.cpp b/src/libs/libdriver/input.cpp
index 99089adb8..268469989 100644
--- a/src/libs/libdriver/input.cpp
+++ b/src/libs/libdriver/input.cpp
@@ -1740,7 +1740,7 @@ do_file(const char *filename)
fatal_command(command);
current_env->hpos = (EnvInt) get_integer_arg();
break;
- case 'm': // m: glyph color
+ case 'm': // m: stroke color
parse_color_command(current_env->col);
pr->change_color(current_env);
break;
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index d0af518e7..7f86b0586 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -673,14 +673,14 @@ void environment::set_char_slant(int n)
char_slant = n;
}
-color *environment::get_prev_glyph_color()
+color *environment::get_prev_stroke_color()
{
- return prev_glyph_color;
+ return prev_stroke_color;
}
-color *environment::get_glyph_color()
+color *environment::get_stroke_color()
{
- return glyph_color;
+ return stroke_color;
}
color *environment::get_prev_fill_color()
@@ -693,12 +693,12 @@ color *environment::get_fill_color()
return fill_color;
}
-void environment::set_glyph_color(color *c)
+void environment::set_stroke_color(color *c)
{
if (line_interrupted)
return;
- curenv->prev_glyph_color = curenv->glyph_color;
- curenv->glyph_color = c;
+ curenv->prev_stroke_color = curenv->stroke_color;
+ curenv->stroke_color = c;
}
void environment::set_fill_color(color *c)
@@ -775,8 +775,8 @@ environment::environment(symbol nm)
#ifdef WIDOW_CONTROL
want_widow_control(false),
#endif /* WIDOW_CONTROL */
- glyph_color(&default_color),
- prev_glyph_color(&default_color),
+ stroke_color(&default_color),
+ prev_stroke_color(&default_color),
fill_color(&default_color),
prev_fill_color(&default_color),
control_character('.'),
@@ -869,8 +869,8 @@ environment::environment(const environment *e)
#ifdef WIDOW_CONTROL
want_widow_control(e->want_widow_control),
#endif /* WIDOW_CONTROL */
- glyph_color(e->glyph_color),
- prev_glyph_color(e->prev_glyph_color),
+ stroke_color(e->stroke_color),
+ prev_stroke_color(e->prev_stroke_color),
fill_color(e->fill_color),
prev_fill_color(e->prev_fill_color),
control_character(e->control_character),
@@ -961,8 +961,8 @@ void environment::copy(const environment *e)
hyphenation_space = e->hyphenation_space;
hyphenation_margin = e->hyphenation_margin;
composite = false;
- glyph_color= e->glyph_color;
- prev_glyph_color = e->prev_glyph_color;
+ stroke_color= e->stroke_color;
+ prev_stroke_color = e->prev_stroke_color;
fill_color = e->fill_color;
prev_fill_color = e->prev_fill_color;
}
@@ -1279,13 +1279,13 @@ void fill_color_change()
skip_line();
}
-void glyph_color_change()
+void stroke_color_change()
{
symbol s = get_name();
if (s.is_null())
- curenv->set_glyph_color(curenv->get_prev_glyph_color());
+ curenv->set_stroke_color(curenv->get_prev_stroke_color());
else
- do_glyph_color(s);
+ do_stroke_color(s);
skip_line();
}
@@ -2625,8 +2625,8 @@ void title()
curenv->char_slant = env.char_slant;
curenv->fontno = env.fontno;
curenv->prev_fontno = env.prev_fontno;
- curenv->glyph_color = env.glyph_color;
- curenv->prev_glyph_color = env.prev_glyph_color;
+ curenv->stroke_color = env.stroke_color;
+ curenv->prev_stroke_color = env.prev_stroke_color;
curenv->fill_color = env.fill_color;
curenv->prev_fill_color = env.prev_fill_color;
node *nd = 0 /* nullptr */;
@@ -3355,9 +3355,9 @@ const char *environment::get_font_family_string()
return family->nm.contents();
}
-const char *environment::get_glyph_color_string()
+const char *environment::get_stroke_color_string()
{
- return glyph_color->nm.contents();
+ return stroke_color->nm.contents();
}
const char *environment::get_fill_color_string()
@@ -4194,7 +4194,7 @@ void init_env_requests()
init_request("fi", fill);
init_request("fcolor", fill_color_change);
init_request("ft", select_font);
- init_request("gcolor", glyph_color_change);
+ init_request("gcolor", stroke_color_change);
init_request("hc", hyphen_char);
init_request("hla", select_hyphenation_language);
init_request("hlm", hyphen_line_max_request);
@@ -4263,7 +4263,7 @@ void init_env_requests()
init_hunits_env_reg(".l", get_line_length);
init_hunits_env_reg(".ll", get_saved_line_length);
init_string_env_reg(".M", get_fill_color_string);
- init_string_env_reg(".m", get_glyph_color_string);
+ init_string_env_reg(".m", get_stroke_color_string);
init_hunits_env_reg(".n", get_prev_text_length);
init_int_env_reg(".nm", get_numbering_nodes);
init_int_env_reg(".nn", get_no_number_count);
diff --git a/src/roff/troff/env.h b/src/roff/troff/env.h
index 3052cb50e..350e52dd8 100644
--- a/src/roff/troff/env.h
+++ b/src/roff/troff/env.h
@@ -223,8 +223,8 @@ class environment {
#ifdef WIDOW_CONTROL
bool want_widow_control;
#endif /* WIDOW_CONTROL */
- color *glyph_color;
- color *prev_glyph_color;
+ color *stroke_color;
+ color *prev_stroke_color;
color *fill_color;
color *prev_fill_color;
unsigned char control_character;
@@ -326,10 +326,10 @@ public:
int get_no_number_count();
int get_prev_line_interrupted() { return prev_line_interrupted; }
color *get_fill_color();
- color *get_glyph_color();
- color *get_prev_glyph_color();
+ color *get_stroke_color();
+ color *get_prev_stroke_color();
color *get_prev_fill_color();
- void set_glyph_color(color *c);
+ void set_stroke_color(color *c);
void set_fill_color(color *c);
node *make_char_node(charinfo *);
node *extract_output_line();
@@ -358,7 +358,7 @@ public:
void space();
void space(hunits, hunits);
void space_newline();
- const char *get_glyph_color_string();
+ const char *get_stroke_color_string();
const char *get_fill_color_string();
const char *get_font_family_string();
const char *get_font_name_string();
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 4b5fa9616..c329a1bab 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -1328,22 +1328,22 @@ static color *lookup_color(symbol nm)
return c;
}
-void do_glyph_color(symbol nm)
+void do_stroke_color(symbol nm) // \m
{
if (nm.is_null())
return;
if (nm.is_empty())
- curenv->set_glyph_color(curenv->get_prev_glyph_color());
+ curenv->set_stroke_color(curenv->get_prev_stroke_color());
else {
color *tem = lookup_color(nm);
if (tem)
- curenv->set_glyph_color(tem);
+ curenv->set_stroke_color(tem);
else
(void) color_dictionary.lookup(nm, new color(nm));
}
}
-void do_fill_color(symbol nm)
+void do_fill_color(symbol nm) // \M
{
if (nm.is_null())
return;
@@ -2338,7 +2338,7 @@ void token::next()
return;
}
case 'm':
- do_glyph_color(read_escape_parameter(ALLOW_EMPTY));
+ do_stroke_color(read_escape_parameter(ALLOW_EMPTY));
if (!want_att_compat)
have_formattable_input = true;
break;
@@ -9254,7 +9254,7 @@ static node *read_drawing_command()
}
draw_node *dn = new draw_node(type, point, npoints,
curenv->get_font_size(),
- curenv->get_glyph_color(),
+ curenv->get_stroke_color(),
curenv->get_fill_color());
delete[] point;
return dn;
diff --git a/src/roff/troff/input.h b/src/roff/troff/input.h
index 32b3421a6..ca0855991 100644
--- a/src/roff/troff/input.h
+++ b/src/roff/troff/input.h
@@ -63,7 +63,7 @@ const int DOUBLE_QUOTE = 0216;
const int INPUT_NO_BREAK_SPACE = 0240;
const int INPUT_SOFT_HYPHEN= 0255;
-extern void do_glyph_color(symbol);
+extern void do_stroke_color(symbol);
extern void do_fill_color(symbol);
extern bool suppress_push;
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 84128bb82..2436e543d 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -796,7 +796,7 @@ class troff_output_file : public real_output_file {
int current_height;
tfont *current_tfont;
color *current_fill_color;
- color *current_glyph_color;
+ color *current_stroke_color;
int current_font_number;
symbol *font_position;
int nfont_positions;
@@ -841,7 +841,7 @@ public:
void draw(char, hvpair *, int, font_size, color *, color *);
void determine_line_limits (char code, hvpair *point, int npoints);
void check_charinfo(tfont *tf, charinfo *ci);
- void glyph_color(color *c);
+ void stroke_color(color *c);
void fill_color(color *c);
int get_hpos() { return hpos; }
int get_vpos() { return vpos; }
@@ -890,7 +890,7 @@ void troff_output_file::start_special(tfont *tf, color
*gcol,
bool omit_command_prefix)
{
set_font(tf);
- glyph_color(gcol);
+ stroke_color(gcol);
fill_color(fcol);
flush_tbuf();
do_motion();
@@ -1077,7 +1077,7 @@ void troff_output_file::put_char_width(charinfo *ci,
tfont *tf,
set_font(tf);
unsigned char c = ci->get_ascii_code();
if (c == '\0') {
- glyph_color(gcol);
+ stroke_color(gcol);
fill_color(fcol);
flush_tbuf();
do_motion();
@@ -1101,7 +1101,7 @@ void troff_output_file::put_char_width(charinfo *ci,
tfont *tf,
}
else if (device_has_tcommand) {
if (tbuf_len > 0 && hpos == output_hpos && vpos == output_vpos
- && (!gcol || gcol == current_glyph_color)
+ && (!gcol || gcol == current_stroke_color)
&& (!fcol || fcol == current_fill_color)
&& kk == tbuf_kern
&& tbuf_len < TBUF_SIZE) {
@@ -1111,7 +1111,7 @@ void troff_output_file::put_char_width(charinfo *ci,
tfont *tf,
hpos = output_hpos;
return;
}
- glyph_color(gcol);
+ stroke_color(gcol);
fill_color(fcol);
flush_tbuf();
do_motion();
@@ -1127,7 +1127,7 @@ void troff_output_file::put_char_width(charinfo *ci,
tfont *tf,
check_charinfo(tf, ci);
// check_output_limits(output_hpos, output_vpos);
if (vpos == output_vpos
- && (!gcol || gcol == current_glyph_color)
+ && (!gcol || gcol == current_stroke_color)
&& (!fcol || fcol == current_fill_color)
&& (n > 0) && (n < 100) && !must_update_drawing_position) {
put(char(n / 10 + '0'));
@@ -1136,7 +1136,7 @@ void troff_output_file::put_char_width(charinfo *ci,
tfont *tf,
output_hpos = hpos;
}
else {
- glyph_color(gcol);
+ stroke_color(gcol);
fill_color(fcol);
do_motion();
put('c');
@@ -1155,7 +1155,7 @@ void troff_output_file::put_char(charinfo *ci, tfont *tf,
set_font(tf);
unsigned char c = ci->get_ascii_code();
if (c == '\0') {
- glyph_color(gcol);
+ stroke_color(gcol);
fill_color(fcol);
flush_tbuf();
do_motion();
@@ -1178,7 +1178,7 @@ void troff_output_file::put_char(charinfo *ci, tfont *tf,
else {
int n = hpos - output_hpos;
if (vpos == output_vpos
- && (!gcol || gcol == current_glyph_color)
+ && (!gcol || gcol == current_stroke_color)
&& (!fcol || fcol == current_fill_color)
&& n > 0 && n < 100) {
put(char(n/10 + '0'));
@@ -1187,7 +1187,7 @@ void troff_output_file::put_char(charinfo *ci, tfont *tf,
output_hpos = hpos;
}
else {
- glyph_color(gcol);
+ stroke_color(gcol);
fill_color(fcol);
flush_tbuf();
do_motion();
@@ -1315,13 +1315,13 @@ void troff_output_file::fill_color(color *col)
put('\n');
}
-// glyph_color calls 'flush_tbuf' and 'do_motion' if necessary.
+// stroke_color calls 'flush_tbuf' and 'do_motion' if necessary.
-void troff_output_file::glyph_color(color *col)
+void troff_output_file::stroke_color(color *col)
{
- if (!col || current_glyph_color == col)
+ if (!col || current_stroke_color == col)
return;
- current_glyph_color = col;
+ current_stroke_color = col;
if (!want_color_output)
return;
flush_tbuf();
@@ -1470,7 +1470,7 @@ void troff_output_file::draw(char code, hvpair *point,
int npoints,
font_size fsize, color *gcol, color *fcol)
{
int i;
- glyph_color(gcol);
+ stroke_color(gcol);
fill_color(fcol);
flush_tbuf();
do_motion();
@@ -1612,7 +1612,7 @@ void troff_output_file::trailer(vunits page_length)
troff_output_file::troff_output_file()
: current_slant(0), current_height(0), current_fill_color(0),
- current_glyph_color(0), nfont_positions(10), tbuf_len(0),
+ current_stroke_color(0), nfont_positions(10), tbuf_len(0),
has_page_begun(false), cur_div_level(0)
{
font_position = new symbol[nfont_positions];
@@ -1902,7 +1902,7 @@ public:
hunits skew();
hyphenation_type get_hyphenation_type();
tfont *get_tfont();
- color *get_glyph_color();
+ color *get_stroke_color();
color *get_fill_color();
void tprint(troff_output_file *);
void zero_width_tprint(troff_output_file *);
@@ -2086,12 +2086,12 @@ tfont *glyph_node::get_tfont()
return tf;
}
-color *node::get_glyph_color()
+color *node::get_stroke_color()
{
return 0;
}
-color *glyph_node::get_glyph_color()
+color *glyph_node::get_stroke_color()
{
return gcol;
}
@@ -2342,7 +2342,7 @@ node *kern_pair_node::add_discretionary_hyphen()
tfont *tf = n1->get_tfont();
if (tf) {
if (tf->contains(soft_hyphen_char)) {
- color *gcol = n2->get_glyph_color();
+ color *gcol = n2->get_stroke_color();
color *fcol = n2->get_fill_color();
node *next1 = next;
next = 0;
@@ -2489,7 +2489,7 @@ node *node::add_discretionary_hyphen()
if (!tf)
return new hyphen_inhibitor_node(this);
if (tf->contains(soft_hyphen_char)) {
- color *gcol = get_glyph_color();
+ color *gcol = get_stroke_color();
color *fcol = get_fill_color();
node *next1 = next;
next = 0;
@@ -3896,7 +3896,7 @@ special_node::special_node(const macro &m, bool b)
tf = font_table[fontno]->get_tfont(fs, char_height, char_slant, fontno);
if (curenv->is_composite())
tf = tf->get_plain();
- gcol = curenv->get_glyph_color();
+ gcol = curenv->get_stroke_color();
fcol = curenv->get_fill_color();
is_special = 1;
}
@@ -5063,7 +5063,7 @@ static node *make_glyph_node(charinfo *s, environment
*env,
tfont *tf = font_table[fontno]->get_tfont(fs, char_height, char_slant, fn);
if (env->is_composite())
tf = tf->get_plain();
- color *gcol = env->get_glyph_color();
+ color *gcol = env->get_stroke_color();
color *fcol = env->get_fill_color();
return new glyph_node(s, tf, gcol, fcol, 0, 0);
}
diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h
index f781ec537..2ae451142 100644
--- a/src/roff/troff/node.h
+++ b/src/roff/troff/node.h
@@ -106,7 +106,7 @@ struct node {
virtual node *merge_glyph_node(glyph_node *);
virtual tfont *get_tfont();
- virtual color *get_glyph_color();
+ virtual color *get_stroke_color();
virtual color *get_fill_color();
virtual void tprint(troff_output_file *);
virtual void zero_width_tprint(troff_output_file *);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 09/28: [troff]: Trivially refactor.,
G. Branden Robinson <=