Skip to content

Commit

Permalink
Use is_composing() instead of raw ime_in_progress_
Browse files Browse the repository at this point in the history
(cherry-picked from commit 6212a62)
  • Loading branch information
fujimo-t authored and jyrkive committed Oct 7, 2018
1 parent 60f00b4 commit db183b3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/gui/widgets/text_box_base.cpp
Expand Up @@ -165,7 +165,7 @@ void text_box_base::insert_char(const utf8::string& unicode)

size_t text_box_base::get_composition_length() const
{
if(!ime_in_progress_) {
if(!is_composing()) {
return 0;
}

Expand Down Expand Up @@ -395,7 +395,7 @@ void text_box_base::handle_key_backspace(SDL_Keymod /*modifier*/, bool& handled)
delete_selection();
} else if(selection_start_) {
delete_char(true);
if(ime_in_progress_) {
if(is_composing()) {
if(get_composition_length() == 0) {
ime_in_progress_ = false;
}
Expand All @@ -413,7 +413,7 @@ void text_box_base::handle_key_delete(SDL_Keymod /*modifier*/, bool& handled)
delete_selection();
} else if(selection_start_ < text_.get_length()) {
delete_char(false);
if(ime_in_progress_) {
if(is_composing()) {
if(get_composition_length() == 0) {
ime_in_progress_ = false;
}
Expand All @@ -428,7 +428,7 @@ void text_box_base::handle_commit(bool& handled, const utf8::string& unicode)

if(unicode.size() > 1 || unicode[0] != 0) {
handled = true;
if(ime_in_progress_) {
if(is_composing()) {
set_selection(ime_start_point_ + get_composition_length(), 0);
ime_in_progress_ = false;
} else {
Expand All @@ -447,7 +447,7 @@ void text_box_base::handle_editing(bool& handled, const utf8::string& unicode, i
if(unicode.size() > 1 || unicode[0] != 0) {
handled = true;
std::size_t new_len = utf8::size(unicode);
if(!ime_in_progress_) {
if(!is_composing()) {
ime_in_progress_ = true;
delete_selection();
ime_start_point_ = selection_start_;
Expand Down Expand Up @@ -608,15 +608,15 @@ void text_box_base::signal_handler_sdl_key_down(const event::ui_event event,

case SDLK_RETURN:
case SDLK_KP_ENTER:
if(!ime_in_progress_ || (modifier & (KMOD_CTRL | KMOD_ALT | KMOD_GUI | KMOD_SHIFT))) {
if(!is_composing() || (modifier & (KMOD_CTRL | KMOD_ALT | KMOD_GUI | KMOD_SHIFT))) {
return;
}
// The IME will handle it, we just need to make sure nothing else handles it too.
handled = true;
break;

case SDLK_ESCAPE:
if(!ime_in_progress_ || (modifier & (KMOD_CTRL | KMOD_ALT | KMOD_GUI | KMOD_SHIFT))) {
if(!is_composing() || (modifier & (KMOD_CTRL | KMOD_ALT | KMOD_GUI | KMOD_SHIFT))) {
return;
}
interrupt_composition();
Expand Down

0 comments on commit db183b3

Please sign in to comment.