pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/inputmethod/xcin Use the new APIs of libchewing-0.5.1,...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/d690125bec99
branches:  trunk
changeset: 379621:d690125bec99
user:      rxg <rxg%pkgsrc.org@localhost>
date:      Fri May 20 13:38:45 2022 +0000

description:
Use the new APIs of libchewing-0.5.1, bump revision.

diffstat:

 inputmethod/xcin/Makefile             |    9 +-
 inputmethod/xcin/distinfo             |    5 +-
 inputmethod/xcin/files/xcin_chewing.c |  492 ++++++++++++++++++++++++++++++++
 inputmethod/xcin/patches/patch-af     |    4 +-
 inputmethod/xcin/patches/patch-ag     |  520 ----------------------------------
 5 files changed, 502 insertions(+), 528 deletions(-)

diffs (truncated from 1090 to 300 lines):

diff -r 8028a363c8ae -r d690125bec99 inputmethod/xcin/Makefile
--- a/inputmethod/xcin/Makefile Fri May 20 12:10:28 2022 +0000
+++ b/inputmethod/xcin/Makefile Fri May 20 13:38:45 2022 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.45 2021/05/24 19:52:29 wiz Exp $
+# $NetBSD: Makefile,v 1.46 2022/05/20 13:38:45 rxg Exp $
 
 DISTNAME=      xcin-2.5.3.pre2
 PKGNAME=       xcin-2.5.3rc2
-PKGREVISION=   20
+PKGREVISION=   21
 CATEGORIES=    chinese x11
 #MASTER_SITES= ftp://xcin.linux.org.tw/pub/xcin/xcin/devel/
 
@@ -58,6 +58,9 @@
 post-extract:
        ${CP} ${FILESDIR}/xcinrc.DRAGONFLY ${WRKSRC}/etc
 
+post-patch:
+       ${CP} ${FILESDIR}/xcin_chewing.c ${WRKSRC}/src/Cinput/chewing
+
 post-install:
        cd ${WRKSRC}/doc && pax -rw     \
                -s ',^\./man$$,,' -s ',^\./man/.*,,'    \
@@ -72,7 +75,7 @@
 
 .include "../../converters/libiconv/buildlink3.mk"
 .include "../../devel/gettext-lib/buildlink3.mk"
-.include "../../inputmethod/libchewing02/buildlink3.mk"
+.include "../../inputmethod/libchewing/buildlink3.mk"
 .include "../../inputmethod/libtabe/buildlink3.mk"
 .include "../../x11/libX11/buildlink3.mk"
 .include "../../x11/libXext/buildlink3.mk"
diff -r 8028a363c8ae -r d690125bec99 inputmethod/xcin/distinfo
--- a/inputmethod/xcin/distinfo Fri May 20 12:10:28 2022 +0000
+++ b/inputmethod/xcin/distinfo Fri May 20 13:38:45 2022 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.11 2021/10/26 10:49:47 nia Exp $
+$NetBSD: distinfo,v 1.12 2022/05/20 13:38:45 rxg Exp $
 
 BLAKE2s (xcin-2.5.3.pre2.tar.gz) = fc0e2dece86f69c7bdc0a174009f4ee2b8529f11ffb72c409e8993e1d52b13b0
 SHA512 (xcin-2.5.3.pre2.tar.gz) = 01b44d0cf1e90fd42a7a45443bc32bb0e2eb85a500a7ee8ca3a4968becf43f8ffbc37f5beec9307a0687a51b7d0a28fba7ed6f9501786c2fbacf562d5dffec86
@@ -8,8 +8,7 @@
 SHA1 (patch-ac) = 63ad86449dd44ddf3db2ed661de2e290c894131f
 SHA1 (patch-ad) = 6e59d32f5e3f8f06f8b4bcbb32e221678db74018
 SHA1 (patch-ae) = 13985687af55de0a6727150d41d2d6333d103689
-SHA1 (patch-af) = 23dde43647de72fb6492a51016379db88f37cdd2
-SHA1 (patch-ag) = 009aff61710ad0da4492e366f35fa565b0abc32c
+SHA1 (patch-af) = 0f2764178a6705c77de5ac3976d954e5217edb66
 SHA1 (patch-ah) = 0bc13a5e03157cc788228162d7f212d5741c29bf
 SHA1 (patch-ai) = 324cd99f69bd226846dc65f100c523c056fc13c6
 SHA1 (patch-aj) = d7b9adac4d08fcee744f80aaece059bdd96ab23c
diff -r 8028a363c8ae -r d690125bec99 inputmethod/xcin/files/xcin_chewing.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/inputmethod/xcin/files/xcin_chewing.c     Fri May 20 13:38:45 2022 +0000
@@ -0,0 +1,492 @@
+/*
+ * This code is derived from xcin-chewing-20041004.diff and
+ * rewritten by Rui-Xiang Guo to use the new libchewing APIs.
+ *
+ * Bridge interface between libchewing and xcin
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <chewing/chewing.h>
+#include <string.h>
+
+#include <X11/Xlib.h>
+#include <X11/keysym.h>
+#include "xcintool.h"
+#include "module.h"
+
+#include <iconv.h>
+#include <langinfo.h>
+
+/* the following keystate masks are defined by xcin */
+#define CAPS_MASK (2)
+#define CTRL_MASK (4)
+
+#define XCIN_BYTE_NATIVE       2
+#define XCIN_BYTE_UTF8                 3
+
+/* internal/chewing-private.h */
+#define MAX_UTF8_SIZE          4
+#define BOPOMOFO_SIZE          4
+#define AUX_PREFIX_LEN         (3)     /* showMsg */
+#define MAX_PHRASE_LEN         11
+#define MAX_PHONE_SEQ_LEN      50      /* commitBuf */
+#define MAX_CHOICE_BUF         (50)    /* max length of the choise buffer */
+
+static char *cname;
+static char *kb_type_str;
+
+static int chewing_codeset;
+static int chewing_mbs_wcs(wch_t *wcs, char *mbs, int wcs_len);
+void preconvert(const char *input, char *output, int n_char);
+
+static char selKey_define[11] = "1234567890\0"; /* Default */
+
+int MakeInpinfo(inpinfo_t *inpinfo);
+
+static int
+ChewingInit(void *conf, char *objname, xcin_rc_t *xc)
+{
+       char *cmd[2], value[50];
+       int i;
+       ChewingConfigData *cf = (ChewingConfigData *) conf;
+
+       putenv("CHEWING_PATH=" CHEWING_DATA_PREFIX);
+
+       /* For compatible purposes */
+       cf->candPerPage = 9;
+       cf->maxChiSymbolLen = 16;
+
+       /*
+        * The new libchewing uses UTF-8 encoding for all its structure
+        * so we need to check if it is UTF-8 locale and do any conv
+        */
+       chewing_codeset = (!strcasecmp(xc->locale.encoding, "utf-8")) ?
+               XCIN_BYTE_UTF8 :
+               XCIN_BYTE_NATIVE;
+       cname = (char *) calloc(3, sizeof(char) * chewing_codeset);
+
+       cmd[0] = objname;
+       /* Set keyboard type */
+       cmd[1] = "KB_TYPE";
+       kb_type_str = "KB_DEFAULT";
+       if (get_resource(xc, cmd, value, 50, 2)) {
+               kb_type_str = value;
+       }
+
+       /* Support selection key definitions */
+       cmd[1] = "SELECTION_KEYS_DEFINE";
+       if (get_resource(xc, cmd, value, 50, 2)) {
+               if (strlen(value) == 10) {
+                       strcpy(selKey_define, value);
+                       selKey_define[11] = '\0';
+               }
+       }
+       for (i = 0; i < 10; i++)
+               cf->selKey[i] = selKey_define[i];
+
+       /* Set phrase direction */
+       cmd[1] = "ADD_PHRASE_FORWARD";
+       cf->bAddPhraseForward = 0;
+       if (get_resource(xc, cmd, value, 50, 2)) {
+               if (atoi(value) == 1) {
+                       cf->bAddPhraseForward = 1;
+               }
+       }
+
+       return True;
+}
+
+static int 
+ChewingXimInit(void *conf, inpinfo_t *inpinfo)
+{
+       static char cchBuffer[MAX_PHONE_SEQ_LEN * MAX_UTF8_SIZE + 1];
+       ChewingConfigData *cf = (ChewingConfigData *) conf;
+       int i;
+
+       /* Initialize Chewing */
+       inpinfo->iccf = chewing_new();
+
+       /* CallSetConfig */
+       chewing_set_candPerPage(inpinfo->iccf, cf->candPerPage);
+       chewing_set_maxChiSymbolLen(inpinfo->iccf, cf->maxChiSymbolLen);
+       chewing_set_KBType(inpinfo->iccf, chewing_KBStr2Num(kb_type_str));
+       chewing_set_selKey(inpinfo->iccf, cf->selKey, 10);
+       chewing_set_addPhraseDirection(inpinfo->iccf, cf->bAddPhraseForward);
+
+       inpinfo->lcch = (wch_t *) calloc(MAX_PHONE_SEQ_LEN, sizeof(wch_t));
+       inpinfo->lcch_grouping = (ubyte_t *) calloc(MAX_PHONE_SEQ_LEN, sizeof(ubyte_t));
+       inpinfo->cch = cchBuffer;
+
+       preconvert("\xE6\x96\xB0\xE9\x85\xB7\xE9\x9F\xB3", cname, 9);
+       inpinfo->inp_cname = cname;
+       inpinfo->inp_ename = "chewing";
+       inpinfo->area3_len = 2 * BOPOMOFO_SIZE + 4;
+       inpinfo->guimode = GUIMOD_LISTCHAR | GUIMOD_SELKEYSPOT;
+       inpinfo->keystroke_len = 0;
+       inpinfo->s_keystroke = (wch_t *) calloc(MAX_PHRASE_LEN + AUX_PREFIX_LEN, sizeof(wch_t));
+
+       inpinfo->mcch = (wch_t *) calloc(MAX_CHOICE_BUF, sizeof(wch_t));
+       inpinfo->mcch_grouping = (ubyte_t *) calloc(MAX_SELKEY, sizeof(ubyte_t));
+       inpinfo->n_mcch = 0;
+
+       inpinfo->n_lcch = 0;
+       inpinfo->edit_pos = 0;
+       inpinfo->cch_publish.wch = (wchar_t) 0;
+
+       /*
+        * check_winsize(inpinfo, iccf);
+        * [yet] check winsize is under construction.
+        */
+
+       inpinfo->n_selkey = 10;
+       inpinfo->s_selkey = (wch_t *) calloc(MAX_SELKEY, sizeof(wch_t));
+
+       for (i = 0; i < 10; i++) {
+               inpinfo->s_selkey[i].wch = (wchar_t) 0;
+               inpinfo->s_selkey[i].s[0] = selKey_define[i];
+       }
+
+       return True;
+}
+
+void CommitString(inpinfo_t *inpinfo)
+{
+       int len;
+       char *str, *output;
+
+       memset(inpinfo->cch, 0, sizeof(char) * (MAX_PHONE_SEQ_LEN * MAX_UTF8_SIZE + 1));
+       str = chewing_commit_String(inpinfo->iccf);
+       len = strlen(str);
+       output = (char *) calloc(len, sizeof(char) * chewing_codeset);
+       preconvert(str, output, len);
+       strcat(inpinfo->cch, output);
+       free(output);
+}
+
+static unsigned int 
+ChewingXimEnd(void *conf, inpinfo_t *inpinfo)
+{
+       int rtn;
+
+       /* if preedit exists, commit the string */
+       chewing_handle_Enter(inpinfo->iccf);
+
+       rtn = MakeInpinfo(inpinfo);
+       chewing_delete(inpinfo->iccf);
+       free(inpinfo->s_keystroke);
+       free(inpinfo->lcch);
+       free(inpinfo->mcch);
+       free(inpinfo->mcch_grouping);
+
+       inpinfo->iccf = NULL;
+       inpinfo->s_keystroke = NULL;
+       inpinfo->lcch = NULL;
+
+       return rtn;
+}      
+
+void ShowChoose(inpinfo_t *inpinfo)
+{
+       int i = 1, len, pageno;
+       char *buf, *output;
+       const char *const_buf;
+
+       memset(inpinfo->mcch, 0, sizeof(wch_t) * MAX_CHOICE_BUF);
+       /*
+        * for new xcin, there is no need to modify the lcch buffer
+        * instead, we put phrase to choose in mcch
+        */
+       if (chewing_cand_TotalPage(inpinfo->iccf) == 0)
+               return;
+
+       buf = (char *) calloc(MAX_CHOICE_BUF, sizeof(char) * chewing_codeset);
+       chewing_cand_Enumerate(inpinfo->iccf);
+       while (chewing_cand_hasNext(inpinfo->iccf)) {
+               /* in the last page, no will exceed nTotalChoice */
+               if (i > chewing_cand_ChoicePerPage(inpinfo->iccf))
+                       break;
+
+               /* set grouping to the length of the phrase */
+               const_buf = chewing_cand_String_static(inpinfo->iccf);
+               inpinfo->mcch_grouping[i] = strlen(const_buf) / 3;
+               strcat(buf, const_buf);
+               i++;
+       }
+
+       /* i stores how many choices are available */
+       inpinfo->mcch_grouping[0] = i;
+
+       /* set pgstate according to the current page position */
+       if (chewing_cand_TotalPage(inpinfo->iccf) == 1)
+               inpinfo->mcch_pgstate = MCCH_ONEPG;
+       else {
+               pageno = chewing_cand_CurrentPage(inpinfo->iccf);
+               if (pageno == 0)
+                       inpinfo->mcch_pgstate = MCCH_BEGIN;
+               else if (pageno == (chewing_cand_TotalPage(inpinfo->iccf) - 1))
+                       inpinfo->mcch_pgstate = MCCH_END;
+               else
+                       inpinfo->mcch_pgstate = MCCH_MIDDLE;
+       }
+
+       len = strlen(buf);
+       output = (char *) calloc(len, sizeof(char) * chewing_codeset);
+       preconvert(buf, output, len);
+       inpinfo->n_mcch = chewing_mbs_wcs(inpinfo->mcch, output, (len + 1) * chewing_codeset);
+       free(buf);
+       free(output);
+}
+
+void ShowText(inpinfo_t *inpinfo)
+{



Home | Main Index | Thread Index | Old Index