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

Comparing deliantra/Deliantra-Client/DC/MapWidget.pm (file contents):
Revision 1.141 by root, Wed Aug 27 20:19:52 2008 UTC vs.
Revision 1.157 by root, Mon Dec 21 03:30:23 2009 UTC

11use DC::Macro; 11use DC::Macro;
12 12
13our @ISA = DC::UI::Base::; 13our @ISA = DC::UI::Base::;
14 14
15my $magicmap_tex = 15my $magicmap_tex =
16 new_from_file DC::Texture DC::find_rcfile "magicmap.png", 16 new_from_resource DC::Texture "magicmap.png",
17 mipmap => 1, wrap => 0, internalformat => GL_ALPHA; 17 mipmap => 1, wrap => 0, internalformat => GL_ALPHA;
18 18
19sub new { 19sub new {
20 my $class = shift; 20 my $class = shift;
21 21
163sub invoke_button_down { 163sub invoke_button_down {
164 my ($self, $ev, $x, $y) = @_; 164 my ($self, $ev, $x, $y) = @_;
165 165
166 if ($ev->{button} == 1) { 166 if ($ev->{button} == 1) {
167 $self->grab_focus; 167 $self->grab_focus;
168 return unless $::CONN; 168 return unless $::CONN && $self->{ctilesize};
169 169
170 my $x = $self->{dx} + DC::floor +($ev->{x} - $self->{sx0}) / $self->{ctilesize}; 170 my $x = $self->{dx} + DC::floor +($ev->{x} - $self->{sx0}) / $self->{ctilesize};
171 my $y = $self->{dy} + DC::floor +($ev->{y} - $self->{sy0}) / $self->{ctilesize}; 171 my $y = $self->{dy} + DC::floor +($ev->{y} - $self->{sy0}) / $self->{ctilesize};
172 172
173 $x -= DC::floor $::MAP->w * 0.5; 173 $x -= DC::floor $::MAP->w * 0.5;
201 ["Skills\tF3", sub { ::toggle_player_page ($::SKILL_PAGE) }], 201 ["Skills\tF3", sub { ::toggle_player_page ($::SKILL_PAGE) }],
202 ["Spells…\tF4", sub { ::toggle_player_page ($::SPELL_PAGE) }], 202 ["Spells…\tF4", sub { ::toggle_player_page ($::SPELL_PAGE) }],
203 ["Inventory…\tF5", sub { ::toggle_player_page ($::INVENTORY_PAGE) }], 203 ["Inventory…\tF5", sub { ::toggle_player_page ($::INVENTORY_PAGE) }],
204 ["Setup… \tF9", sub { $::SETUP_DIALOG->toggle_visibility }], 204 ["Setup… \tF9", sub { $::SETUP_DIALOG->toggle_visibility }],
205# ["Server Messages…", sub { $::MESSAGE_WINDOW->toggle_visibility }], 205# ["Server Messages…", sub { $::MESSAGE_WINDOW->toggle_visibility }],
206 [
207 $::PICKUP_ENABLE->{state}
208 ? "Disable automatic pickup"
209 : "Enable automatic pickup",
210 sub { $::PICKUP_ENABLE->toggle }
211 ],
212 ); 206 );
213 207
214 if ($::CONN && $::CONN->{editor_support}) { 208 if ($::CONN && $::CONN->{editor_support}) {
215# push @items, [ 209# push @items, [
216# "Edit this map <span size='xx-small'>(" . (DC::asxml $::CONN->{map_info}[0]) . ")</span>", 210# "Edit this map <span size='xx-small'>(" . (DC::asxml $::CONN->{map_info}[0]) . ")</span>",
285 $self->{need_update} = 1; 279 $self->{need_update} = 1;
286 $self->SUPER::update; 280 $self->SUPER::update;
287} 281}
288 282
289my %DIR = ( 283my %DIR = (
290 ( "," . DC::SDLK_KP5 ), [0, "stay fire"], 284 ( "," . DC::SDLK_KP5 ), [0, "stay fire"],
291 ( "," . DC::SDLK_KP8 ), [1, "north"], 285 ( "," . DC::SDLK_KP8 ), [1, "north"],
292 ( "," . DC::SDLK_KP9 ), [2, "northeast"], 286 ( "," . DC::SDLK_KP9 ), [2, "northeast"],
293 ( "," . DC::SDLK_KP6 ), [3, "east"], 287 ( "," . DC::SDLK_KP6 ), [3, "east"],
294 ( "," . DC::SDLK_KP3 ), [4, "southeast"], 288 ( "," . DC::SDLK_KP3 ), [4, "southeast"],
295 ( "," . DC::SDLK_KP2 ), [5, "south"], 289 ( "," . DC::SDLK_KP2 ), [5, "south"],
296 ( "," . DC::SDLK_KP1 ), [6, "southwest"], 290 ( "," . DC::SDLK_KP1 ), [6, "southwest"],
297 ( "," . DC::SDLK_KP4 ), [7, "west"], 291 ( "," . DC::SDLK_KP4 ), [7, "west"],
298 ( "," . DC::SDLK_KP7 ), [8, "northwest"], 292 ( "," . DC::SDLK_KP7 ), [8, "northwest"],
299 293
294 ( "," . DC::SDLK_PAGEUP ), [2, "northeast"],
295 ( "," . DC::SDLK_PAGEDOWN ), [4, "southeast"],
296 ( "," . DC::SDLK_END ), [6, "southwest"],
297 ( "," . DC::SDLK_HOME ), [8, "northwest"],
298
300 ( "," . DC::SDLK_UP ), [1, "north"], 299 ( "," . DC::SDLK_UP ), [1, "north"],
301 ("1," . DC::SDLK_UP ), [2, "northeast"], 300 ("1," . DC::SDLK_UP ), [2, "northeast"],
302 ( "," . DC::SDLK_RIGHT), [3, "east"], 301 ( "," . DC::SDLK_RIGHT ), [3, "east"],
303 ("1," . DC::SDLK_RIGHT), [4, "southeast"], 302 ("1," . DC::SDLK_RIGHT ), [4, "southeast"],
304 ( "," . DC::SDLK_DOWN ), [5, "south"], 303 ( "," . DC::SDLK_DOWN ), [5, "south"],
305 ("1," . DC::SDLK_DOWN ), [6, "southwest"], 304 ("1," . DC::SDLK_DOWN ), [6, "southwest"],
306 ( "," . DC::SDLK_LEFT ), [7, "west"], 305 ( "," . DC::SDLK_LEFT ), [7, "west"],
307 ("1," . DC::SDLK_LEFT ), [8, "northwest"], 306 ("1," . DC::SDLK_LEFT ), [8, "northwest"],
308); 307);
309 308
310sub invoke_key_down { 309sub invoke_key_down {
311 my ($self, $ev) = @_; 310 my ($self, $ev) = @_;
312 311
313 my $mod = $ev->{mod}; 312 my $mod = $ev->{mod};
314 my $sym = $ev->{sym}; 313 my $sym = $ev->{sym};
315 my $uni = $ev->{unicode}; 314 my $uni = $ev->{unicode};
316 315
317 $mod &= DC::KMOD_CTRL | DC::KMOD_ALT | DC::KMOD_SHIFT; 316 $mod &= DC::KMOD_CTRL | DC::KMOD_ALT | DC::KMOD_META | DC::KMOD_SHIFT;
318 317
319 # ignore repeated keypresses 318 # ignore repeated keypresses
320 return if $self->{last_mod} == $mod && $self->{last_sym} == $sym; 319 return if $self->{last_mod} == $mod && $self->{last_sym} == $sym;
321 $self->{last_mod} = $mod; 320 $self->{last_mod} = $mod;
322 $self->{last_sym} = $sym; 321 $self->{last_sym} = $sym;
323 322
324 if ($::CONN && (my $dir = $DIR{(!!($mod & DC::KMOD_ALT)) . ",$sym"})) { 323 my $dir = $DIR{ (!!($mod & (DC::KMOD_ALT | DC::KMOD_META))) . ",$sym" };
324
325 if ($::CONN && $dir) {
325 if ($mod & DC::KMOD_SHIFT) { 326 if ($mod & DC::KMOD_SHIFT) {
326 $self->{shft}++; 327 $self->{shft}++;
327 if ($dir->[0] != $self->{fire_dir}) { 328 if ($dir->[0] != $self->{fire_dir}) {
328 $::CONN->user_send ("fire $dir->[0]"); 329 $::CONN->user_send ("fire $dir->[0]");
329 } 330 }
356 $::CONN->user_send ("fire_stop"); 357 $::CONN->user_send ("fire_stop");
357 delete $self->{fire_dir}; 358 delete $self->{fire_dir};
358 $res = 1; 359 $res = 1;
359 } 360 }
360 } else { 361 } else {
361 if (exists $DIR{(!!($mod & DC::KMOD_ALT)) . ",$sym"} && delete $self->{shft}) { 362 my $dir = $DIR{ (!!($mod & (DC::KMOD_ALT | DC::KMOD_META))) . ",$sym" };
363
364 if ($dir && delete $self->{shft}) {
362 $::CONN->user_send ("fire_stop"); 365 $::CONN->user_send ("fire_stop");
363 delete $self->{fire_dir}; 366 delete $self->{fire_dir};
364 $res = 1; 367 $res = 1;
365 } elsif (($sym == DC::SDLK_LSHIFT || $sym == DC::SDLK_RSHIFT) 368 } elsif (($sym == DC::SDLK_LSHIFT || $sym == DC::SDLK_RSHIFT)
366 && delete $self->{shft}) { # XXX: is RSHIFT ok? 369 && delete $self->{shft}) { # XXX: is RSHIFT ok?
368 delete $self->{fire_dir}; 371 delete $self->{fire_dir};
369 $res = 1; 372 $res = 1;
370 } 373 }
371 } 374 }
372 375
373 if (!($mod & DC::KMOD_CTRL ) && delete $self->{ctrl}) { 376 if (!($mod & DC::KMOD_CTRL) && delete $self->{ctrl}) {
374 $::CONN->user_send ("run_stop"); 377 $::CONN->user_send ("run_stop");
375 $res = 1; 378 $res = 1;
376 } 379 }
377 380
378 $res 381 $res
393} 396}
394 397
395sub scroll { 398sub scroll {
396 my ($self, $dx, $dy) = @_; 399 my ($self, $dx, $dy) = @_;
397 400
398 $::MAP->scroll ($dx, $dy);
399
400 $self->movement_update; 401 $self->movement_update;
401 402
402 $self->{sdx} += $dx * $self->{tilesize}; # smooth displacement 403 $self->{sdx} += $dx * $self->{tilesize}; # smooth displacement
403 $self->{sdy} += $dy * $self->{tilesize}; 404 $self->{sdy} += $dy * $self->{tilesize};
405
406 # save old fow texture, if applicable
407 $self->{last_fow_texture} = $self->{fow_texture}
408 if $::CFG->{smooth_transitions};
409 $self->{lfdx} = $dx;
410 $self->{lfdy} = $dy;
411 $self->{lmdx} = $self->{dx};
412 $self->{lmdy} = $self->{dy};
413
414 $::MAP->scroll ($dx, $dy);
404} 415}
405 416
406sub set_magicmap { 417sub set_magicmap {
407 my ($self, $w, $h, $x, $y, $data) = @_; 418 my ($self, $w, $h, $x, $y, $data) = @_;
408 419
423 my $spd = $::CONN->{stat}{DC::Protocol::CS_STAT_SPEED}; 434 my $spd = $::CONN->{stat}{DC::Protocol::CS_STAT_SPEED};
424 435
425 # the minimum time for a single tile movement 436 # the minimum time for a single tile movement
426 my $mintime = DC::Protocol::TICK * DC::ceil 1 / ($spd * DC::Protocol::TICK || 1); 437 my $mintime = DC::Protocol::TICK * DC::ceil 1 / ($spd * DC::Protocol::TICK || 1);
427 438
439 $spd *= $self->{tilesize};
440
428 # jump if "impossibly high" speed 441 # jump if "impossibly high" speed
429 if ( 442 if (
430 (max abs $self->{sdx}, abs $self->{sdy}) 443 (max abs $self->{sdx}, abs $self->{sdy})
431 > $spd * $self->{tilesize} * $mintime * 1.1 444 > $spd * $mintime * 2.1
432 ) { 445 ) {
433 #warn "jump ", (max abs $self->{sdx}, abs $self->{sdy}), " ", $spd * $mintime * 1.0;#d# 446 #warn "jump ", (max abs $self->{sdx}, abs $self->{sdy}), " ", $spd * $mintime * 2.1;#d#
434 $self->{sdx} = $self->{sdy} = 0; 447 $self->{sdx} = $self->{sdy} = 0;
435 } else { 448 } else {
436 $spd *= $self->{tilesize} * $diff * 1.0001; # 1.0001 so that we don't accumulate rounding errors the wrong direction 449 $spd *= $diff * 1.0001; # 1.0001 so that we don't accumulate rounding errors the wrong direction
437 450
438 my $dx = $self->{sdx} < 0 ? -$spd : $spd; 451 my $dx = $self->{sdx} < 0 ? -$spd : $spd;
439 my $dy = $self->{sdy} < 0 ? -$spd : $spd; 452 my $dy = $self->{sdy} < 0 ? -$spd : $spd;
440 453
441 if ($self->{sdx} * ($self->{sdx} - $dx) <= 0) { $self->{sdx} = 0 } else { $self->{sdx} -= $dx } 454 if ($self->{sdx} * ($self->{sdx} - $dx) <= 0) { $self->{sdx} = 0 } else { $self->{sdx} -= $dx }
442 if ($self->{sdy} * ($self->{sdy} - $dy) <= 0) { $self->{sdy} = 0 } else { $self->{sdy} -= $dy } 455 if ($self->{sdy} * ($self->{sdy} - $dy) <= 0) { $self->{sdy} = 0 } else { $self->{sdy} -= $dy }
443
444 $self->update;
445 } 456 }
457
458 $self->update;
446 } 459 }
447 } else { 460 } else {
448 $self->{sdx} = $self->{sdy} = 0; 461 $self->{sdx} = $self->{sdy} = 0;
449 } 462 }
450 463
477 490
478 my $dx = $self->{dx} = DC::ceil 0.5 * ($::MAP->w - $sw) - $sx; 491 my $dx = $self->{dx} = DC::ceil 0.5 * ($::MAP->w - $sw) - $sx;
479 my $dy = $self->{dy} = DC::ceil 0.5 * ($::MAP->h - $sh) - $sy; 492 my $dy = $self->{dy} = DC::ceil 0.5 * ($::MAP->h - $sh) - $sy;
480 493
481 if ($::CFG->{fow_enable}) { 494 if ($::CFG->{fow_enable}) {
482 $sdx_t = $sdy_t = 0;#d#
483 my ($w, $h, $data) = $::MAP->fow_texture ( 495 my ($w, $h, $data) = $::MAP->fow_texture ($dx, $dy, $sw, $sh);
484 $dx + (min 0, $sdx_t),
485 $dy + (min 0, $sdy_t),
486 $sw + abs $sdx_t,
487 $sh + abs $sdy_t
488 );
489 496
490 $self->{fow_texture} = new DC::Texture 497 $self->{fow_texture} = new DC::Texture
491 w => $w, 498 w => $w,
492 h => $h, 499 h => $h,
493 data => $data, 500 data => $data,
500 glNewList ($self->{list} ||= glGenList); 507 glNewList ($self->{list} ||= glGenList);
501 508
502 glPushMatrix; 509 glPushMatrix;
503 glTranslate $sx0, $sy0; 510 glTranslate $sx0, $sy0;
504 glScale $::CFG->{map_scale}, $::CFG->{map_scale}; 511 glScale $::CFG->{map_scale}, $::CFG->{map_scale};
505 glTranslate $self->{sdx}, $self->{sdy}; 512 glTranslate DC::ceil $self->{sdx}, DC::ceil $self->{sdy};
506 513
507 $::MAP->draw ($dx, $dy, $sw, $sh, 514 $::MAP->draw ($dx, $dy, $sw, $sh,
508 $self->{tilesize}, 515 $self->{tilesize},
509 $::CONN->{player}{tag}, 516 $::CONN->{player}{tag},
510 -$self->{sdx}, -$self->{sdy}); 517 -$self->{sdx}, -$self->{sdy});
511 518
512 #glTranslate -$self->{sdx}, -$self->{sdy}; # anchro fow at player
513 glScale $self->{tilesize}, $self->{tilesize}; 519 glScale $self->{tilesize}, $self->{tilesize};
514 520
515 if (my $tex = $self->{fow_texture}) { 521 if (my $tex = $self->{fow_texture}) {
516 glPushMatrix; 522 if ($DC::OpenGL::GL_MULTITEX && $self->{last_fow_texture}) {#d#
517 glTranslate +(min 0, $sdx_t), (min 0, $sdy_t); 523 my $d1 = DC::distance $self->{sdx}, $self->{sdy};
518 glScale 1/3, 1/3; 524 my $d2 = (DC::distance $self->{lfdx}, $self->{lfdy}) * $tilesize;
519 glEnable GL_TEXTURE_2D;
520 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
521 525
522 glColor +($::CFG->{fow_intensity}) x 3, 0.9; 526 if ($d1 * $d2) {
523 $self->{fow_texture}->draw_quad_alpha (0, 0); 527 DC::Texture::draw_fow_texture
528 $::CFG->{fow_intensity},
529 @{$self->{fow_texture}}{qw(name s t w h)},
530 (min 1, $d1 / $d2),
531 $self->{lmdx} - $dx - $self->{lfdx},
532 $self->{lmdy} - $dy - $self->{lfdy},
533 @{$self->{last_fow_texture}}{qw(name s t w h)};
534 } else {
535 delete $self->{last_fow_texture};
536 }
537 }
524 538
525 glDisable GL_TEXTURE_2D; 539 unless ($self->{last_fow_texture}) {
526 glPopMatrix; 540 DC::Texture::draw_fow_texture
541 $::CFG->{fow_intensity},
542 @{$self->{fow_texture}}{qw(name s t w h)};
543 }
527 } 544 }
528 545
529 if ($self->{magicmap}) { 546 if ($self->{magicmap}) {
530 my ($x, $y, $w, $h, $data) = @{ $self->{magicmap} }; 547 my ($x, $y, $w, $h, $data) = @{ $self->{magicmap} };
531 548
532 $x += $::MAP->ox + $self->{dx}; 549 $x += $::MAP->ox + $self->{dx};
533 $y += $::MAP->oy + $self->{dy}; 550 $y += $::MAP->oy + $self->{dy};
534 551
535 glTranslate - $x - 1, - $y - 1; 552 glTranslate - $x - 1, - $y - 1;
536 glBindTexture GL_TEXTURE_2D, $magicmap_tex->{name}; 553 glBindTexture GL_TEXTURE_2D, $magicmap_tex->{name};
537 $::MAP->draw_magicmap ($x, $y, $w, $h, $data); 554 $::MAP->draw_magicmap ($w, $h, $data);
538 } 555 }
539 556
540 glPopMatrix; 557 glPopMatrix;
541 glEndList; 558 glEndList;
542 } 559 }
601sub refresh_hook { 618sub refresh_hook {
602 my ($self) = @_; 619 my ($self) = @_;
603 620
604 if ($::MAP && $self->{texture_atime} < time) { 621 if ($::MAP && $self->{texture_atime} < time) {
605 my ($w, $h) = @$self{qw(w h)}; 622 my ($w, $h) = @$self{qw(w h)};
623
624 return unless $w && $h;
606 625
607 my $sw = int $::WIDTH / ($::MAPWIDGET->{tilesize} * $::CFG->{map_scale}) + 0.99; 626 my $sw = int $::WIDTH / ($::MAPWIDGET->{tilesize} * $::CFG->{map_scale}) + 0.99;
608 my $sh = int $::HEIGHT / ($::MAPWIDGET->{tilesize} * $::CFG->{map_scale}) + 0.99; 627 my $sh = int $::HEIGHT / ($::MAPWIDGET->{tilesize} * $::CFG->{map_scale}) + 0.99;
609 628
610 my $ox = 0.5 * ($w - $sw); 629 my $ox = 0.5 * ($w - $sw);
839 my $text = $self->{entry}->get_text; 858 my $text = $self->{entry}->get_text;
840 859
841 length $text 860 length $text
842 or return $self->hide; 861 or return $self->hide;
843 862
844 my ($cmd, $arg) = $text =~ /^\s*([^[:space:]]*)(.*)$/;
845
846 if ($text ne $self->{last_search}) { 863 if ($text ne $self->{last_search}) {
847 my @match; 864 my @match;
848 865
849 if ($text =~ /^(.*?)\s+$/) { 866 if ($text =~ /^(.*?)\s+$/) {
867 my ($cmd, $arg) = $text =~ /^\s*([^[:space:]]*)(.*)$/;
850 @match = [$cmd, "(appended whitespace suppresses completion)"]; 868 @match = ([[$cmd,'(appended whitespace suppresses completion)'],$text]);
851 } else { 869 } else {
870 # @match is [command, penalty, command with arguments] until sort
871
872 my ($cmd, $arg) = $text =~ /^\s*([^[:space:]]*)(.*)$/;
873
852 my $regexp = do { 874 my $regexp_abbrev = do {
853 my ($beg, @chr) = split //, lc $cmd; 875 my ($beg, @chr) = split //, lc $cmd;
854 876
855 # the following regex is used to match our "completion entry" 877 # the following regex is used to match our "completion entry"
856 # to an actual command - the parentheses match kind of "overhead" 878 # to an actual command - the parentheses match kind of "overhead"
857 # - the more characters the parentheses match, the less attractive 879 # - the more characters the parentheses match, the less attractive
859 my $regexp = "^\Q$beg\E" 881 my $regexp = "^\Q$beg\E"
860 . join "", map "(?:.*?[ \\\\]\Q$_\E|(.*?)\Q$_\E)", @chr; 882 . join "", map "(?:.*?[ \\\\]\Q$_\E|(.*?)\Q$_\E)", @chr;
861 qr<$regexp> 883 qr<$regexp>
862 }; 884 };
863 885
864 my @penalty; 886 my $regexp_partial = do {
887 my $regexp = "^\Q$text\E(.*)";
888 qr<$regexp>
889 };
865 890
866 for (keys %{$self->{command}}) { 891 for (keys %{$self->{command}}) {
867 if (@penalty = $_ =~ $regexp) { 892 my @scores;
868 push @match, [$_, length join "", map "::$_", grep defined, @penalty]; 893
894 # 1. Complete command [with args]
895 # command is a prefix of the text
896 # score is length of complete command matched
897 # e.g. "invoke summon pet monster bat"
898 # "invoke" "summon pet monster bat" = 6
899 # "invoke summon pet monster" "bat" = 25
900 if ($text =~ /^\Q$_\E(.*)/) {
901 push @scores, [$_, length $_, $text];
869 } 902 }
903
904 # 2. Partial command
905 # text is a prefix of the full command
906 # score is the length of the input text
907 # e.g. "invoke s"
908 # "invoke small fireball" = 8
909 # "invoke summon pet monster" = 8
910
911 if ($_ =~ $regexp_partial) {
912 push @scores, [$_, length $text, $_];
913 }
914
915 # 3. Abbreviation match
916 # attempts to use first word of text as an abbreviated command
917 # score is length of word + 1 - 3 per non-word-initial character
918
919 if (my @penalty = $_ =~ $regexp_abbrev) {
920 push @scores, [$_, (length $cmd) + 1 - (length join "", map "::$_", grep defined, @penalty), "$_$arg"];
921 }
922
923 # Pick the best option for this command
924 push @match, (sort {
925 $b->[1] <=> $a->[1]
926 } @scores)[0];
870 } 927 }
871 928
929 # @match is now [command object, command with arguments]
872 @match = map $self->{command}{$_->[0]}, 930 @match = map [$self->{command}{$_->[0]}, $_->[2]],
873 sort { 931 sort {
874 $a->[1] <=> $b->[1] 932 $b->[1] <=> $a->[1]
875 or $self->{command}{$a->[0]}[4] <=> $self->{command}{$b->[0]}[4] 933 or $self->{command}{$a->[0]}[4] <=> $self->{command}{$b->[0]}[4]
876 or (length $b->[0]) <=> (length $a->[0]) 934 or (length $b->[0]) <=> (length $a->[0])
877 } @match; 935 } @match;
878 } 936 }
879 937
898 $label->{fg} = [1, 1, 1, 1]; 956 $label->{fg} = [1, 1, 1, 1];
899 $label->{bg} = [0, 0, 0, 0]; 957 $label->{bg} = [0, 0, 0, 0];
900 } 958 }
901 959
902 if (@matches) { 960 if (@matches) {
903 $self->{select} = "$matches[0][0]$arg"; 961 $self->{select} = "$matches[0][1]";
904 962
905 $labels[0]->{fg} = [0, 0, 0, 1]; 963 $labels[0]->{fg} = [0, 0, 0, 1];
906 $labels[0]->{bg} = [1, 1, 1, 0.8]; 964 $labels[0]->{bg} = [1, 1, 1, 0.8];
907 } else { 965 } else {
908 $self->{select} = "$cmd$arg"; 966 $self->{select} = "$text";
909 } 967 }
910 968
911 for my $match (@matches) { 969 for my $match (@matches) {
912 my $label = shift @labels; 970 my $label = shift @labels;
913 971
914 if (@labels) { 972 if (@labels) {
915 $label->set_text ("$match->[0]$arg"); 973 $label->set_text ("$match->[1]");
916 $label->set_tooltip ($match->[1]); 974 $label->set_tooltip ("$match->[0][1]");
917 } else { 975 } else {
918 $label->set_text ("..."); 976 $label->set_text ("...");
919 $label->set_tooltip ("Use Cursor-Down to view more matches"); 977 $label->set_tooltip ("Use Cursor-Down to view more matches");
920 last; 978 last;
921 } 979 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines