Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 157180 Details for
Bug 233054
scim-pinyin-shuangpin not enabled
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
The patch that allows the preedit string in scim-pinyin-shuangpin to be more easily edited.
rsp-3220-3293.patch (text/plain), 7.06 KB, created by
r6144
on 2007-06-16 06:19:30 UTC
(
hide
)
Description:
The patch that allows the preedit string in scim-pinyin-shuangpin to be more easily edited.
Filename:
MIME Type:
Creator:
r6144
Created:
2007-06-16 06:19:30 UTC
Size:
7.06 KB
patch
obsolete
>Index: scim_pinyin.cpp >=================================================================== >--- scim_pinyin.cpp (revision 3220) >+++ scim_pinyin.cpp (revision 3293) >@@ -715,6 +715,24 @@ > return (m_bitmap [ val >> 3 ] & (1 << (val % 8))) == 0; > } > >+/* Since it is immaterial which key is found, we don't bother to normalize */ >+bool >+PinyinValidator::find_some_final (PinyinInitial initial, PinyinKey &key) const >+{ >+ if (initial != SCIM_PINYIN_ZeroInitial) { >+ for (int j = 0; j < (int) SCIM_PINYIN_FinalNumber; j++) { >+ PinyinFinal final = (PinyinFinal) j; >+ key.set(initial, final); >+ if ((*this)(key)) return true; >+ } >+ } >+ >+ /* Well, we will always try to find something... */ >+ key.set(SCIM_PINYIN_ZeroInitial, SCIM_PINYIN_A); >+ return (*this)(key); >+} >+ >+ > const PinyinValidator * > PinyinValidator::get_default_pinyin_validator () > { >@@ -1119,28 +1137,31 @@ > PinyinTone tone = SCIM_PINYIN_ZeroTone; > > int idx [2] = {-1, -1}; >+ bool is_initial[2] = {true, true}; > int used_len = 0; > > size_t i; > bool matched = false; > >+ if (len <= 0) return 0; // just to be safe >+ > for (i = 0; i < 2 && i < len; ++i) { >- if (str [i] >= 'a' && str [i] <= 'z') idx [i] = str [i] - 'a'; >- else if (str [i] == ';') idx [i] = 26; >+ if (str [i] >= 'a' && str [i] <= 'z') { idx [i] = str [i] - 'a'; is_initial[i] = false; } >+ else if (str[i] >= 'A' && str[i] <= 'Z') { idx[i] = str[i] - 'A'; is_initial[i] = true; } >+ else if (str [i] == ';') { idx [i] = 26; is_initial[i] = false; } > } > > // parse initial or final > if (idx [0] >= 0) { >- initial = m_initial_map [idx[0]]; >- final_cands [0] = m_final_map [idx[0]][0]; >- final_cands [1] = m_final_map [idx[0]][1]; >+ if (is_initial[0]) initial = m_initial_map [idx[0]]; >+ else { >+ final_cands [0] = m_final_map [idx[0]][0]; >+ final_cands [1] = m_final_map [idx[0]][1]; >+ } > } > >- if (initial == SCIM_PINYIN_ZeroInitial && final_cands [0] == SCIM_PINYIN_ZeroFinal) >- return 0; >- > // parse final, if str [0] == 'o' (idx [0] == 14) then just skip to parse final. >- if (idx [1] >= 0 && (initial != SCIM_PINYIN_ZeroInitial || idx[0] == 14)) { >+ if (idx [1] >= 0 && ! is_initial[1] && (initial != SCIM_PINYIN_ZeroInitial || (idx[0] == 14 && is_initial[0]))) { > final_cands [2] = m_final_map [idx [1]][0]; > final_cands [3] = m_final_map [idx [1]][1]; > >@@ -1161,13 +1182,14 @@ > } > } > >+ // lone final > if (!matched) { >- initial = SCIM_PINYIN_ZeroInitial; > for (i = 0; i < 2; ++i) { >- key.set (initial, final_cands [i]); >+ key.set (SCIM_PINYIN_ZeroInitial, final_cands [i]); > normalize (key); > > if (validator (key)) { >+ initial = SCIM_PINYIN_ZeroInitial; > final = final_cands [i]; > matched = true; > used_len = 1; >@@ -1178,6 +1200,18 @@ > } > } > >+ // lone initial -- we will always find something to match here >+ if (! matched) { >+ if (validator.find_some_final(initial, key)) { >+ initial = key.get_initial(); >+ final = key.get_final(); >+ matched = true; >+ used_len = 1; >+ ++str; >+ --len; >+ } >+ } >+ > if (!matched) return 0; > > // parse tone >@@ -1991,3 +2025,9 @@ > /* > vi:ts=4:nowrap:ai:expandtab > */ >+/* >+ Local Variables: >+ tab-width: 4 >+ c-indentation-style: "k&r" >+ c-basic-offset: 4 >+*/ >Index: scim_pinyin.h >=================================================================== >--- scim_pinyin.h (revision 3220) >+++ scim_pinyin.h (revision 3293) >@@ -438,6 +438,16 @@ > */ > bool operator () (PinyinKey key) const; > >+ /** >+ * Find some valid final for the given initial and set key to it. >+ * >+ * @param initial some initial to be matched. >+ * @param key will be set to a valid key if this function returns true. >+ * @return true = some valid key is found. >+ */ >+ >+ bool find_some_final (PinyinInitial initial, PinyinKey &key) const; >+ > public: > static const PinyinValidator * get_default_pinyin_validator (); > }; >@@ -1113,3 +1123,9 @@ > /* > vi:ts=4:nowrap:ai:expandtab > */ >+/* >+ Local Variables: >+ tab-width: 4 >+ c-indentation-style: "k&r" >+ c-basic-offset: 4 >+*/ >Index: scim_pinyin_imengine.cpp >=================================================================== >--- scim_pinyin_imengine.cpp (revision 3220) >+++ scim_pinyin_imengine.cpp (revision 3293) >@@ -1644,6 +1644,11 @@ > > String::iterator i = m_inputed_string.begin () + inputed_caret; > >+ if (m_factory->m_shuang_pin) { // decide whether it is an initial (capitalized) or a final >+ if (i != m_inputed_string.begin() && *(i-1) >= 'A' && *(i-1) <= 'Z') ; // after an initial; should be a final >+ else if (key >= 'a' && key <= 'z') key = key - 'a' + 'A'; >+ } >+ > if (key != '\'') { > m_inputed_string.insert (i, key); > } else { >@@ -1662,14 +1667,16 @@ > return true; > } > >- unsigned int len; >- for (len = 0; len < m_parsed_keys.size () && len < old_parsed_keys.size (); ++ len) { >- if (!equal (m_parsed_keys [len], old_parsed_keys [len])) >- break; >- } >+ unsigned int len; > >- if (m_converted_string.length () > len) >- m_converted_string.erase (m_converted_string.begin () + len, m_converted_string.end ()); >+ /* NOTE: The original program preserves all converted characters that corresponds to unmodified pinyin keys (including >+ cases where modifying the input string does not change the parsed pinyin key). This leads to several undesirable >+ effects in auto-fill-preedit mode, e.g. the semi-greedily converted string is suboptimal, and completing an incomplete >+ pinyin (e.g. "Ji Ff" for "ji fen") hides the lookup window. In principle, we should only preserve the manually >+ selected characters in m_converted_string, not the auto-filled ones, but we erase them all for now. */ >+ len = 0; >+ if (m_converted_string.length() > len) >+ m_converted_string.erase (m_converted_string.begin () + len, m_converted_string.end ()); > > m_keys_caret = inputed_caret_to_key_index (inputed_caret + 1); > >@@ -1710,17 +1717,11 @@ > > m_keys_caret = inputed_caret_to_key_index (inputed_caret - 1); > >- unsigned int len; >- PinyinKeyExactEqualTo equal; >+ unsigned int len; >+ len = 0; >+ if (m_converted_string.length() > len) >+ m_converted_string.erase (m_converted_string.begin () + len, m_converted_string.end ()); > >- for (len = 0; len < m_parsed_keys.size () && len < old_parsed_keys.size (); len ++) { >- if (!equal (m_parsed_keys [len], old_parsed_keys [len])) >- break; >- } >- >- if (m_converted_string.length () > len) >- m_converted_string.erase (m_converted_string.begin () + len, m_converted_string.end ()); >- > if (m_keys_caret <= (int) m_converted_string.length () && > m_lookup_caret > m_keys_caret) > m_lookup_caret = m_keys_caret; >@@ -2986,3 +2987,8 @@ > /* > vi:ts=4:nowrap:ai:expandtab > */ >+/* >+ Local Variables: >+ tab-width: 4 >+ c-indentation-style: "k&r" >+*/
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 233054
: 157180