@@ -11,7 +11,7 @@ void (*f_anthy_set_string)(anthy_context_t ac, char *);
1111extern int eng_ph ;
1212extern gint64 key_press_time ;
1313static GtkWidget * event_box_anthy ;
14-
14+ gint64 current_time ();
1515
1616struct {
1717 char * en ;
@@ -430,13 +430,18 @@ static void cursor_markup(int idx, char *s)
430430
431431void minimize_win_anthy ()
432432{
433+ if (!win_anthy )
434+ return ;
433435 gtk_window_resize (GTK_WINDOW (win_anthy ), 32 , 12 );
434436}
435437
436438static void disp_input ()
437439{
438440 int i ;
439441
442+ if (gcin_edit_display & GCIN_EDIT_DISPLAY_ON_THE_SPOT )
443+ return ;
444+
440445// printf("cursor %d\n", cursor);
441446 clear_seg_label ();
442447 for (i = 0 ; i < jpN ; i ++ ) {
@@ -483,6 +488,15 @@ void delete_jpstr(idx)
483488 jpN -- ;
484489}
485490
491+ static void clear_all ()
492+ {
493+ clear_seg_label ();
494+ jpN = 0 ;
495+ keys [0 ]= 0 ;
496+ keysN = 0 ;
497+ segN = 0 ;
498+ auto_hide ();
499+ }
486500
487501
488502static void send_seg ()
@@ -495,13 +509,9 @@ static void send_seg()
495509 seg [i ].selidx = 0 ;
496510 }
497511
498- clear_seg_label ();
499- jpN = 0 ;
500- keysN = 0 ;
501-
502512// printf("sent convert '%s'\n", out);
503513 send_text (out );
504- segN = 0 ;
514+ clear_all () ;
505515}
506516
507517static char merge_jp (char out [])
@@ -553,7 +563,8 @@ static void disp_select()
553563 int x ,y ;
554564 get_widget_xy (win_anthy , seg [cursor ].label , & x , & y );
555565// printf("%x cusor %d %d\n", win_anthy, cursor, x);
556- disp_selections (x , win_y + win_yl );
566+ y = gcin_edit_display == GCIN_EDIT_DISPLAY_ON_THE_SPOT ?win_y :win_y + win_yl ;
567+ disp_selections (x , y );
557568}
558569
559570static void load_seg ()
@@ -624,8 +635,10 @@ gboolean feedkey_anthy(int kv, int kvstate)
624635 int shift_m = (kvstate & ShiftMask ) > 0 ;
625636// printf("%x %c %d\n", kv, kv, shift_m);
626637
627- if (kv == XK_Shift_L || kv == XK_Shift_R )
638+ if (kv == XK_Shift_L || kv == XK_Shift_R ) {
639+ puts ("shift" );
628640 key_press_time = current_time ();
641+ }
629642
630643 if (!eng_ph )
631644 return 0 ;
@@ -970,7 +983,9 @@ int anthy_visible()
970983extern gboolean force_show ;
971984void show_win_anthy ()
972985{
973- if (!gcin_pop_up_win || !is_empty () || force_show ) {
986+ if (gcin_edit_display & GCIN_EDIT_DISPLAY_ON_THE_SPOT )
987+ return ;
988+ if (!gcin_pop_up_win || !is_empty () || force_show ) {
974989 if (!anthy_visible ())
975990 gtk_widget_show (win_anthy );
976991 show_win_sym ();
@@ -1053,3 +1068,83 @@ int feedkey_anthy_release(KeySym xkey, int kbstate)
10531068 return 0 ;
10541069 }
10551070}
1071+
1072+ #include "im-client/gcin-im-client-attr.h"
1073+
1074+ int anthy_get_preedit (char * str , GCIN_PREEDIT_ATTR attr [], int * pcursor )
1075+ {
1076+ int i ;
1077+ int tn = 0 ;
1078+
1079+ // dbg("anthy_get_preedit\n");
1080+ str [0 ]= 0 ;
1081+ * pcursor = 0 ;
1082+
1083+ attr [0 ].flag = GCIN_PREEDIT_ATTR_FLAG_UNDERLINE ;
1084+ attr [0 ].ofs0 = 0 ;
1085+ int attrN = 0 ;
1086+ int ch_N = 0 ;
1087+
1088+ if (state == STATE_CONVERT ) {
1089+ if (segN )
1090+ attrN = 1 ;
1091+
1092+ for (i = 0 ; i < segN ; i ++ ) {
1093+ char * s = gtk_label_get_text (GTK_LABEL (seg [i ].label ));
1094+ int N = utf8_str_N (s );
1095+ ch_N += N ;
1096+ if (i < cursor )
1097+ * pcursor += N ;
1098+ if (i == cursor ) {
1099+ attr [1 ].ofs0 = * pcursor ;
1100+ attr [1 ].ofs1 = * pcursor + N ;
1101+ attr [1 ].flag = GCIN_PREEDIT_ATTR_FLAG_REVERSE ;
1102+ attrN ++ ;
1103+ }
1104+ strcat (str , s );
1105+ }
1106+
1107+ attr [0 ].ofs1 = ch_N ;
1108+ } else {
1109+ if (jpN )
1110+ attrN = 1 ;
1111+
1112+ for (i = 0 ;i < jpN ; i ++ ) {
1113+ char * s = anthy_romaji_map [jp [i ]].ro ;
1114+ int N = utf8_str_N (s );
1115+ ch_N += N ;
1116+ if (i < cursor )
1117+ * pcursor += N ;
1118+ if (i == cursor ) {
1119+ attr [1 ].ofs0 = * pcursor ;
1120+ attr [1 ].ofs1 = * pcursor + N ;
1121+ attr [1 ].flag = GCIN_PREEDIT_ATTR_FLAG_REVERSE ;
1122+ attrN ++ ;
1123+ }
1124+ strcat (str , s );
1125+ }
1126+
1127+ strcat (str , keys );
1128+ attr [0 ].ofs1 = ch_N + keysN ;
1129+ }
1130+
1131+ ret :
1132+ return attrN ;
1133+ }
1134+
1135+
1136+ void gcin_anthy_reset ()
1137+ {
1138+ if (!win_anthy )
1139+ return ;
1140+ clear_all ();
1141+ }
1142+
1143+ void get_win_anthy_geom ()
1144+ {
1145+ if (!win_anthy )
1146+ return ;
1147+ gtk_window_get_position (GTK_WINDOW (win_anthy ), & win_x , & win_y );
1148+
1149+ get_win_size (win_anthy , & win_xl , & win_yl );
1150+ }
0 commit comments