File tree Expand file tree Collapse file tree 1 file changed +43
-30
lines changed
Expand file tree Collapse file tree 1 file changed +43
-30
lines changed Original file line number Diff line number Diff line change @@ -1789,11 +1789,49 @@ pub unsafe extern "C" fn chewing_handle_KeyboardEvent(
17891789) -> c_int {
17901790 let ctx = as_mut_or_return ! ( ctx, ERROR ) ;
17911791
1792- ctx. editor . process_keyevent ( KeyboardEvent {
1793- code : Keycode ( code) ,
1794- ksym : Keysym ( ksym) ,
1795- state,
1796- } ) ;
1792+ // XXX hack for selkey
1793+ let key = if ctx. editor . is_selecting ( ) {
1794+ match ctx
1795+ . sel_keys
1796+ . 0
1797+ . iter ( )
1798+ . position ( |& it| it == Keysym ( ksym) . to_unicode ( ) as i32 )
1799+ {
1800+ Some ( idx) => {
1801+ let key = match idx {
1802+ 0 => b'1' ,
1803+ 1 => b'2' ,
1804+ 2 => b'3' ,
1805+ 3 => b'4' ,
1806+ 4 => b'5' ,
1807+ 5 => b'6' ,
1808+ 6 => b'7' ,
1809+ 7 => b'8' ,
1810+ 8 => b'9' ,
1811+ 9 => b'0' ,
1812+ _ => b'0' ,
1813+ } ;
1814+ Some ( key as c_int )
1815+ }
1816+ None => None ,
1817+ }
1818+ } else {
1819+ None
1820+ } ;
1821+
1822+ let evt = if let Some ( key) = key {
1823+ let mut evt = map_ascii ( & ctx. keymap , key as u8 ) ;
1824+ evt. state = state;
1825+ evt
1826+ } else {
1827+ KeyboardEvent {
1828+ code : Keycode ( code) ,
1829+ ksym : Keysym ( ksym) ,
1830+ state,
1831+ }
1832+ } ;
1833+
1834+ ctx. editor . process_keyevent ( evt) ;
17971835 OK
17981836}
17991837
@@ -2108,31 +2146,6 @@ pub unsafe extern "C" fn chewing_handle_Capslock(ctx: *mut ChewingContext) -> c_
21082146pub unsafe extern "C" fn chewing_handle_Default ( ctx : * mut ChewingContext , key : c_int ) -> c_int {
21092147 let ctx = as_mut_or_return ! ( ctx, ERROR ) ;
21102148
2111- // XXX hack for selkey
2112- let key = if ctx. editor . is_selecting ( ) {
2113- match ctx. sel_keys . 0 . iter ( ) . position ( |& it| it == key) {
2114- Some ( idx) => {
2115- let key = match idx {
2116- 0 => b'1' ,
2117- 1 => b'2' ,
2118- 2 => b'3' ,
2119- 3 => b'4' ,
2120- 4 => b'5' ,
2121- 5 => b'6' ,
2122- 6 => b'7' ,
2123- 7 => b'8' ,
2124- 8 => b'9' ,
2125- 9 => b'0' ,
2126- _ => b'0' ,
2127- } ;
2128- key as c_int
2129- }
2130- None => key,
2131- }
2132- } else {
2133- key
2134- } ;
2135-
21362149 let evt = map_ascii ( & ctx. keymap , key as u8 ) ;
21372150
21382151 unsafe { chewing_handle_KeyboardEvent ( ctx, evt. code . 0 , evt. ksym . 0 , evt. state ) }
You can’t perform that action at this time.
0 commit comments