1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "imapi.h"
#include "ucimf.h"
#include "imf/widget.h"
//#include "debug.h"
static char raw_mode = 1;
static char first_show = 1;
//int LogFd=-1;
static void im_active()
{
if (raw_mode) {
extern void init_keycode_state();
init_keycode_state();
}
//UrDEBUG("im active\n");
/* patch */
int buf_len = 5;
unsigned char *buf = (unsigned char*)malloc( sizeof(unsigned char)*( buf_len+1) );
buf[0]=27;
buf[1]=91;
buf[2]=50;
buf[3]=52;
buf[4]=126;
buf[5]=0;
ucimf_switch( buf, &buf_len );
/* patch */
}
static void im_deactive()
{
/* patch */
int buf_len = 5;
unsigned char *buf = (unsigned char*)malloc( sizeof(unsigned char)*( buf_len+1) );
buf[0]=27;
buf[1]=91;
buf[2]=50;
buf[3]=52;
buf[4]=126;
buf[5]=0;
ucimf_switch( buf, &buf_len );
/* patch */
//UrDEBUG("im deactive\n");
//set_im_windows(0, 0);
first_show = 1;
}
static void process_raw_key(char *buf, unsigned int len)
{
if( len <= 0 ) { return; }
char* result = ucimf_process_raw( buf, (int*)&len );
if( len <= 0 ) {
return;
}
else
{
unsigned short result_len = len;
//UrDEBUG("ucimf: return text, '%s', length:%d \n", result, len );
put_im_text( result, result_len );
}
}
static void cursor_pos_changed(unsigned x, unsigned y)
{
//UrDEBUG("cursor, %d, %d\n", x, y);
ucimf_cursor_position( x, y);
}
static ImCallbacks cbs = {
im_active, // .active
im_deactive, // .deactive
0,
0,
process_raw_key, // .send_key
cursor_pos_changed, // .cursor_position
0, // .fbterm_info
0 // .term_mode
};
int main()
{
/* patch */
ucimf_init();
/* patch */
register_im_callbacks(cbs);
connect_fbterm(raw_mode);
while (check_im_message()) ;
//UrDEBUG("im exit normally\n");
return 0;
}
|