Fixes cursor behavior

This commit is contained in:
Peng Wu 2015-09-17 13:58:00 +08:00
parent e0b8fd5272
commit 8c1ad47347
2 changed files with 86 additions and 2 deletions

View File

@ -0,0 +1,81 @@
From f69aa02f2318dff8af34993f57c924e3b1514c2f Mon Sep 17 00:00:00 2001
From: Peng Wu <alexepico@gmail.com>
Date: Fri, 11 Sep 2015 11:55:59 +0800
Subject: [PATCH] fixes input behavior
---
src/ZYZPhoneticEditor.cc | 20 ++++++++++++++++++++
src/ZYZPhoneticEditor.h | 5 +++++
2 files changed, 25 insertions(+)
diff --git a/src/ZYZPhoneticEditor.cc b/src/ZYZPhoneticEditor.cc
index 0672706..27b28be 100644
--- a/src/ZYZPhoneticEditor.cc
+++ b/src/ZYZPhoneticEditor.cc
@@ -79,6 +79,8 @@ PhoneticEditor::PhoneticEditor (ZhuyinProperties & props, Config & config)
loadEasySymbolFile (path) ||
loadEasySymbolFile (PKGDATADIR G_DIR_SEPARATOR_S "easysymbol.txt");
g_free(path);
+
+ m_moved_left = FALSE;
}
PhoneticEditor::~PhoneticEditor (void)
@@ -122,6 +124,12 @@ PhoneticEditor::processEscape (guint keyval, guint keycode,
STATE_USER_SYMBOL_SHOWN == m_input_state) {
m_input_state = STATE_INPUT;
+
+ if (m_moved_left) {
+ moveCursorRight ();
+ m_moved_left = FALSE;
+ }
+
update ();
return TRUE;
}
@@ -293,6 +301,12 @@ PhoneticEditor::processShowCandidateKey (guint keyval, guint keycode,
switch (keyval) {
case IBUS_Down:
case IBUS_KP_Down:
+ if (m_config.candidatesAfterCursor () &&
+ m_cursor == get_enhanced_text_length (m_text)) {
+ moveCursorLeft ();
+ m_moved_left = TRUE;
+ }
+
/* check phonetic or symbol section here */
prepareCandidates ();
break;
@@ -301,6 +315,12 @@ PhoneticEditor::processShowCandidateKey (guint keyval, guint keycode,
case IBUS_KP_Up:
m_lookup_table.clear ();
m_input_state = STATE_INPUT;
+
+ if (m_moved_left) {
+ moveCursorRight ();
+ m_moved_left = FALSE;
+ }
+
break;
default:
diff --git a/src/ZYZPhoneticEditor.h b/src/ZYZPhoneticEditor.h
index 9e178f8..bedb66c 100644
--- a/src/ZYZPhoneticEditor.h
+++ b/src/ZYZPhoneticEditor.h
@@ -130,6 +130,11 @@ protected:
zhuyin_instance_vec m_instances;
SymbolLookup m_easy_symbols;
+
+ /* move left one character when cursor is at the end,
+ * only in candidates after cursor option.
+ */
+ gboolean m_moved_left;
};
};
--
2.4.3

View File

@ -1,8 +1,8 @@
%global snapshot 0
%global snapshot 1
Name: ibus-libzhuyin
Version: 1.7.4
Release: 1%{?dist}
Release: 2%{?dist}
Summary: New Zhuyin engine based on libzhuyin for IBus
License: GPLv2+
URL: https://github.com/libzhuyin/ibus-libzhuyin
@ -64,6 +64,9 @@ make install DESTDIR=${RPM_BUILD_ROOT} INSTALL="install -p"
%changelog
* Thu Sep 17 2015 Peng Wu <pwu@redhat.com> - 1.7.4-2
- Fixes cursor behavior
* Wed Aug 19 2015 Peng Wu <pwu@redhat.com> - 1.7.4-1
- Update to 1.7.4