File Coverage

blib/lib/X11/Terminal/XTerm.pm
Criterion Covered Total %
statement 18 18 100.0
branch 12 12 100.0
condition n/a
subroutine 2 2 100.0
pod 1 1 100.0
total 33 33 100.0


line stmt bran cond sub pod time code
1             package X11::Terminal::XTerm;
2              
3 2     2   69588 use Moose;
  2         466879  
  2         19  
4             extends 'X11::Terminal';
5              
6             our $VERSION = 1.0.0;
7              
8             =head1 NAME
9              
10             X11::Terminal::XTerm - Create customised xterm windows
11              
12             =head1 SYNOPSIS
13              
14             This module provides an object interface to launching xterm windows.
15              
16             use X11::Terminal::XTerm;
17              
18             my $t1 = X11::Terminal::XTerm->new();
19             my $t2 = X11::Terminal::XTerm->new(host => "remoteserver");
20             my $t3 = X11::Terminal::XTerm->new(foreground => "green");
21              
22             for ( $t1, $t2, $t3 ) {
23             $_->launch();
24             }
25              
26              
27             =head1 CONSTRUCTOR
28              
29             =over 4
30              
31             =item X11::Terminal::XTerm->new(%attr);
32              
33             Create a new XTerm object, optionally with the specified attributes
34             (see below).
35              
36             =back
37              
38              
39             =head1 ATTRIBUTES
40              
41             Each of the following attributes provide an accessor method, but they can
42             also be set in the constructor.
43              
44             =over 4
45            
46             =item host
47              
48             Specifies the remote host to log in to (using ssh).
49              
50             =item agentforward
51              
52             If the host has been specified, and agentforward is true, the login to that
53             host will use SSH Agent Forwarding.
54              
55             =item xforward
56              
57             If the host has been specified, and xforward is true, the login to that host
58             will use SSH X Forwarding.
59              
60             =item foreground
61              
62             Set the forground colour to be used in the XTerm window
63              
64             =item background
65              
66             Set the background colour to be used in the XTerm window
67              
68             =item scrollback
69              
70             Set the number of lines that should be stored made accessible via the xterm
71             scrollback buffer
72              
73             =item font
74              
75             Set the font used in the XTerm window
76              
77             =item profile
78              
79             Set the X11 resource name used by the XTerm window
80              
81             =item geometry
82              
83             Set the preferred size and position of the XTerm window
84              
85             =back
86              
87              
88             =head1 OTHER METHODS
89              
90             =over 4
91              
92             =item launch($debug);
93              
94             Calculates (and returns) the command that will launch your xterm. It also
95             runs that command in a child process - unless $debug is specified.
96              
97             =item terminalArgs();
98              
99             Return the arguments that will be passed to the xterm. This will provide
100             the customisations. There should be no reason to call this method directly.
101             =cut
102              
103             sub terminalArgs {
104 38     38 1 62 my ($self) = @_;
105              
106 38         56 my $args = "";
107 38 100       899 if ( my $font = $self->font() ) {
108 3         8 $args .= " -fn $font";
109             }
110 38 100       874 if ( my $name = $self->profile() ) {
111 3         7 $args .= " -name $name";
112             }
113 38 100       917 if ( my $colour = $self->foreground() ) {
114 3         7 $args .= " -fg $colour";
115             }
116 38 100       880 if ( my $geo = $self->geometry() ) {
117 3         8 $args .= " -geometry $geo";
118             }
119 38 100       901 if ( my $colour = $self->background() ) {
120 3         7 $args .= " -bg $colour";
121             }
122 38 100       902 if ( my $lines = $self->scrollback() ) {
123 3         9 $args .= " -sl $lines";
124             }
125 38         103 return "$args";
126             }
127              
128             =back
129              
130             =head1 SEE ALSO
131              
132             L<X11::Terminal>
133              
134             =head1 COPYRIGHT
135              
136             Copyright 2010-2011 Evan Giles.
137              
138             This module is free software; you can redistribute it and/or modify it
139             under the same terms as Perl itself.
140             =cut
141              
142             1; # End of X11::Terminal::XTerm