| 1 | package App::optex::up; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 80 | our $VERSION = "1.20"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | =encoding utf-8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | up - optex module for multi-column paged output | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | optex -Mup command ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | optex -Mup -C2 -- command ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | optex -Mup -C2,2 -- command ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | B<up> is a module for the B<optex> command that pipes the output | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | through L<App::ansicolumn> for multi-column formatting and a pager. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | The name comes from the printing term "n-up" (2-up, 3-up, etc.) which | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | refers to printing multiple pages on a single sheet. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | The module automatically calculates the number of columns based on the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | terminal width divided by the pane width (default 85 characters). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | The terminal size is taken from the controlling terminal (C</dev/tty>); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | when it is not available, the C<COLUMNS> environment variable gives the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | width (default 80), and C<LINES> gives the height (default 24) used | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | when the number of rows is set, as in C<-C2,2>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | Both stdout and stderr are merged and passed through the filter, so | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | error messages are also displayed in the multi-column paged output. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | The pager command is taken from the C<NUP_PAGER> environment variable | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | if set, otherwise defaults to C<less -F +Gg>. When page mode is | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | active, the C<NUP_PAGE_PAGER> environment variable is consulted | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | first. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | The environment variables are named after the L<nup> command, a | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | wrapper for this module. The C<PAGER> variable is not used to avoid | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | an infinite loop when C<PAGER> is set to C<nup>. Use the C<--pager> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | option to specify a different pager on the command line. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | The C<-F> option causes C<less> to exit immediately if the output | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | fits on one screen. C<+Gg> causes C<less> to read all input before | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | displaying, which may take time for large output, but prevents empty | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | trailing pages from being shown. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | The C<--file-size> option of C<less> 590 (June 2021) and later does | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | the same as C<+Gg>; it is not the default because older versions, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | such as the C<less> 581 that comes with macOS, do not have it and | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | print an error message for it. Set C<NUP_PAGER> to use it: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | export NUP_PAGER="less --file-size" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | =head1 OPTIONS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | Module options must be specified before C<--> separator. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | =item B<-C> I<C>[,I<R>], B<--pane>=I<C>[,I<R>] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | Set the number of columns (panes) directly, and the number of rows | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | when it is given after a comma. For example, C<-C2> creates 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | columns, and C<-C2,3> creates a 2-column, 3-row layout (6-up). The | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | page height is calculated by dividing the terminal height by the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | number of rows. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | =item B<-R> I<N>, B<--row>=I<N> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | Set the number of rows. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | This option is kept for compatibility and may be removed in the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | future. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | =item B<-G> I<CxR>, B<--grid>=I<CxR> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | Set the grid layout. C<--grid=2x3> or C<--grid=2,3> is equivalent to | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | C<-C2,3>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | This option is kept for compatibility and may be removed in the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | future. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | =item B<-S> I<N>, B<--pane-width>=I<N> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | Set the pane width in characters. Default is 85. When B<--pane> is | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | not specified, the number of panes is calculated by dividing the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | terminal width by this value. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | =item B<--bs>=I<STYLE>, B<--border-style>=I<STYLE> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | Set the border style for ansicolumn. Default is C<heavy-box>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | See L<App::ansicolumn> for available styles. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | =item B<--no-paginate> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | Disable page mode. Without pagination, the entire content is | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | split evenly across columns. Page mode is the default. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | Note that L<App::ansicolumn> uses parallel layout when multiple | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | files are given, which has no page structure. Specify this option | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | in such cases so that C<NUP_PAGE_PAGER> is not used (the L<nup> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | command does this automatically). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | =item B<-A>, B<--auto-paginate> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | Automatically disable page mode when only one column fits the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | terminal. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | =item B<-L>, B<-->[B<no->]B<lateral> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | Put all the pages in one row, however wide it becomes. The screen | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | shows as many panes as without this option, as many as fit or the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | number given by C<-C>, and the row goes on to the right: the panes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | are given to C<ansicolumn> by their width (C<-S>), the width of the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | screen divided by that number, in a very large output width. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | When the pager is C<less>, C<< -S --shift=I<N> --rscroll=- >> is | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | added to it, where I<N> is the width of a pane, so that the lines are | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | not wrapped and the arrow keys move by one page. Keys are added to | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | C<LESSKEY_CONTENT> (less 661 or later), after the keys of the user, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | or those of C<NUP_LESSKEY> in their place, none when it is empty: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | C<h> and C<l>, C<,> and C<.>, and ESC-( and ESC-), move by one page | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | as the arrow keys, C<H> and C<L> go to the left and the right end, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | and so do C<g> and C<G>, C<E<lt>> and C<E<gt>>, and space and C<b> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | move to the right and to the left by the panes on the screen, as do | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | C<j> and C<k>, the down and up arrows, C<d> and C<u>, C<^D> and | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | C<^U>, and the return key, and C<J> and C<K> go to the right and the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | left end. With less 710 or | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | later, C<l>, C<.>, the right arrow and ESC-) stop at the right end. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | The build of less in tecolicom/tap does more; see | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | L<nup/"LESS INTEGRATION">. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | With C<--no-paginate>, it is for the files side by side, as the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | L<nup> command gives it for more than one file: each file is a column | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | of its own, the columns go on to the right, and only C<h>, C<l>, C<,>, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | C<.>, the arrow keys, ESC-( and ESC-), C<H>, C<L>, C<E<lt>> and | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | C<E<gt>> are put in C<LESSKEY_CONTENT>. One input without pages | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | makes a column of each line. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | It cannot be used with rows (C<-R>, C<-C2,2>, C<-G>) or PDF output, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | and C<--auto-paginate> is ignored. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | Without this option, when the output has pages and the pager is | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | C<less>, C<j> and C<k>, the down and up arrows, C<d> and C<u>, C<^D> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | and C<^U>, and the return key are put in C<LESSKEY_CONTENT> to move by the screen as space and C<b> do, and | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | C<J> and C<K> to go to the last and the first page, unless | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | C<NUP_LESSKEY> is set. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | =item B<--pager>=I<COMMAND> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | Set the pager command, overriding the environment variables. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | Default is C<NUP_PAGE_PAGER> (page mode only), C<NUP_PAGER>, or | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | C<less -F +Gg>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | =item B<--no-pager> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | Disable pager. Output goes directly to stdout. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | =item B<--device>=I<DEVICE>, B<-T> I<DEVICE> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | Set the device to show the output on. The default is C<tty>, the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | terminal. Any other device is a paper, and the output is printed to | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | PDF by C<ansi2pdf>. The name of a paper is the one for the C<-p> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | option of C<ansi2pdf>, as C<a4> or C<a3>, and C<p> or C<l> after it | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | gives the orientation, as C<a4p> for A4 in portrait. A paper without | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | it is used in landscape. The device C<pdf> is the default paper of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | C<ansi2pdf>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | The size of a sheet of paper in columns and lines, which | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | C<ansi2pdf --geometry> tells, is used in place of the terminal size, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | and C<ansi2pdf> is used in place of the pager. Each screen is | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | printed on a sheet as it is. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | =item B<--output>=I<FILE>, B<-o> I<FILE> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | Write the output to I<FILE>. When the name ends with C<.pdf>, the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | output is PDF without C<--device> as well. Otherwise, what is shown | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | on the terminal is written to the file as it is, with the ANSI | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | sequences, and the pager is not used. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | The page height given by C<-P> (C<--page>) is the number of lines of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | a page here too: a sheet has that many lines for each row. The width | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | given by C<-w> (C<--width>) is the number of columns of a sheet. The | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | font size follows them, and the one that is not given is decided to | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | fill the sheet. The default is 60 lines on a sheet. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | =item B<--geometry> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | Print the size of the device in columns and lines and its kind, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | C<tty> or C<pdf>, as C<206 60 pdf>, and exit without running the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | command. For a paper, the size is that of a sheet, which follows | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | C<--device>, C<--output>, C<--page>, C<--width>, the number of rows | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | and C<--pdf-opts>. For the terminal, it is the size of the terminal. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | =item B<--pdf-opts>=I<OPTIONS> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | Give other options to C<ansi2pdf>, such as C<-l 80> for the number | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | of lines on a sheet and C<-m 15> for the margin. They are given | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | after the paper, so they take precedence. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | =item B<--highlight>=I<NAME> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | When the command is C<ansicolumn>, give it the option | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | C<--highlight=>I<NAME>: the files are read through the highlighter of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | the name, and shown with syntax highlight. The highlighters are | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | those of L<Text::ANSI::Highlight>: C<pandoc>, C<sourcehighlight> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | (C<gnu>) and C<skylighting> (C<sky>). Nothing is done when | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | L<Text::ANSI::Highlight::IO> is not installed. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | =item Other options | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | Any unrecognized options are passed through to L<App::ansicolumn>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | For example, C<--cm> option can be used to set colormap: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | optex -Mup --cm=BORDER=R -- command | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | See L<App::ansicolumn> for available options. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | =head1 EXAMPLES | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | Display perldoc output in multiple columns: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | optex -Mup perldoc App::optex::up | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | =begin html | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | <p><img width="750" src="https://raw.githubusercontent.com/tecolicom/App-nup/main/images/nup.png"> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | =end html | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | List files in multiple columns with pager: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | optex -Mup ls -l | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | Use 2 columns: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | optex -Mup -C2 -- ls -l | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | Set pane width to 100: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | optex -Mup -S100 -- ls -l | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | Use 2x2 grid (4-up): | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | optex -Mup -C2,2 -- ls -l | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | No pagination: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | optex -Mup --no-paginate -- man perl | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | Use a different border style: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | optex -Mup --bs=round-box -- ls -l | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | Output without pager (useful for piping): | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | optex -Mup --no-pager -C2 -- ls -l | head | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | Truncate long lines: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | optex -Mup --ls=truncate -- ps aux | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | =head1 INSTALL | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | =head2 Homebrew | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | Use L<tecolicom/tap|https://github.com/tecolicom/homebrew-tap>: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | brew tap tecolicom/tap | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | brew install app-nup | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | =head2 CPANMINUS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | cpanm App::nup | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | L<App::nup>, L<https://github.com/tecolicom/App-nup> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | L<App::optex>, L<https://github.com/kaz-utashiro/optex> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | L<App::ansicolumn> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | Kazumasa Utashiro | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | Copyright © 2025 Kazumasa Utashiro. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | This library is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 81 | ▶ | use v5.16; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 81 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 81 | ▶ | use List::Util qw(max); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 81 | ▶ | use Getopt::EX::Config; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 81 | ▶ | use Term::ReadKey; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 69 | ▶ | sub term_size { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
term_size: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 69 | my @size; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 69 | ▶ | if (open my $tty, ">", "/dev/tty") { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | @size = GetTerminalSize $tty, $tty; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 69 | @size; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 242 | ▶ | sub shell_escape { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shell_escape: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 242 | $_[0] =~ s/([<>&|;'"\$`\\ ])/\\$1/gr; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | # Take the number given to an option (-X N, -XN, --name N, --name=N) out | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | # of the options for ansicolumn, and return it. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 7 | ▶ | sub take_option { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
take_option: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 7 | my($argv, $short, $long) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 7 | my $value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 7 | ▶ | for (my $i = 0; $i < @$argv; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 15 | ▶ | if ($argv->[$i] =~ /^(?:-$short|--$long)$/ | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition83%5/6
$argv->[$i] =~ /^(?:-$short|--$long)$/u and $i < $argv->$#* and $$argv[$i + 1] =~ /^\d+$/u
$argv->[$i] =~ /^(?:-$short|--$long)$/u and $i < $argv->$#*
MC/DC66%2/3
$argv->[$i] =~ /^(?:-$short|--$long)$/u and $i < $argv->$#* and $$argv[$i + 1] =~ /^\d+$/u
$argv->[$i] =~ /^(?:-$short|--$long)$/u
$i < $argv->$#*
$$argv[$i + 1] =~ /^\d+$/u
Truth table75%3/4
A and B and C
A= $argv->[$i] =~ /^(?:-$short|--$long)$/uB= $i < $argv->$#*C= $$argv[$i + 1] =~ /^\d+$/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | and $i < $#$argv and $argv->[$i + 1] =~ /^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 3 | (undef, $value) = splice @$argv, $i--, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | elsif ($argv->[$i] =~ /^(?:-$short|--$long=)(\d+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 2 | $value = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 2 | splice @$argv, $i--, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 7 | $value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 80 | my $config = Getopt::EX::Config->new( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 'grid' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 'pane-width' => 85, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 'pane' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 'row' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 'border-style' => 'heavy-box', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 'paginate' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 'auto-paginate' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 'lateral' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 'pager' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 'no-pager' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 'device' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 'output' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 'pdf-opts' => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 'geometry' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 'highlight' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | # The number of panes that the row of --lateral has room for. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 80 | our $LATERAL_PANES = 10000; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | # What the less command knows: its version, and whether it has the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | # --align-shift option of the build in tecolicom/tap. Both are told by | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | # one run with --version, since an unknown option does not make less | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | # fail, but only gives a message. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | # Add the keys to LESSKEY_CONTENT. They go after those of the user, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | # in a #command section of their own: the later of the same keys wins, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | # and the keys of ~/.lesskey are read before LESSKEY_CONTENT. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 40 | ▶ | sub add_lesskey { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_lesskey: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 40 | my $keys = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 40 | ▶ | return if $keys eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 38 | ▶ | my $user = $ENV{LESSKEY_CONTENT} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$ENV{"LESSKEY_CONTENT"} // ""
MC/DC100%1/1
$ENV{"LESSKEY_CONTENT"} // ""
$ENV{"LESSKEY_CONTENT"}
Truth table100%2/2
A
A= $ENV{"LESSKEY_CONTENT"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 38 | ▶ | $ENV{LESSKEY_CONTENT} = $user eq '' ? $keys : "$user\n#command\n$keys"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 33 | ▶ | sub less_features { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
less_features: called CC=6 SCAR=18.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 33 | my $less = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 33 | ▶ | my $pid = open(my $fh, '-|') // return (0, 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
open(my $fh, "-|") // (return 0, 0)
MC/DC0%0/1
open(my $fh, "-|") // (return 0, 0)
open(my $fh, "-|")
Truth table50%1/2
A
A= open(my $fh, "-|")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 33 | ▶ | if ($pid == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 17 | open STDERR, '>&', \*STDOUT; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 17 | open STDIN, '<', '/dev/null'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 17 | ▶ | exec $less, '--align-shift', '--version' or exit 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 16 | ▶ | my $out = do { local $/; <$fh> } // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
do {
local $/;
readline $fh
} // ""
MC/DC0%0/1
do {
local $/;
readline $fh
} // ""
do {
local $/;
readline $fh
}
Truth table50%1/2
A
A= do {
local $/;
readline $fh
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 16 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 16 | ▶ | my($version) = $out =~ /^less (\d+)/m or return (0, 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 3 | ($version, $out !~ /There is no -*align-shift option/); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | # Size of a sheet of paper in columns and lines, asked to ansi2pdf. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | sub pdf_size { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pdf_size: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | my $command = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | my $geometry = qx($command --geometry) // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
`$command --geometry` // ""
MC/DC0%0/1
`$command --geometry` // ""
`$command --geometry`
Truth table0%0/2
A
A= `$command --geometry`
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | $geometry =~ /^(\d+) (\d+)$/ | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | or die "Failed to get the page geometry from ansi2pdf.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ($1, $2); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 79 | ▶ | sub finalize { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finalize: called CC=73 SCAR=51.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 79 | my($mod, $argv) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 79 | $config->configure('pass_through')->deal_with($argv, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 'grid|G=s', 'pane-width|S=i', 'pane|C=s', 'row|R=i', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 'border-style|bs=s', 'paginate!', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 'auto-paginate|autopaginate|A', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 'lateral|L!', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 'pager:s', 'no-pager|nopager', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 'device|T=s', 'output|o=s', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 'pdf-opts=s', 'geometry', 'highlight=s'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 79 | my @passthru = $config->argv; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | ## Panes and rows: -C C[,R] and -G CxR | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 79 | ▶ | if (defined(my $pane = $config->{pane})) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 20 | ▶ | my($c, $r) = $pane =~ /^(\d+)(?:,(\d+))?$/ | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | or die "Invalid pane format: $pane (expected C or C,R)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 16 | $config->{pane} = $c; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 16 | ▶ | $config->{row} //= $r; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$config->{"row"} //= $r
MC/DC100%2/2
$config->{"row"} //= $r
$config->{"row"}
$r
Truth table100%3/3
A //= B
A= $config->{"row"}B= $r
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 75 | ▶ | if (my $grid = $config->{grid}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 5 | ▶ | my($c, $r) = $grid =~ /^(\d+)[x,](\d+)$/ | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | or die "Invalid grid format: $grid (expected CxR or C,R)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 4 | ▶ | $config->{pane} //= $c; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$config->{"pane"} //= $c
MC/DC0%0/2
$config->{"pane"} //= $c
$config->{"pane"}
$c
Truth table33%1/3
A //= B
A= $config->{"pane"}B= $c
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 4 | ▶ | $config->{row} //= $r; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$config->{"row"} //= $r
MC/DC0%0/2
$config->{"row"} //= $r
$config->{"row"}
$r
Truth table33%1/3
A //= B
A= $config->{"row"}B= $r
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | ## Device: -T and -o | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | ## The device is the terminal (tty), or a paper (a4, a4p, ... or | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | ## "pdf" for the default one). For a paper, a sheet takes the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | ## place of the screen and ansi2pdf that of the pager. A file | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | ## name ending with .pdf chooses PDF by itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 74 | my $device = $config->{device}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 74 | my $output = $config->{output}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 74 | ▶ | $device //= 'pdf' if defined $output and $output =~ /\.pdf$/i; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
defined $output and $output =~ /\.pdf$/iu
$device //= "pdf"
MC/DC50%1/2
defined $output and $output =~ /\.pdf$/iu
defined $output
$output =~ /\.pdf$/iu
MC/DC0%0/1
$device //= "pdf"
$device
Truth table66%2/3
A and B
A= defined $outputB= $output =~ /\.pdf$/iu
Truth table50%1/2
A
A= $device
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 74 | ▶ | $device //= 'tty'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$device //= "tty"
MC/DC100%1/1
$device //= "tty"
$device
Truth table100%2/2
A
A= $device
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | # -o with the terminal: write what would be shown on it | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 74 | ▶ | if (defined $output and $device eq 'tty' and not $config->{geometry}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $output and $device eq "tty" and not $config->{"geometry"}
defined $output and $device eq "tty"
MC/DC0%0/3
defined $output and $device eq "tty" and not $config->{"geometry"}
defined $output
$device eq "tty"
not $config->{"geometry"}
Truth table50%2/4
A and B and not(C)
A= defined $outputB= $device eq "tty"C= not $config->{"geometry"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | $config->{pager} = 'cat > ' . shell_escape($output); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | $config->{'no-pager'} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | ## --lateral | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | ## All the pages are in one row, scrolled sideways by the pager. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | ## Without pages (--no-paginate), each file is a column of the row. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | ## There are no rows and no sheet of paper. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 74 | my $lateral = $config->{lateral}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 74 | ▶ | if ($lateral) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 39 | ▶ | my $with = defined $config->{row} ? 'the number of rows (-R, -C, -G)' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | : $device ne 'tty' ? 'PDF output (-T, -o)' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 39 | ▶ | die "--lateral cannot be used with $with.\n" if $with; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | ## ansi2pdf command, for a paper | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 69 | my $ansi2pdf; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 69 | ▶ | if ($device ne 'tty') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | $ansi2pdf = join ' ', 'ansi2pdf -C1 --no-border -L', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | ($device eq 'pdf' ? () : '-p ' . shell_escape($device)), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | $config->{'pdf-opts'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | # -P (lines of a page) and -w (columns of a sheet) decide the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | # size of a sheet; ansi2pdf decides the one not given. They | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | # are among the options of this module, or among the arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | # of ansicolumn in file view mode (nup FILE -w 100). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | my @lists = (\@passthru, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@$argv and $argv->[0] eq "ansicolumn"
MC/DC0%0/2
@$argv and $argv->[0] eq "ansicolumn"
@$argv
$argv->[0] eq "ansicolumn"
Truth table0%0/3
A and B
A= @$argvB= $argv->[0] eq "ansicolumn"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | @$argv && $argv->[0] eq 'ansicolumn' ? $argv : ()); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | my($page) = grep defined, reverse map take_option($_, 'P', 'page'), @lists; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | my($width) = grep defined, reverse map take_option($_, 'w', 'width'), @lists; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | $ansi2pdf .= ' -l ' . $page * ($config->{row} || 1) if $page; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$config->{'row'} || 1
MC/DC0%0/1
$config->{'row'} || 1
$config->{'row'}
Truth table0%0/2
A
A= $config->{'row'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | $ansi2pdf .= " -w $width" if $width; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | ## Size of the screen or the sheet, and the layout in it | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 69 | ▶ | my($term_width, $term_height) = $ansi2pdf ? pdf_size($ansi2pdf) : term_size(); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 69 | ▶ | $term_width ||= $ENV{COLUMNS} || 80; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$term_width ||= $ENV{"COLUMNS"} || 80
$ENV{'COLUMNS'} || 80
MC/DC0%0/2
$term_width ||= $ENV{"COLUMNS"} || 80
$term_width
$ENV{'COLUMNS'}
Truth table0%0/3
A ||= B
A= $term_widthB= $ENV{'COLUMNS'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 69 | ▶ | $term_height ||= $ENV{LINES} || 24; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$term_height ||= $ENV{"LINES"} || 24
$ENV{'LINES'} || 24
MC/DC0%0/2
$term_height ||= $ENV{"LINES"} || 24
$term_height
$ENV{'LINES'}
Truth table0%0/3
A ||= B
A= $term_heightB= $ENV{'LINES'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 69 | my $pane_width = $config->{'pane-width'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 69 | ▶ | my $cols = $config->{pane} // max(1, int($term_width / $pane_width)); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$config->{"pane"} // &max(1, int $term_width / $pane_width)
MC/DC0%0/2
$config->{"pane"} // &max(1, int $term_width / $pane_width)
$config->{"pane"}
&max(1, int $term_width / $pane_width)
Truth table66%2/3
A // B
A= $config->{"pane"}B= &max(1, int $term_width / $pane_width)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 69 | my $rows = $config->{row}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 69 | ▶ | my $height = defined $rows ? int(($term_height - 1) / $rows) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 69 | ▶ | if ($ansi2pdf) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | # a sheet has no line for the pager, and the pages fill it | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | $height = int($term_height / ($rows || 1)); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$rows || 1
MC/DC0%0/1
$rows || 1
$rows
Truth table0%0/2
A
A= $rows
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | my $lines = $height * ($rows || 1); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$rows || 1
MC/DC0%0/1
$rows || 1
$rows
Truth table0%0/2
A
A= $rows
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | $config->{pager} = "$ansi2pdf -w $term_width -l $lines" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | . (defined $output ? ' -o ' . shell_escape($output) : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | $config->{'no-pager'} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | ## --geometry: print the size and the kind of the device, and exit | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 69 | ▶ | if ($config->{geometry}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 3 | ▶ | my $lines = $ansi2pdf ? $height * ($rows || 1) : $term_height; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$rows || 1
MC/DC0%0/1
$rows || 1
$rows
Truth table0%0/2
A
A= $rows
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 3 | ▶ | say join ' ', $term_width, $lines, $ansi2pdf ? 'pdf' : 'tty'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 3 | exit 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | ## Pager | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 66 | my $border_style = $config->{'border-style'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | my $no_page = !$config->{paginate} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 66 | ▶ | || ($config->{'auto-paginate'} && $cols <= 1 && !$lateral); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition77%7/9
!$config->{'paginate'} || $config->{'auto-paginate'} && $cols <= 1 && !$lateral
$config->{"auto-paginate"} and $cols <= 1 and not $lateral
$config->{"auto-paginate"} and $cols <= 1
MC/DC50%2/4
!$config->{'paginate'} || $config->{'auto-paginate'} && $cols <= 1 && !$lateral
!$config->{'paginate'}
$config->{"auto-paginate"}
$cols <= 1
not $lateral
Truth table60%3/5
not(A) || B and C and not(D)
A= !$config->{'paginate'}B= $config->{"auto-paginate"}C= $cols <= 1D= not $lateral
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | # +Gg makes less read all the input first, so that -F and the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | # percentage work. less 590 has --file-size for this, but the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | # less 581 of macOS does not: +Gg is the default. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | my $pager = $config->{pager} // | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 66 | ▶ | ((!$no_page && $ENV{NUP_PAGE_PAGER}) || $ENV{NUP_PAGER} || 'less -F +Gg'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%10/10
$config->{"pager"} // (!$no_page && $ENV{"NUP_PAGE_PAGER"} || $ENV{"NUP_PAGER"} || "less -F +Gg")
not $no_page and $ENV{"NUP_PAGE_PAGER"} or $ENV{"NUP_PAGER"} or "less -F +Gg"
not $no_page and $ENV{"NUP_PAGE_PAGER"} or $ENV{"NUP_PAGER"}
not $no_page and $ENV{"NUP_PAGE_PAGER"}
MC/DC100%1/1
$config->{"pager"} // (!$no_page && $ENV{"NUP_PAGE_PAGER"} || $ENV{"NUP_PAGER"} || "less -F +Gg")
$config->{"pager"}
Truth table100%2/2
A
A= $config->{"pager"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | ## --lateral with less: options and keys | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | ## less shows the row without wrapping (-S), and shifts it by the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | ## width of a pane (--shift). --rscroll=- shows the text in the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | ## last column, where less puts a mark for the lines that go on. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | ## What less can do, by its version: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | ## 661 reads LESSKEY_CONTENT (an older one ignores it, and H is | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | ## the help as usual) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | ## 710 has right-limit-scroll, which stops at the right end (an | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | ## older one takes the name for an error: use right-scroll) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | ## tap the build in tecolicom/tap has --align-shift, which keeps | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | ## the shift at the boundaries of the panes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 66 | my $lateral_width = max(1, int($term_width / $cols)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 66 | ▶ | if ($lateral and $pager =~ m{^\s*((?:\S*/)?less)(?:\s|$)}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$lateral and $pager =~ m[^\s*((?:\S*/)?less)(?:\s|$)]u
MC/DC100%2/2
$lateral and $pager =~ m[^\s*((?:\S*/)?less)(?:\s|$)]u
$lateral
$pager =~ m[^\s*((?:\S*/)?less)(?:\s|$)]u
Truth table100%3/3
A and B
A= $lateralB= $pager =~ m[^\s*((?:\S*/)?less)(?:\s|$)]u
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 33 | my($version, $align_shift) = less_features($1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 16 | $pager .= " -S --shift=$lateral_width --rscroll=-"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 16 | ▶ | $pager .= " --align-shift" if $align_shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | # one page to the right: l, ., the right arrow and ESC-) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 16 | ▶ | my $right = $version >= 710 ? 'right-limit-scroll' : 'right-scroll'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | # The panes on the screen to the right and to the left: space | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | # and b. With --align-shift, it is a count given to the key; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | # without, a count would change the shift, so the key is typed | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | # as many times. The key is ESC-) or ESC-(, because the arrow | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | # keys cannot be written in the string of noaction. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 16 | my $n = max(1, int($term_width / $lateral_width)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 16 | ▶ | my($fwd, $back) = map { $align_shift ? "$n$_" : $_ x $n } '\e)', '\e('; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | # The right end: G and >. With --align-shift, the count makes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | # the last screen the same as without --lateral. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 16 | ▶ | my $end = $align_shift ? "noaction ${n}L" : 'end-scroll'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | # NUP_LESSKEY gives the keys in place of these; an empty one | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | # gives none. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | my $keys = $ENV{NUP_LESSKEY} // join ';', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | # one page: h l , . and the arrows | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | "h left-scroll;l $right;, left-scroll;. $right", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | "\\kl left-scroll;\\kr $right;\\e( left-scroll;\\e) $right", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | # the ends of the row | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | "H no-scroll;L end-scroll", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | $config->{paginate} ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | # with pages: g G < > go to the ends as H and L | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 16 | ▶ | "g no-scroll;G $end;< no-scroll;> $end", | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$ENV{"NUP_LESSKEY"} // join(";", "h left-scroll;l $right;, left-scroll;. $right", "\\kl left-scroll;\\kr $right;\\e( left-scroll;\\e) $right", "H no-scroll;L end-scroll", $config->{"paginate"} ? ("g no-scroll;G $end;< no-scroll;> $end", "\\ noaction $fwd;b noaction $back", "j noaction $fwd;k noaction $back", "\\kd noaction $fwd;\\ku noaction $back", "d noaction $fwd;u noaction $back", "^D noaction $fwd;^U noaction $back", "\\r noaction $fwd;\\n noaction $fwd", "J $end;K no-scroll") : "< no-scroll;> end-scroll")
MC/DC100%1/1
$ENV{"NUP_LESSKEY"} // join(";", "h left-scroll;l $right;, left-scroll;. $right", "\\kl left-scroll;\\kr $right;\\e( left-scroll;\\e) $right", "H no-scroll;L end-scroll", $config->{"paginate"} ? ("g no-scroll;G $end;< no-scroll;> $end", "\\ noaction $fwd;b noaction $back", "j noaction $fwd;k noaction $back", "\\kd noaction $fwd;\\ku noaction $back", "d noaction $fwd;u noaction $back", "^D noaction $fwd;^U noaction $back", "\\r noaction $fwd;\\n noaction $fwd", "J $end;K no-scroll") : "< no-scroll;> end-scroll")
$ENV{"NUP_LESSKEY"}
Truth table100%2/2
A
A= $ENV{"NUP_LESSKEY"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | # the panes on the screen: space and b, and the keys | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | # to go down and up, since a page has the height of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | # the screen and there is nothing below it | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | "\\ noaction $fwd;b noaction $back", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | "j noaction $fwd;k noaction $back", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | "\\kd noaction $fwd;\\ku noaction $back", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | "d noaction $fwd;u noaction $back", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | "^D noaction $fwd;^U noaction $back", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | "\\r noaction $fwd;\\n noaction $fwd", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | # the ends, in the direction of j and k | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | "J $end;K no-scroll", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | ) : ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | # without pages: the columns go on downward, and the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | # keys move up and down as usual. g and G are the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | # first and the last line; < and > go to the ends. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | "< no-scroll;> end-scroll", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 16 | add_lesskey($keys); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | ## Pages without --lateral, with less: keys | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | ## The pages fill the screen and go on below. The keys to go down | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | ## and up move by the screen, as space and b do: a line down would | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | ## show the pages cut in the middle. NUP_LESSKEY is for --lateral, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | ## and when it is set, these keys are not added. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | ▶ | elsif (!$lateral and !$no_page and !defined $ENV{NUP_LESSKEY} | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%9/9
not $lateral || $no_page || defined $ENV{"NUP_LESSKEY"} and $pager =~ m[^\s*(?:\S*/)?less(?:\s|$)]u
$lateral || $no_page || defined $ENV{'NUP_LESSKEY'}
$lateral or $no_page
MC/DC100%4/4
not $lateral || $no_page || defined $ENV{"NUP_LESSKEY"} and $pager =~ m[^\s*(?:\S*/)?less(?:\s|$)]u
$lateral
$no_page
defined $ENV{'NUP_LESSKEY'}
$pager =~ m[^\s*(?:\S*/)?less(?:\s|$)]u
Truth table100%5/5
not(A or B || C) and D
A= $lateralB= $no_pageC= defined $ENV{'NUP_LESSKEY'}D= $pager =~ m[^\s*(?:\S*/)?less(?:\s|$)]u
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | and $pager =~ m{^\s*(?:\S*/)?less(?:\s|$)}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 24 | add_lesskey(join ';', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | "j forw-screen;k back-screen", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | "\\kd forw-screen;\\ku back-screen", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | "d forw-screen;u back-screen", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | "^D forw-screen;^U back-screen", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | "\\r forw-screen;\\n forw-screen", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | # the last and the first page | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | "J goto-end;K goto-line"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | ## ansicolumn options | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | ## With --lateral, the panes are given by their width in a row | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | ## wide enough for any number of them: ansicolumn puts all the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | ## pages in one row. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 49 | ▶ | my @ac_opts = ("--bs=$border_style", "--cm=BORDER=L13", "-DBP", | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | $lateral ? ("-w" . $lateral_width * $LATERAL_PANES, "-S$lateral_width") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | : ("-w$term_width", "-C$cols")); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 49 | ▶ | push @ac_opts, "--height=$height" if defined $height; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 49 | ▶ | push @ac_opts, "--no-page" if $no_page; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 49 | push @ac_opts, @passthru; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | ## The command is ansicolumn (file view mode of nup): give it the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | ## options, and filter its output by the pager | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 49 | ▶ | if (@$argv && $argv->[0] eq 'ansicolumn') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@$argv and $argv->[0] eq "ansicolumn"
MC/DC50%1/2
@$argv and $argv->[0] eq "ansicolumn"
@$argv
$argv->[0] eq "ansicolumn"
Truth table66%2/3
A and B
A= @$argvB= $argv->[0] eq "ansicolumn"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | # --highlight=NAME: ansicolumn reads the files in the colors | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | # of the highlighter of the name, by Text::ANSI::Highlight::IO. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | # Without the module, ansicolumn fails by the option: look for | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | # it, without loading. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 4 | ▶ | if (my $name = $config->{highlight}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | unshift @ac_opts, "--highlight=$name" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | if $name =~ /\A\w+\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 3 | ▶ | and grep { !ref and -f "$_/Text/ANSI/Highlight/IO.pm" } @INC; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$name =~ /\A\w+\z/u and grep {not ref $_ and -f "$_/Text/ANSI/Highlight/IO.pm";} @INC
!ref($_) && -f "$_/Text/ANSI/Highlight/IO.pm"
MC/DC50%1/2
$name =~ /\A\w+\z/u and grep {not ref $_ and -f "$_/Text/ANSI/Highlight/IO.pm";} @INC
$name =~ /\A\w+\z/u
grep {not ref $_ and -f "$_/Text/ANSI/Highlight/IO.pm";} @INC
MC/DC50%1/2
!ref($_) && -f "$_/Text/ANSI/Highlight/IO.pm"
!ref($_)
-f "$_/Text/ANSI/Highlight/IO.pm"
Truth table66%2/3
A and B
A= $name =~ /\A\w+\z/uB= grep {not ref $_ and -f "$_/Text/ANSI/Highlight/IO.pm";} @INC
Truth table66%2/3
not(A) && B
A= !ref($_)B= -f "$_/Text/ANSI/Highlight/IO.pm"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | # the options go before those of the user, which win | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 4 | splice @$argv, 1, 0, @ac_opts; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 4 | ▶ | if ($config->{'no-pager'} || $pager eq '') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$config->{"no-pager"} or $pager eq ""
MC/DC0%0/2
$config->{"no-pager"} or $pager eq ""
$config->{"no-pager"}
$pager eq ""
Truth table33%1/3
A or B
A= $config->{"no-pager"}B= $pager eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 4 | return; # No filter needed | |||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | $mod->setopt(default => "-Mutil::filter --of='$pager' --ef='>&1'"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | ## Any other command: filter its output by ansicolumn and the pager | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 45 | my $column = join ' ', 'ansicolumn', map { shell_escape($_) } @ac_opts; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 45 | ▶ | my $filter = ($config->{'no-pager'} || $pager eq '') ? $column : "$column|$pager"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$config->{"no-pager"} or $pager eq ""
MC/DC50%1/2
$config->{"no-pager"} or $pager eq ""
$config->{"no-pager"}
$pager eq ""
Truth table66%2/3
A or B
A= $config->{"no-pager"}B= $pager eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 45 | $mod->setopt(default => "-Mutil::filter --of='$filter' --ef='>&1'"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 80 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||