Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

revise function and dont hardcode dic path

  • Loading branch information...
commit 6f835798c1f5ecd6ceb0e2f882c15b02a1387f19 1 parent 31be317
@taylorchu authored
Showing with 10 additions and 10 deletions.
  1. +1 −1  config.h.in
  2. +1 −1  data/CMakeLists.txt
  3. +8 −8 src/eim.c
View
2  config.h.in
@@ -1 +1 @@
-
+#define EN_DIC_FILE "@CMAKE_INSTALL_PREFIX@/share/fcitx/data/en_dic.txt"
View
2  data/CMakeLists.txt
@@ -4,4 +4,4 @@ fcitx_add_inputmethod_conf_file(en.conf)
install(FILES en.png DESTINATION share/fcitx/skin/default/)
install(FILES en.png DESTINATION share/fcitx/skin/classic/)
install(FILES en.png DESTINATION share/fcitx/skin/dark/)
-install(FILES en_dic.txt DESTINATION share/fcitx/)
+install(FILES en_dic.txt DESTINATION share/fcitx/data)
View
16 src/eim.c
@@ -52,7 +52,7 @@ static void FcitxEnReloadConfig(void* arg);
static boolean LoadEnConfig(FcitxEnConfig* fs);
static void SaveEnConfig(FcitxEnConfig* fs);
static void ConfigEn(FcitxEn* en);
-static int en_prefix_suggest(const char * prefix, char *** cp);
+static char ** en_prefix_suggest(const char * prefix, int * n);
static void en_free_list(char *** cp, const int n);
static char * en_prefix_hint(const char * prefix);
const FcitxHotkey FCITX_TAB[2] = {{NULL, FcitxKey_Tab, FcitxKeyState_None}, {NULL, FcitxKey_None, FcitxKeyState_None}};
@@ -61,9 +61,9 @@ const FcitxHotkey FCITX_SLASH[2] = {{NULL, FcitxKey_slash, FcitxKeyState_None},
const FcitxHotkey FCITX_APOS[2] = {{NULL, FcitxKey_apostrophe, FcitxKeyState_None}, {NULL, FcitxKey_None, FcitxKeyState_None}};
const FcitxHotkey FCITX_GRAV[2] = {{NULL, FcitxKey_grave, FcitxKeyState_None}, {NULL, FcitxKey_None, FcitxKeyState_None}};
-int en_prefix_suggest(const char * prefix, char *** cp)
+char ** en_prefix_suggest(const char * prefix, int * n)
{
- FILE * file = fopen("/usr/local/share/fcitx/en_dic.txt", "r");
+ FILE * file = fopen(EN_DIC_FILE, "r");
if (file == NULL)
return 0;
char line [32];
@@ -82,13 +82,13 @@ int en_prefix_suggest(const char * prefix, char *** cp)
break;
}
}
- *cp = candlist;
- return list_size;
+ *n = list_size;
+ return candlist;
}
char * en_prefix_hint(const char * prefix)
{
- FILE * file = fopen("/usr/local/share/fcitx/en_dic.txt", "r");
+ FILE * file = fopen(EN_DIC_FILE, "r");
if (file == NULL)
return NULL;
char line [32];
@@ -320,8 +320,8 @@ INPUT_RETURN_VALUE FcitxEnGetCandWords(void* arg)
if(en->chooseMode) {
int index = 0;
- char ** candList;
- int candNum = en_prefix_suggest(en->buf, &candList);
+ int candNum;
+ char ** candList = en_prefix_suggest(en->buf, &candNum);
while (index < candNum) {
FcitxCandidateWord cw;
cw.callback = FcitxEnGetCandWord;
Please sign in to comment.
Something went wrong with that request. Please try again.