Skip to content

Commit

Permalink
Rename *-passthrough to *-unhandled and change variable name
Browse files Browse the repository at this point in the history
  * Renamed `abort-to-latin-passthrough` command to
    `abort-to-latin-unhandled`
  * Renamed a variable `allow_passthrough` to `event_handled`.
    Note that they use inverse values to represent states,
    i.e. "event is handled" means "passthrough is *NOT* allowed",
    and vice versa.

See <#48 (comment)>.
  • Loading branch information
YOSHIOKA Takuma committed Jan 22, 2018
1 parent 366de46 commit f656399
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
23 changes: 12 additions & 11 deletions libskk/state.vala
Original file line number Diff line number Diff line change
Expand Up @@ -425,29 +425,30 @@ namespace Skk {
// check abort and commit event
if (command == "abort" ||
command == "abort-to-latin" ||
command == "abort-to-latin-passthrough") {
command == "abort-to-latin-unhandled") {
bool something_changed;
bool allow_passthrough;
bool event_handled;
if (state.rom_kana_converter.preedit.length > 0) {
something_changed = true;
} else {
something_changed = state.recursive_edit_abort ();
}
allow_passthrough = !something_changed;
event_handled = something_changed;
state.reset ();
if (command == "abort") {
return something_changed;
}
// change to latin mode
if (state.input_mode != InputMode.LATIN) {
state.input_mode = InputMode.LATIN;
// this change doesn't affect `should_passthrough`
// this change doesn't affect `event_handled`
something_changed = true;
}
// if nothing changed by "abort-to-latin-passthrough" command,
// if the key event will not be handled by
// "abort-to-latin-unhandled" command,
// let key event pass through
if (command == "abort-to-latin-passthrough" &&
allow_passthrough) {
if (command == "abort-to-latin-unhandled" &&
!event_handled) {
return false;
}
return something_changed;
Expand Down Expand Up @@ -634,7 +635,7 @@ namespace Skk {
var command = state.lookup_key (key);
if (command == "abort" ||
command == "abort-to-latin" ||
command == "abort-to-latin-passthrough") {
command == "abort-to-latin-unhandled") {
state.reset ();
return true;
}
Expand Down Expand Up @@ -683,7 +684,7 @@ namespace Skk {
var command = state.lookup_key (key);
if (command == "abort" ||
command == "abort-to-latin" ||
command == "abort-to-latin-passthrough") {
command == "abort-to-latin-unhandled") {
state.reset ();
return true;
}
Expand Down Expand Up @@ -745,7 +746,7 @@ namespace Skk {
var command = state.lookup_key (key);
if (command == "abort" ||
command == "abort-to-latin" ||
command == "abort-to-latin-passthrough") {
command == "abort-to-latin-unhandled") {
state.reset ();
return true;
}
Expand Down Expand Up @@ -1027,7 +1028,7 @@ namespace Skk {
}
else if (command == "abort" ||
command == "abort-to-latin" ||
command == "abort-to-latin-passthrough") {
command == "abort-to-latin-unhandled") {
state.candidates.clear ();
state.cancel_okuri ();
state.handler_type = typeof (StartStateHandler);
Expand Down
2 changes: 1 addition & 1 deletion rules/README.rules
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ The current available commands are:
abbrev
abort
abort-to-latin
abort-to-latin-passthrough
abort-to-latin-unhandled
commit
commit-unhandled
complete
Expand Down

0 comments on commit f656399

Please sign in to comment.