[Bps-public-commit] r9850 - in RT-Client-Console: trunk/lib/RT/Client trunk/lib/RT/Client/Console/Session trunk/lib/RT/Client/Console/Session/Ticket
dams at bestpractical.com
dams at bestpractical.com
Sat Dec 8 11:53:21 EST 2007
Author: dams
Date: Sat Dec 8 11:53:20 2007
New Revision: 9850
Modified:
RT-Client-Console/ (props changed)
RT-Client-Console/trunk/lib/RT/Client/Console.pm
RT-Client-Console/trunk/lib/RT/Client/Console/Session/KeyHandler.pm
RT-Client-Console/trunk/lib/RT/Client/Console/Session/Root.pm
RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Attachments.pm
RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/CustFields.pm
RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Header.pm
RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Links.pm
Log:
r23 at pundit: dams | 2007-12-08 16:51:02 +0000
keys are now displayed per sections
Modified: RT-Client-Console/trunk/lib/RT/Client/Console.pm
==============================================================================
--- RT-Client-Console/trunk/lib/RT/Client/Console.pm (original)
+++ RT-Client-Console/trunk/lib/RT/Client/Console.pm Sat Dec 8 11:53:20 2007
@@ -68,6 +68,66 @@
}
+sub draw_keys_label {
+ my ($class, %params) = @_;
+
+ my $max_length = $params{COLUMNS};
+ my $current_x = 0;
+
+ my $foreground = $params{FOREGROUND} || 'white';
+ my $foreground2 = $params{FOREGROUND2} || 'yellow';
+ my $background = $params{BACKGROUND} || 'blue';
+
+ use Curses;
+
+ foreach my $key_struct (@{$params{VALUE}}) {
+ my ($key, $text) = @$key_struct;
+ $key = " $key: ";
+ $text = "$text ";
+ attron(A_BOLD);
+ $max_length -= length($key);
+ $max_length >= 0 or last;
+ my $label = Curses::Widgets::Label->new({
+ BORDER => 0,
+ LINES => 1,
+ COLUMNS => length($key),
+ Y => $params{Y},
+ X => $params{X} + $current_x,
+ VALUE => $key,
+ FOREGROUND => $foreground2,
+ BACKGROUND => $background,
+ });
+ $label->draw($class->get_curses_handler());
+ $current_x += length($key);
+ attroff(A_BOLD);
+
+ $max_length - length($text) >= 0 or $text = substr($text, 0, $max_length);
+ $max_length -= length($text);
+ $label = Curses::Widgets::Label->new({
+ BORDER => 0,
+ LINES => 1,
+ COLUMNS => length($text),
+ Y => $params{Y},
+ X => $params{X} + $current_x,
+ VALUE => $text,
+ FOREGROUND => $foreground,
+ BACKGROUND => $background,
+ });
+ $label->draw($class->get_curses_handler());
+ $current_x += length($text);
+ $current_x++;
+ $max_length--;
+ }
+}
+# $params{Y}
+# $params{X}
+# $params{COLUMNS}
+# $params{FOREGROUND}
+# $params{BACKGROUND}
+# }
+
+
+
use Curses::Forms::Dialog;
sub error {
my ($class, $message) = @_;
Modified: RT-Client-Console/trunk/lib/RT/Client/Console/Session/KeyHandler.pm
==============================================================================
--- RT-Client-Console/trunk/lib/RT/Client/Console/Session/KeyHandler.pm (original)
+++ RT-Client-Console/trunk/lib/RT/Client/Console/Session/KeyHandler.pm Sat Dec 8 11:53:20 2007
@@ -72,11 +72,11 @@
draw_all => sub {
my ($kernel, $heap) = @_[ KERNEL, HEAP ];
noutrefresh();
- if ($class->GLOBAL_HEAP->{curses}{need_clear}) {
- clear();
- $class->GLOBAL_HEAP->{curses}{need_clear} = 0;
- $kernel->yield('draw_all');
- } else {
+# if ($class->GLOBAL_HEAP->{curses}{need_clear}) {
+# clear();
+# $class->GLOBAL_HEAP->{curses}{need_clear} = 0;
+# $kernel->yield('draw_all');
+# } else {
my %sessions = $class->get_sessions();
while (my ($session_name, $struct) = each %sessions) {
$struct->{displayed} and
@@ -85,7 +85,7 @@
foreach my $modal_session ($class->get_modal_sessions()) {
$kernel->call($modal_session, 'draw');
}
- }
+# }
doupdate();
}
},
Modified: RT-Client-Console/trunk/lib/RT/Client/Console/Session/Root.pm
==============================================================================
--- RT-Client-Console/trunk/lib/RT/Client/Console/Session/Root.pm (original)
+++ RT-Client-Console/trunk/lib/RT/Client/Console/Session/Root.pm Sat Dec 8 11:53:20 2007
@@ -19,8 +19,19 @@
print STDERR "root : init\n";
$class->get_curses_handler()->clear();
$kernel->yield('create_tab_bar');
- $kernel->yield('create_status_session');
+# $kernel->yield('create_status_session');
$kernel->yield('create_progress_session');
+
+ my ($screen_w, $screen_h);
+ $class->get_curses_handler()->getmaxyx($screen_h, $screen_w);
+
+ $heap->{'pos_x'} = 0;
+ $heap->{'pos_y'} = $screen_h - 2;
+ $heap->{width} = $screen_w;
+ $heap->{height} = 1;
+
+ $kernel->call('root', 'draw');
+
},
available_keys => sub {
my @available_list = ();
@@ -39,6 +50,38 @@
}
return @available_list;
},
+ draw => sub {
+ my ($kernel, $heap) = @_[ KERNEL, HEAP ];
+ my @keys = $kernel->call(root => 'available_keys');
+ $class->draw_keys_label( Y => $heap->{'pos_y'},
+ X => $heap->{'pos_x'},
+ COLUMNS => $heap->{width},
+ VALUE => \@keys,
+ );
+# my $message = ' ' . join(' - ', @keys);
+#print STDERR "\n\n----------------- $message ----------\n";
+#use Curses;
+# move($heap->{'pos_y'}, $heap->{'pos_x'});
+# addstr("** TEST **");
+# doupdate();
+# addch("** TEST **", )
+# # Render the key box
+# use Curses::Widgets::Label;
+# $label = Curses::Widgets::Label->new({
+# CAPTION => ' Keys ',
+# BORDER => 0,
+# LINES => $heap->{height},
+# COLUMNS => $heap->{width},
+# Y => $heap->{'pos_y'},
+# X => $heap->{'pos_x'},
+# VALUE => $message,
+# FOREGROUND => 'white',
+# BACKGROUND => 'blue',
+## BORDERCOL => 'black',
+# });
+# #refresh;
+# $label->draw($class->get_curses_handler());
+ },
create_tab_bar => sub {
use RT::Client::Console::Session::TabBar;
RT::Client::Console::Session::TabBar->create();
Modified: RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Attachments.pm
==============================================================================
--- RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Attachments.pm (original)
+++ RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Attachments.pm Sat Dec 8 11:53:20 2007
@@ -21,9 +21,9 @@
$class->get_curses_handler()->getmaxyx($screen_h, $screen_w);
$heap->{'pos_x'} = 0;
- $heap->{'pos_y'} = 1+5+5;
+ $heap->{'pos_y'} = 1+5+5+1;
$heap->{width} = $screen_w * 2 / 3 - 2;
- $heap->{height} = $screen_h - 5 - 7 - 5;
+ $heap->{height} = $screen_h - 5 - 7 - 4;
},
available_keys => sub {
@@ -33,17 +33,17 @@
},
next_attachment => sub {
my ( $kernel, $heap) = @_[ KERNEL, HEAP ];
- $class->GLOBAL_HEAP->{rt}{attachments}{$ticket_id}{current}++;
- $class->GLOBAL_HEAP->{rt}{attachments}{$ticket_id}{current} > $class->GLOBAL_HEAP->{rt}{attachments}{$ticket_id}{total} - 1
- and $class->GLOBAL_HEAP->{rt}{attachments}{$ticket_id}{current} = $class->GLOBAL_HEAP->{rt}{attachments}{$ticket_id}{total} - 1;
- $kernel->call('key_handler', 'draw_all');
+ $heap->{current}++;
+ $heap->{current} > $heap->{total} - 1
+ and $heap->{current} = $heap->{total} - 1;
+ $kernel->post('key_handler', 'draw_all');
},
prev_attachment => sub {
my ( $kernel, $heap) = @_[ KERNEL, HEAP ];
- $class->GLOBAL_HEAP->{rt}{attachments}{$ticket_id}{current}--;
- $class->GLOBAL_HEAP->{rt}{attachments}{$ticket_id}{current} < 0
- and $class->GLOBAL_HEAP->{rt}{attachments}{$ticket_id}{current} = 0;
- $kernel->call('key_handler', 'draw_all');
+ $heap->{current}--;
+ $heap->{current} < 0
+ and $heap->{current} = 0;
+ $kernel->post('key_handler', 'draw_all');
},
draw => sub {
my ($kernel, $heap) = @_[ KERNEL, HEAP ];
@@ -53,11 +53,11 @@
$class->_generate_job($kernel, $heap, $ticket_id);
}
defined($heap->{attachments}{$ticket_id}) or return;
- my $total = $class->GLOBAL_HEAP->{rt}{attachments}{$ticket_id}{total};
+ my $total = $heap->{total};
$total > 0 or return;
- $class->GLOBAL_HEAP->{rt}{attachments}{$ticket_id}{current} ||= 0;
+ $heap->{current} ||= 0;
- my $idx = $class->GLOBAL_HEAP->{rt}{attachments}{$ticket_id}{current};
+ my $idx = $heap->{current};
my $attachment = $heap->{attachments}{$ticket_id}->[$idx];
@@ -118,6 +118,15 @@
}
);
$widget->draw($class->get_curses_handler());
+
+ # draw keys
+ my @keys = $kernel->call("ticket_attachments_$ticket_id" => 'available_keys');
+ $class->draw_keys_label( Y => $heap->{'pos_y'} + $heap->{height} + 1 ,
+ X => $heap->{'pos_x'} + 1,
+ COLUMNS => $heap->{width} - 2,
+ VALUE => \@keys,
+ BACKGROUND => 'black'
+ );
},
},
heap => { 'pos_x' => 0,
@@ -169,21 +178,21 @@
my $iterator;
use RT::Client::Console::Session::Progress;
RT::Client::Console::Session::Progress->add_progress(
- steps_nb => sub { $class->GLOBAL_HEAP->{rt}{attachments}{$ticket_id}{total} },
+ steps_nb => sub { $heap->{total} },
caption => sub { 'attachments' },
initially => sub {
use RT::Client::Console::Session::Ticket;
my $ticket = RT::Client::Console::Session::Ticket->get_current_ticket();
my $attachments_obj = $ticket->attachments();
my $count = $attachments_obj->count();
- $class->GLOBAL_HEAP->{rt}{attachments}{$ticket_id}{total} = $count;
+ $heap->{total} = $count;
$iterator = $attachments_obj->get_iterator();
},
code => sub {
my $attachment = $iterator->();
defined $attachment or return;
push @{$heap->{attachments}{$ticket_id}}, $attachment;
- $idx++ or $kernel->call('key_handler', 'draw_all');
+ $idx++ or $kernel->post('key_handler', 'draw_all');
return 1;
},
finally => sub { },
Modified: RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/CustFields.pm
==============================================================================
--- RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/CustFields.pm (original)
+++ RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/CustFields.pm Sat Dec 8 11:53:20 2007
@@ -22,7 +22,7 @@
$heap->{'pos_x'} = 0;
$heap->{'pos_y'} = 8;
$heap->{width} = $screen_w * 2 / 3;
- $heap->{height} = 3;
+ $heap->{height} = 4;
},
available_keys => sub {
@@ -64,7 +64,7 @@
} @custom_fields
];
- my %custom_fields_widgets = $class->struct_to_widgets(\@custom_fields_labels, $heap->{height}, $heap->{width});
+ my %custom_fields_widgets = $class->struct_to_widgets(\@custom_fields_labels, $heap->{height}-1, $heap->{width});
use Curses::Forms;
my $form = Curses::Forms->new({
@@ -86,7 +86,16 @@
);
$form->draw($class->get_curses_handler());
# refresh($mwh);
- },
+
+ # draw keys
+ my @keys = $kernel->call("ticket_custfields_$id" => 'available_keys');
+ $class->draw_keys_label( Y => $heap->{'pos_y'} + $heap->{height} -1 ,
+ X => $heap->{'pos_x'} + 1,
+ COLUMNS => $heap->{width} - 2,
+ VALUE => \@keys,
+ );
+
+ },
},
heap => { 'pos_x' => 0,
'pos_y' => 0,
Modified: RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Header.pm
==============================================================================
--- RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Header.pm (original)
+++ RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Header.pm Sat Dec 8 11:53:20 2007
@@ -153,6 +153,15 @@
);
$form->draw($class->get_curses_handler());
# refresh($mwh);
+
+ # draw keys
+ my @keys = $kernel->call("ticket_header_$id" => 'available_keys');
+ $class->draw_keys_label( Y => $heap->{'pos_y'} + $heap->{height} + 1,
+ X => $heap->{'pos_x'} + 1,
+ COLUMNS => $heap->{width} - 2,
+ VALUE => \@keys,
+ );
+
},
},
heap => { 'pos_x' => 0,
Modified: RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Links.pm
==============================================================================
--- RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Links.pm (original)
+++ RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Links.pm Sat Dec 8 11:53:20 2007
@@ -22,7 +22,7 @@
$heap->{'pos_x'} = $screen_w * 2 / 3 + 1;
$heap->{'pos_y'} = 1;
$heap->{width} = $screen_w - ($screen_w * 2 / 3);
- $heap->{height} = $screen_h - 5 - 1;
+ $heap->{height} = $screen_h - 3;
},
available_keys => sub {
return (['l', 'change links', 'change_links']);
@@ -183,6 +183,14 @@
use Data::Dumper;
$form->draw($class->get_curses_handler());
# refresh($mwh);
+
+ # draw keys
+ my @keys = $kernel->call("ticket_links_$id" => 'available_keys');
+ $class->draw_keys_label( Y => $heap->{'pos_y'} + $heap->{height} - 1,
+ X => $heap->{'pos_x'},
+ COLUMNS => $heap->{width},
+ VALUE => \@keys,
+ );
},
},
heap => { 'pos_x' => 0,
More information about the Bps-public-commit
mailing list