3 # groffer - display groff files
5 # Source file position: <groff-source>/contrib/groffer/groffer.pl
6 # Installed position: <prefix>/bin/groffer
8 # Copyright (C) 2006-2018 Free Software Foundation, Inc.
10 # Written by Bernd Warken <groff-bernd.warken-72@web.de>.
12 # Last update: 27 Aug 2015
14 # This file is part of 'groffer', which is part of 'groff'.
16 # 'groff' is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation, either version 2 of the License, or
19 # (at your option) any later version.
21 # 'groff' is distributed in the hope that it will be useful, but
22 # WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 # General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with this program. If not, see
28 # <http://www.gnu.org/licenses/gpl-2.0.html>.
30 ########################################################################
36 # temporary dir and files
37 use File::Temp qw/ tempfile tempdir /;
39 # needed for temporary dir
42 # for 'copy' and 'move'
45 # for fileparse, dirname and basename
48 # current working directory
51 # $Bin is the directory where this script is located
55 ########################################################################
56 # system variables and exported variables
57 ########################################################################
67 our ($fh_cat, $tmp_cat);
68 our ($fh_stdin, $tmp_stdin);
77 our $Output_File_Name;
85 our $Special_Filespec;
91 $Dev_Null = File::Spec->devnull();
97 # flush after each print or write command
102 ########################################################################
103 # read-only variables with double-@ construct
104 ########################################################################
106 our $File_split_env_sh;
107 our $File_version_sh;
110 my $before_make; # script before run of 'make'
113 $before_make = 1 if '@VERSION@' eq "${at}VERSION${at}";
120 my $groffer_source_dir = $FindBin::Bin;
121 $at_at{'BINDIR'} = $groffer_source_dir;
123 $at_at{'LIBDIR'} = '';
124 $groffer_libdir = $groffer_source_dir;
125 $File_version_sh = File::Spec->catfile($groffer_source_dir, 'version.sh');
128 $Groff_Version = '@VERSION@';
129 $at_at{'BINDIR'} = '@BINDIR@';
131 $at_at{'LIBDIR'} = '@libdir@';
132 $groffer_libdir = '@groffer_dir@';
133 $File_version_sh = File::Spec->catfile($groffer_libdir, 'version.sh');
136 die "$groffer_libdir is not an existing directory;"
137 unless -d $groffer_libdir;
139 unshift(@INC, $groffer_libdir);
141 $File_split_env_sh = File::Spec->catfile($groffer_libdir, 'split_env.sh');
142 die "$File_split_env_sh does not exist;" unless -f "$File_split_env_sh";
145 require 'main_subs.pl';
148 @Path = &path_uniq( File::Spec->path() );
150 if ( &where_is_prog('gzip') ) {
151 $Has_Compression = 1;
152 $Has_bzip = 1 if &where_is_prog('bzip2');
156 ########################################################################
157 # modes, viewers, man sections, and defaults
158 ########################################################################
160 # configuration files
161 our @Conf_Files = (File::Spec->catfile(File::Spec->rootdir(),
162 'etc', 'groff', 'groffer.conf'),
163 File::Spec->catfile("$ENV{'HOME'}", '.groff',
167 our @Default_Modes = ('pdf', 'pdf2', 'html', 'xhtml', 'ps', 'x', 'dvi',
169 our $Default_Resolution = 100;
170 our $Default_tty_Device = 'utf8';
172 our @Macro_Packages = ('-man', '-mdoc', '-me', '-mm', '-mom', '-ms');
174 our %Viewer_tty = ('DVI' => [],
175 'HTML' => ['lynx', 'w3m'],
178 'TTY' => ['less -r -R', 'more', 'pager'],
182 our %Viewer_X = ('DVI' => ['kdvi', 'xdvi', 'dvilx'],
183 'HTML' => ['konqueror', 'epiphany'. 'mozilla-firefox',
184 'firefox', 'mozilla', 'netscape', 'galeon',
185 'opera', 'amaya','arena', 'mosaic'],
186 'XHTML' => ['konqueror', 'epiphany'. 'mozilla-firefox',
187 'firefox', 'mozilla', 'netscape', 'galeon',
188 'opera', 'amaya','arena', 'mosaic'],
189 'PDF' => ['okular', 'kpdf', 'acroread', 'evince',
190 'xpdf -z 150', 'gpdf', 'xpdf', 'zathura'.
191 'epdfview', 'qpdfview', 'apvlv', 'qpdfview',
192 'kghostview --scale 1.45', 'gv', 'ggv'],
193 'PS' => ['okular', 'evince', 'gv',
194 'gs', 'gs_x11', 'ghostscript', 'ghostview',
195 'kghostview --scale 1.45', 'ggv', 'kpdf'],
197 'X' => ['gxditview', 'xditview'],
201 'AUTO_SEC' => ['1', '2', '3', '4', '5', '6', '7', '8', '9',
215 $Man{'AUTO_SEC_CHARS'} = join('', @{$Man{'AUTO_SEC'}});
218 ########################################################################
220 ########################################################################
222 our %Opts_Cmdline_Short;
223 our %Opts_Cmdline_Long;
224 our $Opts_Cmdline_Long_Str;
225 our %Opts_Cmdline_Double;
226 our %Opts_Groff_Short;
231 ########################################################################
233 ########################################################################
235 # handle environment variable $MANOPT
238 &main_parse_MANOPT();
241 ########################################################################
242 # configuration files, $GROFFER_OPT, and command line, main_config_params()
243 ########################################################################
248 our @Starting_ARGV = @ARGV;
250 &main_config_params();
253 print STDERR "<$_>\n" foreach @ARGV;
257 ########################################################################
258 # main_parse_params()
259 ########################################################################
266 &main_parse_params();
269 ########################################################################
271 ########################################################################
273 our $Viewer_Background;
274 our $PDF_Did_Not_Work;
277 our %Display = ('MODE' => '',
285 ########################################################################
286 # groffer temporary directory, main_temp()
287 ########################################################################
292 ########################################################################
293 # tmp functions and compression
294 ########################################################################
296 ########################################################################
297 # main_do_fileargs() and related subs
298 ########################################################################
306 ########################################################################
307 # main_set_resources()
308 ########################################################################
310 &main_set_resources();
313 ########################################################################
315 ########################################################################
327 ########################################################################