add MAKEWPARAM and FIRSTBYTE~FOURTHBYTE macros, and remove HIBYTE_WORD16, LOBYTE_WORD16 macros. Now, MAKEWORD(lobyte, hibyte) returns same value on both 32-bit and 64-bit platforms

This commit is contained in:
VincentWei
2018-02-02 15:05:00 +08:00
parent e2c2ac0704
commit 0bec004433
15 changed files with 197 additions and 110 deletions
+11 -10
View File
@@ -61,15 +61,16 @@ pointer precision.
#### Integer macros
`MAKEWPARAM`: this new macro makes a WPARAM value by using four bytes.
On the contrary, `FIRSTBYTE`, `SECONDBYTE`, `THIRDBYTE`, and `FOURTH`
macros get the four bytes from a `WPARAM` or a `Uint32` value.
`MAKEWORD16`: this new macro makes a 16-bit word by using two bytes.
Meanwhile, `MAKEWORD` makes a 16-bit word on 32-bit platform, and a 32-bit
word on 64-bit platform.
`LOBYTE_WORD16` and `HIBYTE_WORD16`: these two new macros get the low byte
and the high byte in a 16-bit word respectively.
Note that `MAKELONG` macro always makes a `DWORD` integer, which has pointer
precision.
precision. Meanwhile, `MAKELONG32` macro makes a `Uint32` integer.
Note that `MakeRGB` and `MakeRGBA` macros always make `DWORD32` integers.
In contract, `GetRValue`, `GetRValue`, `GetBValue`, `GetAValue` always
@@ -115,16 +116,16 @@ to
_IMPORTANT NOTE_
For best portability, you should use `LOBYTE_WORD16` and `HIBYTE_WORD16`
For best portability, you should use `FIRSTBYTE` to `FOURTHBYTE` macros
to get the bytes of a character when you extract the bytes from `WPARAM`
parameter of a `MSG_CHAR` message:
MSG_CHAR
WORD16 ch = (WORD16)wParam;
DWORD key_flags = (DWORD)lParam;
byte0 = LOBYTE_WORD16 (ch);
byte1 = HIBYTE_WORD16 (ch);
unsigned char ch_buff [4];
unsigned char ch_buff [0] = FIRSTBYTE(wParam);
unsigned char ch_buff [1] = SECONDBYTE(wParam);
unsigned char ch_buff [2] = THIRDBYTE(wParam);
unsigned char ch_buff [3] = FOURTHBYTE(wParam);
##### Window callback procedure
+50 -20
View File
@@ -436,11 +436,11 @@ typedef signed char SBYTE;
#endif
#if SIZEOF_PTR == 8
# define NR_BITS_BYTE (16)
# define NR_BITS_BYTE (8)
# define NR_BITS_WORD (32)
# define NR_BITS_DWORD (64)
# define BITMASK_BYTE (0xFFFF)
# define BITMASK_BYTE (0xFF)
# define BITMASK_WORD (0xFFFFFFFF)
# define BITMASK_DWORD (0xFFFFFFFFFFFFFFFF)
@@ -661,34 +661,64 @@ typedef UINT_PTR LPARAM;
* \def MAKEWORD(low, high)
* \brief Makes a word from \a low byte and \a high byte.
*
* \sa MAKEWORD16
* \sa LOBYTE, HIBYTE
*/
#define MAKEWORD(low, high) ((WORD)(((BYTE)(low)) | (((WORD)((BYTE)(high))) << NR_BITS_BYTE)))
/**
* \def LOBYTE_WORD16(w)
* \brief Returns the low byte of the 16-bit word \a w.
*
* \sa MAKEWORD16
*/
#define LOBYTE_WORD16(w) ((BYTE)(w))
/**
* \def HIBYTE_WORD16(w)
* \brief Returns the high byte of the 16-bit word \a w.
*
* \sa MAKEWORD16
*/
#define HIBYTE_WORD16(w) ((BYTE)(((WORD16)(w) >> 8) & 0xFF))
/**
* \def MAKEWORD16(low, high)
* \brief Makes a 16-bit word from \a low byte and \a high byte.
*
* \sa MAKEWORD
* \sa LOBYTE, HIBYTE
*/
#define MAKEWORD16(low, high) ((WORD16)(((BYTE)(low)) | (((WORD16)((BYTE)(high))) << 8)))
/**
* \def MAKEWPARAM(first, second, third, fourth)
* \brief Makes a WPARAM value with four bytes.
*
* \sa MAKEWORD, FIRSTBYTE, SECONDBYTE, THIRDBYTE, FOURTHBYTE
*/
#define MAKEWPARAM(first, second, third, fourth) \
((WPARAM)( \
((BYTE)(first)) | \
(((WPARAM)((BYTE)(second))) << 8) | \
(((WPARAM)((BYTE)(third))) << 16) | \
(((WPARAM)((BYTE)(fourth))) << 24) \
))
/**
* \def FIRSTBYTE(w)
* \brief Returns the first byte of the WPARAM \a w.
*
* \sa MAKEWPARAM
*/
#define FIRSTBYTE(w) ((BYTE)(w))
/**
* \def SECONDBYTE(w)
* \brief Returns the second byte of the WPARAM \a w.
*
* \sa MAKEWPARAM
*/
#define SECONDBYTE(w) ((BYTE)(((DWORD32)(w)) >> 8))
/**
* \def THIRDBYTE(w)
* \brief Returns the third byte of the WPARAM \a w.
*
* \sa MAKEWPARAM
*/
#define THIRDBYTE(w) ((BYTE)(((DWORD32)(w)) >> 16))
/**
* \def FOURTHBYTE(w)
* \brief Returns the fourth byte of the WPARAM \a w.
*
* \sa MAKEWPARAM
*/
#define FOURTHBYTE(w) ((BYTE)(((DWORD32)(w)) >> 24))
/**
* \def LOWORD(l)
* \brief Returns the low word of the double word \a l
+34 -5
View File
@@ -420,15 +420,20 @@ extern "C" {
*
* \code
* MSG_CHAR
* WORD16 ch = (WORD16)wParam;
* unsigned char ch_buff [4];
* unsigned char ch_buff [0] = FIRSTBYTE(wParam);
* unsigned char ch_buff [1] = SECONDBYTE(wParam);
* unsigned char ch_buff [2] = THIRDBYTE(wParam);
* unsigned char ch_buff [3] = FOURTHBYTE(wParam);
* DWORD key_flags = (DWORD)lParam;
* \endcode
*
* \param ch The EUC code of the pressed key.
* \param ch_buff The buffer to store the bytes of the character.
* \param key_flags The shift key status when this message occurred.
*
* \note Please use \a LOBYTE_WORD16 and \a HIBYTE_WORD16 to get the bytes
* if the character is a two-byte character.
* \note Please use \a FIRSTBYTE ~ \a FOURTHBYTE to get the bytes
* if the character is a multi-byte character. Use MSG_UTF8CHAR
* to handle the characters encoded in UTF-8.
*
* \sa MSG_SYSCHAR, TranslateMessage, key_defs
*/
@@ -560,7 +565,31 @@ extern "C" {
*
* \sa MSG_SYSCHAR, TranslateMessage, key_defs
*/
#define MSG_KEYSYM 0x0018
#define MSG_KEYSYM 0x0018
/**
* \def MSG_UTF8CHAR
* \brief A character translated from MSG_KEYDOWN message.
*
* This message generally sent by a IME window to the current active window.
* The chararcter will be encoded in UTF-8.
*
* \code
* MSG_UTF8CHAR
* unsigned char ch_utf8 [6];
* unsigned char ch_utf8 [0] = FIRSTBYTE(wParam);
* unsigned char ch_utf8 [1] = SECONDBYTE(wParam);
* unsigned char ch_utf8 [2] = THIRDBYTE(wParam);
* unsigned char ch_utf8 [3] = FOURTHBYTE(wParam);
* unsigned char ch_utf8 [4] = FIRSTBYTE(lParam);
* unsigned char ch_utf8 [5] = SECONDBYTE(lParam);
* \endcode
*
* \param ch_utf8 The buffer to save the character in UTF-8.
*
* \sa MSG_CHAR, key_defs
*/
#define MSG_UTF8CHAR 0x0019
/**
* \def DEF_LPRESS_TIME
+14 -10
View File
@@ -2463,30 +2463,34 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case MSG_CHAR:
{
unsigned char charBuffer [3];
unsigned char charBuffer [4];
int chars;
_MG_PRINTF("get char-----------------char----%p\n", (PVOID)wParam);
if (wParam == 127) // BS
wParam = '\b';
if (dwStyle & ES_READONLY)
return 0;
charBuffer [0] = LOBYTE_WORD16 (wParam);
charBuffer [1] = HIBYTE_WORD16 (wParam);
charBuffer [2] = (0x00ff0000 & wParam) >> 16;
if (charBuffer [2]) {
charBuffer [0] = FIRSTBYTE (wParam);
charBuffer [1] = SECONDBYTE (wParam);
charBuffer [2] = THIRDBYTE (wParam);
charBuffer [3] = FOURTHBYTE (wParam);
if (charBuffer [3]) {
chars = 4;
}
else if (charBuffer [2]) {
chars = 3;
}
else if (HIBYTE_WORD16 (wParam)) {
else if (charBuffer [1]) {
chars = 2;
}
else {
chars = 1;
if (charBuffer [0] == 127) // BS
charBuffer [0] = '\b';
if (dwStyle & ES_UPPERCASE) {
charBuffer [0] = toupper (charBuffer[0]);
}
+3 -3
View File
@@ -816,12 +816,12 @@ static LRESULT ButtonCtrlProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
break;
case MSG_CHAR:
if (HIBYTE_WORD16 (wParam)==0 && BUTTON_IS_CHECKBTN (pctrl)) {
if (HIBYTE (wParam)==0 && BUTTON_IS_CHECKBTN (pctrl)) {
int old_check = BUTTON_GET_CHECK(pctrl);
if (LOBYTE_WORD16(wParam) == '+' || LOBYTE_WORD16(wParam) == '=')
if (LOBYTE(wParam) == '+' || LOBYTE(wParam) == '=')
BUTTON_SET_CHECK(pctrl, BST_CHECKED);
else if (LOBYTE_WORD16(wParam) == '-')
else if (LOBYTE(wParam) == '-')
BUTTON_SET_CHECK(pctrl, BST_UNCHECKED);
if (old_check != BUTTON_GET_CHECK(pctrl))
+17 -9
View File
@@ -2070,30 +2070,38 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
return sleKeyDown (hWnd, wParam, lParam);
}
case MSG_UTF8CHAR:
_ERR_PRINTF ("CONTROL>EDIT: MSG_UTF8CHAR is not implemented.\n");
break;
case MSG_CHAR:
{
unsigned char charBuffer [3];
unsigned char charBuffer [4];
int chars;
if (wParam == 127) // BS
wParam = '\b';
if (dwStyle & ES_READONLY)
return 0;
charBuffer [0] = LOBYTE_WORD16 (wParam);
charBuffer [1] = HIBYTE_WORD16 (wParam);
charBuffer [2] = (0x00ff0000 & wParam) >> 16;
charBuffer [0] = FIRSTBYTE (wParam);
charBuffer [1] = SECONDBYTE (wParam);
charBuffer [2] = THIRDBYTE (wParam);
charBuffer [3] = FOURTHBYTE (wParam);
if (charBuffer [2]) {
if (charBuffer [3]) {
chars = 4;
}
else if (charBuffer [2]) {
chars = 3;
}
else if (HIBYTE_WORD16 (wParam)) {
else if (charBuffer [1]) {
chars = 2;
}
else {
chars = 1;
if (charBuffer [0] == 127) // BS
charBuffer [0] = '\b';
if (dwStyle & ES_UPPERCASE) {
charBuffer [0] = toupper (charBuffer[0]);
}
+2 -2
View File
@@ -1885,10 +1885,10 @@ static LRESULT ListboxCtrlProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM l
int newTop;
PLISTBOXITEM plbi;
if (HIBYTE_WORD16 (wParam))
if (HIBYTE (wParam))
break;
head [0] = LOBYTE_WORD16 (wParam);
head [0] = LOBYTE (wParam);
head [1] = '\0';
pData = (PLISTBOXDATA)pCtrl->dwAddData2;
+13 -5
View File
@@ -1990,7 +1990,7 @@ static void teSetCaretPosOnChar (HWND hWnd, PTEDATA ptedata, int old_caret_pos)
static void teOnChar (HWND hWnd, PTEDATA ptedata, WPARAM wParam)
{
int chlen;
unsigned char ch[3];
unsigned char ch[4];
TextNode *node;
TextMark *mark;
TextDoc *txtdoc;
@@ -2004,11 +2004,15 @@ static void teOnChar (HWND hWnd, PTEDATA ptedata, WPARAM wParam)
return;
}
ch [0] = LOBYTE_WORD16 (wParam);
ch [1] = HIBYTE_WORD16 (wParam);
ch [2] = (0x0ff0000 & wParam) >> 16;
ch [0] = FIRSTBYTE (wParam);
ch [1] = SECONDBYTE (wParam);
ch [2] = THIRDBYTE (wParam);
ch [3] = FOURTHBYTE (wParam);
if (ch[2]) {
if (ch[3]) {
chlen = 4;
}
else if (ch[2]) {
chlen = 3;
}
else if (ch[1]) {
@@ -3214,6 +3218,10 @@ static LRESULT TextEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM
break;
}
case MSG_UTF8CHAR:
_ERR_PRINTF ("CONTROL>EDIT: MSG_UTF8CHAR is not implemented.\n");
break;
case MSG_CHAR:
if (wParam == 127) /* BS */
wParam = '\b';
+12 -12
View File
@@ -3718,8 +3718,8 @@ static int utf16le_conv_from_uc32 (UChar32 wc, unsigned char* mchar)
}
if (wc < 0x10000) {
mchar [0] = LOBYTE_WORD16 (wc);
mchar [1] = HIBYTE_WORD16 (wc);
mchar [0] = LOBYTE (wc);
mchar [1] = HIBYTE (wc);
return 2;
}
@@ -3730,10 +3730,10 @@ static int utf16le_conv_from_uc32 (UChar32 wc, unsigned char* mchar)
w1 |= (wc >> 10);
w2 |= (wc & 0x03FF);
mchar [0] = LOBYTE_WORD16 (w1);
mchar [1] = HIBYTE_WORD16 (w1);
mchar [2] = LOBYTE_WORD16 (w2);
mchar [3] = HIBYTE_WORD16 (w2);
mchar [0] = LOBYTE (w1);
mchar [1] = HIBYTE (w1);
mchar [2] = LOBYTE (w2);
mchar [3] = HIBYTE (w2);
return 4;
}
@@ -3944,8 +3944,8 @@ static int utf16be_conv_from_uc32 (UChar32 wc, unsigned char* mchar)
}
if (wc < 0x10000) {
mchar [1] = LOBYTE_WORD16 (wc);
mchar [0] = HIBYTE_WORD16 (wc);
mchar [1] = LOBYTE (wc);
mchar [0] = HIBYTE (wc);
return 2;
}
@@ -3956,10 +3956,10 @@ static int utf16be_conv_from_uc32 (UChar32 wc, unsigned char* mchar)
w1 |= (wc >> 10);
w2 |= (wc & 0x03FF);
mchar [1] = LOBYTE_WORD16 (w1);
mchar [0] = HIBYTE_WORD16 (w1);
mchar [3] = LOBYTE_WORD16 (w2);
mchar [2] = HIBYTE_WORD16 (w2);
mchar [1] = LOBYTE (w1);
mchar [0] = HIBYTE (w1);
mchar [3] = LOBYTE (w2);
mchar [2] = HIBYTE (w2);
return 4;
}
+2 -2
View File
@@ -816,9 +816,9 @@ static LRESULT MsgBoxProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
{
int id = 0;
if (HIBYTE_WORD16 (wParam))
if (HIBYTE (wParam))
break;
switch (LOBYTE_WORD16 (wParam)) {
switch (LOBYTE (wParam)) {
case 'Y':
case 'y':
id = IDYES;
+13 -13
View File
@@ -396,7 +396,7 @@ static void handle_scancode_on_keydown (int scancode, key_info* kinfo)
key_map = __mg_key_maps [shift_final];
if (key_map != NULL) {
keysym = key_map [scancode];
kinfo->type = HIBYTE_WORD16 (keysym);
kinfo->type = HIBYTE (keysym);
if (kinfo->type >= 0xf0) {
kinfo->type -= 0xf0;
@@ -406,7 +406,7 @@ static void handle_scancode_on_keydown (int scancode, key_info* kinfo)
if (key_map)
keysym = key_map [scancode];
kinfo->type = HIBYTE_WORD16 (keysym);
kinfo->type = HIBYTE (keysym);
/*Now, the kinfo->type maybe changed to KT_ARABIC_COMPOSE.
* So we have to deal with this situation */
if(kinfo->type >= 0xf0){
@@ -423,7 +423,7 @@ static void handle_scancode_on_keydown (int scancode, key_info* kinfo)
key_map = __mg_key_maps[shift_final ^(1<<KG_SHIFT)];
if (key_map)
keysym = key_map [scancode];
kinfo->type = HIBYTE_WORD16 (keysym);
kinfo->type = HIBYTE (keysym);
if(kinfo->type >= 0xf0){
kinfo->type -= 0xf0;
@@ -457,7 +457,7 @@ static void handle_scancode_on_keyup (int scancode, key_info* kinfo)
key_map = __mg_key_maps [shift_final];
if (key_map != NULL) {
keysym = key_map [scancode];
kinfo->type = HIBYTE_WORD16 (keysym);
kinfo->type = HIBYTE (keysym);
if (kinfo->type >= 0xf0) {
kinfo->type -= 0xf0;
@@ -559,19 +559,19 @@ BOOL GUIAPI TranslateMessage (PMSG pMsg)
SendNotifyMessage (pMsg->hwnd, MSG_CHAR, __mg_kinfo.buff[0], pMsg->lParam);
}
else if (__mg_kinfo.pos == 2 && arabic_compose_flag) {
/*
#if 0
SendNotifyMessage (pMsg->hwnd, MSG_CHAR,
MAKEWORD16 (__mg_kinfo.buff[0], __mg_kinfo.buff[1]),
pMsg->lParam);
*/
MAKEWPARAM (__mg_kinfo.buff[0], __mg_kinfo.buff[1], 0, 0), pMsg->lParam);
#else
SendNotifyMessage (pMsg->hwnd, MSG_CHAR, __mg_kinfo.buff[0], pMsg->lParam);
SendNotifyMessage (pMsg->hwnd, MSG_CHAR, __mg_kinfo.buff[1], pMsg->lParam);
#endif
arabic_compose_flag =0;
}
else {
for (i = 0; i < __mg_kinfo.pos; i++)
SendNotifyMessage (pMsg->hwnd, MSG_KEYSYM,
MAKEWORD16 (__mg_kinfo.buff[i], i), pMsg->lParam);
MAKEWORD (__mg_kinfo.buff[i], i), pMsg->lParam);
}
return FALSE;
@@ -610,13 +610,13 @@ BOOL GUIAPI TranslateMessage (PMSG pMsg)
SendNotifyMessage (pMsg->hwnd, MSG_CHAR, kinfo.buff[0], pMsg->lParam);
}
else if (kinfo.pos == 2 && arabic_compose_flag) {
/*
#if 0
SendNotifyMessage (pMsg->hwnd, MSG_CHAR,
MAKEWORD16 (__mg_kinfo.buff[0], __mg_kinfo.buff[1]),
pMsg->lParam);
*/
MAKEWPARAM (__mg_kinfo.buff[0], __mg_kinfo.buff[1], 0, 0), pMsg->lParam);
#else
SendNotifyMessage (pMsg->hwnd, MSG_CHAR, kinfo.buff[0], pMsg->lParam);
SendNotifyMessage (pMsg->hwnd, MSG_CHAR, kinfo.buff[1], pMsg->lParam);
#endif
arabic_compose_flag =0;
}
else {
+6 -6
View File
@@ -138,7 +138,7 @@ void VFBSetCaption(const char* caption)
/*one XVFBCaptionEventData struct costs 8 bytes,
* change that '8' below if the struct is changed*/
if (mg_writesocket(__mg_pcxvfb_client_sockfd, ced, 8+len) < (8+len)) {
_MG_PRINTF ("IAL>PCXVFB: error occurred when calling VFBSetCaption.\n");
_ERR_PRINTF ("IAL>PCXVFB: error occurred when calling VFBSetCaption.\n");
}
}
@@ -153,7 +153,7 @@ void VFBOpenIME(int bOpen)
return;
if (mg_writesocket(__mg_pcxvfb_client_sockfd, &ime, sizeof(ime)) < sizeof(ime)) {
_MG_PRINTF ("IAL>PCXVFB: error occurred when calling VFBOpenIME.\n");
_ERR_PRINTF ("IAL>PCXVFB: error occurred when calling VFBOpenIME.\n");
}
}
@@ -167,7 +167,7 @@ void VFBShowWindow(int show)
return;
if (mg_writesocket(__mg_pcxvfb_client_sockfd, info, sizeof(info)) < sizeof(info)) {
_MG_PRINTF ("IAL>PCXVFB: error occurred when calling VFBShowWindow.\n");
_ERR_PRINTF ("IAL>PCXVFB: error occurred when calling VFBShowWindow.\n");
}
}
@@ -267,7 +267,7 @@ static void write_rec (const void* buf, size_t n)
/* TODO: */
#else
if (write(record_fd, buf, n) < n) {
_MG_PRINTF ("IAL>PCXVFB: error occurred when calling write_rec.\n");
_ERR_PRINTF ("IAL>PCXVFB: error occurred when calling write_rec.\n");
}
#endif
}
@@ -346,7 +346,7 @@ static void mouse_setxy (int x, int y)
return;
if (mg_writesocket (__mg_pcxvfb_client_sockfd, &mouse_event, sizeof(XVFBEVENT)) < sizeof(XVFBEVENT)) {
_MG_PRINTF ("IAL>PCXVFB: error occurred when setting mouse position.\n");
_ERR_PRINTF ("IAL>PCXVFB: error occurred when setting mouse position.\n");
}
}
@@ -423,7 +423,7 @@ static int keyboard_update (void)
}
else {
scancode = unicode;
_MG_PRINTF ("IAL>PCXVFB: get a key state change (%s): scancode = %d\n",
_DBG_PRINTF ("IAL>PCXVFB: get a key state change (%s): scancode = %d\n",
press?"pressed":"released", scancode);
kbd_state [scancode] = press;
if (press)
+1 -1
View File
@@ -38,7 +38,7 @@ const char *__mg_msgstr1 [] =
"MSG_KEYLONGPRESS ", // 0x0016
"MSG_KEYALWAYSPRESS ", // 0x0017
"MSG_KEYSYM ", // 0x0018
"", // 0x0019
"MSG_UTF8CHAR ", // 0x0019
"", // 0x001A
"", // 0x001B
"", // 0x001C
+1 -1
View File
@@ -830,7 +830,7 @@ RES_KEY Str2Key (const char* str)
l = (strlen(str)+1) / 2;
for (i=0; i<l; i++) {
Uint16 w = MAKEWORD16(str[i<<1], str[(i<<1)+1]);
Uint16 w = MAKEWORD(str[i<<1], str[(i<<1)+1]);
ret ^= (w<<(i&0x0f));
}
+18 -11
View File
@@ -4312,25 +4312,28 @@ static int texteditor_get_text_char_size(mTextEditor* self, int begin)
return char_size;
}
static int mTextEditor_onChar(mTextEditor *self, int asciiCode, DWORD keyFlags)
static int mTextEditor_onChar(mTextEditor *self, WPARAM eucCode, DWORD keyFlags)
{
int selBegin, selEnd, chlen;
unsigned char ch[3];
unsigned char ch[4];
int replace_char_size = 0;
if (!TE_VALID_OBJ(self) || _read_only(self) || (keyFlags & KS_CTRL))
return 0;
if(asciiCode == 127 || asciiCode == '\b')
{
if(eucCode == 127 || eucCode == '\b') {
_remove_chars(self, TRUE);
return 0;
}
ch [0] = LOBYTE_WORD16 (asciiCode);
ch [1] = HIBYTE_WORD16 (asciiCode);
ch [2] = (0x0ff0000 & asciiCode) >> 16;
if (ch[2]) {
ch [0] = FIRSTBYTE (eucCode);
ch [1] = SECONDBYTE (eucCode);
ch [2] = THIRDBYTE (eucCode);
ch [3] = FOURTHBYTE (eucCode);
if (ch[3]) {
chlen = 4;
}
else if (ch[2]) {
chlen = 3;
}
else if (ch[1]) {
@@ -4369,10 +4372,10 @@ static int mTextEditor_onChar(mTextEditor *self, int asciiCode, DWORD keyFlags)
if (chlen == 1) {
if (GetWindowStyle(self->hwnd) & NCSS_TE_UPPERCASE) {
asciiCode = toupper(asciiCode);
eucCode = toupper(eucCode);
}
else if (GetWindowStyle(self->hwnd) & NCSS_TE_LOWERCASE) {
asciiCode = tolower(asciiCode);
eucCode = tolower(eucCode);
}
}
@@ -4386,7 +4389,7 @@ static int mTextEditor_onChar(mTextEditor *self, int asciiCode, DWORD keyFlags)
_c(self->textBuffer)->replace(self->textBuffer,
selBegin, selEnd - selBegin, (char*)&asciiCode, -1);
selBegin, selEnd - selBegin, (char*)&eucCode, -1);
ncsNotifyParent (self, NCSN_TE_CHANGE);
_set_cont_changed(self, TRUE);
@@ -6380,6 +6383,10 @@ static int mTextEditor_wndProc(mTextEditor *self, int message, WPARAM wParam, LP
case MSG_CHAR:
return _c(self)->onChar(self, wParam, lParam);
case MSG_UTF8CHAR:
_ERR_PRINTF ("CONTROL>EDIT: MSG_UTF8CHAR is not implemented.\n");
break;
case MSG_FONTCHANGED:
_c(self)->onFontChanged(self);
return 0;