Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
linhuman authored and linhuman committed Apr 11, 2019
1 parent 442f371 commit 7a971bb
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
7 changes: 6 additions & 1 deletion include/lunispim_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ extern "C" {
#define HZ_SYMBOL_CHINESE (1 << 5) //中文符号
#define HZ_SYMBOL_HALFSHAPE (1 << 6) //半角符号
#define MAX_PATH 390
//拼音方式
#define PINYIN_QUANPIN 0 //全拼
#define PINYIN_SHUANGPIN 1 //双拼
typedef char16_t TCHAR;
typedef struct lunispim_context_t {
int candidate_count;
Expand All @@ -49,10 +52,11 @@ typedef struct lunispim_context_t {
} LunispimContext;
typedef struct lunispim_config_t {
int hz_output_mode;
int english_state;
int symbol_type;
char* resources_data_dir;
char* user_data_dir;
int pinyin_mode;
int use_english_input;
} LunispimConfig;
typedef struct lunispim_api_t {
int data_size;
Expand All @@ -76,6 +80,7 @@ typedef struct lunispim_api_t {
int (*get_symbol)(TCHAR ch, char *buffer, int buffer_size);
void (*toggle_english_candidate)();
void (*switch_chiness_input)();
void (*switch_english_input)();
void (*switch_english_cand)();
void (*set_soft_cursor)();
int (*get_syllable_index)();
Expand Down
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ add_library(${LIB_LUNISPIM} SHARED ${SRC_LUNISPIM})
target_link_libraries (${LIB_LUNISPIM} ${LIB_RIME})
set_target_properties(${LIB_LUNISPIM} PROPERTIES OUTPUT_NAME ${LIB_LUNISPIM} VERSION ${LUNISPIM_VERSION})
if(DEFINED DESTDIR)
install(TARGETS ${LIB_LUNISPIM} DESTINATION ${DESTDIR}${LIB_INSTALL_DIR})
install(TARGETS ${LIB_LUNISPIM} LIBRARY DESTINATION ${DESTDIR}${LIB_INSTALL_DIR})
install(FILES ${API_HEAD_FILE} DESTINATION ${DESTDIR}${INC_INSTALL_DIR}/lunispim)
else()
install(TARGETS ${LIB_LUNISPIM} DESTINATION ${LIB_INSTALL_DIR})
install(TARGETS ${LIB_LUNISPIM} LIBRARY DESTINATION ${LIB_INSTALL_DIR})
install(FILES ${API_HEAD_FILE} DESTINATION ${INC_INSTALL_DIR}/lunispim)
endif()
6 changes: 1 addition & 5 deletions src/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void ResetContext(PIMCONTEXT *context)
context->english_state = ENGLISH_STATE_NONE;
*/
if (!pim_config->use_english_input)
context->english_state = ENGLISH_STATE_NONE;
context->english_state = ENGLISH_STATE_NONE;
}

/** 第一次进行上下文的初始化
Expand Down Expand Up @@ -547,16 +547,12 @@ int ToggleEnglishCandidate(PIMCONTEXT *context)
{
if (!context || !pim_config)
return -1;
#ifdef __DEBUG
DEBUG_ECHO("切换英文候选模式");
#endif

if (ENGLISH_STATE_CAND == context->english_state)
context->english_state = ENGLISH_STATE_NONE;
else
context->english_state = ENGLISH_STATE_CAND;
return context->english_state;
//PostMessage(context->ui_context->ui_window, UIM_ENGLISH_INPUT, 0, 0);
}
/*
//设置候选显示模式
Expand Down
6 changes: 4 additions & 2 deletions src/editor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,6 @@ int BackSelectedCandidate(PIMCONTEXT *context)
}
void MoveCursorRight(PIMCONTEXT *context)
{
DEBUG_ECHO("context->cursor_pos:%d", context->cursor_pos);
if (context->cursor_pos < context->input_length)
{

Expand Down Expand Up @@ -1684,7 +1683,10 @@ void MoveCursorLeftBySyllable(PIMCONTEXT *context)
TCHAR pinyin[0x10];
int last_pos;
int py_len;
py_len = GetSyllableString(context->syllables[i], pinyin, _SizeOf(pinyin), 0);
if(pim_config->pinyin_mode == PINYIN_SHUANGPIN)
py_len = GetSyllableStringSP(context->syllables[i], pinyin, _SizeOf(pinyin));
else
py_len = GetSyllableString(context->syllables[i], pinyin, _SizeOf(pinyin), 0);
last_pos = pos;
pos += py_len;
if (context->input_string[pos] == SYLLABLE_SEPARATOR_CHAR)
Expand Down
14 changes: 11 additions & 3 deletions src/lunispim_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,15 @@ void toggle_english_candidate()
void switch_chiness_input()
{
if(demo_context.english_state != ENGLISH_STATE_NONE){
ToggleEnglishCandidate(&demo_context);
demo_context.english_state = ENGLISH_STATE_NONE;
}
ProcessContext(&demo_context);
}
void switch_english_input()
{
demo_context.english_state = ENGLISH_STATE_INPUT;
}

void switch_english_cand()
{
if(demo_context.english_state != ENGLISH_STATE_CAND){
Expand All @@ -211,7 +216,6 @@ void get_config(LunispimConfig* config)
{
if(pim_config == 0) LoadDefaultConfig();
config->hz_output_mode = pim_config->hz_output_mode;
config->english_state = demo_context.english_state;
if(pim_config->hz_option & HZ_SYMBOL_CHINESE){
config->symbol_type |= HZ_SYMBOL_CHINESE;
}else{
Expand All @@ -228,12 +232,13 @@ void get_config(LunispimConfig* config)
}
config->user_data_dir = pim_config->user_data_dir;
config->resources_data_dir = pim_config->resources_data_dir;
config->pinyin_mode = pim_config->pinyin_mode;
config->use_english_input = pim_config->use_english_input;
}
void update_config(LunispimConfig* config)
{
if(pim_config == 0) LoadDefaultConfig();
pim_config->hz_output_mode = config->hz_output_mode;
demo_context.english_state = config->english_state;
if(config->symbol_type & HZ_SYMBOL_CHINESE){
pim_config->hz_option |= HZ_SYMBOL_CHINESE;
}else{
Expand All @@ -250,6 +255,8 @@ void update_config(LunispimConfig* config)
}
strcpy_s(pim_config->user_data_dir, MAX_PATH, config->user_data_dir);
strcpy_s(pim_config->resources_data_dir, MAX_PATH, config->resources_data_dir);
pim_config->pinyin_mode = config->pinyin_mode;
pim_config->use_english_input = config->use_english_input;

}
char* initialize()
Expand Down Expand Up @@ -284,6 +291,7 @@ LunispimApi* get_unispim_api()
u_api.toggle_english_candidate = &toggle_english_candidate;
u_api.switch_english_cand = &switch_english_cand;
u_api.switch_chiness_input = &switch_chiness_input;
u_api.switch_english_input = &switch_english_input;
u_api.set_soft_cursor = &set_soft_cursor;
u_api.get_config = &get_config;
u_api.update_config = &update_config;
Expand Down

0 comments on commit 7a971bb

Please sign in to comment.