summaryrefslogtreecommitdiff
path: root/src/devices/grotty
diff options
context:
space:
mode:
authorwlemb <wlemb>2002-10-13 23:19:41 +0000
committerwlemb <wlemb>2002-10-13 23:19:41 +0000
commitb0f4e8a18bdc1ef90a2f4a7bf4344060fea98d3b (patch)
tree515e22d70778bc2808b2ae3607113b38530b0029 /src/devices/grotty
parent7e490c18e6bbc17edc27b4cf4d04ee0f108c385d (diff)
downloadgroff-b0f4e8a18bdc1ef90a2f4a7bf4344060fea98d3b.tar.gz
Add the new -r option to grotty. It is similar to the -i option
except it tells grotty(1) to use the "reverse video" attribute to render italic fonts. * src/devices/grotty/tty.cc (reverse_flag): New global variable. (SGR_REVERSE, SGR_NO_REVERSE): New macros. (tty_printer::make_underline, tty_printer::put_color, tty_printer::end_page): Use it. (main): Add -r switch. (usage): Updated. * src/devices/grotty/grotty.man: Document it.
Diffstat (limited to 'src/devices/grotty')
-rw-r--r--src/devices/grotty/grotty.man10
-rw-r--r--src/devices/grotty/tty.cc25
2 files changed, 31 insertions, 4 deletions
diff --git a/src/devices/grotty/grotty.man b/src/devices/grotty/grotty.man
index da5f9443..198ca473 100644
--- a/src/devices/grotty/grotty.man
+++ b/src/devices/grotty/grotty.man
@@ -26,7 +26,7 @@ grotty \- groff driver for typewriter-like devices
.SH SYNOPSIS
.B grotty
[
-.B \-bBcdfhiouUv
+.B \-bBcdfhioruUv
] [
.BI \-F dir
] [
@@ -260,6 +260,14 @@ case the old output format has been activated with
.BR \-c ).
.
.TP
+.B \-r
+Use escape sequences to set the reverse text attribute instead of the
+underline attribute for italic fonts (`I' and `BI').
+Ignored if
+.B \-c
+is active.
+.
+.TP
.B \-u
Suppress the use of underlining for italic characters.
Ignored if
diff --git a/src/devices/grotty/tty.cc b/src/devices/grotty/tty.cc
index 81183b88..7cfb658b 100644
--- a/src/devices/grotty/tty.cc
+++ b/src/devices/grotty/tty.cc
@@ -42,6 +42,7 @@ static int underline_flag = 1;
static int overstrike_flag = 1;
static int draw_flag = 1;
static int italic_flag = 0;
+static int reverse_flag = 0;
static int old_drawing_scheme = 0;
enum {
@@ -69,6 +70,8 @@ static unsigned char bold_underline_mode = BOLD_MODE|UNDERLINE_MODE;
#define SGR_NO_ITALIC CSI "23m"
#define SGR_UNDERLINE CSI "4m"
#define SGR_NO_UNDERLINE CSI "24m"
+#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
// `CSI 0 m' exclusively
@@ -249,6 +252,8 @@ void tty_printer::make_underline()
if (!is_underline) {
if (italic_flag)
putstring(SGR_ITALIC);
+ else if (reverse_flag)
+ putstring(SGR_REVERSE);
else
putstring(SGR_UNDERLINE);
}
@@ -478,6 +483,8 @@ void tty_printer::put_color(unsigned char color_index, int back)
if (is_underline) {
if (italic_flag)
putstring(SGR_ITALIC);
+ else if (reverse_flag)
+ putstring(SGR_REVERSE);
else
putstring(SGR_UNDERLINE);
}
@@ -568,6 +575,8 @@ void tty_printer::end_page(int page_length)
else if (!old_drawing_scheme && is_underline) {
if (italic_flag)
putstring(SGR_NO_ITALIC);
+ else if (reverse_flag)
+ putstring(SGR_NO_REVERSE);
else
putstring(SGR_NO_UNDERLINE);
is_underline = 0;
@@ -582,6 +591,8 @@ void tty_printer::end_page(int page_length)
else if (!old_drawing_scheme && is_underline) {
if (italic_flag)
putstring(SGR_NO_ITALIC);
+ else if (reverse_flag)
+ putstring(SGR_NO_REVERSE);
else
putstring(SGR_NO_UNDERLINE);
is_underline = 0;
@@ -608,6 +619,8 @@ void tty_printer::end_page(int page_length)
else if (!old_drawing_scheme && is_underline) {
if (italic_flag)
putstring(SGR_NO_ITALIC);
+ else if (reverse_flag)
+ putstring(SGR_NO_REVERSE);
else
putstring(SGR_NO_UNDERLINE);
is_underline = 0;
@@ -673,7 +686,7 @@ int main(int argc, char **argv)
{ "version", no_argument, 0, 'v' },
{ NULL, 0, 0, 0 }
};
- while ((c = getopt_long(argc, argv, "F:vhfbciuoBUd", long_options, NULL))
+ while ((c = getopt_long(argc, argv, "bBcdfF:hioruUv", long_options, NULL))
!= EOF)
switch(c) {
case 'v':
@@ -700,6 +713,10 @@ int main(int argc, char **argv)
// Do not overstrike (other than emboldening and underlining).
overstrike_flag = 0;
break;
+ case 'r':
+ // Use reverse mode instead of underlining.
+ reverse_flag = 1;
+ break;
case 'B':
// Do bold-underlining as bold.
bold_underline_mode = BOLD_MODE;
@@ -733,8 +750,10 @@ int main(int argc, char **argv)
default:
assert(0);
}
- if (old_drawing_scheme)
+ if (old_drawing_scheme) {
italic_flag = 0;
+ reverse_flag = 0;
+ }
else {
bold_underline_mode = BOLD_MODE|UNDERLINE_MODE;
bold_flag = 1;
@@ -752,6 +771,6 @@ int main(int argc, char **argv)
static void usage(FILE *stream)
{
- fprintf(stream, "usage: %s [-hfvbciuodBU] [-F dir] [files ...]\n",
+ fprintf(stream, "usage: %s [-bBcdfhioruUv] [-F dir] [files ...]\n",
program_name);
}