From 61ada7b217aa04109e499301cf54ffee67d26ae5 Mon Sep 17 00:00:00 2001 From: VincentWei Date: Thu, 1 Feb 2018 23:10:31 +0800 Subject: [PATCH 1/7] develmode does not control tracemsg option --- configure.ac | 1 - 1 file changed, 1 deletion(-) diff --git a/configure.ac b/configure.ac index 5544d1cd..a7fc75a0 100644 --- a/configure.ac +++ b/configure.ac @@ -1638,7 +1638,6 @@ fi if test "x$devel_mode" = "xyes"; then message_string="yes" - trace_message="no" build_auto_ial_engine="yes" build_random_ial_engine="yes" From d9c95e1900470676dbfd27143818b938906d1d24 Mon Sep 17 00:00:00 2001 From: VincentWei Date: Thu, 1 Feb 2018 23:11:32 +0800 Subject: [PATCH 2/7] tune format --- src/newgal/pixels.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/newgal/pixels.c b/src/newgal/pixels.c index 2f8bb8fc..a7f623a0 100644 --- a/src/newgal/pixels.c +++ b/src/newgal/pixels.c @@ -360,12 +360,12 @@ Uint32 GAL_MapRGB(GAL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b) | (b >> format->Bloss) << format->Bshift | format->Amask; #ifdef _NEWGAL_SWAP16 - pixv = (pixv & 0xFFFF0000) | ArchSwap16((unsigned short)pixv); + pixv = (pixv & 0xFFFF0000) | ArchSwap16((unsigned short)pixv); #endif #if defined(_EM86_IAL) || defined (_EM85_IAL) - if (pixv == 0) pixv ++; + if (pixv == 0) pixv ++; #endif - return pixv; + return pixv; } else { if (format->DitheredPalette) return GAL_FindDitheredColor (format->BitsPerPixel, r, g, b); @@ -378,14 +378,14 @@ Uint32 GAL_MapRGB(GAL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b) Uint32 GAL_MapRGBA(GAL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { if ( format->palette == NULL ) { - Uint32 pixv = (r >> format->Rloss) << format->Rshift + Uint32 pixv = (r >> format->Rloss) << format->Rshift | (g >> format->Gloss) << format->Gshift | (b >> format->Bloss) << format->Bshift | ((a >> format->Aloss) << format->Ashift & format->Amask); #ifdef _NEWGAL_SWAP16 - pixv = (pixv & 0xFFFF0000) | ArchSwap16((unsigned short)pixv); + pixv = (pixv & 0xFFFF0000) | ArchSwap16((unsigned short)pixv); #endif - return pixv; + return pixv; } else { if (format->DitheredPalette) return GAL_FindDitheredColor (format->BitsPerPixel, r, g, b); From f4ccf7ee1c20925ea8ead15221c76312afc11818 Mon Sep 17 00:00:00 2001 From: VincentWei Date: Thu, 1 Feb 2018 23:12:42 +0800 Subject: [PATCH 3/7] use HIBYTE_WORD16/LOBYTE_WORD16 to get the bytes from short type values --- src/font/charset.c | 24 ++++++++++++------------ src/gui/keyboard.c | 8 ++++---- src/ial/pcxvfbial.c | 3 ++- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/font/charset.c b/src/font/charset.c index 2893bfd0..56a7ccef 100644 --- a/src/font/charset.c +++ b/src/font/charset.c @@ -3718,8 +3718,8 @@ static int utf16le_conv_from_uc32 (UChar32 wc, unsigned char* mchar) } if (wc < 0x10000) { - mchar [0] = LOBYTE (wc); - mchar [1] = HIBYTE (wc); + mchar [0] = LOBYTE_WORD16 (wc); + mchar [1] = HIBYTE_WORD16 (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 (w1); - mchar [1] = HIBYTE (w1); - mchar [2] = LOBYTE (w2); - mchar [3] = HIBYTE (w2); + mchar [0] = LOBYTE_WORD16 (w1); + mchar [1] = HIBYTE_WORD16 (w1); + mchar [2] = LOBYTE_WORD16 (w2); + mchar [3] = HIBYTE_WORD16 (w2); return 4; } @@ -3944,8 +3944,8 @@ static int utf16be_conv_from_uc32 (UChar32 wc, unsigned char* mchar) } if (wc < 0x10000) { - mchar [1] = LOBYTE (wc); - mchar [0] = HIBYTE (wc); + mchar [1] = LOBYTE_WORD16 (wc); + mchar [0] = HIBYTE_WORD16 (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 (w1); - mchar [0] = HIBYTE (w1); - mchar [3] = LOBYTE (w2); - mchar [2] = HIBYTE (w2); + mchar [1] = LOBYTE_WORD16 (w1); + mchar [0] = HIBYTE_WORD16 (w1); + mchar [3] = LOBYTE_WORD16 (w2); + mchar [2] = HIBYTE_WORD16 (w2); return 4; } diff --git a/src/gui/keyboard.c b/src/gui/keyboard.c index 7ae04a1e..d4e10e14 100644 --- a/src/gui/keyboard.c +++ b/src/gui/keyboard.c @@ -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 (keysym); + kinfo->type = HIBYTE_WORD16 (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(keysym); + kinfo->type = HIBYTE_WORD16 (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<type =HIBYTE(keysym); + kinfo->type = HIBYTE_WORD16 (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 (keysym); + kinfo->type = HIBYTE_WORD16 (keysym); if (kinfo->type >= 0xf0) { kinfo->type -= 0xf0; diff --git a/src/ial/pcxvfbial.c b/src/ial/pcxvfbial.c index 1bcfcdcb..91ce37cb 100644 --- a/src/ial/pcxvfbial.c +++ b/src/ial/pcxvfbial.c @@ -423,7 +423,8 @@ static int keyboard_update (void) } else { scancode = unicode; - //printf ("scancode = %d\n", scancode); + _MG_PRINTF ("IAL>PCXVFB: get a key state change (%s): scancode = %d\n", + press?"pressed":"released", scancode); kbd_state [scancode] = press; if (press) last = scancode; From c6c60b862be9cd695944a3d31005f57a0c5c1bfb Mon Sep 17 00:00:00 2001 From: VincentWei Date: Fri, 2 Feb 2018 11:40:01 +0800 Subject: [PATCH 4/7] use MAKEWORD16 for Str2Key and MSG_CHAR --- configure.ac | 14 +++++++++- include/common.h | 44 ++++++++++++++++++++------------ include/window.h | 3 +++ src/control/textedit.c | 4 +-- src/font/charset.c | 16 ++++++------ src/font/utils/makepytab.c | 2 +- src/gui/keyboard.c | 6 ++--- src/ime/hzinput.c | 2 +- src/newgal/pcxvfb/pcxvfb-winfb.c | 4 +-- src/newgdi/gdi.c | 12 ++++----- src/sysres/resmgr.c | 2 +- src/sysres/resource.c | 1 - 12 files changed, 68 insertions(+), 42 deletions(-) diff --git a/configure.ac b/configure.ac index a7fc75a0..85694c61 100644 --- a/configure.ac +++ b/configure.ac @@ -83,6 +83,7 @@ dnl User selectable options dnl System wide options devel_mode="no" +detail_debug="no" trace_message="no" message_string="no" @@ -285,6 +286,10 @@ AC_ARG_ENABLE(develmode, [ --enable-develmode developer mode ], devel_mode=$enableval) +AC_ARG_ENABLE(detaildebug, +[ --enable-detaildebug detailed debug info ], +detail_debug=$enableval) + AC_ARG_ENABLE(tracemsg, [ --enable-tracemsg trace messages of MiniGUI ], trace_message=$enableval) @@ -1638,6 +1643,9 @@ fi if test "x$devel_mode" = "xyes"; then message_string="yes" + if test "x$detail_debug" = "xyes"; then + trace_message="yes" + fi build_auto_ial_engine="yes" build_random_ial_engine="yes" @@ -2425,7 +2433,11 @@ dnl define _GNU_SOURCE for pthread_rwlock_t CFLAGS="$CFLAGS -D_GNU_SOURCE" if test "x$devel_mode" = "xyes"; then - CPPFLAGS="$CPPFLAGS -DDEBUG -D_DEBUG" + CPPFLAGS="$CPPFLAGS -D_DEBUG" + if test "x$detail_debug" = "xyes"; then + CPPFLAGS="$CPPFLAGS -DDEBUG" + fi + if test "$ac_cv_prog_gcc" = "yes"; then CPPFLAGS="$CPPFLAGS -Wall -Werror" fi diff --git a/include/common.h b/include/common.h index 29833a20..fcd06a9e 100644 --- a/include/common.h +++ b/include/common.h @@ -719,9 +719,17 @@ typedef UINT_PTR LPARAM; */ #define HISWORD(l) ((SWORD)((((DWORD)(l)) >> NR_BITS_WORD) & BITMASK_WORD)) +/** + * \def MAKELONG32(low, high) + * \brief Makes a 32-bit double word from \a low word and \a high word which are both in 16-bit. + * \sa MAKELONG + */ +#define MAKELONG32(low, high) ((DWORD32)(((WORD16)(low)) | (((DWORD32)((WORD16)(high))) << 16))) + /** * \def MAKELONG(low, high) - * \brief Makes a double word from \a low word and \a high word. + * \brief Makes a double word with pointer precision from \a low word and \a high word. + * \sa MAKELONG32 */ #define MAKELONG(low, high) ((DWORD)(((WORD)(low)) | (((DWORD)((WORD)(high))) << NR_BITS_WORD))) @@ -1934,8 +1942,12 @@ int init_minigui_printf (int (*output_char) (int ch), #if defined(__GNUC__) # define _ERR_PRINTF(fmt...) fprintf (stderr, fmt) # ifdef _DEBUG -# define _MG_PRINTF(fmt...) fprintf (stderr, fmt) -# define _DBG_PRINTF(fmt...) fprintf (stdout, fmt) +# define _MG_PRINTF(fmt...) fprintf (stdout, fmt) +# ifdef DEBUG +# define _DBG_PRINTF(fmt...) fprintf (stdout, fmt) +# else +# define _DBG_PRINTF(fmt...) +# endif # else # define _MG_PRINTF(fmt...) # define _DBG_PRINTF(fmt...) @@ -1952,7 +1964,18 @@ static inline void _ERR_PRINTF(const char* fmt, ...) } static inline void _MG_PRINTF(const char* fmt, ...) { -#ifdef _DEBUG +#ifdef DEBUG + va_list ap; + va_start (ap, fmt); + vfprintf (stdout, fmt, ap); + fprintf (stdout, "\n"); + va_end (ap); +#endif +} + +static inline void _DBG_PRINTF(const char* fmt, ...) +{ +#if defined(DEBUG) && defined(_DEBUG) va_list ap; va_start(ap, fmt); vfprintf(stderr, fmt, ap); @@ -1960,18 +1983,7 @@ static inline void _MG_PRINTF(const char* fmt, ...) va_end(ap); #endif } - -static inline void _DBG_PRINTF(const char* fmt, ...) -{ -#ifdef _DEBUG - va_list ap; - va_start(ap, fmt); - vfprintf(stdout, fmt, ap); - fprintf(stdout, "\n"); - va_end(ap); -#endif -} -#endif /* __GNUC__ */ +#endif /* !__GNUC__ */ #ifdef _MGRM_THREADS diff --git a/include/window.h b/include/window.h index 774c14f1..c4f6b2f8 100644 --- a/include/window.h +++ b/include/window.h @@ -427,6 +427,9 @@ extern "C" { * \param ch The ASCII code of the pressed key. * \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. + * * \sa MSG_SYSCHAR, TranslateMessage, key_defs */ #define MSG_CHAR 0x0011 diff --git a/src/control/textedit.c b/src/control/textedit.c index c870ccbe..2a00cc4d 100644 --- a/src/control/textedit.c +++ b/src/control/textedit.c @@ -2004,8 +2004,8 @@ static void teOnChar (HWND hWnd, PTEDATA ptedata, WPARAM wParam) return; } - ch [0] = LOBYTE (wParam); - ch [1] = HIBYTE (wParam); + ch [0] = LOBYTE_WORD16 (wParam); + ch [1] = HIBYTE_WORD16 (wParam); ch [2] = (0x0ff0000 & wParam) >> 16; if (ch[2]) { diff --git a/src/font/charset.c b/src/font/charset.c index 56a7ccef..930f0dc2 100644 --- a/src/font/charset.c +++ b/src/font/charset.c @@ -3525,7 +3525,7 @@ static int utf16le_len_first_char (const unsigned char* mstr, int len) if (len < 2) return 0; - w1 = MAKEWORD (mstr[0], mstr[1]); + w1 = MAKEWORD16 (mstr[0], mstr[1]); if (w1 < 0xD800 || w1 > 0xDFFF) return 2; @@ -3533,7 +3533,7 @@ static int utf16le_len_first_char (const unsigned char* mstr, int len) if (w1 >= 0xD800 && w1 <= 0xDBFF) { if (len < 4) return 0; - w2 = MAKEWORD (mstr[2], mstr[3]); + w2 = MAKEWORD16 (mstr[2], mstr[3]); if (w2 < 0xDC00 || w2 > 0xDFFF) return 0; } @@ -3547,12 +3547,12 @@ static Glyph32 utf16le_char_glyph_value (const unsigned char* pre_mchar, UChar16 w1, w2; UChar32 wc; - w1 = MAKEWORD (cur_mchar[0], cur_mchar[1]); + w1 = MAKEWORD16 (cur_mchar[0], cur_mchar[1]); if (w1 < 0xD800 || w1 > 0xDFFF) return w1; - w2 = MAKEWORD (cur_mchar[2], cur_mchar[3]); + w2 = MAKEWORD16 (cur_mchar[2], cur_mchar[3]); wc = w1; wc <<= 10; @@ -3765,7 +3765,7 @@ static int utf16be_len_first_char (const unsigned char* mstr, int len) if (len < 2) return 0; - w1 = MAKEWORD (mstr[1], mstr[0]); + w1 = MAKEWORD16 (mstr[1], mstr[0]); if (w1 < 0xD800 || w1 > 0xDFFF) return 2; @@ -3773,7 +3773,7 @@ static int utf16be_len_first_char (const unsigned char* mstr, int len) if (w1 >= 0xD800 && w1 <= 0xDBFF) { if (len < 4) return 0; - w2 = MAKEWORD (mstr[3], mstr[2]); + w2 = MAKEWORD16 (mstr[3], mstr[2]); if (w2 < 0xDC00 || w2 > 0xDFFF) return 0; } @@ -3787,12 +3787,12 @@ static Glyph32 utf16be_char_glyph_value (const unsigned char* pre_mchar, UChar16 w1, w2; UChar32 wc; - w1 = MAKEWORD (cur_mchar[1], cur_mchar[0]); + w1 = MAKEWORD16 (cur_mchar[1], cur_mchar[0]); if (w1 < 0xD800 || w1 > 0xDFFF) return w1; - w2 = MAKEWORD (cur_mchar[3], cur_mchar[2]); + w2 = MAKEWORD16 (cur_mchar[3], cur_mchar[2]); wc = w1; wc <<= 10; diff --git a/src/font/utils/makepytab.c b/src/font/utils/makepytab.c index 58334c75..85d240f5 100644 --- a/src/font/utils/makepytab.c +++ b/src/font/utils/makepytab.c @@ -113,7 +113,7 @@ static int set_gbhz_pinyin (unsigned char ch1, unsigned char ch2, unsigned short p = gbhz_py_tab + index; - p->encoding = MAKEWORD (ch2, ch1); + p->encoding = MAKEWORD16 (ch2, ch1); for (i = 0; i < MAX_NR_PINYIN; i++) { if (p->pinyin [i] == 0) { p->pinyin [i] = no_py; diff --git a/src/gui/keyboard.c b/src/gui/keyboard.c index d4e10e14..aeae6014 100644 --- a/src/gui/keyboard.c +++ b/src/gui/keyboard.c @@ -561,7 +561,7 @@ BOOL GUIAPI TranslateMessage (PMSG pMsg) else if (__mg_kinfo.pos == 2 && arabic_compose_flag) { /* SendNotifyMessage (pMsg->hwnd, MSG_CHAR, - MAKEWORD (__mg_kinfo.buff[0], __mg_kinfo.buff[1]), + MAKEWORD16 (__mg_kinfo.buff[0], __mg_kinfo.buff[1]), pMsg->lParam); */ SendNotifyMessage (pMsg->hwnd, MSG_CHAR, __mg_kinfo.buff[0], pMsg->lParam); @@ -571,7 +571,7 @@ BOOL GUIAPI TranslateMessage (PMSG pMsg) else { for (i = 0; i < __mg_kinfo.pos; i++) SendNotifyMessage (pMsg->hwnd, MSG_KEYSYM, - MAKEWORD (__mg_kinfo.buff[i], i), pMsg->lParam); + MAKEWORD16 (__mg_kinfo.buff[i], i), pMsg->lParam); } return FALSE; @@ -612,7 +612,7 @@ BOOL GUIAPI TranslateMessage (PMSG pMsg) else if (kinfo.pos == 2 && arabic_compose_flag) { /* SendNotifyMessage (pMsg->hwnd, MSG_CHAR, - MAKEWORD (__mg_kinfo.buff[0], __mg_kinfo.buff[1]), + MAKEWORD16 (__mg_kinfo.buff[0], __mg_kinfo.buff[1]), pMsg->lParam); */ SendNotifyMessage (pMsg->hwnd, MSG_CHAR, kinfo.buff[0], pMsg->lParam); diff --git a/src/ime/hzinput.c b/src/ime/hzinput.c index 6e7d4a5f..8fd91521 100644 --- a/src/ime/hzinput.c +++ b/src/ime/hzinput.c @@ -1348,7 +1348,7 @@ void __mg_ime_writemsg (BYTE *buffer, int len, LPARAM lParam, BOOL bDByte) if (bDByte) { for (i=0; istep == 1 && !((Uint32)row & 3) && !(w & 3) && (w > 3)) { - Uint16 _w = MAKEWORD (comp_ctxt->cur_pixel, comp_ctxt->cur_pixel); - Uint32 _u = MAKELONG (_w, _w); + Uint16 _w = MAKEWORD16 (comp_ctxt->cur_pixel, comp_ctxt->cur_pixel); + Uint32 _u = MAKELONG32 (_w, _w); ASM_memandset4 (row, _u, w >> 2); return; } @@ -751,8 +751,8 @@ static void _dc_draw_pixel_span_or_1 (COMP_CTXT* comp_ctxt, int w) #ifdef ASM_memorset4 if (comp_ctxt->step == 1 && !((Uint32)row & 3) && !(w & 3) && (w > 3)) { - Uint16 _w = MAKEWORD (comp_ctxt->cur_pixel, comp_ctxt->cur_pixel); - Uint32 _u = MAKELONG (_w, _w); + Uint16 _w = MAKEWORD16 (comp_ctxt->cur_pixel, comp_ctxt->cur_pixel); + Uint32 _u = MAKELONG32 (_w, _w); ASM_memorset4 (row, _u, w >> 2); return; } @@ -826,8 +826,8 @@ static void _dc_draw_pixel_span_xor_1 (COMP_CTXT* comp_ctxt, int w) #ifdef ASM_memxorset4 if (comp_ctxt->step == 1 && !((Uint32)comp_ctxt->cur_dst & 3) && !(w & 3) && (w > 3)) { - Uint16 _w = MAKEWORD (comp_ctxt->cur_pixel, comp_ctxt->cur_pixel); - Uint32 _u = MAKELONG (_w, _w); + Uint16 _w = MAKEWORD16 (comp_ctxt->cur_pixel, comp_ctxt->cur_pixel); + Uint32 _u = MAKELONG32 (_w, _w); ASM_memxorset4 (comp_ctxt->cur_dst, _u, w >> 2); return; } diff --git a/src/sysres/resmgr.c b/src/sysres/resmgr.c index 153927a1..7655052f 100644 --- a/src/sysres/resmgr.c +++ b/src/sysres/resmgr.c @@ -830,7 +830,7 @@ RES_KEY Str2Key (const char* str) l = (strlen(str)+1) / 2; for (i=0; i Date: Fri, 2 Feb 2018 12:07:08 +0800 Subject: [PATCH 5/7] use HIBYTE_WORD16/LOBYTE_WORD16 to extract bytes from wParam of MSG_CHAR --- src/control/bidiedit.c | 6 +++--- src/control/button.c | 6 +++--- src/control/edit.c | 6 +++--- src/control/listbox.c | 4 ++-- src/font/utils/makepytab.c | 2 +- src/gui/dialog.c | 4 ++-- src/textedit/mtextedit.c | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/control/bidiedit.c b/src/control/bidiedit.c index 49168049..64fda4ec 100644 --- a/src/control/bidiedit.c +++ b/src/control/bidiedit.c @@ -2474,14 +2474,14 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if (dwStyle & ES_READONLY) return 0; - charBuffer [0] = LOBYTE (wParam); - charBuffer [1] = HIBYTE (wParam); + charBuffer [0] = LOBYTE_WORD16 (wParam); + charBuffer [1] = HIBYTE_WORD16 (wParam); charBuffer [2] = (0x00ff0000 & wParam) >> 16; if (charBuffer [2]) { chars = 3; } - else if (HIBYTE (wParam)) { + else if (HIBYTE_WORD16 (wParam)) { chars = 2; } else { diff --git a/src/control/button.c b/src/control/button.c index 6ac04144..65744456 100644 --- a/src/control/button.c +++ b/src/control/button.c @@ -816,12 +816,12 @@ static LRESULT ButtonCtrlProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara break; case MSG_CHAR: - if (HIBYTE (wParam)==0 && BUTTON_IS_CHECKBTN (pctrl)) { + if (HIBYTE_WORD16 (wParam)==0 && BUTTON_IS_CHECKBTN (pctrl)) { int old_check = BUTTON_GET_CHECK(pctrl); - if (LOBYTE(wParam) == '+' || LOBYTE(wParam) == '=') + if (LOBYTE_WORD16(wParam) == '+' || LOBYTE_WORD16(wParam) == '=') BUTTON_SET_CHECK(pctrl, BST_CHECKED); - else if (LOBYTE(wParam) == '-') + else if (LOBYTE_WORD16(wParam) == '-') BUTTON_SET_CHECK(pctrl, BST_UNCHECKED); if (old_check != BUTTON_GET_CHECK(pctrl)) diff --git a/src/control/edit.c b/src/control/edit.c index 60310a3d..00487a75 100644 --- a/src/control/edit.c +++ b/src/control/edit.c @@ -2081,14 +2081,14 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if (dwStyle & ES_READONLY) return 0; - charBuffer [0] = LOBYTE (wParam); - charBuffer [1] = HIBYTE (wParam); + charBuffer [0] = LOBYTE_WORD16 (wParam); + charBuffer [1] = HIBYTE_WORD16 (wParam); charBuffer [2] = (0x00ff0000 & wParam) >> 16; if (charBuffer [2]) { chars = 3; } - else if (HIBYTE (wParam)) { + else if (HIBYTE_WORD16 (wParam)) { chars = 2; } else { diff --git a/src/control/listbox.c b/src/control/listbox.c index e8f44d73..da807646 100644 --- a/src/control/listbox.c +++ b/src/control/listbox.c @@ -1885,10 +1885,10 @@ static LRESULT ListboxCtrlProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM l int newTop; PLISTBOXITEM plbi; - if (HIBYTE (wParam)) + if (HIBYTE_WORD16 (wParam)) break; - head [0] = LOBYTE (wParam); + head [0] = LOBYTE_WORD16 (wParam); head [1] = '\0'; pData = (PLISTBOXDATA)pCtrl->dwAddData2; diff --git a/src/font/utils/makepytab.c b/src/font/utils/makepytab.c index 85d240f5..7cb9e6f9 100644 --- a/src/font/utils/makepytab.c +++ b/src/font/utils/makepytab.c @@ -62,7 +62,7 @@ static void output_gbhz_py_tab (void) int j; GBHZ_PINYIN* p = gbhz_py_tab + i; - printf ("\t{0x%04X /* %c%c */, 0, {", p->encoding, HIBYTE (p->encoding), LOBYTE (p->encoding)); + printf ("\t{0x%04X /* %c%c */, 0, {", p->encoding, HIBYTE_WORD16 (p->encoding), LOBYTE_WORD16 (p->encoding)); for (j = 0; j < MAX_NR_PINYIN; j++) { int no_py, tone; if (p->pinyin [j] == 0) diff --git a/src/gui/dialog.c b/src/gui/dialog.c index d5db4d5e..b72931cb 100644 --- a/src/gui/dialog.c +++ b/src/gui/dialog.c @@ -816,9 +816,9 @@ static LRESULT MsgBoxProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam { int id = 0; - if (HIBYTE (wParam)) + if (HIBYTE_WORD16 (wParam)) break; - switch (LOBYTE (wParam)) { + switch (LOBYTE_WORD16 (wParam)) { case 'Y': case 'y': id = IDYES; diff --git a/src/textedit/mtextedit.c b/src/textedit/mtextedit.c index bfac2020..1930fec5 100644 --- a/src/textedit/mtextedit.c +++ b/src/textedit/mtextedit.c @@ -4327,8 +4327,8 @@ static int mTextEditor_onChar(mTextEditor *self, int asciiCode, DWORD keyFlags) return 0; } - ch [0] = LOBYTE (asciiCode); - ch [1] = HIBYTE (asciiCode); + ch [0] = LOBYTE_WORD16 (asciiCode); + ch [1] = HIBYTE_WORD16 (asciiCode); ch [2] = (0x0ff0000 & asciiCode) >> 16; if (ch[2]) { chlen = 3; From e2c2ac07047f95857d3517caec35aa8b31ab6572 Mon Sep 17 00:00:00 2001 From: VincentWei Date: Fri, 2 Feb 2018 12:18:11 +0800 Subject: [PATCH 6/7] tune description of MSG_CHAR --- RELEASE-NOTES.md | 15 ++++++++++++++- include/window.h | 4 ++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 89358396..f2b2c976 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -104,7 +104,7 @@ The main changes in structure and functions: ##### Message -As a result, the strcuture `MSG` and all message-related functions changed. +The strcuture `MSG` and all message-related functions changed. For example, the prototype of `SendMessage` changed from int SendMessage (HWND hWnd, int nMsg, WPARAM wParam, LPARAM lParam) @@ -113,6 +113,19 @@ to LRESULT SendMessage (HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam) +_IMPORTANT NOTE_ + +For best portability, you should use `LOBYTE_WORD16` and `HIBYTE_WORD16` +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); + + ##### Window callback procedure Furthermore, the structure and functions to register window class, diff --git a/include/window.h b/include/window.h index c4f6b2f8..71842bcd 100644 --- a/include/window.h +++ b/include/window.h @@ -420,11 +420,11 @@ extern "C" { * * \code * MSG_CHAR - * int ch = (int)wParam; + * WORD16 ch = (WORD16)wParam; * DWORD key_flags = (DWORD)lParam; * \endcode * - * \param ch The ASCII code of the pressed key. + * \param ch The EUC code of the pressed key. * \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 From 0bec004433ebdd6035d42cba5a8f5744cacad6cd Mon Sep 17 00:00:00 2001 From: VincentWei Date: Fri, 2 Feb 2018 15:05:00 +0800 Subject: [PATCH 7/7] 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 --- RELEASE-NOTES.md | 21 ++++++------ include/common.h | 70 ++++++++++++++++++++++++++++------------ include/window.h | 39 +++++++++++++++++++--- src/control/bidiedit.c | 24 ++++++++------ src/control/button.c | 6 ++-- src/control/edit.c | 26 +++++++++------ src/control/listbox.c | 4 +-- src/control/textedit.c | 18 ++++++++--- src/font/charset.c | 24 +++++++------- src/gui/dialog.c | 4 +-- src/gui/keyboard.c | 26 +++++++-------- src/ial/pcxvfbial.c | 12 +++---- src/include/msgstr.h | 2 +- src/sysres/resmgr.c | 2 +- src/textedit/mtextedit.c | 29 ++++++++++------- 15 files changed, 197 insertions(+), 110 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index f2b2c976..f1b615b2 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -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 diff --git a/include/common.h b/include/common.h index fcd06a9e..5f3e9a4a 100644 --- a/include/common.h +++ b/include/common.h @@ -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 diff --git a/include/window.h b/include/window.h index 71842bcd..c1c63cdd 100644 --- a/include/window.h +++ b/include/window.h @@ -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 diff --git a/src/control/bidiedit.c b/src/control/bidiedit.c index 64fda4ec..b2046475 100644 --- a/src/control/bidiedit.c +++ b/src/control/bidiedit.c @@ -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]); } diff --git a/src/control/button.c b/src/control/button.c index 65744456..6ac04144 100644 --- a/src/control/button.c +++ b/src/control/button.c @@ -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)) diff --git a/src/control/edit.c b/src/control/edit.c index 00487a75..058f3fb9 100644 --- a/src/control/edit.c +++ b/src/control/edit.c @@ -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]); } diff --git a/src/control/listbox.c b/src/control/listbox.c index da807646..e8f44d73 100644 --- a/src/control/listbox.c +++ b/src/control/listbox.c @@ -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; diff --git a/src/control/textedit.c b/src/control/textedit.c index 2a00cc4d..951c970b 100644 --- a/src/control/textedit.c +++ b/src/control/textedit.c @@ -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'; diff --git a/src/font/charset.c b/src/font/charset.c index 930f0dc2..35833938 100644 --- a/src/font/charset.c +++ b/src/font/charset.c @@ -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; } diff --git a/src/gui/dialog.c b/src/gui/dialog.c index b72931cb..d5db4d5e 100644 --- a/src/gui/dialog.c +++ b/src/gui/dialog.c @@ -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; diff --git a/src/gui/keyboard.c b/src/gui/keyboard.c index aeae6014..e4b921d9 100644 --- a/src/gui/keyboard.c +++ b/src/gui/keyboard.c @@ -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<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 { diff --git a/src/ial/pcxvfbial.c b/src/ial/pcxvfbial.c index 91ce37cb..0e6d620b 100644 --- a/src/ial/pcxvfbial.c +++ b/src/ial/pcxvfbial.c @@ -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) diff --git a/src/include/msgstr.h b/src/include/msgstr.h index ff5cbd09..adc3bab6 100644 --- a/src/include/msgstr.h +++ b/src/include/msgstr.h @@ -38,7 +38,7 @@ const char *__mg_msgstr1 [] = "MSG_KEYLONGPRESS ", // 0x0016 "MSG_KEYALWAYSPRESS ", // 0x0017 "MSG_KEYSYM ", // 0x0018 - "", // 0x0019 + "MSG_UTF8CHAR ", // 0x0019 "", // 0x001A "", // 0x001B "", // 0x001C diff --git a/src/sysres/resmgr.c b/src/sysres/resmgr.c index 7655052f..d09680f2 100644 --- a/src/sysres/resmgr.c +++ b/src/sysres/resmgr.c @@ -830,7 +830,7 @@ RES_KEY Str2Key (const char* str) l = (strlen(str)+1) / 2; for (i=0; i> 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;