commit 22fb81f19507c72a28a1ced4e97c5893b903ef94
parent 2e78b43812eb6c4ffeffdcdc2db917e76b999cd6
Author: lumidify <nobody@lumidify.org>
Date: Tue, 14 Apr 2020 10:20:37 +0200
Remove nocompletechoices
Diffstat:
1 file changed, 28 insertions(+), 27 deletions(-)
diff --git a/transliterate.pl b/transliterate.pl
@@ -349,6 +349,8 @@ sub prompt_choose_word {
$vbox->pack_start($hbox, FALSE, FALSE, 10);
$hbox = Gtk2::HBox->new(FALSE, 5);
+ my $skip_button = Gtk2::Button->new("Skip word");
+ $hbox->pack_start($skip_button, FALSE, FALSE, 0);
my $unknown_button = Gtk2::Button->new("Open in unknown word window");
$hbox->pack_start($unknown_button, FALSE, FALSE, 0);
my $stop_button = Gtk2::Button->new("Stop processing");
@@ -392,8 +394,26 @@ sub prompt_choose_word {
$buffer->insert($start, $contextl);
};
+ my $show_accept = sub {
+ $button_vbox->foreach(sub {my $child = shift; $child->destroy();});
+ $accept->show;
+ $accept->grab_focus;
+ $wordlabel->set_text("");
+ };
+
+ my $fill_button_vbox; # forward-declaration so it can be used here already
+ my $next_word = sub {
+ $undo->set_sensitive(TRUE);
+ $cur_replacement++;
+ $fill_text_buffer->();
+ if ($cur_replacement > $#replacements) {
+ $show_accept->();
+ return;
+ }
+ $fill_button_vbox->();
+ };
+
# fill $button_vbox with the word options for the current word
- my $fill_button_vbox;
$fill_button_vbox = sub {
$button_vbox->foreach(sub {my $child = shift; $child->destroy();});
my $word = $replacements[$cur_replacement]->[1];
@@ -412,24 +432,12 @@ sub prompt_choose_word {
}
@choices = sort {$choice_nums{$b} <=> $choice_nums{$a}} @choices;
}
- # also give option to ignore word by just keeping everything
- push @choices, $word if !$args->{"nocompletechoices"};
foreach my $word_choice (@choices) {
my $button = Gtk2::Button->new($word_choice);
$button->signal_connect(
clicked => sub {
$replacements[$cur_replacement]->[1] = $word_choice;
- $undo->set_sensitive(TRUE);
- $cur_replacement++;
- $fill_text_buffer->();
- if ($cur_replacement > $#replacements) {
- $button_vbox->foreach(sub {my $child = shift; $child->destroy();});
- $accept->show;
- $accept->grab_focus;
- $wordlabel->set_text("");
- return;
- }
- $fill_button_vbox->();
+ $next_word->();
}, $window);
$button_vbox->pack_start($button, FALSE, FALSE, 0);
$button->show;
@@ -461,6 +469,8 @@ sub prompt_choose_word {
$window->destroy;
}, $window);
+ $skip_button->signal_connect(clicked => $next_word, $window);
+
$unknown_button->signal_connect(
clicked => sub {
$open_unknown = 1;
@@ -1389,7 +1399,7 @@ GetOptions(
"force", "start=i",
"output=s", "config=s",
"errors=s", "help",
- "checkduplicates", "nocompletechoices") or pod2usage(1);
+ "checkduplicates") or pod2usage(1);
pod2usage(-exitval => 0, -verbose => 2) if $args{"help"};
pod2usage(-exitval => 1, -verbose => 1) if @ARGV > 1;
@@ -1517,13 +1527,6 @@ This can be used to "weed out" all the unknown words before
commencing the laborious task of choosing the right word every time
multiple options exist.
-=item B<--nocompletechoices>
-
-This disables showing the entire "word" (including B<choicesep>) in the
-L<word choice window|/"WORD CHOICE WINDOW">. This is useful if the text
-doesn't ever include B<choicesep> and the extra option just leads to
-careless mistakes.
-
=item B<--nounknowns>
Disables prompting for the right word when a word is not found in the database.
@@ -1598,11 +1601,9 @@ is possible to just press enter instead of manually clicking it. Before the
line is finalized, the user may press "Undo" to undo any changes on the
current line.
-Unless B<--nocompletechoices> is specified on the command line, the last option is
-always the complete word (with B<choicesep>), in case it simply needs to
-be ignored. I guess this could be useful if B<choicesep> occurs in the
-text (although that should be avoided) and is ignored with a B<matchignore>
-statement. It shouldn't be needed in most cases, though.
+"Skip word" just leaves it as is. This shouldn't be needed in most cases
+since B<choicesep> should always be set to a character that doesn't occur
+normally in the text anyways.
"Open in unknown word window" will open the
L<unknown word window|/"UNKNOWN WORD WINDOW"> with the current word