--- deliantra/Deliantra-Client/DC/MapWidget.pm 2012/11/20 14:32:12 1.167 +++ deliantra/Deliantra-Client/DC/MapWidget.pm 2012/11/26 13:14:43 1.171 @@ -35,18 +35,6 @@ $self } -sub add_command {#d# remove - my ($self, $command, $tooltip, $widget, $cb) = @_; - - (my $data = $command) =~ s/\\//g; - - $tooltip =~ s/^\s+//; - $tooltip = "$data\n\n$tooltip"; - $tooltip =~ s/\s+$//; - - $::COMPLETER->{command}{$command} = [$data, $tooltip, $widget, $cb, ++$self->{command_id}]; -} - sub server_login { my ($server) = @_; @@ -715,6 +703,7 @@ my $class = shift; my $self = $class->SUPER::new ( + min_w => $::WIDTH * 0.25, # workaround for layout problems #d# bg => [0, 0, 0, 0.8], @_, ); @@ -815,6 +804,7 @@ my ($self) = @_; $self->hide; + delete $self->{command_lists}; delete $self->{command_list}; } @@ -859,6 +849,8 @@ sub update_labels { my ($self) = @_; + use sort qw(stable); + my $text = $self->{entry}->get_text; length $text @@ -877,7 +869,7 @@ if ($text =~ /^(.*?)\s+$/) { my ($cmd, $arg) = $text =~ /^\s*([^[:space:]]*)(.*)$/; - @match = ([[$cmd,'(appended whitespace suppresses completion)'],$text]); + @match = ([[$cmd,' (appended whitespace suppresses completion)'], $text]); } else { # @match is [command, penalty, command with arguments] until sort @@ -902,8 +894,8 @@ qr<$regexp> }; - for my $list (values %{ $self->{command_list} }) { - for (@$list) { + for my $list (@{ $self->{command_lists} }, "spells") { + for (@{ $self->{command_list}{$list} }) { # we only match and score if the first character matches, # so quickly rule out all others first. next unless $first_char = substr $_, 0, 1; @@ -940,19 +932,14 @@ } # Pick the best option for this command - push @match, (sort { - $b->[1] <=> $a->[1] - } @scores)[0]; + push @match, (sort { $b->[1] <=> $a->[1] } @scores)[0]; } } # @match is now [command object, command with arguments] - @match = map [$self->{command}{$_->[0]}, $_->[2]], - sort { - $b->[1] <=> $a->[1] - or $self->{command}{$a->[0]}[4] <=> $self->{command}{$b->[0]}[4] - or (length $b->[0]) <=> (length $a->[0]) - } @match; + @match = map [$_->[0], $_->[2]], + sort { $b->[1] <=> $a->[1] } + @match; } $self->{last_search} = $text; @@ -991,7 +978,7 @@ if (@labels) { $label->set_text ("$match->[1]"); - $label->set_tooltip ("$match->[0][1]"); + $label->set_tooltip ("#(command/$match->[1])"); } else { $label->set_text ("..."); $label->set_tooltip ("Use Cursor-Down to view more matches");