Changeset 5368d75 for perl/lib/BarnOwl
- Timestamp:
- Jul 27, 2009, 11:23:57 PM (15 years ago)
- Branches:
- master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 0fee298
- Parents:
- 6e48560
- git-author:
- Nelson Elhage <nelhage@mit.edu> (07/25/09 23:03:45)
- git-committer:
- Nelson Elhage <nelhage@mit.edu> (07/27/09 23:23:57)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/lib/BarnOwl/Completion.pm
r6e48560 r5368d75 15 15 16 16 use BarnOwl::Completion::Context; 17 use BarnOwl::Editwin qw(text_before_point text_after_point); 17 use BarnOwl::Editwin qw(save_excursion text_before_point text_after_point 18 point_move replace_region); 18 19 19 20 use List::Util qw(max first); … … 32 33 my $word = $ctx->words->[$ctx->word]; 33 34 34 if($prefix && $prefix ne $word) { 35 if(scalar @words == 1) { 36 $prefix .= ' '; 37 } 38 39 BarnOwl::Editwin::insert_text(substr($prefix, length($word))); 35 if($prefix) { 36 insert_completion($ctx, $prefix, scalar @words == 1); 40 37 } 41 38 42 39 if(scalar @words > 1) { 43 40 show_completions(@words); 41 } else { 42 BarnOwl::message(''); 43 } 44 } 45 46 sub insert_completion { 47 my $ctx = shift; 48 my $completion = shift; 49 my $unique = shift; 50 51 save_excursion { 52 point_move($ctx->word_start - $ctx->point); 53 BarnOwl::Editwin::set_mark(); 54 point_move($ctx->word_end - $ctx->word_start); 55 replace_region(BarnOwl::quote($completion)); 56 }; 57 if($unique && $ctx->word == (scalar @{$ctx->words} - 1)) { 58 save_excursion { 59 BarnOwl::Editwin::set_mark(); 60 replace_region(' '); 61 }; 62 point_move(1); 44 63 } 45 64 }
Note: See TracChangeset
for help on using the changeset viewer.