| 1 | # -*- perl -*- | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | # Author: Slaven Rezic | ||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||
| 6 | # Copyright (C) 2006,2008,2009,2012,2014,2015 Slaven Rezic. All rights reserved. | ||||||||||||||||||||||||||||
| 7 | # This program is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||
| 8 | # modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||
| 10 | # Mail: srezic@cpan.org | ||||||||||||||||||||||||||||
| 11 | # WWW: http://www.rezic.de/eserte/ | ||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | package XTerm::Conf; | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 3 | ▶ | use 5.006; # qr, autovivified filehandles | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | # Plethora of xterm control sequences: | ||||||||||||||||||||||||||||
| 19 | # http://rtfm.etla.org/xterm/ctlseq.html | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 3 | ▶ | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 3 | $VERSION = '0.10'; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 3 | require Exporter; | |||||||||||||||||||||||||||
| 27 | 3 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||
| 28 | 3 | @EXPORT = qw(xterm_conf); | |||||||||||||||||||||||||||
| 29 | 3 | @EXPORT_OK = qw(xterm_conf_string terminal_is_supported); | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 3 | ▶ | use Getopt::Long 2.24; # OO interface | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 3 | ▶ | use constant BEL => ""; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | 3 | ▶ | use constant ESC => ""; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 3 | ▶ | use constant IND => ESC . "D"; # Index | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 37 | 3 | ▶ | use constant IND_8 => chr 0x84; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 38 | 3 | ▶ | use constant NEL => ESC . "E"; # Next Line | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 39 | 3 | ▶ | use constant NEL_8 => chr 0x85; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 40 | 3 | ▶ | use constant HTS => ESC . "H"; # Tab Set | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 41 | 3 | ▶ | use constant HTS_8 => chr 0x88; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 42 | 3 | ▶ | use constant RI => ESC . "M"; # Reverse Index | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 43 | 3 | ▶ | use constant RI_8 => chr 0x8d; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 44 | 3 | ▶ | use constant SS2 => ESC . "N"; # Single Shift Select of G2 Character Set: affects next character only | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 45 | 3 | ▶ | use constant SS2_8 => chr 0x8e; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 46 | 3 | ▶ | use constant SS3 => ESC . "O"; # Single Shift Select of G3 Character Set: affects next character only | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 47 | 3 | ▶ | use constant SS3_8 => chr 0x8f; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 48 | 3 | ▶ | use constant DCS => ESC . "P"; # Device Control String | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 49 | 3 | ▶ | use constant DCS_8 => chr 0x90; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 50 | 3 | ▶ | use constant SPA => ESC . "V"; # Start of Guarded Area | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 51 | 3 | ▶ | use constant SPA_8 => chr 0x96; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 52 | 3 | ▶ | use constant EPA => ESC . "W"; # End of Guarded Area | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 53 | 3 | ▶ | use constant EPA_8 => chr 0x97; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 54 | 3 | ▶ | use constant SOS => ESC . "X"; # Start of String | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 55 | 3 | ▶ | use constant SOS_8 => chr 0x98; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 56 | 3 | ▶ | use constant DECID => ESC . "Z"; # Return Terminal ID Obsolete form of CSI c (DA). | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 57 | 3 | ▶ | use constant DECID_8 => chr 0x9a; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 58 | 3 | ▶ | use constant CSI => ESC . "["; # Control Sequence Introducer | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 59 | 3 | ▶ | use constant CSI_8 => chr 0x9b; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 60 | 3 | ▶ | use constant ST => ESC . "\\"; # String Terminator | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 61 | 3 | ▶ | use constant ST_8 => chr 0x9c; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 62 | 3 | ▶ | use constant OSC => ESC . "]"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 63 | 3 | ▶ | use constant OSC_8 => chr 0x9d; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 64 | 3 | ▶ | use constant PM => ESC . "^"; # Privacy Message | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 65 | 3 | ▶ | use constant PM_8 => chr 0x9e; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 66 | 3 | ▶ | use constant APC => ESC . "_"; # Application Program Command | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 67 | 3 | ▶ | use constant APC_8 => chr 0x9f; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 3 | my %o; | |||||||||||||||||||||||||||
| 70 | my $need_reset_terminal; | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | sub xterm_conf_string { | ||||||||||||||||||||||||||||
| 73 | 7 | ▶ | local @ARGV = @_; | ||||||||||||||||||||||||||
|
Subroutine
xterm_conf_string: called CC=48 SCAR=58.3
Pod
documented
| |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 7 | %o = (); | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 7 | my $p = Getopt::Long::Parser->new; | |||||||||||||||||||||||||||
| 78 | 7 | $p->configure('no_ignore_case'); | |||||||||||||||||||||||||||
| 79 | 7 | ▶ | $p->getoptions(\%o, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | "iconname|n=s", | ||||||||||||||||||||||||||||
| 81 | "title|T=s", | ||||||||||||||||||||||||||||
| 82 | "fg|foreground=s", | ||||||||||||||||||||||||||||
| 83 | "bg|background=s", | ||||||||||||||||||||||||||||
| 84 | "textcursor|cr=s", | ||||||||||||||||||||||||||||
| 85 | "mousefg|mouseforeground|ms=s", | ||||||||||||||||||||||||||||
| 86 | "mousebg|mousebackground=s", | ||||||||||||||||||||||||||||
| 87 | "tekfg|tekforeground=s", | ||||||||||||||||||||||||||||
| 88 | "tekbg|tekbackground=s", | ||||||||||||||||||||||||||||
| 89 | "highlightcolor|hc=s", | ||||||||||||||||||||||||||||
| 90 | "bell", | ||||||||||||||||||||||||||||
| 91 | "cs=s", | ||||||||||||||||||||||||||||
| 92 | "fullreset", | ||||||||||||||||||||||||||||
| 93 | "softreset", | ||||||||||||||||||||||||||||
| 94 | "smoothscroll!", # no visual effect | ||||||||||||||||||||||||||||
| 95 | "reverse|reversevideo!", | ||||||||||||||||||||||||||||
| 96 | "origin!", | ||||||||||||||||||||||||||||
| 97 | "wraparound!", | ||||||||||||||||||||||||||||
| 98 | "autorepeat!", | ||||||||||||||||||||||||||||
| 99 | "formfeed!", | ||||||||||||||||||||||||||||
| 100 | "showcursor!", | ||||||||||||||||||||||||||||
| 101 | "showscrollbar!", # rxvt | ||||||||||||||||||||||||||||
| 102 | "tektronix!", | ||||||||||||||||||||||||||||
| 103 | "marginbell!", | ||||||||||||||||||||||||||||
| 104 | "reversewraparound!", | ||||||||||||||||||||||||||||
| 105 | "backsendsdelete!", | ||||||||||||||||||||||||||||
| 106 | "bottomscrolltty!", # rxvt | ||||||||||||||||||||||||||||
| 107 | "bottomscrollkey!", # rxvt | ||||||||||||||||||||||||||||
| 108 | "metasendsesc|metasendsescape!", | ||||||||||||||||||||||||||||
| 109 | "scrollregion=s", | ||||||||||||||||||||||||||||
| 110 | "deiconify", | ||||||||||||||||||||||||||||
| 111 | "iconify", | ||||||||||||||||||||||||||||
| 112 | "geometry=s", | ||||||||||||||||||||||||||||
| 113 | "raise", | ||||||||||||||||||||||||||||
| 114 | "lower", | ||||||||||||||||||||||||||||
| 115 | "refresh|x11refresh", | ||||||||||||||||||||||||||||
| 116 | "maximize", | ||||||||||||||||||||||||||||
| 117 | "unmaximize", | ||||||||||||||||||||||||||||
| 118 | "xproperty|x11property=s", | ||||||||||||||||||||||||||||
| 119 | "font=s", | ||||||||||||||||||||||||||||
| 120 | "nextfont", | ||||||||||||||||||||||||||||
| 121 | "prevfont", | ||||||||||||||||||||||||||||
| 122 | "report=s", | ||||||||||||||||||||||||||||
| 123 | "debugreport", | ||||||||||||||||||||||||||||
| 124 | "resize=i", | ||||||||||||||||||||||||||||
| 125 | ) | ||||||||||||||||||||||||||||
| 126 | or _usage(); | ||||||||||||||||||||||||||||
| 127 | 6 | ▶ | die _usage() if (@ARGV); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 6 | my $rv = ""; | |||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 6 | ▶ | $rv .= BEL if $o{bell}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | CS_SWITCH: { | ||||||||||||||||||||||||||||
| 134 | 6 | ▶ | if (defined $o{cs}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 135 | 0 | ▶ | $rv .= (ESC . '%G'), last if $o{cs} =~ m{^utf-?8$}i; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | 0 | ▶ | $rv .= (ESC . '%@'), last if $o{cs} =~ m{^(latin-?1|iso-?8859-?1)$}i; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | 0 | warn "Unhandled -cs parameter $o{cs}\n"; | |||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 6 | ▶ | $rv .= ESC . "c" if $o{fullreset}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | { | ||||||||||||||||||||||||||||
| 144 | 6 | my %DECSET = qw(smoothscroll 4 | |||||||||||||||||||||||||||
| 145 | reverse 5 | ||||||||||||||||||||||||||||
| 146 | origin 6 | ||||||||||||||||||||||||||||
| 147 | wraparound 7 | ||||||||||||||||||||||||||||
| 148 | autorepeat 8 | ||||||||||||||||||||||||||||
| 149 | formfeed 18 | ||||||||||||||||||||||||||||
| 150 | showcursor 25 | ||||||||||||||||||||||||||||
| 151 | showscrollbar 30 | ||||||||||||||||||||||||||||
| 152 | tektronix 38 | ||||||||||||||||||||||||||||
| 153 | marginbell 44 | ||||||||||||||||||||||||||||
| 154 | reversewraparound 45 | ||||||||||||||||||||||||||||
| 155 | backsendsdelete 67 | ||||||||||||||||||||||||||||
| 156 | bottomscrolltty 1010 | ||||||||||||||||||||||||||||
| 157 | bottomscrollkey 1011 | ||||||||||||||||||||||||||||
| 158 | metasendsesc 1036 | ||||||||||||||||||||||||||||
| 159 | ); | ||||||||||||||||||||||||||||
| 160 | 6 | ▶ | while(my($optname, $Pm) = each %DECSET) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | 90 | ▶ | if (defined $o{$optname}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 0 | ▶ | my $onoff = $o{$optname} ? 'h' : 'l'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | 0 | $rv .= CSI . '?' . $Pm . $onoff; | |||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 6 | ▶ | $rv .= CSI . '!p' if $o{softreset}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 6 | ▶ | if (defined $o{scrollregion}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 171 | 0 | ▶ | if ($o{scrollregion} eq '' || $o{scrollregion} eq 'default') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$o{"scrollregion"} eq "" or $o{"scrollregion"} eq "default"
MC/DC0%0/2
$o{"scrollregion"} eq "" or $o{"scrollregion"} eq "default"
$o{"scrollregion"} eq ""
$o{"scrollregion"} eq "default"
Truth table0%0/3
A or B
A= $o{"scrollregion"} eq ""B= $o{"scrollregion"} eq "default"
| |||||||||||||||||||||||||||||
| 172 | 0 | $rv .= CSI . 'r'; | |||||||||||||||||||||||||||
| 173 | } else { | ||||||||||||||||||||||||||||
| 174 | 0 | my($top,$bottom) = split /,/, $o{scrollregion}; | |||||||||||||||||||||||||||
| 175 | 0 | for ($top, $bottom) { | |||||||||||||||||||||||||||
| 176 | 0 | ▶ | die "Not a number: $_\n" if !/^\d*$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | 0 | $rv .= CSI . $top . ";" . $bottom . "r"; | |||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 6 | ▶ | $rv .= CSI . "1t" if $o{deiconify}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 6 | ▶ | $rv .= CSI . "2t" if $o{iconify}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 6 | ▶ | if (defined $o{geometry}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 186 | 0 | ▶ | if (my($w,$h,$wc,$hc,$x,$y) = $o{geometry} =~ m{^(?:(\d+)x(\d+)|(\d+)cx(\d+)c)?(?:\+(\d+)\+(\d+))?$}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 187 | 0 | ▶ | $rv .= CSI."3;".$x.";".$y."t" if defined $x; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | 0 | ▶ | $rv .= CSI."4;".$h.";".$w."t" if defined $h; # does not work? | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 189 | 0 | ▶ | $rv .= CSI."8;".$hc.";".$wc."t" if defined $hc; # does not work? | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | } else { | ||||||||||||||||||||||||||||
| 191 | 0 | die "Cannot parse geometry string, must be width x height+x+y\n"; | |||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 6 | ▶ | $rv .= CSI . "5t" if $o{raise}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 196 | 6 | ▶ | $rv .= CSI . "6t" if $o{lower}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | 6 | ▶ | $rv .= CSI . "7t" if $o{refresh}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | 6 | ▶ | $rv .= CSI . "9;0t" if $o{unmaximize}; # does not work? | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 199 | 6 | ▶ | $rv .= CSI . "9;1t" if $o{maximize}; # does not work? | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 200 | 6 | ▶ | if ($o{resize}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 201 | die "-resize parameter must be at least 24\n" | ||||||||||||||||||||||||||||
| 202 | 0 | ▶ | if $o{resize} < 24 || $o{resize} !~ /^\d+$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$o{"resize"} < 24 or not $o{"resize"} =~ /^\d+$/
MC/DC0%0/2
$o{"resize"} < 24 or not $o{"resize"} =~ /^\d+$/
$o{"resize"} < 24
not $o{"resize"} =~ /^\d+$/
Truth table0%0/3
A or not(B)
A= $o{"resize"} < 24B= not $o{"resize"} =~ /^\d+$/
| |||||||||||||||||||||||||||||
| 203 | 0 | $rv .= CSI . $o{resize} . 't'; | |||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 6 | ▶ | $rv .= OSC . "1;$o{iconname}" . BEL if defined $o{iconname}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 207 | 6 | ▶ | $rv .= OSC . "2;$o{title}" . BEL if defined $o{title}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 208 | 6 | ▶ | $rv .= OSC . "3;$o{xproperty}" . BEL if defined $o{xproperty}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | 6 | ▶ | $rv .= OSC . "10;$o{fg}" . BEL if defined $o{fg}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | 6 | ▶ | $rv .= OSC . "11;$o{bg}" . BEL if defined $o{bg}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 211 | 6 | ▶ | $rv .= OSC . "12;$o{textcursor}" . BEL if defined $o{textcursor}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 212 | 6 | ▶ | $rv .= OSC . "13;$o{mousefg}" . BEL if defined $o{mousefg}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 213 | 6 | ▶ | $rv .= OSC . "14;$o{mousebg}" . BEL if defined $o{mousebg}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 214 | 6 | ▶ | $rv .= OSC . "15;$o{tekfg}" . BEL if defined $o{tekfg}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | 6 | ▶ | $rv .= OSC . "16;$o{tekbg}" . BEL if defined $o{tekbg}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 216 | 6 | ▶ | $rv .= OSC . "17;$o{highlightcolor}" . BEL if defined $o{highlightcolor}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 217 | 6 | ▶ | $rv .= OSC . "50;#$o{font}" . BEL if defined $o{font}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | 6 | ▶ | $rv .= OSC . "50;#-" . BEL if $o{prevfont}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 219 | 6 | ▶ | $rv .= OSC . "50;#+" . BEL if $o{nextfont}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 6 | ▶ | if ($o{report}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if ($o{report} eq 'cgeometry') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | 0 | my($h,$w) = _report_cgeometry(); | |||||||||||||||||||||||||||
| 224 | 0 | $rv .= $w."x".$h."\n"; | |||||||||||||||||||||||||||
| 225 | } else { | ||||||||||||||||||||||||||||
| 226 | 0 | my $sub = "_report_" . $o{report}; | |||||||||||||||||||||||||||
| 227 | 3 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 228 | 0 | my(@args) = &$sub; | |||||||||||||||||||||||||||
| 229 | 0 | $rv .= join(" ", @args) . "\n"; | |||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 6 | $rv; | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | sub xterm_conf { | ||||||||||||||||||||||||||||
| 237 | # always call xterm_conf_string(), so option validation is done | ||||||||||||||||||||||||||||
| 238 | 4 | ▶ | my $rv = xterm_conf_string(@_); | ||||||||||||||||||||||||||
|
Subroutine
xterm_conf: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 239 | 4 | ▶ | if (terminal_is_supported()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 240 | 2 | local $| = 1; | |||||||||||||||||||||||||||
| 241 | 2 | print $rv; | |||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | sub terminal_is_supported { | ||||||||||||||||||||||||||||
| 246 | 4 | ▶ | my($term) = @_; | ||||||||||||||||||||||||||
|
Subroutine
terminal_is_supported: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 247 | 4 | ▶ | $term = $ENV{TERM} if !defined $term; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | 4 | ▶ | if (!$ENV{TERM}) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 249 | 1 | 0; | |||||||||||||||||||||||||||
| 250 | } elsif ($ENV{TERM} !~ m{^(xterm|rxvt)}) { | ||||||||||||||||||||||||||||
| 251 | 1 | 0; | |||||||||||||||||||||||||||
| 252 | } else { | ||||||||||||||||||||||||||||
| 253 | 2 | 1; | |||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | sub _report ($$) { | ||||||||||||||||||||||||||||
| 258 | 0 | ▶ | my($cmd, $rx) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_report: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | 0 | require Term::ReadKey; | |||||||||||||||||||||||||||
| 261 | 0 | Term::ReadKey::ReadMode(5); | |||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 0 | my @args; | |||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 0 | eval { | |||||||||||||||||||||||||||
| 266 | 0 | require IO::Select; | |||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | 0 | my $debug = $o{debugreport}; | |||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | 0 | ▶ | open my $TTY, "+< /dev/tty" or die "Cannot open terminal /dev/tty: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 271 | 0 | syswrite $TTY, $cmd; | |||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 0 | my $sel = IO::Select->new; | |||||||||||||||||||||||||||
| 274 | 0 | $sel->add($TTY); | |||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | 0 | my $res = ""; | |||||||||||||||||||||||||||
| 277 | 0 | while() { | |||||||||||||||||||||||||||
| 278 | 0 | my(@ready) = $sel->can_read(5); | |||||||||||||||||||||||||||
| 279 | 0 | ▶ | if (!@ready) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 280 | 0 | die "Cannot report, maybe allowWindowOps is set to false?"; | |||||||||||||||||||||||||||
| 281 | 0 | last; | |||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||
| 283 | 0 | ▶ | sysread $TTY, my $ch, 1 or die "Cannot sysread: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 284 | 0 | ▶ | print STDERR ord($ch)." " if $debug; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 285 | 0 | $res .= $ch; | |||||||||||||||||||||||||||
| 286 | 0 | ▶ | last if (@args = $res =~ $rx); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | 0 | 1; | |||||||||||||||||||||||||||
| 290 | }; | ||||||||||||||||||||||||||||
| 291 | 0 | my $err = $@; | |||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | 0 | Term::ReadKey::ReadMode(0); | |||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | 0 | ▶ | if ($err) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 296 | 0 | die "$err\n"; | |||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | 0 | @args; | |||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | 0 | ▶ | sub _report_status { _report CSI.'5n', qr{0n} } | ||||||||||||||||||||||||||
|
Subroutine
_report_status: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 302 | 0 | ▶ | sub _report_cursorpos { _report CSI.'6n', qr{(\d+);(\d+)R} } | ||||||||||||||||||||||||||
|
Subroutine
_report_cursorpos: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 303 | 0 | ▶ | sub _report_windowpos { _report CSI.'13t', qr{;(\d+);(\d+)t} } | ||||||||||||||||||||||||||
|
Subroutine
_report_windowpos: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 304 | 0 | ▶ | sub _report_geometry { _report CSI.'14t', qr{;(\d+);(\d+)t} } | ||||||||||||||||||||||||||
|
Subroutine
_report_geometry: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 305 | 0 | ▶ | sub _report_cgeometry { _report CSI.'18t', qr{;(\d+);(\d+)t} } | ||||||||||||||||||||||||||
|
Subroutine
_report_cgeometry: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 306 | 0 | ▶ | sub _report_cscreengeom { _report CSI.'19t', qr{;(\d+);(\d+)t} } | ||||||||||||||||||||||||||
|
Subroutine
_report_cscreengeom: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 307 | 0 | ▶ | sub _report_iconname { _report CSI.'20t', qr{L(.*?)(?:\Q@{[ST]}\E|\Q@{[ST_8]}\E)} } | ||||||||||||||||||||||||||
|
Subroutine
_report_iconname: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 308 | 0 | ▶ | sub _report_title { _report CSI.'21t', qr{l(.*?)(?:\Q@{[ST]}\E|\Q@{[ST_8]}\E)} } | ||||||||||||||||||||||||||
|
Subroutine
_report_title: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | sub _usage { | ||||||||||||||||||||||||||||
| 311 | 1 | ▶ | die <<EOF; | ||||||||||||||||||||||||||
|
Subroutine
_usage: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 312 | usage: $0 [-n|iconname string] [-T|title string] [-cr|textcursor color] | ||||||||||||||||||||||||||||
| 313 | [-fg|-foreground color] [-bg|-background color color] | ||||||||||||||||||||||||||||
| 314 | [-ms|mousefg|-mouseforeground color] [-mousebg|-mousebackground color] | ||||||||||||||||||||||||||||
| 315 | [-tekfg|-tekforeground color] [-tekbg|-tekbackground color] | ||||||||||||||||||||||||||||
| 316 | [-hc|highlightcolor color] [-bell] [-cs ...] [-fullreset] [-softreset] | ||||||||||||||||||||||||||||
| 317 | [-[no]smoothscroll] [-[no]reverse|reversevideo], [-[no]origin] | ||||||||||||||||||||||||||||
| 318 | [-[no]wraparound] [-[no]autorepeat] [-[no]formfeed] [-[no]showcursor] | ||||||||||||||||||||||||||||
| 319 | [-[no]showscrollbar] [-[no]tektronix] [-[no]marginbell] | ||||||||||||||||||||||||||||
| 320 | [-[no]reversewraparound] [-[no]backsendsdelete] | ||||||||||||||||||||||||||||
| 321 | [-[no]bottomscrolltty] [-[no]bottomscrollkey] | ||||||||||||||||||||||||||||
| 322 | [-[no]metasendsesc|metasendsescape] [-scrollregion ...] | ||||||||||||||||||||||||||||
| 323 | [-deiconify] [-iconify] [-geometry x11geom] [-raise] [-lower] | ||||||||||||||||||||||||||||
| 324 | [-refresh|x11refresh] [-maximize] [-unmaximize] | ||||||||||||||||||||||||||||
| 325 | [-xproperty|x11property ...] [-font ...] [-nextfont] [-prevfont] | ||||||||||||||||||||||||||||
| 326 | [-report ...] [-debugreport] [-resize ...] | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | EOF | ||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | 3 | ▶ | return 1 if caller; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | 0 | xterm_conf(@ARGV); | |||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | __END__ | ||||||||||||||||||||||||||||