Revision: 7484 http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7484 Author: zmatsuo Date: 2019-03-15 00:53:55 +0900 (Fri, 15 Mar 2019) Log Message: ----------- GetConvString()#ttime.cの戻り値をconst wchar_t *に変更 前後参照変換の処理を ttime.c に移動 CommTextOutW(), CommTextEchoW() を ttcmn.c に追加 imm32.lib をリンクから外した Modified Paths: -------------- trunk/teraterm/common/ttcommon.h trunk/teraterm/teraterm/CMakeLists.txt trunk/teraterm/teraterm/ttime.c trunk/teraterm/teraterm/ttime.h trunk/teraterm/teraterm/vtwin.cpp trunk/teraterm/ttpcmn/ttcmn.c trunk/teraterm/ttpcmn/ttpcmn.def -------------- next part -------------- Modified: trunk/teraterm/common/ttcommon.h =================================================================== --- trunk/teraterm/common/ttcommon.h 2019-03-14 15:38:24 UTC (rev 7483) +++ trunk/teraterm/common/ttcommon.h 2019-03-14 15:53:55 UTC (rev 7484) @@ -76,8 +76,10 @@ int PASCAL CommBinaryOut(PComVar cv, PCHAR B, int C); int PASCAL CommBinaryBuffOut(PComVar cv, PCHAR B, int C); int PASCAL CommTextOut(PComVar cv, PCHAR B, int C); +int PASCAL CommTextOutW(PComVar cv, const wchar_t *B, int C); int PASCAL CommBinaryEcho(PComVar cv, PCHAR B, int C); int PASCAL CommTextEcho(PComVar cv, PCHAR B, int C); +int PASCAL CommTextEchoW(PComVar cv, const wchar_t *B, int C); void PASCAL CreateNotifyIcon(PComVar cv); void PASCAL DeleteNotifyIcon(PComVar cv); Modified: trunk/teraterm/teraterm/CMakeLists.txt =================================================================== --- trunk/teraterm/teraterm/CMakeLists.txt 2019-03-14 15:38:24 UTC (rev 7483) +++ trunk/teraterm/teraterm/CMakeLists.txt 2019-03-14 15:53:55 UTC (rev 7484) @@ -164,7 +164,6 @@ gdi32 comctl32 ws2_32 - imm32 imagehlp delayimp uuid Modified: trunk/teraterm/teraterm/ttime.c =================================================================== --- trunk/teraterm/teraterm/ttime.c 2019-03-14 15:38:24 UTC (rev 7483) +++ trunk/teraterm/teraterm/ttime.c 2019-03-14 15:53:55 UTC (rev 7484) @@ -1,6 +1,6 @@ /* * Copyright (C) 1994-1998 T. Teranishi - * (C) 2007-2017 TeraTerm Project + * (C) 2007-2019 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,18 +29,25 @@ /* Tera Term */ /* TERATERM.EXE, IME interface */ -#include "teraterm.h" -#include "tttypes.h" +#undef UNICODE +#undef _UNICODE + +#include <windows.h> #include <stdlib.h> #include <string.h> #include <imm.h> +#include "ttime.h" +#include "ttlib.h" + +#if 1 +#include "teraterm.h" +#include "tttypes.h" #include "ttwinman.h" #include "ttcommon.h" +#include "buffer.h" // for BuffGetCurrentLineData() +#endif -#include "ttime.h" -#include "ttlib.h" - #ifndef _IMM_ #define _IMM_ @@ -55,8 +62,8 @@ #define GCS_RESULTSTR 0x0800 -typedef LONG (WINAPI *TImmGetCompositionString) - (HIMC, DWORD, LPVOID, DWORD); +typedef LONG (WINAPI *TImmGetCompositionStringA)(HIMC, DWORD, LPVOID, DWORD); +typedef LONG (WINAPI *TImmGetCompositionStringW)(HIMC, DWORD, LPVOID, DWORD); typedef HIMC (WINAPI *TImmGetContext)(HWND); typedef BOOL (WINAPI *TImmReleaseContext)(HWND, HIMC); typedef BOOL (WINAPI *TImmSetCompositionFont)(HIMC, LPLOGFONTA); @@ -64,7 +71,8 @@ typedef BOOL (WINAPI *TImmGetOpenStatus)(HIMC); typedef BOOL (WINAPI *TImmSetOpenStatus)(HIMC, BOOL); -static TImmGetCompositionString PImmGetCompositionString; +static TImmGetCompositionStringW PImmGetCompositionStringW; +static TImmGetCompositionStringA PImmGetCompositionStringA; static TImmGetContext PImmGetContext; static TImmReleaseContext PImmReleaseContext; static TImmSetCompositionFont PImmSetCompositionFont; @@ -74,8 +82,29 @@ static HANDLE HIMEDLL = NULL; -static LOGFONT lfIME; +static LOGFONTA lfIME; +#if 1 +static void show_message() +{ + char uimsg[MAX_UIMSG]; + get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: Error", ts.UILanguageFile); + get_lang_msg("MSG_USE_IME_ERROR", ts.UIMsg, sizeof(ts.UIMsg), "Can't use IME", ts.UILanguageFile); + MessageBoxA(0,ts.UIMsg,uimsg,MB_ICONEXCLAMATION); + WritePrivateProfileStringA("Tera Term","IME","off",ts.SetupFName); + ts.UseIME = 0; +#if 0 + tempts = (PTTSet)malloc(sizeof(TTTSet)); + if (tempts!=NULL) + { + GetDefaultSet(tempts); + tempts->UseIME = 0; + ChangeDefaultSet(tempts,NULL); + free(tempts); + } +#endif +} +#endif BOOL LoadIME() { @@ -83,38 +112,27 @@ #if 0 PTTSet tempts; #endif - char uimsg[MAX_UIMSG]; char imm32_dll[MAX_PATH]; if (HIMEDLL != NULL) return TRUE; - GetSystemDirectory(imm32_dll, sizeof(imm32_dll)); + GetSystemDirectoryA(imm32_dll, sizeof(imm32_dll)); strncat_s(imm32_dll, sizeof(imm32_dll), "\\imm32.dll", _TRUNCATE); - HIMEDLL = LoadLibrary(imm32_dll); + HIMEDLL = LoadLibraryA(imm32_dll); if (HIMEDLL == NULL) { - get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: Error", ts.UILanguageFile); - get_lang_msg("MSG_USE_IME_ERROR", ts.UIMsg, sizeof(ts.UIMsg), "Can't use IME", ts.UILanguageFile); - MessageBox(0,ts.UIMsg,uimsg,MB_ICONEXCLAMATION); - WritePrivateProfileString("Tera Term","IME","off",ts.SetupFName); - ts.UseIME = 0; -#if 0 - tempts = (PTTSet)malloc(sizeof(TTTSet)); - if (tempts!=NULL) - { - GetDefaultSet(tempts); - tempts->UseIME = 0; - ChangeDefaultSet(tempts,NULL); - free(tempts); - } -#endif + show_message(); return FALSE; } Err = FALSE; - PImmGetCompositionString = (TImmGetCompositionString)GetProcAddress( + PImmGetCompositionStringW = (TImmGetCompositionStringW)GetProcAddress( + HIMEDLL, "ImmGetCompositionStringW"); + if (PImmGetCompositionStringW==NULL) Err = TRUE; + + PImmGetCompositionStringA = (TImmGetCompositionStringA)GetProcAddress( HIMEDLL, "ImmGetCompositionStringA"); - if (PImmGetCompositionString==NULL) Err = TRUE; + if (PImmGetCompositionStringA==NULL) Err = TRUE; PImmGetContext = (TImmGetContext)GetProcAddress( HIMEDLL, "ImmGetContext"); @@ -202,50 +220,53 @@ (*PImmReleaseContext)(HVTWin,hIMC); } -HGLOBAL GetConvString(UINT wParam, LPARAM lParam) +/* + * @param[in,out] *len wchar_t\x95\xB6\x8E\x9A\x90\x94 + * @reterun \x95ϊ\xB7wchar_t\x95\xB6\x8E\x9A\x97\xF1\x82ւ̃|\x83C\x83\x93\x83^ + * NULL\x82̏ꍇ\x95ϊ\xB7\x8Am\x92肵\x82Ă\xA2\x82Ȃ\xA2(\x82܂\xBD\x82̓G\x83\x89\x81[) + * \x95\xB6\x8E\x9A\x97\xF1\x82͎g\x97p\x8C\xE3free()\x82\xB7\x82邱\x82\xC6 + */ +const wchar_t *GetConvString(HWND hWnd, UINT wParam, LPARAM lParam, size_t *len) { - HIMC hIMC; - HGLOBAL hstr = NULL; - //LPSTR lpstr; wchar_t *lpstr; - DWORD dwSize; + *len = 0; if (HIMEDLL==NULL) return NULL; - hIMC = (*PImmGetContext)(HVTWin); - if (hIMC==0) return NULL; - if ((lParam & GCS_RESULTSTR)==0) - goto skip; + if ((lParam & GCS_RESULTSTR) != 0) { + HIMC hIMC; + LONG size; - // Get the size of the result string. - //dwSize = (*PImmGetCompositionString)(hIMC, GCS_RESULTSTR, NULL, 0); - dwSize = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0); - dwSize += sizeof(WCHAR); - hstr = GlobalAlloc(GHND,dwSize); - if (hstr != NULL) - { -// lpstr = (LPSTR)GlobalLock(hstr); - lpstr = GlobalLock(hstr); - if (lpstr != NULL) - { -#if 0 - // Get the result strings that is generated by IME into lpstr. - (*PImmGetCompositionString) - (hIMC, GCS_RESULTSTR, lpstr, dwSize); -#else - ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, lpstr, dwSize); -#endif - GlobalUnlock(hstr); + hIMC = (*PImmGetContext)(hWnd); + if (hIMC==0) return NULL; + + // Get the size of the result string. + // \x92\x8D\x88\xD3 ImmGetCompositionStringW() \x82̖߂\xE8\x92l\x82\xCD byte \x90\x94 + size = PImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0); + if (size <= 0) { + lpstr = NULL; // \x83G\x83\x89\x81[ + } else { + lpstr = malloc(size + sizeof(WCHAR)); + if (lpstr != NULL) + { + size = PImmGetCompositionStringW(hIMC, GCS_RESULTSTR, lpstr, size); + if (size <= 0) { + free(lpstr); + lpstr = NULL; + } else { + *len = size/2; + lpstr[(size/2)] = 0; // \x83^\x81[\x83~\x83l\x81[\x83g\x82\xB7\x82\xE9 + } + } } - else { - GlobalFree(hstr); - hstr = NULL; - } + + (*PImmReleaseContext)(hWnd, hIMC); + + } else { + lpstr = NULL; } -skip: - (*PImmReleaseContext)(HVTWin, hIMC); - return hstr; + return lpstr; } BOOL GetIMEOpenStatus() @@ -270,3 +291,67 @@ (*PImmSetOpenStatus)(hIMC, stat); (*PImmReleaseContext)(HVTWin, hIMC); } + +// IME\x82̑O\x8C\xE3\x8EQ\x8Fƕϊ\xB7\x8B@\x94\\x82ւ̑Ή\x9E +// MS\x82\xA9\x82炿\x82\xE1\x82\xF1\x82Ǝd\x97l\x82\xAA\x92\xB3\x82\xEA\x82Ă\xA2\x82Ȃ\xA2\x82̂ŁA\x83A\x83h\x83z\x83b\x83N\x82ɂ\xE2\x82邵\x82\xA9\x82Ȃ\xA2\x82炵\x82\xA2\x81B +// cf. http://d.hatena.ne.jp/topiyama/20070703 +// http://ice.hotmint.com/putty/#DOWNLOAD +// http://27213143.at.webry.info/201202/article_2.html +// http://webcache.googleusercontent.com/search?q=cache:WzlX3ouMscIJ:anago.2ch.net/test/read.cgi/software/1325573999/82+IMR_DOCUMENTFEED&cd=13&hl=ja&ct=clnk&gl=jp +// (2012.5.9 yutaka) +LRESULT ReplyIMERequestDocumentfeed(LPARAM lParam, int NumOfColumns) +{ + static int complen, newsize; + static char comp[512]; + int size, ret; + char buf[512], newbuf[1024]; + HIMC hIMC; + + // "IME=off"\x82̏ꍇ\x82́A\x89\xBD\x82\xE0\x82\xB5\x82Ȃ\xA2\x81B + size = NumOfColumns + 1; // \x83J\x81[\x83\\x83\x8B\x82\xAA\x82\xA0\x82\xE9\x8Ds\x82̒\xB7\x82\xB3+null + + if (lParam == 0) { // 1\x89\xF1\x96ڂ̌Ăяo\x82\xB5 + // \x83o\x83b\x83t\x83@\x82̃T\x83C\x83Y\x82\xF0\x95Ԃ\xB7\x82̂݁B + // ATOK2012\x82ł͏\xED\x82\xC9 complen=0 \x82ƂȂ\xE9\x81B + complen = 0; + memset(comp, 0, sizeof(comp)); + hIMC = PImmGetContext(HVTWin); + if (hIMC) { + ret = PImmGetCompositionStringA(hIMC, GCS_COMPSTR, comp, sizeof(comp)); + if (ret == IMM_ERROR_NODATA || ret == IMM_ERROR_GENERAL) { + memset(comp, 0, sizeof(comp)); + } + complen = strlen(comp); // w/o null + PImmReleaseContext(HVTWin, hIMC); + } + newsize = size + complen; // \x95ϊ\xB7\x95\xB6\x8E\x9A\x82\xE0\x8A܂߂\xBD\x91S\x91̂̒\xB7\x82\xB3(including null) + + } else { // 2\x89\xF1\x96ڂ̌Ăяo\x82\xB5 + //lParam \x82\xF0 RECONVERTSTRING \x82\xC6 \x95\xB6\x8E\x9A\x97\xF1\x8Ai\x94[\x83o\x83b\x83t\x83@\x82Ɏg\x97p\x82\xB7\x82\xE9 + RECONVERTSTRING *pReconv = (RECONVERTSTRING*)lParam; + char* pszParagraph = (char*)pReconv + sizeof(RECONVERTSTRING); + int cx; + + cx = BuffGetCurrentLineData(buf, sizeof(buf)); + + // \x83J\x81[\x83\\x83\x8B\x88ʒu\x82ɕϊ\xB7\x95\xB6\x8E\x9A\x97\xF1\x82\xF0\x91}\x93\xFC\x82\xB7\x82\xE9\x81B + memset(newbuf, 0, sizeof(newbuf)); + memcpy(newbuf, buf, cx); + memcpy(newbuf + cx, comp, complen); + memcpy(newbuf + cx + complen, buf + cx, size - cx); + newsize = size + complen; // \x95ϊ\xB7\x95\xB6\x8E\x9A\x82\xE0\x8A܂߂\xBD\x91S\x91̂̒\xB7\x82\xB3(including null) + + pReconv->dwSize = sizeof(RECONVERTSTRING); + pReconv->dwVersion = 0; + pReconv->dwStrLen = newsize - 1; + pReconv->dwStrOffset = sizeof(RECONVERTSTRING); + pReconv->dwCompStrLen = complen; + pReconv->dwCompStrOffset = cx; + pReconv->dwTargetStrLen = complen; + pReconv->dwTargetStrOffset = cx; + + memcpy(pszParagraph, newbuf, newsize); + //OutputDebugPrintf("cx %d buf [%d:%s] -> [%d:%s]\n", cx, size, buf, newsize, newbuf); + } + return (sizeof(RECONVERTSTRING) + newsize); +} Modified: trunk/teraterm/teraterm/ttime.h =================================================================== --- trunk/teraterm/teraterm/ttime.h 2019-03-14 15:38:24 UTC (rev 7483) +++ trunk/teraterm/teraterm/ttime.h 2019-03-14 15:53:55 UTC (rev 7484) @@ -1,6 +1,6 @@ /* * Copyright (C) 1994-1998 T. Teranishi - * (C) 2007-2017 TeraTerm Project + * (C) 2007-2019 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -38,11 +38,12 @@ void FreeIME(); BOOL CanUseIME(); void SetConversionWindow(HWND HWin, int X, int Y); -void SetConversionLogFont(HWND HWin, PLOGFONT lf); +void SetConversionLogFont(HWND HWin, PLOGFONTA lf); BOOL GetIMEOpenStatus(void); void SetIMEOpenStatus(BOOL stat); -HGLOBAL GetConvString(UINT wParam, LPARAM lParam); +const wchar_t *GetConvString(HWND hWnd, UINT wParam, LPARAM lParam, size_t *len); +LRESULT ReplyIMERequestDocumentfeed(LPARAM lParam, int NumOfColumns); #ifndef WM_IME_COMPOSITION #define WM_IME_COMPOSITION 0x010F Modified: trunk/teraterm/teraterm/vtwin.cpp =================================================================== --- trunk/teraterm/teraterm/vtwin.cpp 2019-03-14 15:38:24 UTC (rev 7483) +++ trunk/teraterm/teraterm/vtwin.cpp 2019-03-14 15:53:55 UTC (rev 7484) @@ -3218,63 +3218,34 @@ LRESULT CVTWindow::OnIMEComposition(WPARAM wParam, LPARAM lParam) { - HGLOBAL hstr; - //LPSTR lpstr; - wchar_t *lpstr; - int Len; - char *mbstr; - int mlen; - if (CanUseIME()) { - hstr = GetConvString(wParam, lParam); - } - else { - hstr = NULL; - } - - if (hstr!=NULL) { - //lpstr = (LPSTR)GlobalLock(hstr); - lpstr = (wchar_t *)GlobalLock(hstr); - if (lpstr!=NULL) { - mlen = wcstombs(NULL, lpstr, 0); - mbstr = (char *)malloc(sizeof(char) * (mlen + 1)); - if (mbstr == NULL) { - goto skip; - } - Len = wcstombs(mbstr, lpstr, mlen + 1); - - // add this string into text buffer of application - Len = strlen(mbstr); - if (Len==1) { - switch (mbstr[0]) { + size_t len; + const wchar_t *lpstr = GetConvString(HVTWin, wParam, lParam, &len); + if (lpstr != NULL) { + if (len == 1 && ControlKey()) { + const static wchar_t code_ctrl_space = 0; + const static wchar_t code_ctrl_backslash = 0x1c; + switch(*lpstr) { case 0x20: - if (ControlKey()) { - mbstr[0] = 0; /* Ctrl-Space */ - } + lpstr = &code_ctrl_space; break; case 0x5c: // Ctrl-\ support for NEC-PC98 - if (ControlKey()) { - mbstr[0] = 0x1c; - } + lpstr = &code_ctrl_backslash; break; } } if (ts.LocalEcho>0) { - CommTextEcho(&cv,mbstr,Len); + CommTextEchoW(&cv,lpstr,len); } - CommTextOut(&cv,mbstr,Len); - - free(mbstr); - GlobalUnlock(hstr); + CommTextOutW(&cv,lpstr,len); + free((void *)lpstr); + return 0; } -skip: - GlobalFree(hstr); - return 0; } return CFrameWnd::DefWindowProc(WM_IME_COMPOSITION,wParam,lParam); } -LONG CVTWindow::OnIMEInputChange(UINT wParam, LONG lParam) +LRESULT CVTWindow::OnIMEInputChange(WPARAM wParam, LPARAM lParam) { ChangeCaret(); @@ -3281,7 +3252,7 @@ return CFrameWnd::DefWindowProc(WM_INPUTLANGCHANGE,wParam,lParam); } -LONG CVTWindow::OnIMENotify(UINT wParam, LONG lParam) +LRESULT CVTWindow::OnIMENotify(WPARAM wParam, LPARAM lParam) { switch (wParam) { case IMN_SETOPENSTATUS: { @@ -3326,72 +3297,17 @@ return CFrameWnd::DefWindowProc(WM_IME_NOTIFY,wParam,lParam); } -// IME\x82̑O\x8C\xE3\x8EQ\x8Fƕϊ\xB7\x8B@\x94\\x82ւ̑Ή\x9E -// MS\x82\xA9\x82炿\x82\xE1\x82\xF1\x82Ǝd\x97l\x82\xAA\x92\xB3\x82\xEA\x82Ă\xA2\x82Ȃ\xA2\x82̂ŁA\x83A\x83h\x83z\x83b\x83N\x82ɂ\xE2\x82邵\x82\xA9\x82Ȃ\xA2\x82炵\x82\xA2\x81B -// cf. http://d.hatena.ne.jp/topiyama/20070703 -// http://ice.hotmint.com/putty/#DOWNLOAD -// http://27213143.at.webry.info/201202/article_2.html -// http://webcache.googleusercontent.com/search?q=cache:WzlX3ouMscIJ:anago.2ch.net/test/read.cgi/software/1325573999/82+IMR_DOCUMENTFEED&cd=13&hl=ja&ct=clnk&gl=jp -// (2012.5.9 yutaka) -LONG CVTWindow::OnIMERequest(UINT wParam, LONG lParam) +LRESULT CVTWindow::OnIMERequest(WPARAM wParam, LPARAM lParam) { - static int complen, newsize; - static char comp[512]; - int size, ret; - char buf[512], newbuf[1024]; - HIMC hIMC; - // "IME=off"\x82̏ꍇ\x82́A\x89\xBD\x82\xE0\x82\xB5\x82Ȃ\xA2\x81B - if (ts.UseIME > 0 && - wParam == IMR_DOCUMENTFEED) { - size = NumOfColumns + 1; // \x83J\x81[\x83\\x83\x8B\x82\xAA\x82\xA0\x82\xE9\x8Ds\x82̒\xB7\x82\xB3+null - - if (lParam == 0) { // 1\x89\xF1\x96ڂ̌Ăяo\x82\xB5 - // \x83o\x83b\x83t\x83@\x82̃T\x83C\x83Y\x82\xF0\x95Ԃ\xB7\x82̂݁B - // ATOK2012\x82ł͏\xED\x82\xC9 complen=0 \x82ƂȂ\xE9\x81B - complen = 0; - memset(comp, 0, sizeof(comp)); - hIMC = ImmGetContext(HVTWin); - if (hIMC) { - ret = ImmGetCompositionString(hIMC, GCS_COMPSTR, comp, sizeof(comp)); - if (ret == IMM_ERROR_NODATA || ret == IMM_ERROR_GENERAL) { - memset(comp, 0, sizeof(comp)); - } - complen = strlen(comp); // w/o null - ImmReleaseContext(HVTWin, hIMC); - } - newsize = size + complen; // \x95ϊ\xB7\x95\xB6\x8E\x9A\x82\xE0\x8A܂߂\xBD\x91S\x91̂̒\xB7\x82\xB3(including null) - - } else { // 2\x89\xF1\x96ڂ̌Ăяo\x82\xB5 - //lParam \x82\xF0 RECONVERTSTRING \x82\xC6 \x95\xB6\x8E\x9A\x97\xF1\x8Ai\x94[\x83o\x83b\x83t\x83@\x82Ɏg\x97p\x82\xB7\x82\xE9 - RECONVERTSTRING *pReconv = (RECONVERTSTRING*)lParam; - char* pszParagraph = (char*)pReconv + sizeof(RECONVERTSTRING); - int cx; - - cx = BuffGetCurrentLineData(buf, sizeof(buf)); - - // \x83J\x81[\x83\\x83\x8B\x88ʒu\x82ɕϊ\xB7\x95\xB6\x8E\x9A\x97\xF1\x82\xF0\x91}\x93\xFC\x82\xB7\x82\xE9\x81B - memset(newbuf, 0, sizeof(newbuf)); - memcpy(newbuf, buf, cx); - memcpy(newbuf + cx, comp, complen); - memcpy(newbuf + cx + complen, buf + cx, size - cx); - newsize = size + complen; // \x95ϊ\xB7\x95\xB6\x8E\x9A\x82\xE0\x8A܂߂\xBD\x91S\x91̂̒\xB7\x82\xB3(including null) - - pReconv->dwSize = sizeof(RECONVERTSTRING); - pReconv->dwVersion = 0; - pReconv->dwStrLen = newsize - 1; - pReconv->dwStrOffset = sizeof(RECONVERTSTRING); - pReconv->dwCompStrLen = complen; - pReconv->dwCompStrOffset = cx; - pReconv->dwTargetStrLen = complen; - pReconv->dwTargetStrOffset = cx; - - memcpy(pszParagraph, newbuf, newsize); - //OutputDebugPrintf("cx %d buf [%d:%s] -> [%d:%s]\n", cx, size, buf, newsize, newbuf); + if (ts.UseIME > 0) { + switch(wParam) { + case IMR_DOCUMENTFEED: + return ReplyIMERequestDocumentfeed(lParam, NumOfColumns); + default: + break; } - return (sizeof(RECONVERTSTRING) + newsize); } - return CFrameWnd::DefWindowProc(WM_IME_REQUEST,wParam,lParam); } Modified: trunk/teraterm/ttpcmn/ttcmn.c =================================================================== --- trunk/teraterm/ttpcmn/ttcmn.c 2019-03-14 15:38:24 UTC (rev 7483) +++ trunk/teraterm/ttpcmn/ttcmn.c 2019-03-14 15:53:55 UTC (rev 7484) @@ -48,6 +48,7 @@ #include "compat_w95.h" #include "tt_res.h" +#include "ttcommon.h" #include "codeconv.h" // TMap \x82\xF0\x8Ai\x94[\x82\xB7\x82\xE9\x83t\x83@\x83C\x83\x8B\x83}\x83b\x83s\x83\x93\x83O\x83I\x83u\x83W\x83F\x83N\x83g(\x8B\xA4\x97L\x83\x81\x83\x82\x83\x8A)\x82̖\xBC\x91O @@ -1918,6 +1919,38 @@ return i; } +// TODO: UTF-16\x82\xA9\x82璼\x90ڕϊ\xB7\x82\xB5\x82ďo\x97͂\xB7\x82\xE9 +int WINAPI CommTextOutW(PComVar cv, const wchar_t *B, int C) +{ + int CodePage = *cv->CodePage; + size_t mb_len; + int r; + char *mb_str = _WideCharToMultiByte(B, C, CodePage, &mb_len); + if (mb_str == NULL) { + r = 0; + } else { + r = CommTextOut(cv, mb_str, mb_len); + free(mb_str); + } + return r; +} + +// TODO: UTF-16\x82\xA9\x82璼\x90ڕϊ\xB7\x82\xB5\x82ďo\x97͂\xB7\x82\xE9 +int WINAPI CommTextEchoW(PComVar cv, const wchar_t *B, int C) +{ + int CodePage = *cv->CodePage; + size_t mb_len; + int r; + char *mb_str = _WideCharToMultiByte(B, C, CodePage, &mb_len); + if (mb_str == NULL) { + r = 0; + } else { + r = CommTextEcho(cv, mb_str, mb_len); + free(mb_str); + } + return r; +} + int WINAPI CommBinaryEcho(PComVar cv, PCHAR B, int C) { int a, i, Len; Modified: trunk/teraterm/ttpcmn/ttpcmn.def =================================================================== --- trunk/teraterm/ttpcmn/ttpcmn.def 2019-03-14 15:38:24 UTC (rev 7483) +++ trunk/teraterm/ttpcmn/ttpcmn.def 2019-03-14 15:53:55 UTC (rev 7484) @@ -23,8 +23,10 @@ CommBinaryOut @24 CommBinaryBuffOut @52 CommTextOut @25 + CommTextOutW CommBinaryEcho @26 CommTextEcho @27 + CommTextEchoW DetectComPorts @42 GetDefaultFName @47 ExtractFileName @48