From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <9front-bounces@9front.inri.net> X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: from 9front.inri.net (9front.inri.net [168.235.81.73]) by inbox.vuxu.org (Postfix) with ESMTP id 14D9722078 for ; Sun, 24 Mar 2024 11:59:22 +0100 (CET) Received: from mail.gs25vs.cyou ([210.123.73.190]) by 9front; Sun Mar 24 06:58:13 -0400 2024 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id A30BC1505E8 for <9front@9front.org>; Sun, 24 Mar 2024 19:57:51 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mkv.li; s=dkim; t=1711277875; h=from:subject:date:message-id:to:mime-version:content-type: content-transfer-encoding; bh=ODDXMBt8TDqy3nLhYeNSW7NTKszGSHnDVnFh4LsxndM=; b=dc+j4UZ1V0A4zqC3GbnYXeRk/AuVveM6xZnRhx5nagN2bIPCsbzp8c1qH+njx+Z57aTUFi H6CtVrnPF6d9CNAUqq+lcwTr4yhsrV8v9Iz06j8J8xzClhPAY7Ma5PSWL39BOffA7j7gXa BYa5eB/IrgX3kSkZG7R5S0hFMW3NYKR7GoYsbN0V6BVzxcz34f1M6T4rytEf6hytBkFz5D S8NvpOTHjIr5ng4WbNw3pa5jgHPgjyKOJtoEMVqyn1fFTbb+8OmWYiUarbPTd9FBLftT2z aaPR5w0OPb64agBJMEMRAzrzZ1tPp4XNAIUSEzaP+MSec5F6lCADfd4KgPIuXg== Date: Sun, 24 Mar 2024 19:57:42 +0900 From: npmania To: 9front@9front.org Message-ID: <20240324195742.15746b88@coaster> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: markup SVG factory map/reduce interface Subject: [9front] [PATCH] ktrans: fix Korean input Reply-To: 9front@9front.org Precedence: bulk Before applying the patch, /lib/ktrans/hangul.map file has to be replaced with new one to work properly. The file was generated to provide correct mapping between QWERTY and Dubeolsik layout. Due to it's size, I have uploaded it on: http://okturing.com/src/19014/body This patch implements two specific behaviors of Dubeolsik layout. dubeollkup function makes Jongseong(final consonant) to be treated as Choseong(initial consonant) when possible. For example, QWERTY input "zhem" in Dubeolsik has to be "=EC=BD=94=EB=93=9C", not "=EC=BD=9B=E3=85=A1= " where switched Jongseong is "=E3=84=B7". dubeolbksp function emits out syllable remaining after single backspace. So when user presses backspace on "=EC=BD=94=EB=93=9C", the expe= cted output is "=EC=BD=94=E3=84=B7", still allowing user to edit latter syllable, rathe= r than "=EC=BD=94" without dubeolbksp. This should only apply to last syllable considering it's de facto in Dubeolsik implementations. diff 57b4f2b8e4c5037f726d71c71479a4561ab03137 uncommitted --- a/sys/man/1/ktrans +++ b/sys/man/1/ktrans @@ -167,8 +167,8 @@ standard diacritic suffixes. .SS KOREAN Mapping is done by emulating a Dubeolsik layout, with each Latin -character mapping to a single Jamo. Sequences of up to three Jamo -are automatically converted to Hangul syllables. +character mapping to a single Jamo. Sequences of Jamo are automatically +converted to Hangul syllables. .SH EXAMPLES To type the following Japanese text: --- a/sys/src/cmd/ktrans/main.c +++ b/sys/src/cmd/ktrans/main.c @@ -581,6 +581,59 @@ } static void +dubeolbksp(Str *line) +{ + Map lkup; + + popstr(line); + /* lookup and emit remaining Jamo to output */ + if(hmapget(hangul, line->b, &lkup) < 0) + return; + emitutf(output, lkup.kana, 0); +} + +static void +dubeollkup(Str *line) +{ + Map lkup; + char buf[UTFmax*2]; + char *e2, *e1; + + e1 =3D peekstr(line->p, line->b); + if(e1 !=3D line->b){ + e2 =3D peekstr(e1, line->b); + pushutf(buf, buf+sizeof buf, e2, utflen(e2)); + }else + pushutf(buf, buf+sizeof buf, e1, utflen(e1)); + + if(hmapget(hangul, line->b, &lkup) < 0){ + if(hmapget(hangul, buf, &lkup) < 0){ + resetstr(line, nil); + line->p =3D pushutf(line->p, strend(line), e1, utflen(e1)); + if(hmapget(hangul, line->b, &lkup) < 0) + return; + }else{ + /* treat Jongseong as Choseong when it matches with new Jamo */ + popstr(line); + popstr(line); + hmapget(hangul, line->b, &lkup); + emitutf(output, backspace, 2); + emitutf(output, lkup.kana, 0); + + hmapget(hangul, buf, &lkup); + emitutf(output, lkup.kana, 0); + line->p =3D pushutf(line->b, strend(line), buf, utflen(buf)); + return; + } + } + if(utflen(line->b) =3D=3D 1) + emitutf(output, backspace, 1); + else + emitutf(output, backspace, 2); + emitutf(output, lkup.kana, 0); +} + +static void keythread(void*) { int lang; @@ -645,6 +698,10 @@ resetstr(&line, nil); continue; } else if(r =3D=3D '\b'){ + if(lang =3D=3D LangKO){ + dubeolbksp(&line); + continue; + } popstr(&line); continue; } @@ -652,6 +709,9 @@ line.p =3D pushutf(line.p, strend(&line), p, 1); if(lang =3D=3D LangVN){ telexlkup(&line); + continue; + }else if(lang =3D=3D LangKO){ + dubeollkup(&line); continue; } if(maplkup(lang, line.b, &lkup) < 0){ --- a/sys/src/cmd/ktrans/test.c +++ b/sys/src/cmd/ktrans/test.c @@ -43,6 +43,9 @@ "=0Cddaua", L"=C4=91=C3=A2u", "=0Choir", L"h=E1=BB=8Fi", "=0Cgi=0Cof", L"gi=C3=B2", + + "=0C=13gpffhdnjfemsms wlruqwksw\bgdk, wha tlstjsgks rj djqtdj?", + L"=ED=97=AC=EB=A1=9C=EC=9B=94=EB=93=9C=EB=8A=94 =EC=A7=80=EA=B2=B9=EC=9E= =96=EC=95=84, =EC=A2=80 =EC=8B=A0=EC=84=A0=ED=95=9C =EA=B1=B0 =EC=97=86=EC= =96=B4?", }; char*