Skip to content

Commit 439f74f

Browse files
author
David T. Lewis
committed
Apply the changes of Mr Hachisuka for multibyte character composition.
The diff is in the earlier email from Yoshiki: http://lists.squeakfoundation.org/pipermail/squeak-dev/2016-May/189599.html http://www2.asu.ac.jp/hachi/v3/scratch14ime.html Changes are licenced MIT: http://lists.squeakfoundation.org/pipermail/squeak-dev/2016-May/189646.html Adapt the patch to use the -compositioninput option of the X11 display module. Also fix invocation of that option, which was missing the necessary declaration in sqUnixMain.c (hence did not work). With this change, if the -compositioninput options is on the command line, or if the equivalent SQUEAK_COMPOSITIONINPUT environment variable is set, then the recordPendingKeys() function in the X11 desplay module will use the enhancement of Mr. Hachisuka. Otherwise the original recordPendingKeys() logic is used. git-svn-id: http://squeakvm.org/svn/squeak/branches/Cog@3731 fa1542d4-bde8-0310-ad64-8ed1123d492a Former-commit-id: 72716aa2c8c99cc5a221a6fc10d51bc5b52e835a
1 parent 35ea881 commit 439f74f

File tree

1 file changed

+88
-17
lines changed

1 file changed

+88
-17
lines changed

platforms/unix/vm-display-X11/sqUnixX11.c

Lines changed: 88 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,29 +1713,100 @@ static unsigned char *lookupKeys(int (*lookup)(XIC, XKeyPressedEvent*, char*, in
17131713

17141714
static int recordPendingKeys(void)
17151715
{
1716-
if (inputCount > 0)
1716+
if (compositionInput)
17171717
{
1718-
int i= iebOut - iebIn;
1719-
for (i= (i > 0 ? i : IEB_SIZE + i) / 4; i > 0; -- i)
1720-
{
1718+
if (inputCount <= 0) {
1719+
if (inputBuf != inputString) {
1720+
free(inputBuf);
1721+
inputBuf= inputString;
1722+
}
1723+
return 0;
1724+
}
1725+
1726+
int utf32= 0;
1727+
while (inputCount > 0) {
17211728
# if defined(DEBUG_XIM)
1722-
fprintf(stderr, "%3d pending key %2d=0x%02x\n", inputCount, i, *pendingKey);
1729+
fprintf(stderr, "%3d pending key 0x%02x\n", inputCount, *pendingKey);
17231730
# endif
1724-
recordKeyboardEvent(*pendingKey, EventKeyDown, modifierState, 0);
1725-
recordKeyboardEvent(*pendingKey, EventKeyChar, modifierState, 0);
1726-
recordKeystroke(*pendingKey); /* DEPRECATED */
1727-
++pendingKey;
1728-
if (--inputCount == 0) break;
1729-
}
1730-
return 1;
1731+
/* 110x xxxx 10xx xxxx */
1732+
if (inputCount >= 2 &&
1733+
pendingKey[0] >= 0xc0 && pendingKey[0] <= 0xdf &&
1734+
pendingKey[1] >= 0x80 && pendingKey[1] <= 0xbf)
1735+
{
1736+
utf32= ((pendingKey[0] & 0x1f) << 6) |
1737+
(pendingKey[1] & 0x3f);
1738+
recordKeyboardEvent(0, EventKeyDown, modifierState, utf32);
1739+
recordKeyboardEvent(0, EventKeyChar, modifierState, utf32);
1740+
pendingKey += 2;
1741+
inputCount -= 2;
1742+
}
1743+
/* 1110 xxxx 10xx xxxx 10xx xxxx */
1744+
else if (inputCount >= 3 &&
1745+
pendingKey[0] >= 0xe0 && pendingKey[0] <= 0xef &&
1746+
pendingKey[1] >= 0x80 && pendingKey[1] <= 0xbf &&
1747+
pendingKey[2] >= 0x80 && pendingKey[2] <= 0xbf)
1748+
{
1749+
utf32= ((pendingKey[0] & 0x0f) << 12) |
1750+
((pendingKey[1] & 0x3f) << 6) |
1751+
(pendingKey[2] & 0x3f);
1752+
recordKeyboardEvent(0, EventKeyDown, modifierState, utf32);
1753+
recordKeyboardEvent(0, EventKeyChar, modifierState, utf32);
1754+
pendingKey += 3;
1755+
inputCount -= 3;
1756+
}
1757+
/* 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx */
1758+
else if (inputCount >= 4 &&
1759+
pendingKey[0] >= 0xf0 && pendingKey[0] <= 0xf7 &&
1760+
pendingKey[1] >= 0x80 && pendingKey[1] <= 0xbf &&
1761+
pendingKey[2] >= 0x80 && pendingKey[2] <= 0xbf &&
1762+
pendingKey[3] >= 0x80 && pendingKey[3] <= 0xbf)
1763+
{
1764+
utf32= ((pendingKey[0] & 0x07) << 18) |
1765+
((pendingKey[1] & 0x3f) << 12) |
1766+
((pendingKey[2] & 0x3f) << 6) |
1767+
(pendingKey[3] & 0x3f);
1768+
recordKeyboardEvent(0, EventKeyDown, modifierState, utf32);
1769+
recordKeyboardEvent(0, EventKeyChar, modifierState, utf32);
1770+
pendingKey += 4;
1771+
inputCount -= 4;
1772+
}
1773+
else
1774+
{
1775+
recordKeyboardEvent(*pendingKey, EventKeyDown, modifierState, 0);
1776+
recordKeyboardEvent(*pendingKey, EventKeyChar, modifierState, 0);
1777+
recordKeystroke(*pendingKey); /* DEPRECATED */
1778+
pendingKey++;
1779+
inputCount--;
1780+
}
1781+
}
1782+
return 0;
17311783
}
1732-
/* inputBuf is allocated by lookupKeys */
1733-
if (inputBuf != inputString)
1784+
else
17341785
{
1735-
free(inputBuf);
1736-
inputBuf= inputString;
1786+
if (inputCount > 0)
1787+
{
1788+
int i= iebOut - iebIn;
1789+
for (i= (i > 0 ? i : IEB_SIZE + i) / 4; i > 0; -- i)
1790+
{
1791+
# if defined(DEBUG_XIM)
1792+
fprintf(stderr, "%3d pending key %2d=0x%02x\n", inputCount, i, *pendingKey);
1793+
# endif
1794+
recordKeyboardEvent(*pendingKey, EventKeyDown, modifierState, 0);
1795+
recordKeyboardEvent(*pendingKey, EventKeyChar, modifierState, 0);
1796+
recordKeystroke(*pendingKey); /* DEPRECATED */
1797+
++pendingKey;
1798+
if (--inputCount == 0) break;
1799+
}
1800+
return 1;
1801+
}
1802+
/* inputBuf is allocated by lookupKeys */
1803+
if (inputBuf != inputString)
1804+
{
1805+
free(inputBuf);
1806+
inputBuf= inputString;
1807+
}
1808+
return 0;
17371809
}
1738-
return 0;
17391810
}
17401811

17411812
static int xkeysym2ucs4(KeySym keysym);

0 commit comments

Comments
 (0)