1
/* Copyright (C) 1994-2011 Edward Der-Hua Liu, Hsin-Chu, Taiwan
3
* This library is free software; you can redistribute it and/or
4
* modify it under the terms of the GNU Lesser General Public
5
* License as published by the Free Software Foundation; either
6
* version 2.1 of the License, or (at your option) any later version.
8
* This library is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public
14
* License along with this library; if not, write to the Free Software
15
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24
#include "im-client/hime-im-client-attr.h"
25
#include "hime-module.h"
26
#include "hime-module-cb.h"
28
extern GtkWidget *gwin_int;
29
HIME_module_main_functions gmf;
30
int current_intcode = INTCODE_UTF32;
32
static char inch[MAX_INTCODE];
35
void create_win_intcode();
36
void module_show_win();
38
int module_init_win(HIME_module_main_functions *funcs)
48
return (x<='9'?x-'0':x-'A'+10);
51
static void utf32to8(char *t, char *s)
55
char *utf8 = g_convert(s, 4, "UTF-8", "UTF-32", &rn, &wn, &err);
66
void big5_utf8_n(char *s, int len, char out[])
72
char *utf8 = g_convert(s, len, "UTF-8", "Big5", &rn, &wn, &err);
75
dbg("big5_utf8 convert error\n");
86
void big5_utf8(char *s, char out[])
88
big5_utf8_n(s, strlen(s), out);
92
static unich_t *dstr[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F" };
94
void disp_int(int index, char *intcode);
95
void clear_int_code_all();
97
gboolean module_feedkey(int key, int kvstate)
101
if (key <= XK_KP_9 && key >= XK_KP_0)
102
key -= XK_KP_0 - '0';
105
if (key==XK_BackSpace||key==XK_Delete) {
114
if ((key<'0'||key>'F'||(key>'9' && key<'A')) && (key!=' ')){
118
if (current_intcode==INTCODE_BIG5) {
119
if (intcode_cin==0 && key<'8')
121
if (intcode_cin==1 && inch[0]=='F' && key=='F')
123
if (intcode_cin==2 && (key<'4' || (key>'7' && key<'A')))
125
if (intcode_cin==3 && (inch[2]=='7'||inch[2]=='F') && key=='F')
129
if (!intcode_cin && key==' ')
131
if ((intcode_cin<MAX_INTCODE-1 || (current_intcode!=INTCODE_BIG5 && intcode_cin < MAX_INTCODE)) && key!=' ')
132
inch[intcode_cin++]=key;
135
clear_int_code_all();
142
for(i=0;i<intcode_cin;i++) {
143
disp_int(i, _(dstr[h2i(inch[i])]));
146
if (((current_intcode==INTCODE_BIG5 && intcode_cin==4) ||
147
(current_intcode==INTCODE_UTF32 && intcode_cin==6)) || key==' ') {
148
u_char utf8[CH_SZ+1];
150
if (current_intcode==INTCODE_BIG5) {
153
ttt[0]=(h2i(inch[0])<<4)+h2i(inch[1]);
154
ttt[1]=(h2i(inch[2])<<4)+h2i(inch[3]);
155
big5_utf8((char *)ttt, (char *)utf8);
160
for(i=0; i < intcode_cin; i++) {
165
utf32to8((char *)utf8, (char *)&v);
168
gmf.mf_send_utf8_ch((char *)utf8);
171
clear_int_code_all();
177
extern GtkWidget *gwin_int;
179
int module_get_preedit(char *str, HIME_PREEDIT_ATTR attr[], int *cursor, int *comp_flag)
181
*comp_flag = intcode_cin>0;
183
if (gwin_int && GTK_WIDGET_VISIBLE(gwin_int))
186
// dbg("comp_len %x\n", *sub_comp_len);
192
int module_feedkey_release(KeySym xkey, int kbstate)
197
int module_flush_input()