Skip to content

Commit eb2ce0b

Browse files
committed
genpng: Improve dark-mode support
Add --dark-mode command-line option to genpng for enabling dark-mode. Signed-off-by: Peter Oberparleiter <[email protected]>
1 parent 72c4f63 commit eb2ce0b

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

Diff for: bin/genpng

+9-5
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ our $tool_name = basename($0);
4747
sub gen_png($$$$@);
4848
sub check_and_load_module($);
4949
sub genpng_print_usage(*);
50-
sub genpng_process_file($$$$);
50+
sub genpng_process_file($$$$$);
5151
sub genpng_warn_handler($);
5252
sub genpng_die_handler($);
5353

@@ -74,6 +74,7 @@ if (!caller)
7474
my $filename;
7575
my $tab_size = 4;
7676
my $width = 80;
77+
my $dark = 0;
7778
my $out_filename;
7879
my $help;
7980
my $version;
@@ -85,6 +86,7 @@ if (!caller)
8586
if (!GetOptions("tab-size=i" => \$tab_size,
8687
"width=i" => \$width,
8788
"output-filename=s" => \$out_filename,
89+
"dark-mode" => \$dark,
8890
"help" => \$help,
8991
"version" => \$version))
9092
{
@@ -121,7 +123,7 @@ if (!caller)
121123
$out_filename = "$filename.png";
122124
}
123125

124-
genpng_process_file($filename, $out_filename, $width, $tab_size);
126+
genpng_process_file($filename, $out_filename, $width, $tab_size, $dark);
125127
exit(0);
126128
}
127129

@@ -146,6 +148,7 @@ or .gcov file format.
146148
-v, --version Print version number, then exit
147149
-t, --tab-size TABSIZE Use TABSIZE spaces in place of tab
148150
-w, --width WIDTH Set width of output image to WIDTH pixel
151+
-d, --dark-mode Use a light-on-dark color scheme
149152
-o, --output-filename FILENAME Write image to FILENAME
150153
151154
For more information see: $lcov_url
@@ -170,15 +173,16 @@ sub check_and_load_module($)
170173

171174

172175
#
173-
# genpng_process_file(filename, out_filename, width, tab_size)
176+
# genpng_process_file(filename, out_filename, width, tab_size, dark)
174177
#
175178

176-
sub genpng_process_file($$$$)
179+
sub genpng_process_file($$$$$)
177180
{
178181
my $filename = $_[0];
179182
my $out_filename = $_[1];
180183
my $width = $_[2];
181184
my $tab_size = $_[3];
185+
my $dark = $_[4];
182186
local *HANDLE;
183187
my @source;
184188

@@ -215,7 +219,7 @@ sub genpng_process_file($$$$)
215219
}
216220
close(HANDLE);
217221

218-
gen_png($out_filename, 0, $width, $tab_size, @source);
222+
gen_png($out_filename, $dark, $width, $tab_size, @source);
219223
}
220224

221225

Diff for: man/genpng.1

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ genpng \- Generate an overview image from a source file
1111
.IR tabsize ]
1212
.RB [ \-w | \-\-width
1313
.IR width ]
14+
.RB [ \-d | \-\-dark\-mode ]
1415
.br
1516
.RB [ \-o | \-\-output\-filename
1617
.IR output\-filename ]
@@ -79,6 +80,12 @@ Note that source code lines which are longer than
7980
will be truncated.
8081
.RE
8182

83+
.B \-d
84+
.br
85+
.B \-\-dark\-mode
86+
.RS
87+
Use a light-display-on-dark-background color scheme rather than the default dark-display-on-light-background.
88+
.RE
8289

8390
.BI "\-o " filename
8491
.br

0 commit comments

Comments
 (0)