ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC.pm (file contents):
Revision 1.132 by root, Wed Dec 6 00:04:13 2006 UTC vs.
Revision 1.133 by root, Wed Dec 6 00:15:12 2006 UTC

47 bless \(my $cb = $_[0]), "CFPlus::Guard" 47 bless \(my $cb = $_[0]), "CFPlus::Guard"
48} 48}
49 49
50sub CFPlus::Guard::DESTROY { 50sub CFPlus::Guard::DESTROY {
51 ${$_[0]}->() 51 ${$_[0]}->()
52}
53
54=item shorten $string[, $maxlength]
55
56=cut
57
58sub shorten($;$) {
59 my ($str, $len) = @_;
60 substr $str, $len, (length $str), "..." if $len + 3 <= length $str;
61 $str
52} 62}
53 63
54sub asxml($) { 64sub asxml($) {
55 local $_ = $_[0]; 65 local $_ = $_[0];
56 66
390 } elsif ($ev->{button} == 3) { 400 } elsif ($ev->{button} == 3) {
391 my $move_prefix = $::CONN->{open_container} ? 'put' : 'drop'; 401 my $move_prefix = $::CONN->{open_container} ? 'put' : 'drop';
392 if ($self->{container} == $::CONN->{open_container}) { 402 if ($self->{container} == $::CONN->{open_container}) {
393 $move_prefix = "take"; 403 $move_prefix = "take";
394 } 404 }
405
406 my $shortname = CFPlus::shorten $self->{name}, 14;
395 407
396 my @menu_items = ( 408 my @menu_items = (
397 ["examine", sub { $::CONN->send ("examine $self->{tag}") }], 409 ["examine", sub { $::CONN->send ("examine $self->{tag}") }],
398 ["mark", sub { $::CONN->send ("mark ". pack "N", $self->{tag}) }], 410 ["mark", sub { $::CONN->send ("mark ". pack "N", $self->{tag}) }],
399 ["ignite/thaw", # first try of an easier use of flint&steel 411 ["ignite/thaw", # first try of an easier use of flint&steel
435 do_n_dialog (sub { $::CONN->send ("move $targ $self->{tag} $_[0]") }) 447 do_n_dialog (sub { $::CONN->send ("move $targ $self->{tag} $_[0]") })
436 } 448 }
437 ] 449 ]
438 ) 450 )
439 ), 451 ),
440 ["bind <i>apply $self->{name}</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["apply $self->{name}"]) }], 452 ["bind <i>apply $shortname</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["apply $self->{name}"]) }],
441 ); 453 );
442 454
443 CFPlus::UI::Menu->new (items => \@menu_items)->popup ($ev); 455 CFPlus::UI::Menu->new (items => \@menu_items)->popup ($ev);
444 } 456 }
445 457

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines