| 1 | package Curses::UI; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 11 | ▶ | use base qw(Curses::UI::Common Curses::UI::Container); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # If we do not know a terminal type, then imply VT100. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 8 | ▶ | BEGIN { $ENV{TERM} = 'vt100' unless defined $ENV{TERM} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 8 | ▶ | use Curses; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 8 | ▶ | use Curses::UI::Language; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 8 | ▶ | use Curses::UI::Color; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 8 | ▶ | use FileHandle; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 8 | ▶ | use Term::ReadKey; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | Curses::UI - A curses based OO user interface framework | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | Version 0.9609 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 8 | ▶ | use vars qw( $VERSION ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | $VERSION = 0.9609; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | use Curses::UI; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # create a new C::UI object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | my $cui = Curses::UI->new( -clear_on_exit => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | -debug => $debug, ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # this is where we gloss over setting up all the widgets and data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # structures :) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # start the event loop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | $cui->mainloop; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | Curses::UI is an object-oriented user interface framework for Perl. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | It contains basic widgets (like buttons and text areas), more | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | "advanced" widgets (like UI tabs and a fully-functional basic text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | editor), and some higher-level classes like pre-fab error dialogues. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | See L<Curses::UI::Tutorial> and the C<examples> directory of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | source distribution for more introductory material. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | $Curses::UI::debug = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | $Curses::UI::screen_too_small = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | $Curses::UI::initialized = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | $Curses::UI::color_support = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | $Curses::UI::color_object = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | $Curses::UI::ncurses_mouse = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | $Curses::UI::gpm_mouse = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # Detect if we should use the new moushandler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | if ($ENV{"TERM"} ne "xterm") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | eval { require Curses::UI::Mousehandler::GPM; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | import Curses::UI::Mousehandler::GPM; }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | if (!$@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | $Curses::UI::gpm_mouse = gpm_enable(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | print STDERR "DEBUG: gpm_mouse: " . $Curses::UI::gpm_mouse . "\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | if $Curses::UI::debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # Detect ncurses functionality. Magic for Solaris 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | eval { $Curses::UI::ncurses_mouse = (Curses->can('NCURSES_MOUSE_VERSION') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | (NCURSES_MOUSE_VERSION() >= 1 ) ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | print STDERR "DEBUG: Detected mouse support $Curses::UI::ncurses_mouse\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | if $Curses::UI::debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | =head1 CONSTRUCTOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | Create a new Curses::UI object: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | my $cui = Curses::UI->new( OPTIONS ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | where C<OPTIONS> is one or more of the following. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | =head2 -clear_on_exit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | If true, Curses::UI will call C<clear> on exit. Defaults to false. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | =head2 -color_support | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | If true, Curses::UI tries to enable color for the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | application. Defaults to false. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | =head2 -compat | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | If true, Curses::UI will run in compatibility mode, meaning that only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | very simple characters will be used for creating the widgets. Defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | to false. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | =head2 -keydelay | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | If set to a positive integer, Curses::UI will track elapsed seconds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | since the user's last keystroke, preventing timer events from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | occurring for the specified number of seconds afterwards. By default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | this option is set to '0' (disabled). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | =head2 -mouse_support | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | Curses::UI attempts to auto-discover if mouse support should be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | enabled or not. This option allows a hard override. Expects a boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | =head2 -userdata | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | Takes a scalar (frequently a hashref) as its argument, and stows that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | scalar inside the Curses::UI object where it can be retrieved with the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | L<#userdata> method. Handy inside callbacks and the like. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | =head2 -default_colors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | Directs the underlying Curses library to allow use of default color | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | pairs on terminals. Is preset to true and you almost certainly don't | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | want to twiddle it. See C<man use_default_colors> if you think you do. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 9 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=8 SCAR=21.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 9 | my ($class,%userargs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 9 | ▶ | fatalerror("Curses::UI->new can only be called once!") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | if $Curses::UI::initialized; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 9 | &Curses::UI::Common::keys_to_lowercase(\%userargs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 9 | my %args = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | -compat => 0, # Use compatibility mode? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | -clear_on_exit => 0, # Clear screen if program exits? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | -cursor_mode => 0, # What is the current cursor_mode? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | -debug => undef, # Turn on debugging mode? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | -keydelay => 0, # Track seconds since last keystroke? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | -language => undef, # Which language to use? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | -mouse_support => 1, # Do we want mouse support | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | -overlapping => 1, # Whether overlapping widgets are supported | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | -color_support => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | -default_colors=> 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | #user data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | -userdata => undef, #user internal data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | %userargs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | -read_timeout => -1, # full blocking read by default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | -scheduled_code => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | -added_code => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | -lastkey => 0, # Last keypress time (set in mainloop) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | $Curses::UI::debug = $args{-debug} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 9 | ▶ | if defined $args{-debug}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | $Curses::UI::ncurses_mouse = $args{-mouse_support} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 9 | ▶ | if defined $args{-mouse_support}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 9 | ▶ | if ($Curses::UI::gpm_mouse && $args{-mouse_support}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$Curses::UI::gpm_mouse and $args{"-mouse_support"}
MC/DC50%1/2
$Curses::UI::gpm_mouse and $args{"-mouse_support"}
$Curses::UI::gpm_mouse
$args{"-mouse_support"}
Truth table66%2/3
A and B
A= $Curses::UI::gpm_mouseB= $args{"-mouse_support"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | $Curses::UI::ncurses_mouse = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 1 | $args{-read_timeout} = 0.25; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 8 | $Curses::UI::gpm_mouse = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 9 | my $self = bless { %args }, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 9 | my $lang = new Curses::UI::Language($self->{-language}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 9 | $self->lang($lang); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 9 | ▶ | print STDERR "DEBUG: Loaded language: $lang->{-lang}\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | if $Curses::UI::debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | # Color support | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | $Curses::UI::color_support = $args{-color_support} if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 9 | ▶ | defined $args{-color_support}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 9 | $self->layout(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 9 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 3 | ▶ | DESTROY { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 3 | my $scr = $self->{-canvasscr}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 3 | ▶ | $scr->delwin() if (defined($scr)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 3 | endwin(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 3 | $Curses::UI::initialized = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 3 | ▶ | if ($self->{-clear_on_exit}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | { Curses::erase(); Curses::clear() } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | =head1 EVENT HANDLING METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | =head2 mainloop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | The Curses::UI event handling loop. Call once setup is finished to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | "start" a C::UI program. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | sub mainloop { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mainloop: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # Draw the initial screen. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $self->focus(undef, 1); # 1 = forced focus | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $self->draw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | doupdate(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | $self->{mainloop}=1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | # Inifinite event loop. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | while ($self->{mainloop}) { $self->do_one_event } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | =head2 mainloopExit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | This exits the main loop. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | sub mainloopExit{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mainloopExit: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | my $self=$_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | $self->{mainloop}=undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | =head2 schedule_event | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | Pushes its argument (a coderef) onto the scheduled event stack | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | sub schedule_event { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
schedule_event: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | my ($self, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | $self->fatalerror("schedule_event(): callback is no CODE reference") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $code and ref $code eq "CODE"
MC/DC0%0/2
defined $code and ref $code eq "CODE"
defined $code
ref $code eq "CODE"
Truth table0%0/3
A and B
A= defined $codeB= ref $code eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | unless defined $code and ref $code eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | push @{$self->{-scheduled_code}}, $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | =head1 WINDOW/LAYOUT METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | =head2 layout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | The layout method of Curses::UI tries to find the size of the screen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | then calls the C<layout> method of every contained object (i.e. window | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | or widget). It is not normally necessary to call this method directly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 9 | ▶ | sub layout { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
layout: called CC=10 SCAR=27.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 9 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 9 | $Curses::UI::screen_too_small = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | # find the terminal size. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 9 | my ($cols,$lines) = GetTerminalSize; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 9 | $ENV{COLS} = $cols; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 9 | $ENV{LINES} = $lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 9 | ▶ | if ($Curses::UI::initialized) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my $scr = $self->{-canvasscr}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | $scr->delwin() if (defined($scr)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | endwin(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | # Initialize the curses screen. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 9 | initscr(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 9 | noecho(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 9 | raw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | # Colors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 9 | ▶ | if ($Curses::UI::color_support) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | if ( has_colors() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | $Curses::UI::color_object = new Curses::UI::Color(-default_colors => $self->{-default_colors}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $Curses::UI::color_support = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # Mouse events if possible | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 9 | my $old = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 9 | my $mmreturn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 9 | ▶ | if ( $Curses::UI::ncurses_mouse ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 9 | ▶ | print STDERR "DEBUG: ncurses mouse events are enabled\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | if $Curses::UI::debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # In case of gpm, mousemask fails. (MT: Not for me, maybe GPM changed?) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 9 | eval { $mmreturn = mousemask( ALL_MOUSE_EVENTS(), $old ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 9 | ▶ | if ($Curses::UI::debug) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | print STDERR "DEBUG: mousemask returned $mmreturn\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | print STDERR "DEBUG: Old is now $old\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | print STDERR "DEBUG: mousemask() failed: $@\n" if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | # Create root window. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 9 | my $root = newwin($lines, $cols, 0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 9 | ▶ | die "newwin($lines, $cols, 0, 0) failed\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | unless defined $root; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | # Let this object present itself as a standard | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | # Curses::UI widget, regarding size, location and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | # drawing area. This will make it possible for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | # child windows / widgets to layout and draw themselves. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 9 | $self->{-width} = $self->{-w} = $self->{-bw} = $cols; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 9 | $self->{-height} = $self->{-h} = $self->{-bh} = $lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 9 | $self->{-x} = $self->{-y} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 9 | $self->{-canvasscr} = $root; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | # Walk through all contained objects and let them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | # layout themselves. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 9 | $self->layout_contained_objects; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 9 | $self->draw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 9 | $Curses::UI::initialized = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 9 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | sub layout_new() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
layout_new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $Curses::UI::screen_too_small = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | # find the terminal size. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my ($cols,$lines) = GetTerminalSize; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $ENV{COLS} = $cols; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | $ENV{LINES} = $lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | # Let this object present itself as a standard | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | # Curses::UI widget, regarding size, location and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | # drawing area. This will make it possible for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | # child windows / widgets to layout and draw themselves. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | $self->{-width} = $self->{-w} = $self->{-bw} = $cols; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | $self->{-height} = $self->{-h} = $self->{-bh} = $lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | $self->{-x} = $self->{-y} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | # $self->{-canvasscr} = $root; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | # Walk through all contained objects and let them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | # layout themselves. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | $self->layout_contained_objects; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | $Curses::UI::initialized = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | $self->draw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # Event handling | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | # TODO: document | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | sub do_one_event(;$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_one_event: called CC=18 SCAR=40.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 2 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 2 | ▶ | $object = $self unless defined $object; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 2 | eval {curs_set($self->{-cursor_mode})}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | # gpm mouse? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 2 | ▶ | if ($Curses::UI::gpm_mouse) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 1 | $self->handle_gpm_mouse_event($object); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | doupdate(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | # Read a key or use the feeded key. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 1 | my $key = $self->{-feedkey}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 1 | ▶ | unless (defined $key) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 1 | $key = $self->get_key($self->{-read_timeout}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 1 | $self->{-feedkey} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | # If there was a keypress, set -lastkey | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 1 | ▶ | $self->{-lastkey} = time() unless ($key eq '-1'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | # ncurses sends KEY_RESIZE() key on resize. Ignore this key. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | # TODO: Try to redraw and layout everything anew | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | # KEY_RESIZE doesn't seem to work right; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 1 | ▶ | if (Curses->can("KEY_RESIZE")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | eval { $key = '-1' if $key eq KEY_RESIZE(); }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 1 | my ($cols,$lines) = GetTerminalSize; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 1 | ▶ | if ( ($ENV{COLS} != $cols) || ( $ENV{LINES} != $lines )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ENV{"COLS"} != $cols or $ENV{"LINES"} != $lines
MC/DC0%0/2
$ENV{"COLS"} != $cols or $ENV{"LINES"} != $lines
$ENV{"COLS"} != $cols
$ENV{"LINES"} != $lines
Truth table33%1/3
A or B
A= $ENV{"COLS"} != $colsB= $ENV{"LINES"} != $lines
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | $self->layout(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | $self->draw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | # ncurses sends KEY_MOUSE() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 1 | ▶ | if ($Curses::UI::ncurses_mouse) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 1 | ▶ | if ($key eq KEY_MOUSE()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | print STDERR "DEBUG: Got a KEY_MOUSE(), handeling it\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | if $Curses::UI::debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | $self->handle_mouse_event($object); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | doupdate(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | # If the screen is too small, then <CTRL+C> will exit. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | # Else the next event loop will be started. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 1 | ▶ | if ($Curses::UI::screen_too_small) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | exit(1) if $key eq "\cC"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | # Delegate the keypress. This is not done to $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | # but to $object, so all events will go to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | # object that called do_one_event(). This is used to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | # enable modal focusing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 1 | ▶ | $object->event_keypress($key) unless $key eq '-1'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | # Execute timer code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 1 | $self->do_timer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | # Execute one scheduled event; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 1 | ▶ | if (@{$self->{-scheduled_code}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | my $code = shift @{$self->{-scheduled_code}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | $code->($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | # Execute added code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 1 | foreach my $key (keys %{$self->{-added_code}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | my $code = $self->{-added_code}->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | $self->fatalerror("Method $key is not a coderef") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | if (ref $code ne 'CODE'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | $code->($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | # Update the screen. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 1 | doupdate(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | # TODO: document | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | # TODO: document | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | sub add_callback() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_callback: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | my $id = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | $self->fatalerror( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | "add_callback(): is is not set" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | ) unless defined $id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | $self->fatalerror( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $code and ref $code eq "CODE"
MC/DC0%0/2
defined $code and ref $code eq "CODE"
defined $code
ref $code eq "CODE"
Truth table0%0/3
A and B
A= defined $codeB= ref $code eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | "add_callback(): callback is no CODE reference" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | ) unless defined $code and ref $code eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | $self->{-added_code}->{$id} = $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | # TODO: document | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | sub delete_callback() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_callback: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | my $id = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | $self->fatalerror( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | "delete_callback(): id is not set" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | ) unless defined $id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | delete $self->{-added_code}->{$id} if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | defined $self->{-added_code}->{$id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | sub draw() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 10 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
draw: called CC=4 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 10 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 10 | ▶ | my $no_doupdate = shift || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 10 | ▶ | if ($Curses::UI::screen_too_small) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | my $s = $self->{-canvasscr}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | $s->clear; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | $s->addstr(0, 0, $self->lang->get('screen_too_small')); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | $s->move(4,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | $s->noutrefresh(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | doupdate(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 10 | $self->SUPER::draw(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 10 | ▶ | doupdate() unless $no_doupdate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | # TODO: document | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | sub feedkey() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
feedkey: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | my $key = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | $self->{-feedkey} = $key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | # TODO: document | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | sub flushkeys() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flushkeys: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | my $key = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | my @k = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | ▶ | until ( $key eq "-1" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | $key = $self->get_key(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | # Returns 0 if less than -keydelay seconds have elapsed since the last | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | # user action. Returns the number of elapsed seconds otherwise. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | sub keydelay() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
keydelay: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | my $time = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | my $elapsed = $time - $self->{-lastkey}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | return 0 if ($elapsed < $self->{-keydelay}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | return $elapsed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | # Timed event handling | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | sub set_read_timeout() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_read_timeout: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | my $new_timeout = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | TIMER: while (my ($id, $config) = each %{$self->{-timers}}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | # Skip timer if it is disabled. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | ▶ | next TIMER unless $config->{-enabled}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | $new_timeout = $config->{-time} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | unless $new_timeout != -1 and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | $new_timeout < $config->{-time}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$new_timeout != -1 and $new_timeout < $config->{"-time"}
MC/DC0%0/2
$new_timeout != -1 and $new_timeout < $config->{"-time"}
$new_timeout != -1
$new_timeout < $config->{"-time"}
Truth table0%0/3
A and B
A= $new_timeout != -1B= $new_timeout < $config->{"-time"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | $new_timeout = 1 if $new_timeout < 0 and $new_timeout != -1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$new_timeout < 0 and $new_timeout != -1
MC/DC0%0/2
$new_timeout < 0 and $new_timeout != -1
$new_timeout < 0
$new_timeout != -1
Truth table0%0/3
A and B
A= $new_timeout < 0B= $new_timeout != -1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | $self->{-read_timeout} = $new_timeout; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | sub set_timer($$;) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_timer: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | my $id = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | my $callback = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | my $time = shift || 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 1
MC/DC0%0/1
shift() || 1
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | ▶ | $self->fatalerror( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $callback and ref $callback eq "CODE"
MC/DC0%0/2
defined $callback and ref $callback eq "CODE"
defined $callback
ref $callback eq "CODE"
Truth table0%0/3
A and B
A= defined $callbackB= ref $callback eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | "add_timer(): callback is no CODE reference" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | ) unless defined $callback and ref $callback eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | ▶ | $self->fatalerror( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | "add_timer(): id is not set" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | ) unless defined $id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | my $config = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | -time => $time, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | -callback => $callback, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | -enabled => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | -lastrun => time(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | $self->{-timers}->{$id} = $config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | $self->set_read_timeout; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | sub disable_timer($;) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
disable_timer: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | my ($self,$id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | if (defined $self->{-timers}->{$id}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | $self->{-timers}->{$id}->{-enabled} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | $self->set_read_timeout; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | sub enable_timer($;) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enable_timer: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | my ($self,$id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | ▶ | if (defined $self->{-timers}->{$id}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | $self->{-timers}->{$id}->{-enabled} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | $self->set_read_timeout; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | sub delete_timer($;) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_timer: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | my ($self,$id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | ▶ | if (defined $self->{-timers}->{$id}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | delete $self->{-timers}->{$id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | $self->set_read_timeout; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | sub do_timer() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_timer: called CC=8 SCAR=32.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 1 | my $now = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 1 | my $timers_done = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | # Short-circuit timers if the keydelay hasn't elapsed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 1 | ▶ | if ($self->{-keydelay}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | ▶ | return $self unless $self->keydelay; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 1 | ▶ | TIMER: while (my ($id, $config) = each %{$self->{-timers}}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | # Skip timer if it is disabled. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | ▶ | next TIMER unless $config->{-enabled}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | # No -lastrun set? Then do it now. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | ▶ | unless (defined $config->{-lastrun}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | $config->{-lastrun} = $now; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | next TIMER; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | if ($config->{-lastrun} <= ($now - $config->{-time})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | $config->{-callback}->($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | $config->{-lastrun} = $now; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | $timers_done++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | # Bring the cursor back to the focused object by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | # redrawing it. Due to drawing other objects, it might | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | # have moved to another widget or screen location. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 1 | ▶ | $self->focus_path(-1)->draw if $timers_done; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | # Mouse events | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | sub handle_mouse_event() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_mouse_event: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | ▶ | $object = $self unless defined $object; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | my $MEVENT = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | getmouse($MEVENT); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | # $MEVENT is a struct. From curses.h (note: this might change!): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | # typedef struct | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | # { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | # short id; /* ID to distinguish multiple devices */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | # int x, y, z; /* event coordinates (character-cell) */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | # mmask_t bstate; /* button state bits */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | # } MEVENT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | # --------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | # s signed short | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | # x null byte | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | # x null byte | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | # --------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | # i integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | # --------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | # i integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | # --------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | # i integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | # --------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | # l long | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | # --------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | my ($id, $x, $y, $z, $bstate) = unpack("sx2i3l", $MEVENT); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | my %MEVENT = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | -id => $id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | -x => $x, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | -y => $y, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | -bstate => $bstate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | # Get the objects at the mouse event position. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | my $tree = $self->object_at_xy($object, $MEVENT{-x}, $MEVENT{-y}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | # Walk through the object tree, top object first. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | foreach my $object (reverse @$tree) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | # Send the mouse-event to the object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | # Leave the loop if the object handled the event. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | ▶ | print STDERR "Asking $object to handle $MEVENT{-bstate} ...\n" if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | $Curses::UI::debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | my $return = $object->event_mouse(\%MEVENT); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | ▶ | last if defined $return and $return ne 'DELEGATE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $return and $return ne "DELEGATE"
MC/DC0%0/2
defined $return and $return ne "DELEGATE"
defined $return
$return ne "DELEGATE"
Truth table0%0/3
A and B
A= defined $returnB= $return ne "DELEGATE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | sub handle_gpm_mouse_event() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_gpm_mouse_event: called CC=7 SCAR=31.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 1 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 1 | ▶ | $object = $self unless defined $object; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 1 | ▶ | return unless $Curses::UI::gpm_mouse; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 1 | my $MEVENT = gpm_get_mouse_event(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | # $MEVENT from C:UI:MH:GPM is identical. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | return unless $MEVENT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | my ($id, $x, $y, $z, $bstate) = unpack("sx2i3l", $MEVENT); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | my %MEVENT = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | -id => $id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | -x => $x, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | -y => $y, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | -bstate => $bstate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | # Get the objects at the mouse event position. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | my $tree = $self->object_at_xy($object, $MEVENT{-x}, $MEVENT{-y}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | # Walk through the object tree, top object first. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | foreach my $object (reverse @$tree) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | # Send the mouse-event to the object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | # Leave the loop if the object handled the event. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | my $return = $object->event_mouse(\%MEVENT); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | ▶ | last if defined $return and $return ne 'DELEGATE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $return and $return ne "DELEGATE"
MC/DC0%0/2
defined $return and $return ne "DELEGATE"
defined $return
$return ne "DELEGATE"
Truth table0%0/3
A and B
A= defined $returnB= $return ne "DELEGATE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | sub object_at_xy($$;$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
object_at_xy: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | my $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | my $y = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | my $tree = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | ▶ | $tree = [] unless defined $tree; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | push @$tree, $object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | my $idx = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | ▶ | while (defined $object->{-draworder}->[$idx]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | my $testobj = $object->getobj($object->{-draworder}->[$idx]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | $idx--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | # Find the window parameters for the $testobj. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | ▶ | my $scr = defined $testobj->{-borderscr} ? '-borderscr' : '-canvasscr'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | my $winp = $testobj->windowparameters($scr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | # Does the click fall inside this object? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | ▶ | if ( $x >= $winp->{-x} and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$x >= $winp->{"-x"} and $x < $winp->{"-x"} + $winp->{"-w"} and $y >= $winp->{"-y"} and $y < $winp->{"-y"} + $winp->{"-h"}
$x >= $winp->{"-x"} and $x < $winp->{"-x"} + $winp->{"-w"} and $y >= $winp->{"-y"}
$x >= $winp->{"-x"} and $x < $winp->{"-x"} + $winp->{"-w"}
MC/DC0%0/4
$x >= $winp->{"-x"} and $x < $winp->{"-x"} + $winp->{"-w"} and $y >= $winp->{"-y"} and $y < $winp->{"-y"} + $winp->{"-h"}
$x >= $winp->{"-x"}
$x < $winp->{"-x"} + $winp->{"-w"}
$y >= $winp->{"-y"}
$y < $winp->{"-y"} + $winp->{"-h"}
Truth table0%0/5
A and B and C and D
A= $x >= $winp->{"-x"}B= $x < $winp->{"-x"} + $winp->{"-w"}C= $y >= $winp->{"-y"}D= $y < $winp->{"-y"} + $winp->{"-h"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | $x < ($winp->{-x}+$winp->{-w}) and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | $y >= $winp->{-y} and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | $y < ($winp->{-y}+$winp->{-h}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | ▶ | if ( $testobj->isa('Curses::UI::Container') and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$testobj->isa("Curses::UI::Container") and not $testobj->isa("Curses::UI::ContainerWidget")
MC/DC0%0/2
$testobj->isa("Curses::UI::Container") and not $testobj->isa("Curses::UI::ContainerWidget")
$testobj->isa("Curses::UI::Container")
not $testobj->isa("Curses::UI::ContainerWidget")
Truth table0%0/3
A and not(B)
A= $testobj->isa("Curses::UI::Container")B= not $testobj->isa("Curses::UI::ContainerWidget")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | not $testobj->isa('Curses::UI::ContainerWidget')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | $self->object_at_xy($testobj, $x, $y, $tree) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | push @$tree, $testobj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | return $tree; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | return $tree; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | # Other subroutines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | # TODO: document | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | sub fatalerror($$;$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fatalerror: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | my $error = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | my $exit = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | ▶ | $exit = 1 unless defined $exit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | chomp $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | $error .= "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | my $s = $self->{-canvasscr}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | $s->clear; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | $s->addstr(0,0,"Fatal program error:\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | . "-"x($ENV{COLS}-1) . "\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | . $error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | . "-"x($ENV{COLS}-1) . "\n" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | . "Press any key to exit..."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | $s->noutrefresh(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | doupdate(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | $self->flushkeys(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | for (;;) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | my $key = $self->get_key(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | ▶ | last if $key ne "-1"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | exit($exit); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | sub usemodule($;) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 25 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
usemodule: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 25 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 25 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | # Create class filename. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 25 | my $file = $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 25 | $file =~ s|::|/|g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 25 | $file .= '.pm'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | # Automatically load the required class. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 25 | ▶ | if (not defined $INC{$file}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 9 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 9 | require $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 9 | $class->import; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | # Fatal error if the class could not be loaded. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 9 | ▶ | $self->fatalerror("Could not load $class from $file:\n$@") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 25 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | sub focus_path() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
focus_path: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 3 | my $index = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 3 | my $p_obj = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 3 | my @path = ($p_obj); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 3 | for(;;) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 9 | my $p_el = $p_obj->{-draworder}->[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 9 | ▶ | last unless defined $p_el; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 6 | $p_obj = $p_obj->{-id2object}->{$p_el}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 6 | push @path, $p_obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 6 | ▶ | last if $p_obj->isa('Curses::UI::ContainerWidget'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 3 | ▶ | return (defined $index ? $path[$index] : @path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | # add() is overridden, because we only want to be able | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | # to add Curses::UI:Window objects to the Curses::UI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | # rootlevel. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | sub add() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 6 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 6 | my $id = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 6 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 6 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | # Make it possible to specify WidgetType instead of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | # Curses::UI::WidgetType. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 6 | ▶ | $class = "Curses::UI::$class" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $class =~ /\:\:/ or $class =~ /^Dialog\:\:[^\:]+$/
MC/DC0%0/2
not $class =~ /\:\:/ or $class =~ /^Dialog\:\:[^\:]+$/
not $class =~ /\:\:/
$class =~ /^Dialog\:\:[^\:]+$/
Truth table33%1/3
not(A) or B
A= not $class =~ /\:\:/B= $class =~ /^Dialog\:\:[^\:]+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | if $class !~ /\:\:/ or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | $class =~ /^Dialog\:\:[^\:]+$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 6 | $self->usemodule($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 6 | ▶ | $self->fatalerror( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | "You may only add Curses::UI::Window objects to " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | . "Curses::UI and no $class objects" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | ) unless $class->isa('Curses::UI::Window'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 6 | $self->SUPER::add($id, $class, %args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | # Sets/Get the user data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | sub userdata | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
userdata: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 2 | ▶ | if (defined $_[0]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 1 | $self->{-userdata} = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 2 | return $self->{-userdata}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | # Focusable dialog windows | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | sub tempdialog() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tempdialog: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | my $id = "__window_$class"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 0 | my $dialog = $self->add($id, $class, %args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | $dialog->modalfocus; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 0 | my $return = $dialog->get; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | $self->delete($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | $self->root->focus(undef, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | return $return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | # The argument list will be returned unchanged, unless it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | # contains only one item. In that case ($ifone, $_[0]) will | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | # be returned. This enables constructions like: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | # $cui->dialog("Some dialog message"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | # instead of: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | # $cui->dialog(-message => "Some dialog message"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | sub process_args() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process_args: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | my $ifone = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | ▶ | if (@_ == 1) { @_ = ($ifone => $_[0]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | return @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | sub error() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | my %args = $self->process_args('-message', @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | $self->tempdialog('Dialog::Error', %args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | sub dialog() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dialog: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | my %args = $self->process_args('-message', @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | $self->tempdialog('Dialog::Basic', %args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | sub question() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
question: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | my %args = $self->process_args('-question', @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 0 | $self->tempdialog('Dialog::Question', %args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | sub calendardialog() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
calendardialog: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | my %args = $self->process_args('-title', @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | $self->tempdialog('Dialog::Calendar', %args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | sub filebrowser() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filebrowser: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | my %args = $self->process_args('-title', @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | # Create title | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | ▶ | unless (defined $args{-title}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | my $l = $self->root->lang; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | $args{-title} = $l->get('file_title'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | # Select a file to load from. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | $self->tempdialog('Dialog::Filebrowser', %args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | sub dirbrowser() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dirbrowser: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | my %args = $self->process_args('-title', @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | # Create title | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 0 | ▶ | unless (defined $args{-title}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | my $l = $self->root->lang; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | $args{-title} = $l->get('dir_title'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | # Select a file to load from. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | $self->tempdialog('Dialog::Dirbrowser', %args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | sub savefilebrowser() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
savefilebrowser: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | my %args = $self->process_args('-title', @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 0 | my $l = $self->root->lang; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | # Create title. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | $args{-title} = $l->get('file_savetitle') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | ▶ | unless defined $args{-title}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | # Select a file to save to. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | 0 | my $file = $self->filebrowser(-editfilename => 1, %args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 0 | ▶ | return unless defined $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | # Check if the file exists. Ask for overwrite | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | # permission if it does. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 0 | ▶ | if (-e $file) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | # Get language specific data. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 0 | my $pre = $l->get('file_overwrite_question_pre'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 0 | my $post = $l->get('file_overwrite_question_post'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 0 | my $title = $l->get('file_overwrite_title'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | my $overwrite = $self->dialog( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | -title => $title, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | -buttons => [ 'yes', 'no' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | -message => $pre . $file . $post, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 0 | ▶ | return unless $overwrite; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | return $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | sub loadfilebrowser() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loadfilebrowser: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | 0 | my %args = $self->process_args('-title', @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | # Create title | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 0 | ▶ | unless (defined $args{-title}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 0 | my $l = $self->root->lang; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 0 | $args{-title} = $l->get('file_loadtitle'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 0 | $self->filebrowser(-editfilename => 0, %args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | # Non-focusable dialogs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | my $status_id = "__status_dialog"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | sub status($;) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
status: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 0 | my %args = $self->process_args('-message', @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 0 | $self->delete($status_id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 0 | $self->add($status_id, 'Dialog::Status', %args)->draw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | sub nostatus() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nostatus: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 0 | $self->delete($status_id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 0 | $self->flushkeys(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 0 | $self->draw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | sub progress() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
progress: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 0 | $self->add( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | "__progress_$self", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 'Dialog::Progress', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | %args | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 0 | $self->draw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | sub setprogress($;$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setprogress: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 0 | my $pos = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 0 | my $message = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | # If I do not do this, the progress bar seems frozen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | # if a key is pressed on my Solaris machine. Flushing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | # the input keys solves this. And this is not a bad | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | # thing to do during a progress dialog (input is ignored | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | # this way). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 0 | $self->flushkeys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 0 | my $p = $self->getobj("__progress_$self"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 0 | ▶ | return unless defined $p; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 0 | ▶ | $p->pos($pos) if defined $pos; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 0 | ▶ | $p->message($message) if defined $message; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | 0 | $p->draw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | sub noprogress() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
noprogress: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 0 | $self->delete("__progress_$self"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 0 | $self->flushkeys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 0 | $self->draw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | sub leave_curses() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 7 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
leave_curses: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 7 | def_prog_mode(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 7 | endwin(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | sub reset_curses() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_curses: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 0 | reset_prog_mode(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 0 | $self->layout(); # In case the terminal has been resized | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | ### Color support | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 1 | ▶ | sub color() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
color: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 1 | return $Curses::UI::color_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 1 | ▶ | sub set_color { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_color: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 1 | my $co = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 1 | $Curses::UI::color_object = $co; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | # Accessor functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | # ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | 0 | ▶ | sub compat(;$) { shift()->accessor('-compat', shift()) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compat: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | 4 | ▶ | sub clear_on_exit(;$) { shift()->accessor('-clear_on_exit', shift()) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_on_exit: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 0 | ▶ | sub cursor_mode(;$) { shift()->accessor('-cursor_mode', shift()) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cursor_mode: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 9 | ▶ | sub lang(;$) { shift()->accessor('-language_object', shift()) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lang: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | 3 | ▶ | sub overlapping(;$) { shift()->accessor('-overlapping', shift()) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
overlapping: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | # TODO: document | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | sub debug(;$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 0 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | 0 | $Curses::UI::debug = $self->accessor('-debug', $value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | =head1 CONVENIENCE DIALOG METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | =head2 dialog | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | Use the C<dialog> method to show a dialog window. If you only provide | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | a single argument, this argument will be used as the message to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | show. Example: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | $cui->dialog("Hello, world!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | If you want to have some more control over the dialog window, you will | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | have to provide more arguments (for an explanation of the arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | that can be used, see L<Curses::UI::Dialog::Basic>. Example: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | my $yes = $cui->dialog( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | -message => "Hello, world?", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | -buttons =3D> ['yes','no'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | -values => [1,0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | -title => 'Question', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | if ($yes) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | # whatever | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | =head2 error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | The C<error> method will create an error dialog. This is basically a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | Curses::UI::Dialog::Basic, but it has an ASCII-art exclamation sign | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | drawn left to the message. For the rest it's just like | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | C<dialog>. Example: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | $cui->error("It's the end of the\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | ."world as we know it!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | =head2 filebrowser | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | Creates a file browser dialog. For an explanation of the arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | that can be used, see L<Curses::UI::Dialog::Filebrowser>. Example: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | my $file = $cui->filebrowser( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | -path => "/tmp", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | -show_hidden => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | # Filebrowser will return undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | # if no file was selected. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | if (defined $file) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | unless (open F, ">$file") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | print F "Hello, world!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | close F; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | $cui->error(qq(Error on writing to "$file":\n$!)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | =head2 loadfilebrowser, savefilebrowser | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | These two methods will create file browser dialogs as well. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | difference is that these will have the dialogs set up correctly for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | loading and saving files. Moreover, the save dialog will check if the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | selected file exists or not. If it does exist, it will show an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | overwrite confirmation to check if the user really wants to overwrite | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | the selected file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | =head2 status, nostatus | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | Using these methods it's easy to provide status information for the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | user of your program. The status dialog is a dialog with only a label | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | on it. The status dialog doesn't really get the focus. It's only used | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | to display some information. If you need more than one status, you can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | call C<status> subsequently. Any existing status dialog will be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | cleaned up and a new one will be created. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | If you are finished, you can delete the status dialog by calling the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | C<nostatus> method. Example: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | $cui->status("Saying hello to the world..."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | # code for saying "Hello, world!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | $cui->status("Saying goodbye to the world..."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | # code for saying "Goodbye, world!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | $cui->nostatus; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | =head2 progress, setprogress, noprogress | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | Using these methods it's easy to provide progress information to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | user. The progress dialog is a dialog with an optional label on it and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | a progress bar. Similar to the status dialog, this dialog does not get | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | the focus. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | Using the C<progress> method, a new progress dialog can be created. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | This method takes the same arguments as the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | L<Curses::IU::Dialog::Progress> class. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | After that the progress can be set using C<setprogress>. This method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | takes one or two arguments. The first argument is the current position | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | of the progressbar. The second argument is the message to show in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | label. If one of these arguments is undefined, the current value will | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | be kept. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | If you are finished, you can delete the progress dialog by calling the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | C<noprogress> method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | $cui->progress( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | -max => 10, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | -message => "Counting 10 seconds...", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | for my $second (0..10) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | $cui->setprogress($second) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | sleep 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | $cui->noprogress; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | =head1 OTHER METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | =item B<leave_curses> ( ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | Temporarily leaves curses mode and recovers normal terminal mode. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | =item B<reset_curses> ( ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | Return to curses mode after B<leave_curses()>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | =item B<add> ( ID, CLASS, OPTIONS ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | The B<add> method of Curses::UI is almost the same as the B<add> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | method of Curses::UI::Container. The difference is that Curses::UI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | will only accept classes that are (descendants) of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | Curses::UI::Window class. For the rest of the information see | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | L<Curses::UI::Container|Curses::UI::Container>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | =item B<add_callback> ( ID, CODE) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | This method lets you add a callback into the mainloop permanently. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | The code is executed after the input handler has run. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | =item B<delete_callback> ( ID ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | This method deletes the CODE specified by ID from the mainloop. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | =item B<usemodule> ( CLASSNAME ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | Loads the with CLASSNAME given module. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | =item B<userdata> ( [ SCALAR ] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | This method will return the user internal data stored in the UI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | object. If a SCALAR parameter is specified it will also set the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | current user data to it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | =item B<keydelay> ( ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | This method is used internally to control timer events when the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | B<-keydelay> option is set, but it can be called directly it to find | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | out if the required amount of time has passed since the user's last | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | action. B<keydelay>() will return 0 if insufficent time has passed, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | and will return the number of elapsed seconds otherwise. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | =item B<compat> ( [BOOLEAN] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | The B<-compat> option will be set to the BOOLEAN value, unless BOOLEAN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | is omitted. The method returns the current value for B<-compat>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | =item B<clear_on_exit> ( [BOOLEAN] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | The B<-clear_on_exit> option will be set to the BOOLEAN value, unless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | BOOLEAN is omitted. The method returns the current value for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | B<-clear_on_exit>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | =item B<color> ( ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | Returns the currently used Curses::UI::Color object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | =item B<set_color> ( OBJECT ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | Replaces the currently used Color object with another. This can be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | used to fast change all colors in a Curses::UI application. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | =item L<Curses> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | =item L<Curses::UI::POE> (a POE eventsystem and mainloop for Curses::UI) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | =item L<http://curses-ui.googlecode.com/> (SVN repo, info, and links) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | Please report any bugs or feature requests to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | C<bug-curses-ui@rt.cpan.org>, or through the web interface at | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Curses-UI>. I will be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | notified, and then you'll automatically be notified of progress on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | your bug as I make changes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | Shawn Boyette C<< <mdxi@cpan.org> >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | See the CREDITS file for additional information. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | Copyright 2001-2002 Maurice Makaay; 2003-2006 Marcus Thiesen; 2007, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | 2008 Shawn Boyette. All Rights Reserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | This package is free software and is provided "as is" without express | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | or implied warranty. It may be used, redistributed and/or modified | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | under the same terms as perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | =head1 CLASS LISTING | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | =head2 Widgets | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | =item L<Curses::UI::Buttonbox> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | =item L<Curses::UI::Calendar> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | =item L<Curses::UI::Checkbox> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | =item L<Curses::UI::Label> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | =item L<Curses::UI::Listbox> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | =item L<Curses::UI::Menubar> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | =item L<Curses::UI::MenuListbox> (used by Curses::UI::Menubar) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | =item L<Curses::UI::Notebook> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | =item L<Curses::UI::PasswordEntry> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | =item L<Curses::UI::Popupmenu> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | =item L<Curses::UI::Progressbar> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | =item L<Curses::UI::Radiobuttonbox> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | =item L<Curses::UI::SearchEntry> (used by Curses::UI::Searchable) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | =item L<Curses::UI::TextEditor> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | =item L<Curses::UI::TextEntry> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | =item L<Curses::UI::TextViewer> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | =item L<Curses::UI::Window> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | =head2 Dialogs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | =item L<Curses::UI::Dialog::Basic> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | =item L<Curses::UI::Dialog::Error> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | =item L<Curses::UI::Dialog::Filebrowser> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | =item L<Curses::UI::Dialog::Status> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | =head2 Base and Support Classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | =item L<Curses::UI::Widget> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | =item L<Curses::UI::Container> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | =item L<Curses::UI::Color> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | =item L<Curses::UI::Common> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | =item L<Curses::UI::Searchable> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | 1; # end of Curses::UI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||