[Ttssh2-commit] [8342] クリップボードの送信、ファイルの送信を1箇所にまとめた

scmno****@osdn***** scmno****@osdn*****
2019年 10月 29日 (火) 22:04:33 JST


Revision: 8342
          https://osdn.net/projects/ttssh2/scm/svn/commits/8342
Author:   zmatsuo
Date:     2019-10-29 22:04:33 +0900 (Tue, 29 Oct 2019)
Log Message:
-----------
クリップボードの送信、ファイルの送信を1箇所にまとめた

- メモリ内のデータ(text,binary)を送信する sendmem.cpp,h を追加
  - talkerに IdTalkSendMem を追加
- 送信状態を表示する ftdlg_lite.cpp,h を追加
  - sendmem用、ftdlg.cpp,h と同じ外観
- cmakeビルドでデバグ情報を出力できるようにした
  - ttermpro.exe限定
- クリップボードからの送信を sendmem 経由で行うようにした
- クリップボードのペースト確認ダイアログを dlipboarddlg.cpp,h に分離

Modified Paths:
--------------
    branches/unicode_buf/CMakeLists.txt
    branches/unicode_buf/libs/lib_SFMT.cmake
    branches/unicode_buf/libs/lib_oniguruma.cmake
    branches/unicode_buf/teraterm/common/tttypes.h
    branches/unicode_buf/teraterm/teraterm/CMakeLists.txt
    branches/unicode_buf/teraterm/teraterm/addsetting.cpp
    branches/unicode_buf/teraterm/teraterm/clipboar.c
    branches/unicode_buf/teraterm/teraterm/clipboar.h
    branches/unicode_buf/teraterm/teraterm/ftdlg.h
    branches/unicode_buf/teraterm/teraterm/teraterm.cpp
    branches/unicode_buf/teraterm/teraterm/ttwinman.c
    branches/unicode_buf/teraterm/teraterm/ttwinman.h
    branches/unicode_buf/teraterm/teraterm/vtterm.c
    branches/unicode_buf/teraterm/teraterm/vtwin.cpp
    branches/unicode_buf/teraterm/ttptek/CMakeLists.txt

Added Paths:
-----------
    branches/unicode_buf/teraterm/teraterm/clipboarddlg.cpp
    branches/unicode_buf/teraterm/teraterm/clipboarddlg.h
    branches/unicode_buf/teraterm/teraterm/ftdlg_lite.cpp
    branches/unicode_buf/teraterm/teraterm/ftdlg_lite.h
    branches/unicode_buf/teraterm/teraterm/sendmem.cpp
    branches/unicode_buf/teraterm/teraterm/sendmem.h

-------------- next part --------------
Modified: branches/unicode_buf/CMakeLists.txt
===================================================================
--- branches/unicode_buf/CMakeLists.txt	2019-10-29 13:04:14 UTC (rev 8341)
+++ branches/unicode_buf/CMakeLists.txt	2019-10-29 13:04:33 UTC (rev 8342)
@@ -63,8 +63,10 @@
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static-libstdc++")
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
   endif()
-  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -s -Wl,--gc-sections")
-  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -s -Wl,--gc-sections")
+  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc")
+  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc")
+  set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -s -Wl,--gc-sections")
+  set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -s -Wl,--gc-sections")
 endif()
 
 ### create version_info.h

Modified: branches/unicode_buf/libs/lib_SFMT.cmake
===================================================================
--- branches/unicode_buf/libs/lib_SFMT.cmake	2019-10-29 13:04:14 UTC (rev 8341)
+++ branches/unicode_buf/libs/lib_SFMT.cmake	2019-10-29 13:04:33 UTC (rev 8342)
@@ -6,10 +6,12 @@
   set(SFMT_ROOT "${SFMT_ROOT}_x64")
 endif()
 
-set(SFMT_INCLUDE_DIRS
-  "${SFMT_ROOT}/include"
-  )
+set(SFMT_INCLUDE_DIRS "${SFMT_ROOT}/include")
+set(SFMT_LIBRARY_DIRS "${SFMT_ROOT}/lib")
 
-set(SFMT_LIBRARY_DIRS
-  "${SFMT_ROOT}/lib"
-  )
+if(MINGW)
+  set(SFMT_LIB ${SFMT_LIBRARY_DIRS}/libsfmt.a)
+else()
+  set(SFMT_LIB ${SFMT_LIBRARY_DIRS}/sfmt.lib)
+#  set(SFMT_LIB ${SFMT_LIBRARY_DIRS}/sfmtd.lib)
+endif()

Modified: branches/unicode_buf/libs/lib_oniguruma.cmake
===================================================================
--- branches/unicode_buf/libs/lib_oniguruma.cmake	2019-10-29 13:04:14 UTC (rev 8341)
+++ branches/unicode_buf/libs/lib_oniguruma.cmake	2019-10-29 13:04:33 UTC (rev 8342)
@@ -11,3 +11,9 @@
 set(ONIGURUMA_INCLUDE_DIRS ${ONIGURUMA_ROOT}/include)
 set(ONIGURUMA_LIBRARY_DIRS ${ONIGURUMA_ROOT}/lib)
 
+if(MINGW)
+  set(ONIGURUMA_LIB ${ONIGURUMA_LIBRARY_DIRS}/libonig.a)
+else()
+  set(ONIGURUMA_LIB ${ONIGURUMA_LIBRARY_DIRS}/onig.lib)
+#  set(ONIGURUMA_LIB ${ONIGURUMA_LIBRARY_DIRS}/onigd.lib)
+endif()

Modified: branches/unicode_buf/teraterm/common/tttypes.h
===================================================================
--- branches/unicode_buf/teraterm/common/tttypes.h	2019-10-29 13:04:14 UTC (rev 8341)
+++ branches/unicode_buf/teraterm/common/tttypes.h	2019-10-29 13:04:33 UTC (rev 8342)
@@ -52,10 +52,15 @@
 #define IdTEK 2
 
   /* Talker mode */
-#define IdTalkKeyb  0
-#define IdTalkCB    1
-#define IdTalkFile  2
-#define IdTalkQuiet 3
+typedef enum {
+	IdTalkKeyb = 0,
+	IdTalkCB = 1,
+	IdTalkFile = 2,
+	IdTalkQuiet = 3,
+#if UNICODE_INTERNAL_BUFF
+	IdTalkSendMem,
+#endif
+} IdTalk;
 
   /* Character sets */
 #define IdASCII    0

Modified: branches/unicode_buf/teraterm/teraterm/CMakeLists.txt
===================================================================
--- branches/unicode_buf/teraterm/teraterm/CMakeLists.txt	2019-10-29 13:04:14 UTC (rev 8341)
+++ branches/unicode_buf/teraterm/teraterm/CMakeLists.txt	2019-10-29 13:04:33 UTC (rev 8342)
@@ -3,6 +3,7 @@
 include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_SFMT.cmake)
 include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_oniguruma.cmake)
 
+set(ENABLE_DEBUG_INFO 1)
 if(USE_UNICODE_API)
   add_definitions(-DUNICODE -D_UNICODE)
 endif()
@@ -9,66 +10,8 @@
 
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/")
 
-set(COMMON_SRC
-  ../common/tt_res.h
-  ../common/ttcommon.h
-  ../common/ttddecmnd.h
-  ../common/tttypes.h
-  ../common/tektypes.h
-  ../common/ttftypes.h
-  ../common/ttplugin.h
-  ../common/tt-version.h
-  ../common/teraterm.h
-  ../common/ttlib.c
-  ../common/ttlib.h
-  ../common/dlglib.h
-  ../common/dlglib.c
-  ../common/dlglib_cpp.cpp
-  ../common/dlglib_tmpl.cpp
-  ../common/win16api.h
-  ../common/win16api.c
-  ../common/codemap.h
-  ../common/compat_w95.h
-  ../common/compat_win.h
-  ../common/compat_win.cpp
-  ../common/tmfc.cpp
-  ../common/tmfc.h
-  ../common/tmfc_frame.cpp
-  ../common/i18n.h
-  ../common/dllutil.cpp
-  ../common/dllutil.h
-  ../common/codeconv.h
-  ../common/codeconv.cpp
-  ../common/tipwin.h
-  ../common/tipwin.cpp
-  ../common/layer_for_unicode.h
-  ../common/layer_for_unicode.cpp
-  #
-  ../teraterm/unisym2decsp.map
-  ../teraterm/uni2sjis.map
-  ../ttpcmn/sjis2uni.map
-  )
-
-source_group(
-  "common"
-  FILES
-  ${COMMON_SRC}
-  )
-
-set(TTDLG_SRC
-  ../ttpdlg/dlg_res.h
-  ../ttpdlg/ttdlg.c
-  ../ttpdlg/ttdlg.h
-  ../ttpdlg/ttpdlg.rc
-  )
-
-source_group(
-  "ttdlg"
-  FILES
-  ${TTDLG_SRC}
-  )
-
-set(SRC
+add_executable(
+  teraterm WIN32
   addsetting.cpp
   addsetting.h
   buffer.c
@@ -129,6 +72,8 @@
   winjump.h
   WSAAsyncGetAddrInfo.c
   WSAAsyncGetAddrInfo.h
+  sendmem.cpp
+  sendmem.h
   #
   uni_combining.map
   #
@@ -137,9 +82,6 @@
   svnversion.h.in
   ${CMAKE_CURRENT_BINARY_DIR}/../ttpdlg/svnversion.h
   #
-  ${COMMON_SRC}
-  ${TTDLG_SRC}
-  #
   unicode_test.h
   unicode.h
   unicode.cpp
@@ -149,16 +91,81 @@
   #
   ../ttpmacro/fileread.h
   ../ttpmacro/fileread.cpp
+  ftdlg_lite.h
+  ftdlg_lite.cpp
+  clipboarddlg.h
+  clipboarddlg.cpp
   )
 
-link_directories(
-  ${ONIGURUMA_LIBRARY_DIRS}
-  ${SFMT_LIBRARY_DIRS}
+target_sources(
+  teraterm
+  PRIVATE
+  ../common/tt_res.h
+  ../common/ttcommon.h
+  ../common/ttddecmnd.h
+  ../common/tttypes.h
+  ../common/tektypes.h
+  ../common/ttftypes.h
+  ../common/ttplugin.h
+  ../common/tt-version.h
+  ../common/teraterm.h
+  ../common/ttlib.c
+  ../common/ttlib.h
+  ../common/dlglib.h
+  ../common/dlglib.c
+  ../common/dlglib_cpp.cpp
+  ../common/dlglib_tmpl.cpp
+  ../common/win16api.h
+  ../common/win16api.c
+  ../common/codemap.h
+  ../common/compat_w95.h
+  ../common/compat_win.h
+  ../common/compat_win.cpp
+  ../common/tmfc.cpp
+  ../common/tmfc.h
+  ../common/tmfc_frame.cpp
+  ../common/i18n.h
+  ../common/dllutil.cpp
+  ../common/dllutil.h
+  ../common/codeconv.h
+  ../common/codeconv.cpp
+  ../common/tipwin.h
+  ../common/tipwin.cpp
+  ../common/layer_for_unicode.h
+  ../common/layer_for_unicode.cpp
+  #
+  ../teraterm/unisym2decsp.map
+  ../teraterm/uni2sjis.map
+  ../ttpcmn/sjis2uni.map
   )
 
+source_group(
+  "table_datas"
+  REGULAR_EXPRESSION
+  "(map|tbl)$"
+  )
+
+source_group(
+  "common"
+  REGULAR_EXPRESSION
+  "..\/common\/"
+  )
+
+target_sources(
+  teraterm
+  PRIVATE
+  ../ttpdlg/dlg_res.h
+  ../ttpdlg/ttdlg.c
+  ../ttpdlg/ttdlg.h
+  ../ttpdlg/ttpdlg.rc
+  )
+
+source_group(
+  "ttpdlg"
+  REGULAR_EXPRESSION
+  "..\/ttpdlg\/")
+
 if (MSVC)
-  set_source_files_properties(buffer.c PROPERTIES COMPILE_FLAGS /W4)
-
   set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:user32.dll /DELAYLOAD:shell32.dll")
   if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
     # 32bit
@@ -166,11 +173,6 @@
   endif()
 endif()
 
-add_executable(
-  teraterm WIN32
-  ${SRC}
-  )
-
 set_target_properties(
   teraterm
   PROPERTIES
@@ -197,6 +199,23 @@
     )
 endif()
 
+if(MSVC AND ENABLE_DEBUG_INFO)
+  target_compile_options(
+	teraterm
+	PRIVATE
+    $<$<CONFIG:Release>:/Zi>
+    )
+  if(${CMAKE_VERSION} VERSION_GREATER "3.13")
+	target_link_options(
+	  teraterm
+	  PRIVATE
+	  /DEBUG:FULL
+	  /pdbaltpath:ttermpro.pdb
+	  /map
+	  )
+  endif()
+endif()
+
 target_link_libraries(
   teraterm
   ttpcmn
@@ -203,8 +222,10 @@
   ttpfile
   ttpset
   ttptek
-  optimized onig.lib
-  debug onigd.lib
+  optimized ${ONIGURUMA_LIB}
+  debug ${ONIGURUMA_LIB}
+  optimized ${SFMT_LIB}
+  debug ${SFMT_LIB}
   #
   gdi32
   comctl32
@@ -231,3 +252,12 @@
   TARGETS teraterm
   DESTINATION .
   )
+if(MSVC AND ENABLE_DEBUG_INFO)
+  install(
+    FILES
+    $<TARGET_PDB_FILE:teraterm>
+    $<$<CONFIG:Debug>:debug/ttermpro.map>
+    $<$<CONFIG:Release>:release/ttermpro.map>
+    DESTINATION .
+    )
+endif()

Modified: branches/unicode_buf/teraterm/teraterm/addsetting.cpp
===================================================================
--- branches/unicode_buf/teraterm/teraterm/addsetting.cpp	2019-10-29 13:04:14 UTC (rev 8341)
+++ branches/unicode_buf/teraterm/teraterm/addsetting.cpp	2019-10-29 13:04:33 UTC (rev 8342)
@@ -37,6 +37,7 @@
 #include <commctrl.h>
 #include <time.h>
 #include <tchar.h>
+#define _CRTDBG_MAP_ALLOC
 #include <crtdbg.h>
 
 #include "teraterm.h"
@@ -51,18 +52,6 @@
 
 #include "tipwin.h"
 
-#ifdef _DEBUG
-#define free(p)		_free_dbg((p), _NORMAL_BLOCK)
-#define _strdup(s)	_strdup_dbg((s), _NORMAL_BLOCK, __FILE__, __LINE__)
-#define _wcsdup(s)	_wcsdup_dbg((s), _NORMAL_BLOCK, __FILE__, __LINE__)
-#undef _tcsdup
-#ifdef _UNICODE
-#define _tcsdup(s)	_wcsdup_dbg((s), _NORMAL_BLOCK, __FILE__, __LINE__)
-#else
-#define _tcsdup(s)	_strdup_dbg((s), _NORMAL_BLOCK, __FILE__, __LINE__)
-#endif
-#endif
-
 const mouse_cursor_t MouseCursor[] = {
 	{"ARROW", IDC_ARROW},
 	{"IBEAM", IDC_IBEAM},

Modified: branches/unicode_buf/teraterm/teraterm/clipboar.c
===================================================================
--- branches/unicode_buf/teraterm/teraterm/clipboar.c	2019-10-29 13:04:14 UTC (rev 8341)
+++ branches/unicode_buf/teraterm/teraterm/clipboar.c	2019-10-29 13:04:33 UTC (rev 8342)
@@ -36,6 +36,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <commctrl.h>
+#define _CRTDBG_MAP_ALLOC
 #include <crtdbg.h>
 #include <wchar.h>
 
@@ -49,6 +50,8 @@
 #include "tt_res.h"
 #include "../ttpmacro/fileread.h"
 #include "unicode_test.h"
+#include "sendmem.h"
+#include "clipboarddlg.h"
 
 // for clipboard copy
 static HGLOBAL CBCopyHandle = NULL;
@@ -67,25 +70,14 @@
 static BOOL CBEchoOnly;
 static BOOL CBInsertDelay = FALSE;
 
-wchar_t BracketStartW[] = L"\033[200~";
-wchar_t BracketEndW[] = L"\033[201~";
-size_t BracketStartLenW = ((sizeof(BracketStartW) / sizeof(wchar_t)) - 1);
-size_t BracketEndLenW = ((sizeof(BracketEndW) / sizeof(wchar_t)) - 1);
+static const wchar_t BracketStartW[] = L"\033[200~";
+static const wchar_t BracketEndW[] = L"\033[201~";
 
-#if UNICODE_INTERNAL_BUFF
-typedef struct {
-	wchar_t *send_str;
-	size_t str_len;
-	size_t send_left;
-	size_t send_index;
-	BOOL waited;
-	DWORD send_cr_tick;
-} clipboard_work_t;
-static clipboard_work_t cbwork;
+static void CBEcho(void);
+#if !UNICODE_INTERNAL_BUFF
+static INT_PTR CALLBACK OnClipboardDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp);
 #endif
 
-static INT_PTR CALLBACK OnClipboardDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp);
-
 #if !UNICODE_INTERNAL_BUFF
 PCHAR CBOpen(LONG MemSize)
 {
@@ -152,6 +144,12 @@
 }
 #endif
 
+/**
+ * \x95\xB6\x8E\x9A\x97񑗐M
+ * \x8E\x9F\x82̂Ƃ\xB1\x82납\x82\xE7\x8Eg\x97p\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9
+ *  - DDE(TTL)
+ *	- \x83u\x83\x8D\x81[\x83h\x83L\x83\x83\x83X\x83g
+ */
 void CBStartSend(PCHAR DataPtr, int DataSize, BOOL EchoOnly)
 {
 	if (! cv.Ready) {
@@ -186,12 +184,12 @@
 			TalkStatus=IdTalkCB;
 		}
 	}
-
 	if (TalkStatus != IdTalkCB) {
 		CBEndPaste();
 	}
 }
 
+#if !UNICODE_INTERNAL_BUFF
 // \x83N\x83\x8A\x83b\x83v\x83{\x81[\x83h\x83o\x83b\x83t\x83@\x82̖\x96\x94\xF6\x82ɂ\xA0\x82\xE9 CR / LF \x82\xF0\x82\xB7\x82ׂč폜\x82\xB7\x82\xE9
 static BOOL TrimTrailingNL(BOOL AddCR, BOOL Bracketed)
 {
@@ -207,6 +205,7 @@
 
 	return TRUE;
 }
+#endif
 
 static void TrimTrailingNLW(wchar_t *src)
 {
@@ -316,7 +315,6 @@
 	wchar_t *dest_top;
 	wchar_t *dest;
 	size_t len, need_len, alloc_len;
-	const size_t src_len = wcslen(src_);
 
 	// \x93\\x82\xE8\x95t\x82\xAF\x83f\x81[\x83^\x82̒\xB7\x82\xB3(len)\x81A\x82\xA8\x82\xE6\x82ѐ\xB3\x8BK\x89\xBB\x8C\xE3\x82̃f\x81[\x83^\x82̒\xB7\x82\xB3(need_len)\x82̃J\x83E\x83\x93\x83g
 	for (len=0, need_len=0, src=src_; *src != '\0'; src++, len++, need_len++) {
@@ -334,7 +332,7 @@
 
 	// \x90\xB3\x8BK\x89\xBB\x8C\xE3\x82\xE0\x83f\x81[\x83^\x92\xB7\x82\xAA\x95ς\xED\x82\xE7\x82Ȃ\xA2 => \x90\xB3\x8BK\x89\xBB\x82͕K\x97v\x82Ȃ\xB5
 	if (need_len == len) {
-		wchar_t *dest = _wcsdup(src_);
+		dest = _wcsdup(src_);
 		return dest;
 	}
 	alloc_len = need_len + 1;
@@ -381,7 +379,7 @@
 	BOOL ret = FALSE;
 	FILE *fp = NULL;
 	char buf[256];
-	int len;
+	size_t len;
 
 	if (filename == NULL || filename[0] == '\0')
 		return FALSE;
@@ -468,10 +466,10 @@
  *   TRUE  -> \x96\xE2\x91\xE8\x82Ȃ\xB5\x81A\x93\\x82\xE8\x95t\x82\xAF\x82\xF0\x8E\xC0\x8E{
  *   FALSE -> \x93\\x82\xE8\x95t\x82\xAF\x92\x86\x8E~
  */
-BOOL CheckClipboardContent(HWND HWin, BOOL AddCR, BOOL Bracketed)
+#if !UNICODE_INTERNAL_BUFF
+static BOOL CheckClipboardContent(HWND HWin, BOOL AddCR, BOOL Bracketed)
 {
-	int pos;
-	int ret = IDOK;
+	INT_PTR ret = IDOK;
 	BOOL confirm = FALSE;
 
 	if ((ts.PasteFlag & CPF_CONFIRM_CHANGEPASTE) == 0) {
@@ -499,7 +497,7 @@
 		}
 	}
 	else {
-		pos = strcspn(CBMemPtr, "\r\n");  // \x89\xFC\x8Ds\x82\xAA\x8A܂܂\xEA\x82Ă\xA2\x82\xBD\x82\xE7
+		size_t pos = strcspn(CBMemPtr, "\r\n");  // \x89\xFC\x8Ds\x82\xAA\x8A܂܂\xEA\x82Ă\xA2\x82\xBD\x82\xE7
 		if (CBMemPtr[pos] != '\0') {
 			confirm = TRUE;
 		}
@@ -512,7 +510,7 @@
 
 	if (confirm) {
 		ret = TTDialogBox(hInst, MAKEINTRESOURCE(IDD_CLIPBOARD_DIALOG),
-						  HWin, (DLGPROC)OnClipboardDlgProc);
+						  HWin, OnClipboardDlgProc);
 		/*
 		 * \x88ȑO\x82̓_\x83C\x83A\x83\x8D\x83O\x82̓\xE0\x97e\x82\xF0\x83N\x83\x8A\x83b\x83v\x83{\x81[\x83h\x82ɏ\x91\x82\xAB\x96߂\xB5\x82Ă\xA2\x82\xBD\x82\xAF\x82\xEA\x82ǁA\x95K\x97v?
 		 */
@@ -525,6 +523,7 @@
 		return FALSE;
 	}
 }
+#endif
 
 /*
  * \x83N\x83\x8A\x83b\x83v\x83{\x81[\x83h\x82̓\xE0\x97e\x82\xF0\x8Am\x94F\x82\xB5\x81A\x93\\x82\xE8\x95t\x82\xAF\x82\xF0\x8Ds\x82\xA4\x82\xA9\x8Am\x94F\x83_\x83C\x83A\x83\x8D\x83O\x82\xF0\x8Fo\x82\xB7\x81B
@@ -533,11 +532,12 @@
  *   TRUE  -> \x96\xE2\x91\xE8\x82Ȃ\xB5\x81A\x93\\x82\xE8\x95t\x82\xAF\x82\xF0\x8E\xC0\x8E{
  *   FALSE -> \x93\\x82\xE8\x95t\x82\xAF\x92\x86\x8E~
  */
-static BOOL CheckClipboardContentW(HWND HWin, const wchar_t *str_w, BOOL AddCR, BOOL Bracketed)
+static BOOL CheckClipboardContentW(HWND HWin, const wchar_t *str_w, BOOL AddCR, wchar_t **out_str_w)
 {
-	int ret = IDOK;
+	INT_PTR ret;
 	BOOL confirm = FALSE;
 
+	*out_str_w = NULL;
 	if ((ts.PasteFlag & CPF_CONFIRM_CHANGEPASTE) == 0) {
 		return TRUE;
 	}
@@ -559,12 +559,13 @@
 		confirm = TRUE;
 	}
 
+	ret = IDOK;
 	if (confirm) {
-		ret = TTDialogBox(hInst, MAKEINTRESOURCE(IDD_CLIPBOARD_DIALOG),
-						  HWin, (DLGPROC)OnClipboardDlgProc);
-		/*
-		 * \x88ȑO\x82̓_\x83C\x83A\x83\x8D\x83O\x82̓\xE0\x97e\x82\xF0\x83N\x83\x8A\x83b\x83v\x83{\x81[\x83h\x82ɏ\x91\x82\xAB\x96߂\xB5\x82Ă\xA2\x82\xBD\x82\xAF\x82\xEA\x82ǁA\x95K\x97v?
-		 */
+		clipboarddlgdata dlg_data;
+		dlg_data.strW_ptr = str_w;
+		dlg_data.UILanguageFile = ts.UILanguageFile;
+		ret = clipboarddlg(hInst, HWin, &dlg_data);
+		*out_str_w = dlg_data.strW_edited_ptr;
 	}
 
 	if (ret == IDOK) {
@@ -575,6 +576,7 @@
 	}
 }
 
+#if !UNICODE_INTERNAL_BUFF
 void CBStartPaste(HWND HWin, BOOL AddCR, BOOL Bracketed)
 {
 	UINT Cf;
@@ -581,7 +583,7 @@
 	PCHAR TmpPtr;
 	LPWSTR TmpPtrW;
 	HGLOBAL TmpHandle;
-	unsigned int StrLen = 0, BuffLen = 0;
+	size_t StrLen = 0, BuffLen = 0;
 
 	if (! cv.Ready) {
 		return;
@@ -645,7 +647,7 @@
 			if ((CBMemHandle = GlobalAlloc(GHND, BuffLen)) != NULL) {
 				if ((CBMemPtr = GlobalLock(CBMemHandle)) != NULL) {
 					if (Cf == CF_UNICODETEXT) {
-						WideCharToMultiByte(CP_ACP, 0, TmpPtrW, -1, CBMemPtr, BuffLen, NULL, NULL);
+						WideCharToMultiByte(CP_ACP, 0, TmpPtrW, -1, CBMemPtr, (int)BuffLen, NULL, NULL);
 					}
 					else {
 						strncpy_s(CBMemPtr, BuffLen, TmpPtr, _TRUNCATE);
@@ -724,6 +726,7 @@
 	GlobalUnlock(CBMemHandle);
 	CBMemPtr = NULL;
 }
+#endif
 
 /**
  *	\x83N\x83\x8A\x83b\x83v\x83{\x81[\x83h\x82\xA9\x82\xE7wchar_t\x95\xB6\x8E\x9A\x97\xF1\x82\xF0\x8E擾\x82\xB7\x82\xE9
@@ -768,8 +771,10 @@
 			size_t str_cb_len = GlobalSize(TmpHandle);	// bytes
 			str_w_len = str_cb_len / sizeof(wchar_t);
 			str_w = malloc((str_w_len + 1) * sizeof(wchar_t));	// +1 for terminator
-			memcpy(str_w, str_cb, str_cb_len);
-			str_w[str_w_len] = L'\0';
+			if (str_w != NULL) {
+				memcpy(str_w, str_cb, str_cb_len);
+				str_w[str_w_len] = L'\0';
+			}
 		}
 	}
 	else {
@@ -776,10 +781,12 @@
 		const char *str_cb = (char *)GlobalLock(TmpHandle);
 		if (str_cb != NULL) {
 			size_t str_cb_len = GlobalSize(TmpHandle);
-			str_w_len = MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, str_cb, str_cb_len, NULL, 0);
+			str_w_len = MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, str_cb, (int)str_cb_len, NULL, 0);
 			str_w = malloc(sizeof(wchar_t) * (str_w_len + 1));	// +1 for terminator
-			str_w_len = MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, str_cb, str_cb_len, str_w, str_w_len);
-			str_w[str_w_len] = L'\0';
+			if (str_w != NULL) {
+				str_w_len = MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, str_cb, (int)str_cb_len, str_w, (int)str_w_len);
+				str_w[str_w_len] = L'\0';
+			}
 		}
 	}
 	GlobalUnlock(TmpHandle);
@@ -791,11 +798,40 @@
 }
 
 #if UNICODE_INTERNAL_BUFF
-void CBStartPasteW(HWND HWin, BOOL AddCR, BOOL Bracketed)
+/**
+ *	\x83N\x83\x8A\x83b\x83v\x83{\x81[\x83h\x97p\x83e\x83L\x83X\x83g\x91\x97\x90M\x82\xB7\x82\xE9
+ *
+ *	@param	str_w	\x95\xB6\x8E\x9A\x97\xF1\x82ւ̃|\x83C\x83\x93\x83^
+ *					malloc()\x82\xB3\x82ꂽ\x83o\x83b\x83t\x83@\x81A\x91\x97\x90M\x8A\xAE\x97\xB9\x8E\x9E\x82Ɏ\xA9\x93\xAE\x82\xC5free()\x82\xB3\x82\xEA\x82\xE9
+ *	@param	str_len	\x95\xB6\x8E\x9A\x92\xB7(wchar_t\x92P\x88\xCA)
+ *					0\x82̂Ƃ\xAB\x81Astr_w\x82\xA9\x82當\x8E\x9A\x97񒷂𓾂\xE9
+ */
+static void CBSendStart(wchar_t *str_w, size_t str_len)
 {
-	unsigned int StrLen = 0;
-	clipboard_work_t *p;
+	SendMem *sm;
+	if (str_len == 0) {
+		str_len = wcslen(str_w);
+	}
+	sm = SendMemInit(str_w,
+					 str_len * sizeof(wchar_t),
+					 SendMemTypeTextLF);
+	if (sm == NULL)
+		return;
+//	SendMemInitDelay(sm, 0, 1000);
+	SendMemInitDelay(sm, 1000, 0);
+	SendMemInitDialog(sm, hInst, HVTWin, ts.UILanguageFile);
+	SendMemInitDialogCaption(sm, L"from clipboard");
+	SendMemInitDialogFilename(sm, L"Clipboard");
+	SendMemStart(sm);
+}
+#endif
+
+#if UNICODE_INTERNAL_BUFF
+void CBStartPaste(HWND HWin, BOOL AddCR, BOOL Bracketed)
+{
+//	unsigned int StrLen = 0;
 	wchar_t *str_w;
+	wchar_t *str_w_edited;
 
 	if (! cv.Ready) {
 		return;
@@ -806,12 +842,6 @@
 
 	CBEchoOnly = FALSE;
 
-	p = &cbwork;
-	if (p->send_str != NULL) {
-		// \x91\x97\x90M\x92\x86?
-		return;
-	}
-
 	str_w = GetClipboardTextW(HWin, FALSE);
 	if (str_w == NULL) {
 		// \x83N\x83\x8A\x83b\x83v\x83{\x81[\x83h\x82\xA9\x82當\x8E\x9A\x97\xF1\x82\xF0\x8E擾\x82ł\xAB\x82Ȃ\xA9\x82\xC1\x82\xBD
@@ -818,7 +848,6 @@
 		CBEndPaste();
 		return;
 	}
-	p->send_str = str_w;
 
 	if (ts.PasteFlag & CPF_TRIM_TRAILING_NL) {
 		// \x83o\x83b\x83t\x83@\x8DŌ\xE3\x82̉\xFC\x8Ds\x82\xF0\x8D폜
@@ -832,11 +861,15 @@
 		str_w = dest;
 	}
 
-	p->send_str = str_w;	// \x83_\x83C\x83A\x83\x8D\x83O\x82ŕ\\x8E\xA6\x82\xB7\x82\xE9
-	if (!CheckClipboardContentW(HWin, str_w, AddCR, Bracketed)) {
+	if (!CheckClipboardContentW(HWin, str_w, AddCR, &str_w_edited)) {
 		CBEndPaste();
 		return;
 	}
+	if (str_w_edited != NULL) {
+		// \x83_\x83C\x83A\x83\x8D\x83O\x82ŕҏW\x82\xB3\x82ꂽ
+		free(str_w);
+		str_w = str_w_edited;
+	}
 
 	if (AddCR) {
 		size_t str_len = wcslen(str_w) + 2;
@@ -846,6 +879,8 @@
 	}
 
 	if (Bracketed) {
+		const size_t BracketStartLenW = _countof(BracketStartW) - 1;
+		const size_t BracketEndLenW = _countof(BracketEndW) - 1;
 		size_t str_len = wcslen(str_w);
 		size_t dest_len = str_len + BracketStartLenW + BracketEndLenW;
 		wchar_t *dest = malloc(sizeof(wchar_t) * (dest_len+1));
@@ -861,21 +896,16 @@
 		str_w = dest;
 	}
 
-	// \x93\\x82\xE8\x95t\x82\xAF\x82̏\x80\x94\x{142A90}\xB3\x8F\xED\x82ɏo\x97\x88\x82\xBD
-	p->send_str = str_w;
-	p->send_index = 0;
-	p->waited = FALSE;
-	p->str_len = wcslen(p->send_str);
-	p->send_left = p->str_len;
-	TalkStatus = IdTalkCB;
+	CBSendStart(str_w, 0);
 }
 #endif
 
+#if !UNICODE_INTERNAL_BUFF
 void CBStartPasteB64(HWND HWin, PCHAR header, PCHAR footer)
 {
 	HANDLE tmpHandle = NULL;
 	char *tmpPtr = NULL;
-	int len, header_len, footer_len, b64_len;
+	size_t len, header_len, footer_len, b64_len;
 	UINT Cf;
 	LPWSTR tmpPtrWide = NULL;
 
@@ -979,12 +1009,12 @@
 		CBEndPaste();
 	}
 }
+#endif
 
 #if UNICODE_INTERNAL_BUFF
-void CBStartPasteB64W(HWND HWin, PCHAR header, PCHAR footer)
+void CBStartPasteB64(HWND HWin, PCHAR header, PCHAR footer)
 {
 	size_t mb_len, b64_len, header_len = 0, footer_len = 0;
-	clipboard_work_t *p;
 	wchar_t *str_w = NULL;
 	char *str_mb = NULL;
 	char *str_b64 = NULL;
@@ -998,19 +1028,11 @@
 
 	CBEchoOnly = FALSE;
 
-	p = &cbwork;
-	if (p->send_str != NULL) {
-		// \x91\x97\x90M\x92\x86?
-		return;
-	}
-
 	str_w = GetClipboardTextW(HWin, FALSE);
 	if (str_w == NULL) {
 		// \x83N\x83\x8A\x83b\x83v\x83{\x81[\x83h\x82\xA9\x82當\x8E\x9A\x97\xF1\x82\xF0\x8E擾\x82ł\xAB\x82Ȃ\xA9\x82\xC1\x82\xBD
 		goto error;
-		return;
 	}
-	p->send_str = str_w;
 
 	if (ts.Language == IdUtf8 || ts.KanjiCodeSend == IdUTF8) {
 		str_mb = ToU8W(str_w);
@@ -1056,12 +1078,7 @@
 	free(str_b64);
 
 	// \x93\\x82\xE8\x95t\x82\xAF\x82̏\x80\x94\x{142A90}\xB3\x8F\xED\x82ɏo\x97\x88\x82\xBD
-	p->send_str = str_w;
-	p->send_index = 0;
-	p->waited = FALSE;
-	p->str_len = wcslen(p->send_str);
-	p->send_left = p->str_len;
-	TalkStatus = IdTalkCB;
+	CBSendStart(str_w, 0);
 
 	return;
 
@@ -1181,93 +1198,8 @@
 	}
 }
 
-// \x83N\x83\x8A\x83b\x83v\x83{\x81[\x83h\x83f\x81[\x83^\x82\xF0\x92[\x96\x96\x82֑\x97\x82荞\x82ށB
-//
-#if UNICODE_INTERNAL_BUFF
-void CBSendW()
+static void CBEcho()
 {
-	clipboard_work_t *p = &cbwork;
-	int c;
-
-	if (p->send_str == NULL) {
-		return;
-	}
-
-	if (CBEchoOnly) {
-		CBEcho();
-		return;
-	}
-
-	if (ts.PasteDelayPerLine > 0 && p->waited) {
-		// \x8Ds\x96\x88wait
-		if (GetTickCount() - p->send_cr_tick < (DWORD)ts.PasteDelayPerLine) {
-			return;
-		}
-	}
-
-	if (CBRetryEcho) {
-		c = CommTextEcho(&cv,(PCHAR)&CBByte,1);
-		CBRetryEcho = (c==0);
-		if (CBRetryEcho) {
-			return;
-		}
-	}
-
-	for(;;){
-		BOOL send_one_line = FALSE;
-		size_t send_len;
-		int r;
-
-		// \x8FI\x92[?
-		if (p->send_str[p->send_index] == 0) {
-			// \x8FI\x97\xB9
-			CBEndPaste();
-			return;
-		}
-
-		send_len = p->send_left;
-		if (ts.PasteDelayPerLine > 0) {
-			// 1\x8Ds\x8E\xE6\x82\xE8\x8Fo\x82\xB5(clipboard\x82̉\xFC\x8Ds\x82\xCD L"\r\n")
-			const wchar_t *line_top = &p->send_str[p->send_index];
-			const wchar_t *line_end = wcsstr(line_top, L"\r\n");
-			if (line_end != NULL && *line_end == 0x0d && *(line_end+1) == 0x0a) {
-				// L'\r' \x82܂ő\x97\x90M
-				send_len = (line_end - line_top) + 1;
-				send_one_line = TRUE;
-			} else {
-				// \x89\xFC\x8Ds\x8C\xA9\x82‚\xA9\x82炸\x81A\x8DŌ\xE3\x82܂ő\x97\x90M
-				send_len = p->send_left;
-			}
-		}
-
-		r = CommTextOutW(&cv, &p->send_str[p->send_index], send_len);
-		if ((r != 0) && (ts.LocalEcho>0)) {
-			CommTextEchoW(&cv, &p->send_str[p->send_index], send_len);
-		}
-		if (r == 0) {
-			// \x8Fo\x97͂ł\xAB\x82Ȃ\xAD\x82Ȃ\xC1\x82\xBD(\x8Fo\x97̓o\x83b\x83t\x83@\x82\xAA\x82\xA2\x82\xC1\x82ς\xA2?)
-			return;
-		}
-		p->send_index += r;
-		p->send_left -= r;
-
-		if (send_one_line) {
-			// L'\n'\x82̓X\x83\x8B\x81[\x82\xB7\x82\xE9
-			p->send_index++;
-			p->send_left--;
-
-			// wait\x82ɓ\xFC\x82\xE9
-			p->waited = TRUE;
-			p->send_cr_tick = GetTickCount();
-			SetTimer(HVTWin, IdPasteDelayTimer, ts.PasteDelayPerLine, NULL);
-			break;
-		}
-	}
-}
-#endif
-
-void CBEcho()
-{
 	if (CBMemHandle==NULL) {
 		return;
 	}
@@ -1322,16 +1254,6 @@
 {
 	TalkStatus = IdTalkKeyb;
 
-#if UNICODE_INTERNAL_BUFF
-	{
-		clipboard_work_t *p = &cbwork;
-		if (p->send_str != NULL) {
-			free(p->send_str);
-			p->send_str = NULL;
-		}
-	}
-#endif
-
 	if (CBMemHandle!=NULL) {
 		if (CBMemPtr!=NULL) {
 			GlobalUnlock(CBMemHandle);
@@ -1379,7 +1301,13 @@
 		wchar_t *CBCopyWidePtr;
 		const size_t alloc_bytes = (str_len + 1) * sizeof(wchar_t);
 		CBCopyWideHandle = GlobalAlloc(GMEM_MOVEABLE, alloc_bytes);
+		if (CBCopyWideHandle == NULL) {
+			return FALSE;
+		}
 		CBCopyWidePtr = (wchar_t *)GlobalLock(CBCopyWideHandle);
+		if (CBCopyWidePtr == NULL) {
+			return FALSE;
+		}
 		memcpy(CBCopyWidePtr, str_w, alloc_bytes - sizeof(wchar_t));
 		CBCopyWidePtr[str_len] = L'\0';
 		GlobalUnlock(CBCopyWideHandle);
@@ -1447,6 +1375,7 @@
 }
 #endif
 
+#if !UNICODE_INTERNAL_BUFF
 static INT_PTR CALLBACK OnClipboardDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp)
 {
 	static const DlgTextInfo TextInfos[] = {
@@ -1467,15 +1396,7 @@
 		case WM_INITDIALOG:
 			SetDlgTexts(hDlgWnd, TextInfos, _countof(TextInfos), ts.UILanguageFile);
 
-#if UNICODE_INTERNAL_BUFF
-			if (cbwork.send_str != NULL) {
-				SetDlgItemTextW(hDlgWnd, IDC_EDIT, cbwork.send_str);
-			} else {
-				SetDlgItemTextA(hDlgWnd, IDC_EDIT, CBMemPtr);
-			}
-#else
 			SetDlgItemTextA(hDlgWnd, IDC_EDIT, CBMemPtr);
-#endif
 
 			if (ActiveWin == IdVT) { // VT Window
 				/*
@@ -1693,3 +1614,4 @@
 	}
 	return TRUE;
 }
+#endif

Modified: branches/unicode_buf/teraterm/teraterm/clipboar.h
===================================================================
--- branches/unicode_buf/teraterm/teraterm/clipboar.h	2019-10-29 13:04:14 UTC (rev 8341)
+++ branches/unicode_buf/teraterm/teraterm/clipboar.h	2019-10-29 13:04:33 UTC (rev 8342)
@@ -45,12 +45,8 @@
 
 void CBStartSend(PCHAR DataPtr, int DataSize, BOOL EchoOnly);
 void CBStartPaste(HWND HWin, BOOL AddCR, BOOL Bracketed);
-void CBStartPasteW(HWND HWin, BOOL AddCR, BOOL Bracketed);
 void CBStartPasteB64(HWND HWin, PCHAR header, PCHAR footer);
-void CBStartPasteB64W(HWND HWin, PCHAR header, PCHAR footer);
 void CBSend(void);
-void CBSendW(void);
-void CBEcho(void);
 void CBEndPaste(void);
 
 

Added: branches/unicode_buf/teraterm/teraterm/clipboarddlg.cpp
===================================================================
--- branches/unicode_buf/teraterm/teraterm/clipboarddlg.cpp	                        (rev 0)
+++ branches/unicode_buf/teraterm/teraterm/clipboarddlg.cpp	2019-10-29 13:04:33 UTC (rev 8342)
@@ -0,0 +1,277 @@
+/*
+ * (C) 2019 TeraTerm Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* TERATERM.EXE, Clipboard routines */
+#include "teraterm.h"
+#include "tttypes.h"
+#include "vtdisp.h"
+#include "vtterm.h"
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <commctrl.h>
+#define _CRTDBG_MAP_ALLOC
+#include <crtdbg.h>
+#include <wchar.h>
+
+#include "ttwinman.h"
+#include "ttcommon.h"
+#include "ttlib.h"
+#include "dlglib.h"
+
+#include "tt_res.h"
+#include "sendmem.h"
+
+#include "clipboarddlg.h"
+
+static INT_PTR CALLBACK OnClipboardDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp)
+{
+	static const DlgTextInfo TextInfos[] = {
+		{ 0, "DLG_CLIPBOARD_TITLE" },
+		{ IDCANCEL, "BTN_CANCEL" },
+		{ IDOK, "BTN_OK" },
+	};
+	POINT p;
+	RECT rc_dsk, rc_dlg;
+	int dlg_height, dlg_width;
+	static int ok2right, edit2ok, edit2bottom;
+	RECT rc_edit, rc_ok, rc_cancel;
+	// for status bar
+	static HWND hStatus = NULL;
+	static int init_width, init_height;
+	clipboarddlgdata *data = (clipboarddlgdata *)GetWindowLongPtr(hDlgWnd, DWLP_USER);
+
+	switch (msg) {
+		case WM_INITDIALOG:
+			data = (clipboarddlgdata *)lp;
+			SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)data);
+			SetDlgTexts(hDlgWnd, TextInfos, _countof(TextInfos), data->UILanguageFile);
+
+			if (data->strW_ptr != NULL) {
+				SetDlgItemTextW(hDlgWnd, IDC_EDIT, data->strW_ptr);
+			} else {
+				SetDlgItemTextA(hDlgWnd, IDC_EDIT, data->strA_ptr);
+			}
+
+			if (ActiveWin == IdVT) { // VT Window
+				/*
+				 * Caret off \x8E\x9E\x82\xC9 GetCaretPos() \x82Ő\xB3\x8Am\x82ȏꏊ\x82\xAA\x8E\xE6\x82\xEA\x82Ȃ\xA2\x82̂ŁA
+				 * vtdisp.c \x93\xE0\x95\x94\x82ŊǗ\x9D\x82\xB5\x82Ă\xA2\x82\xE9\x92l\x82\xA9\x82\xE7\x8Cv\x8EZ\x82\xB7\x82\xE9
+				 */
+				int x, y;
+				DispConvScreenToWin(CursorX, CursorY, &x, &y);
+				p.x = x;
+				p.y = y;
+			}
+			else if (!GetCaretPos(&p)) { // Tek Window
+				/*
+				 * Tek Window \x82͓\xE0\x95\x94\x8AǗ\x9D\x82̒l\x82\xF0\x8E\xE6\x82\xE9\x82̂\xAA\x96ʓ|\x82Ȃ̂\xC5 GetCaretPos() \x82\xF0\x8Eg\x82\xA4
+				 * GetCaretPos() \x82\xAA\x83G\x83\x89\x81[\x82ɂȂ\xC1\x82\xBD\x8Fꍇ\x82͔O\x82̂\xBD\x82\xDF 0, 0 \x82\xF0\x93\xFC\x82\xEA\x82Ă\xA8\x82\xAD
+				 */
+				p.x = 0;
+				p.y = 0;
+			}
+
+			// x, y \x82̗\xBC\x95\xFB\x82\xAA 0 \x82̎\x9E\x82͐e\x83E\x83B\x83\x93\x83h\x83E\x82̒\x86\x89\x9B\x82Ɉړ\xAE\x82\xB3\x82\xB9\x82\xE7\x82\xEA\x82\xE9\x82̂ŁA
+			// \x82\xBB\x82\xEA\x82\xF0\x96h\x82\xAE\x88ׂ\xC9 x \x82\xF0 1 \x82ɂ\xB7\x82\xE9
+			if (p.x == 0 && p.y == 0) {
+				p.x = 1;
+			}
+
+			ClientToScreen(GetParent(hDlgWnd), &p);
+
+			// \x83L\x83\x83\x83\x8C\x83b\x83g\x82\xAA\x89\xE6\x96ʂ\xA9\x82\xE7\x82͂ݏo\x82\xB5\x82Ă\xA2\x82\xE9\x82Ƃ\xAB\x82ɓ\\x82\xE8\x95t\x82\xAF\x82\xF0\x82\xB7\x82\xE9\x82\xC6
+			// \x8Am\x94F\x83E\x83C\x83\x93\x83h\x83E\x82\xAA\x8C\xA9\x82\xA6\x82\xE9\x82Ƃ\xB1\x82\xEB\x82ɕ\\x8E\xA6\x82\xB3\x82\xEA\x82Ȃ\xA2\x82\xB1\x82Ƃ\xAA\x82\xA0\x82\xE9\x81B
+			// \x83E\x83C\x83\x93\x83h\x83E\x82\xA9\x82\xE7\x82͂ݏo\x82\xB5\x82\xBD\x8Fꍇ\x82ɒ\xB2\x90߂\xB7\x82\xE9 (2008.4.24 maya)
+			if (!HasMultiMonitorSupport()) {
+				// NT4.0, 95 \x82̓}\x83\x8B\x83`\x83\x82\x83j\x83^API\x82ɔ\xF1\x91Ή\x9E
+				SystemParametersInfo(SPI_GETWORKAREA, 0, &rc_dsk, 0);
+			}
+			else {
+				HMONITOR hm;
+				POINT pt;
+				MONITORINFO mi;
+
+				pt.x = p.x;
+				pt.y = p.y;
+				hm = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST);
+
+				mi.cbSize = sizeof(MONITORINFO);
+				GetMonitorInfo(hm, &mi);
+				rc_dsk = mi.rcWork;
+			}
+			GetWindowRect(hDlgWnd, &rc_dlg);
+			dlg_height = rc_dlg.bottom-rc_dlg.top;
+			dlg_width  = rc_dlg.right-rc_dlg.left;
+			if (p.y < rc_dsk.top) {
+				p.y = rc_dsk.top;
+			}
+			else if (p.y + dlg_height > rc_dsk.bottom) {
+				p.y = rc_dsk.bottom - dlg_height;
+			}
+			if (p.x < rc_dsk.left) {
+				p.x = rc_dsk.left;
+			}
+			else if (p.x + dlg_width > rc_dsk.right) {
+				p.x = rc_dsk.right - dlg_width;
+			}
+
+			SetWindowPos(hDlgWnd, NULL, p.x, p.y,
+			             0, 0, SWP_NOSIZE | SWP_NOZORDER);
+
+			// \x83_\x83C\x83A\x83\x8D\x83O\x82̏\x89\x8A\xFA\x83T\x83C\x83Y\x82\xF0\x95ۑ\xB6
+			GetWindowRect(hDlgWnd, &rc_dlg);
+			init_width = rc_dlg.right - rc_dlg.left;
+			init_height = rc_dlg.bottom - rc_dlg.top;
+
+			// \x8C\xBB\x8D݃T\x83C\x83Y\x82\xA9\x82\xE7\x95K\x97v\x82Ȓl\x82\xF0\x8Cv\x8EZ
+			GetClientRect(hDlgWnd,                                 &rc_dlg);
+			GetWindowRect(GetDlgItem(hDlgWnd, IDC_EDIT),           &rc_edit);
+			GetWindowRect(GetDlgItem(hDlgWnd, IDOK),               &rc_ok);
+
+			p.x = rc_dlg.right;
+			p.y = rc_dlg.bottom;
+			ClientToScreen(hDlgWnd, &p);
+			ok2right = p.x - rc_ok.left;
+			edit2bottom = p.y - rc_edit.bottom;
+			edit2ok = rc_ok.left - rc_edit.right;
+
+			// \x83T\x83C\x83Y\x82𕜌\xB3
+			SetWindowPos(hDlgWnd, NULL, 0, 0,
+			             ts.PasteDialogSize.cx, ts.PasteDialogSize.cy,
+			             SWP_NOZORDER | SWP_NOMOVE);
+
+			// \x83\x8A\x83T\x83C\x83Y\x83A\x83C\x83R\x83\x93\x82\xF0\x89E\x89\xBA\x82ɕ\\x8E\xA6\x82\xB3\x82\xB9\x82\xBD\x82\xA2\x82̂ŁA\x83X\x83e\x81[\x83^\x83X\x83o\x81[\x82\xF0\x95t\x82\xAF\x82\xE9\x81B
+			InitCommonControls();
+			hStatus = CreateStatusWindow(
+				WS_CHILD | WS_VISIBLE |
+				CCS_BOTTOM | SBARS_SIZEGRIP, NULL, hDlgWnd, 1);
+
+			return TRUE;
+
+		case WM_COMMAND:
+			switch (LOWORD(wp)) {
+				case IDOK:
+				{
+					INT_PTR result = IDCANCEL;
+
+					size_t len = SendDlgItemMessage(hDlgWnd, IDC_EDIT, WM_GETTEXTLENGTH, 0, 0);
+					len++; // for '\0'
+					wchar_t *strW = (wchar_t *)malloc(sizeof(wchar_t) * len);
+					if (strW != NULL) {
+						GetDlgItemTextW(hDlgWnd, IDC_EDIT, strW, (int)len);
+						result = IDOK;
+					}
+					data->strW_edited_ptr = strW;
+
+					DestroyWindow(hStatus);
+					TTEndDialog(hDlgWnd, result);
+				}
+					break;
+
+				case IDCANCEL:
+					DestroyWindow(hStatus);
+					TTEndDialog(hDlgWnd, IDCANCEL);
+					break;
+
+				default:
+					return FALSE;
+			}
+
+		case WM_SIZE:
+			{
+				// \x8DĔz\x92u
+				int dlg_w, dlg_h;
+
+				GetClientRect(hDlgWnd,                                 &rc_dlg);
+				dlg_w = rc_dlg.right;
+				dlg_h = rc_dlg.bottom;
+
+				GetWindowRect(GetDlgItem(hDlgWnd, IDC_EDIT),           &rc_edit);
+				GetWindowRect(GetDlgItem(hDlgWnd, IDOK),               &rc_ok);
+				GetWindowRect(GetDlgItem(hDlgWnd, IDCANCEL),           &rc_cancel);
+
+				// OK
+				p.x = rc_ok.left;
+				p.y = rc_ok.top;
+				ScreenToClient(hDlgWnd, &p);
+				SetWindowPos(GetDlgItem(hDlgWnd, IDOK), 0,
+				             dlg_w - ok2right, p.y, 0, 0,
+				             SWP_NOSIZE | SWP_NOZORDER);
+
+				// CANCEL
+				p.x = rc_cancel.left;
+				p.y = rc_cancel.top;
+				ScreenToClient(hDlgWnd, &p);
+				SetWindowPos(GetDlgItem(hDlgWnd, IDCANCEL), 0,
+				             dlg_w - ok2right, p.y, 0, 0,
+				             SWP_NOSIZE | SWP_NOZORDER);
+
+				// EDIT
+				p.x = rc_edit.left;
+				p.y = rc_edit.top;
+				ScreenToClient(hDlgWnd, &p);
+				SetWindowPos(GetDlgItem(hDlgWnd, IDC_EDIT), 0,
+				             0, 0, dlg_w - p.x - edit2ok - ok2right, dlg_h - p.y - edit2bottom,
+				             SWP_NOMOVE | SWP_NOZORDER);
+
+				// \x83T\x83C\x83Y\x82\xF0\x95ۑ\xB6
+				GetWindowRect(hDlgWnd, &rc_dlg);
+				ts.PasteDialogSize.cx = rc_dlg.right - rc_dlg.left;
+				ts.PasteDialogSize.cy = rc_dlg.bottom - rc_dlg.top;
+
+				// status bar
+				SendMessage(hStatus , msg , wp , lp);
+			}
+			return TRUE;
+
+		case WM_GETMINMAXINFO:
+			{
+				// \x83_\x83C\x83A\x83\x8D\x83O\x82̏\x89\x8A\xFA\x83T\x83C\x83Y\x82\xE6\x82菬\x82\xB3\x82\xAD\x82ł\xAB\x82Ȃ\xA2\x82悤\x82ɂ\xB7\x82\xE9
+				LPMINMAXINFO lpmmi;
+				lpmmi = (LPMINMAXINFO)lp;
+				lpmmi->ptMinTrackSize.x = init_width;
+				lpmmi->ptMinTrackSize.y = init_height;
+			}
+			return FALSE;
+
+		default:
+			return FALSE;
+	}
+}
+
+INT_PTR clipboarddlg(
+	HINSTANCE hInstance,
+	HWND hWndParent,
+	clipboarddlgdata *data)
+{
+	INT_PTR ret;
+	ret = TTDialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CLIPBOARD_DIALOG),
+						   hWndParent, OnClipboardDlgProc, (LPARAM)data);
+	return ret;
+}

Copied: branches/unicode_buf/teraterm/teraterm/clipboarddlg.h (from rev 8341, branches/unicode_buf/teraterm/teraterm/clipboar.h)
===================================================================
--- branches/unicode_buf/teraterm/teraterm/clipboarddlg.h	                        (rev 0)
+++ branches/unicode_buf/teraterm/teraterm/clipboarddlg.h	2019-10-29 13:04:33 UTC (rev 8342)
@@ -0,0 +1,53 @@
+/*
+ * (C) 2019 TeraTerm Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <windows.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+	const wchar_t *strW_ptr;
+	size_t strW_len;
+	wchar_t *strW_edited_ptr;
+	char *strA_ptr;
+	size_t strA_len;
+	const char *UILanguageFile;
+} clipboarddlgdata;
+
+INT_PTR clipboarddlg(
+	HINSTANCE hInstance,
+	HWND hWndParent,
+	clipboarddlgdata *data);
+
+#ifdef __cplusplus
+}
+#endif

Modified: branches/unicode_buf/teraterm/teraterm/ftdlg.h
===================================================================
--- branches/unicode_buf/teraterm/teraterm/ftdlg.h	2019-10-29 13:04:14 UTC (rev 8341)
+++ branches/unicode_buf/teraterm/teraterm/ftdlg.h	2019-10-29 13:04:33 UTC (rev 8342)
@@ -48,7 +48,8 @@
 
 	enum { IDD = IDD_FILETRANSDLG };
 
-protected:
+private:
+//protected:
 	virtual BOOL OnCancel();
 	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
 	virtual BOOL PostNcDestroy();

Added: branches/unicode_buf/teraterm/teraterm/ftdlg_lite.cpp
===================================================================
--- branches/unicode_buf/teraterm/teraterm/ftdlg_lite.cpp	                        (rev 0)
+++ branches/unicode_buf/teraterm/teraterm/ftdlg_lite.cpp	2019-10-29 13:04:33 UTC (rev 8342)
@@ -0,0 +1,319 @@
+/*
+ * (C) 2019 TeraTerm Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* TERATERM.EXE, file transfer dialog box lite */
+#include "teraterm_conf.h"
+
+#include <stdio.h>
+#include <windows.h>
+#include <commctrl.h>
+#define _CRTDBG_MAP_ALLOC
+#include <crtdbg.h>
+
+#include "teraterm.h"
+#include "tttypes.h"
+#include "ttlib.h"
+#include "dlglib.h"
+#include "tt_res.h"
+#include "teraterml.h"
+
+#include "ftdlg_lite.h"
+
+//	\x8E\x9E\x8A\xD4		\x95\\x8E\xA6\x93\xE0\x97e
+//	0-2sec		\x8D\xBB\x8E\x9E\x8Cv\x83J\x81[\x83\\x83\x8B
+//	2sec		\x90i\x92\xBB50%\x88ȉ\xBA\x82Ȃ\xE7\x83_\x83C\x83A\x83\x8D\x83O\x82\xF0\x8Fo\x82\xB7/\x88ȏゾ\x82\xC1\x82\xBD\x82獻\x8E\x9E\x8Cv\x82̂܂\xDC
+
+#include "tmfc.h"
+
+class PrivateData : public TTCDialog
+{
+public:
+	PrivateData() {
+		SmallIcon = NULL;
+		BigIcon = NULL;
+		check_2sec = NULL;
+		show = FALSE;
+		UILanguageFile_ = NULL;
+		Pause = FALSE;
+		observer_ = NULL;
+	}
+
+	BOOL Create(HINSTANCE hInstance, HWND hParent) {
+		return TTCDialog::Create(hInstance, hParent, IDD_FILETRANSDLG);
+	}
+	void SetUILanguageFile(const char *UILanguageFile) {
+		static const DlgTextInfo TextInfos[] = {
+			{ IDC_TRANS_FILENAME, "DLG_FILETRANS_FILENAME" },
+			{ IDC_FULLPATH_LABEL, "DLG_FILETRANS_FULLPATH" },
+			{ IDC_TRANS_TRANS, "DLG_FILETRANS_TRNAS" },
+			{ IDC_TRANS_ELAPSED, "DLG_FILETRANS_ELAPSED" },
+			{ IDCANCEL, "DLG_FILETRANS_CLOSE" },
+			{ IDC_TRANSPAUSESTART, "DLG_FILETRANS_PAUSE" },
+			{ IDC_TRANSHELP, "BTN_HELP" },
+		};
+		UILanguageFile_ = UILanguageFile;
+		SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), UILanguageFile_);
+	}
+
+	void ChangeButton(BOOL PauseFlag)
+	{
+		wchar_t UIMsg[MAX_UIMSG];
+		Pause = PauseFlag;
+		if (Pause) {
+			get_lang_msgW("DLG_FILETRANS_START", UIMsg, _countof(UIMsg), L"&Start", UILanguageFile_);
+		}
+		else {
+			get_lang_msgW("DLG_FILETRANS_PAUSE", UIMsg, _countof(UIMsg), L"Pau&se", UILanguageFile_);
+
+		}
+		SetDlgItemTextW(IDC_TRANSPAUSESTART, UIMsg);
+		if (observer_ != NULL) {
+			observer_->OnPause(PauseFlag);
+		}
+	}
+
+private:
+	virtual BOOL OnInitDialog() {
+		int fuLoad = LR_DEFAULTCOLOR;
+
+		if (HideDialog) {
+			// Visible = False \x82ł\xE0\x83t\x83H\x83A\x83O\x83\x89\x83E\x83\x93\x83h\x82ɗ\x88\x82Ă\xB5\x82܂\xA4\x82̂ŁA\x82\xBB\x82\xA4\x82Ȃ\xE7\x82Ȃ\xA2
+			// \x82悤\x82Ɋg\x92\xA3\x83X\x83^\x83C\x83\x8B WS_EX_NOACTIVATE \x82\xF0\x8Ew\x92肷\x82\xE9\x81B
+			// (Windows 2000 \x88ȏ\xE3\x82ŗL\x8C\xF8)
+			// WS_EX_NOACTIVATE \x82\xF0\x8Ew\x92肷\x82\xE9\x82ƕ\\x8E\xA6\x82\xB3\x82\xEA\x82Ă\xA2\x82鎞\x82\xE0\x83^\x83X\x83N\x83o\x81[\x82Ɍ\xBB\x82\xEA\x82Ȃ\xA2
+			// \x82̂\xC5 WS_EX_APPWINDOW \x82\xE0\x8Ew\x92肷\x82\xE9\x81B
+			ModifyStyleEx(0, WS_EX_NOACTIVATE | WS_EX_APPWINDOW);
+		}
+
+		if (IsWindowsNT4()) {
+			fuLoad = LR_VGACOLOR;
+		}
+		SmallIcon = LoadImage(m_hInst,
+							  MAKEINTRESOURCE(IDI_TTERM),
+							  IMAGE_ICON, 16, 16, fuLoad);
+		::PostMessage(m_hWnd, WM_SETICON, ICON_SMALL,
+					  (LPARAM)SmallIcon);
+
+		BigIcon = LoadImage(m_hInst,
+							MAKEINTRESOURCE(IDI_TTERM),
+							IMAGE_ICON, 0, 0, fuLoad);
+		::PostMessage(m_hWnd, WM_SETICON, ICON_BIG,
+					  (LPARAM)BigIcon);
+
+		AddModelessHandle(m_hWnd);
+
+		if (observer_ == NULL){
+			EnableDlgItem(IDCANCEL, FALSE);
+			EnableDlgItem(IDC_TRANSPAUSESTART, FALSE);
+			EnableDlgItem(IDC_TRANSHELP, FALSE);
+		}
+		return TRUE;
+	}
+
+	virtual BOOL OnClose()
+	{
+		if (observer_ != NULL) {
+			observer_->OnClose();
+		}
+		return TRUE;
+	}
+
+	virtual BOOL OnCancel()
+	{
+		return OnClose();
+	}
+
+	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam)
+	{
+		switch (LOWORD(wParam)) {
+			case IDC_TRANSPAUSESTART:
+				ChangeButton(!Pause);
+				return TRUE;
+			case IDC_TRANSHELP:
+				observer_->OnHelp();
+				return TRUE;
+			default:
+				return (TTCDialog::OnCommand(wParam, lParam));
+		}
+	}
+
+	virtual BOOL PostNcDestroy() {
+		if (SmallIcon) {
+			DestroyIcon((HICON)SmallIcon);
+			SmallIcon = NULL;
+		}
+
+		if (BigIcon) {
+			DestroyIcon((HICON)BigIcon);
+			BigIcon = NULL;
+		}
+
+		RemoveModelessHandle(m_hWnd);
+
+		delete this;
+		return TRUE;
+	}
+
+private:
+	HANDLE SmallIcon;
+	HANDLE BigIcon;
+	const char *UILanguageFile_;
+	wchar_t *Cation;
+	wchar_t *Filename;
+
+public:
+	BOOL Pause;
+	BOOL check_2sec;
+	BOOL show;
+	DWORD prev_elapsed;
+	DWORD StartTime;
+	BOOL HideDialog;
+
+	CFileTransLiteDlg::Observer *observer_;
+};
+
+CFileTransLiteDlg::CFileTransLiteDlg()
+{
+	pData = NULL;
+}
+
+CFileTransLiteDlg::~CFileTransLiteDlg()
+{
+	if (pData == NULL) {
+		return;
+	}
+
+	Destroy();
+}
+
+BOOL CFileTransLiteDlg::Create(HINSTANCE hInstance, HWND hParent, const char *UILanguageFile)
+{
+	pData = new PrivateData();
+	pData->check_2sec = FALSE;
+	pData->show = FALSE;
+	pData->Pause = FALSE;
+	pData->HideDialog = FALSE;
+
+	BOOL Ok = pData->Create(hInstance, hParent);
+	pData->SetUILanguageFile(UILanguageFile);
+
+	HWND hWnd = ::GetDlgItem(pData->m_hWnd, IDC_TRANSPROGRESS);
+	::SendMessage(hWnd, PBM_SETRANGE, (WPARAM)0, MAKELPARAM(0, 100));
+	::SendMessage(hWnd, PBM_SETSTEP, (WPARAM)1, 0);
+	::SendMessage(hWnd, PBM_SETPOS, (WPARAM)0, 0);
+	::ShowWindow(hWnd, SW_SHOW);
+
+	pData->SetDlgItemTextA(IDC_TRANS_ETIME, "0:00");
+	pData->StartTime = GetTickCount();
+	pData->prev_elapsed = 0;
+
+	return Ok;
+}
+
+void CFileTransLiteDlg::ChangeButton(BOOL PauseFlag)
+{
+	pData->ChangeButton(PauseFlag);
+}
+
+void CFileTransLiteDlg::RefreshNum(size_t ByteCount, size_t FileSize)
+{
+	const DWORD now = GetTickCount();
+
+	if (!pData->check_2sec) {
+		DWORD elapsed_ms = now - pData->StartTime;
+		if (elapsed_ms > 2 * 1000) {
+			// 2sec\x8Co\x89\xDF
+			pData->check_2sec = TRUE;
+			if ((100.0 * (double)ByteCount / (double)FileSize) < 50) {
+				// 50%\x82ɖ\x9E\x82\xBD\x82Ȃ\xA2
+				pData->ShowWindow(SW_SHOWNORMAL);
+			}
+		}
+	}
+
+	char NumStr[24];
+	DWORD elapsed = (now - pData->StartTime) / 1000;
+	if (elapsed != pData->prev_elapsed && elapsed != 0) {
+		char elapsed_str[24];
+		_snprintf_s(elapsed_str, sizeof(elapsed_str), _TRUNCATE, "%ld:%02ld",
+					elapsed / 60, elapsed % 60);
+
+		char speed_str[24];
+		size_t rate2 = ByteCount / elapsed;
+		if (rate2 < 1200) {
+			_snprintf_s(speed_str, sizeof(speed_str), _TRUNCATE, "%lldBytes/s", (unsigned long long)rate2);
+		}
+		else if (rate2 < 1200000) {
+			_snprintf_s(speed_str, sizeof(speed_str), _TRUNCATE, "%lld.%02lldKB/s",
+						(unsigned long long)(rate2 / 1000), (unsigned long long)(rate2 / 10 % 100));
+		}
+		else {
+			_snprintf_s(speed_str, sizeof(speed_str), _TRUNCATE, "%lld.%02lldMB/s",
+						(unsigned long long)(rate2 / (1000*1000)), (unsigned long long)(rate2 / 10000 % 100));
+		}
+		_snprintf_s(NumStr, sizeof(NumStr), _TRUNCATE, "%s (%s)", elapsed_str, speed_str);
+		pData->SetDlgItemTextA(IDC_TRANS_ETIME, NumStr);
+		pData->prev_elapsed = elapsed;
+	}
+
+	if (FileSize > 0) {
+		double rate = 100.0 * (double)ByteCount / (double)FileSize;
+		pData->SendDlgItemMessage(IDC_TRANSPROGRESS, PBM_SETPOS, (WPARAM)rate, 0);
+		_snprintf_s(NumStr,sizeof(NumStr),_TRUNCATE,"%u (%3.1f%%)", (int)ByteCount, rate);
+	}
+	else {
+		_snprintf_s(NumStr,sizeof(NumStr),_TRUNCATE,"%u", (int)ByteCount);
+	}
+	pData->SetDlgItemTextA(IDC_TRANSBYTES, NumStr);
+}
+
+void CFileTransLiteDlg::SetCaption(const wchar_t *caption)
+{
+	pData->SetWindowTextW(caption);
+}
+
+void CFileTransLiteDlg::SetFilename(const wchar_t *filename)
+{
+	pData->SetDlgItemTextW(IDC_TRANSFNAME, filename);
+	pData->SetDlgItemTextW(IDC_EDIT_FULLPATH, filename);
+}
+
+void CFileTransLiteDlg::SetObserver(CFileTransLiteDlg::Observer *observer)
+{
+	pData->observer_ = observer;
+	BOOL enable = observer != NULL;
+	pData->EnableDlgItem(IDCANCEL, enable);
+	pData->EnableDlgItem(IDC_TRANSPAUSESTART, enable);
+	pData->EnableDlgItem(IDC_TRANSHELP, enable);
+}
+
+void CFileTransLiteDlg::Destroy()
+{
+	pData->EndDialog(IDOK);
+	pData = NULL;
+}

Copied: branches/unicode_buf/teraterm/teraterm/ftdlg_lite.h (from rev 8341, branches/unicode_buf/teraterm/teraterm/ftdlg.h)
===================================================================
--- branches/unicode_buf/teraterm/teraterm/ftdlg_lite.h	                        (rev 0)
+++ branches/unicode_buf/teraterm/teraterm/ftdlg_lite.h	2019-10-29 13:04:33 UTC (rev 8342)
@@ -0,0 +1,53 @@
+/*
+ * (C) 2019 TeraTerm Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+class CFileTransLiteDlg
+{
+public:
+	class Observer
+	{
+	public:
+		virtual ~Observer() {};
+		virtual void OnClose() = 0;
+		virtual void OnPause(BOOL pause) = 0;
+		virtual void OnHelp() = 0;
+	};
+	CFileTransLiteDlg();
+	virtual ~CFileTransLiteDlg();
+	BOOL Create(HINSTANCE hInstance, HWND hParent, const char *UILanguageFile);
+	void SetCaption(const wchar_t *caption);
+	void SetFilename(const wchar_t *filename);
+	void ChangeButton(BOOL PauseFlag);
+	void RefreshNum(size_t ByteCount, size_t FileSize);
+	void SetObserver(Observer *observer);
+	void Destroy();
+
+private:
+	class PrivateData *pData;
+};
+

Added: branches/unicode_buf/teraterm/teraterm/sendmem.cpp
===================================================================
--- branches/unicode_buf/teraterm/teraterm/sendmem.cpp	                        (rev 0)
+++ branches/unicode_buf/teraterm/teraterm/sendmem.cpp	2019-10-29 13:04:33 UTC (rev 8342)
@@ -0,0 +1,483 @@
+/*
+ * (C) 2019 TeraTerm Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <windows.h>
+#include <stdlib.h>
+#define _CRTDBG_MAP_ALLOC
+#include <crtdbg.h>
+
+#include "tttypes.h"
+#include "ttcommon.h"
+#include "ftdlg_lite.h"
+
+#include "sendmem.h"
+
+typedef struct SendMemTag {
+	const BYTE *send_ptr;  // \x91\x97\x90M\x83f\x81[\x83^\x82ւ̃|\x83C\x83\x93\x83^
+	size_t send_len;	   // \x91\x97\x90M\x83f\x81[\x83^\x83T\x83C\x83Y
+	SendMemType type;
+	BOOL local_echo_enable;
+	BOOL send_enable;
+	DWORD delay_per_line;  // (ms)
+	DWORD delay_per_char;
+	HWND hWnd;	 // \x83^\x83C\x83}\x81[\x82\xF0\x8E󂯂\xE9window
+	int timer_id;  // \x83^\x83C\x83}\x81[ID
+	char *UILanguageFile;
+	wchar_t *dialog_caption;
+	wchar_t *filename;
+	//
+	size_t send_left;
+	size_t send_index;
+	BOOL waited;
+	DWORD last_send_tick;
+	//
+	CFileTransLiteDlg *dlg;
+	class SendMemDlgObserver *dlg_observer;
+	HINSTANCE hInst_;
+	HWND hWndParent_;
+	//
+	PComVar cv_;
+	BOOL pause;
+	const BYTE *send_out_retry_ptr;
+	size_t send_out_retry_len;
+	const BYTE *send_echo_retry_ptr;
+	size_t send_echo_retry_len;
+} SendMem;
+
+typedef SendMem sendmem_work_t;
+
+extern "C" IdTalk TalkStatus;
+extern "C" HWND HVTWin;
+
+static sendmem_work_t *sendmem_work;
+
+class SendMemDlgObserver : public CFileTransLiteDlg::Observer {
+public:
+	SendMemDlgObserver(HWND hWndParent, void (*OnClose)(), void (*OnPause)(BOOL paused)) {
+		hWndParent_ = hWndParent;
+		OnClose_ = OnClose;
+		OnPause_ = OnPause;
+	}
+private:
+	void OnClose()
+	{
+		OnClose_();
+	};
+	void OnPause(BOOL paused)
+	{
+		OnPause_(paused);
+	};
+	void OnHelp()
+	{
+		MessageBoxA(hWndParent_, "no help topic", "Tera Term", MB_OK);
+	}
+	HWND hWndParent_;
+	void (*OnClose_)();
+	void (*OnPause_)(BOOL paused);
+};
+
+static void EndPaste()
+{
+	sendmem_work_t *p = sendmem_work;
+	p->send_ptr = NULL;
+
+	TalkStatus = IdTalkKeyb;
+	p->dlg->Destroy();
+	delete p->dlg;
+	delete p->dlg_observer;
+	free(p->UILanguageFile);
+	free(p->dialog_caption);
+	free(p->filename);
+	free(p);
+
+	sendmem_work = NULL;
+	EnableWindow(HVTWin, TRUE);
+}
+
+static void OnClose()
+{
+	EndPaste();
+}
+
+static void OnPause(BOOL paused)
+{
+	sendmem_work_t *p = sendmem_work;
+	p->pause = paused;
+	if (!paused) {
+		// \x83|\x81[\x83Y\x89\xF0\x8F\x9C\x8E\x9E, \x83^\x83C\x83}\x81[\x83C\x83x\x83\x93\x83g\x82ōđ\x97\x82̃g\x83\x8A\x83K\x82\xF0\x88\xF8\x82\xAD
+		SetTimer(p->hWnd, p->timer_id, 0, NULL);
+	}
+}
+
+static void SendMemStart_i(SendMem *sm)
+{
+	sendmem_work = sm;
+	sendmem_work_t *p = sm;
+
+	p->send_left = p->send_len;
+	p->send_index = 0;
+	p->send_out_retry_ptr = NULL;
+	p->send_echo_retry_ptr = NULL;
+
+	p->waited = FALSE;
+	p->pause = FALSE;
+
+	if (p->hWndParent_ != NULL) {
+		// \x83_\x83C\x83A\x83\x8D\x83O\x82𐶐\xAC\x82\xB7\x82\xE9
+		p->dlg = new CFileTransLiteDlg();
+		p->dlg->Create(NULL, NULL, sm->UILanguageFile);
+		if (p->dialog_caption != NULL) {
+			p->dlg->SetCaption(p->dialog_caption);
+		}
+		if (p->filename != NULL) {
+			p->dlg->SetFilename(p->filename);
+		}
+		p->dlg_observer = new SendMemDlgObserver(p->hWndParent_, OnClose, OnPause);
+		p->dlg->SetObserver(p->dlg_observer);
+	}
+
+	TalkStatus = IdTalkSendMem;
+
+	EnableWindow(HVTWin, FALSE);
+}
+
+/**
+ * \x91\x97\x90M
+ */
+void SendMemContinuously(void)
+{
+	sendmem_work_t *p = sendmem_work;
+
+	if (p->send_ptr == NULL) {
+		EndPaste();
+		return;
+	}
+
+	if (p->pause) {
+		return;
+	}
+
+	if (p->waited) {
+		const DWORD delay = p->delay_per_line > 0 ? p->delay_per_line : p->delay_per_char;
+		if (GetTickCount() - p->last_send_tick < delay) {
+			// \x83E\x83G\x83C\x83g\x82\xB7\x82\xE9
+			return;
+		}
+	}
+
+	// \x91\x97\x90M\x83o\x83b\x83t\x83@(echo)\x82ł\xAB\x82Ȃ\xA9\x82\xC1\x82\xBD\x95\xAA\x82\xF0\x8Dđ\x97
+	int r;
+	size_t sended_size = 0;
+	if (p->send_out_retry_ptr != NULL) {
+		if (p->type == SendMemTypeBinary) {
+			r = CommBinaryBuffOut(p->cv_, (PCHAR)p->send_out_retry_ptr, (int)p->send_out_retry_len);
+		}
+		else {
+			// text (not binary)
+			r = CommTextOutW(p->cv_, (wchar_t *)p->send_out_retry_ptr, (int)(p->send_out_retry_len / sizeof(wchar_t)));
+			r *= sizeof(wchar_t);
+		}
+		sended_size = r;
+		p->send_out_retry_len -= r;
+		if (p->send_out_retry_len == 0) {
+			p->send_out_retry_ptr = NULL;
+		}
+		else {
+			p->send_out_retry_ptr += r;
+		}
+	}
+	if (p->send_echo_retry_ptr != NULL) {
+		size_t echo_size = sended_size < p->send_echo_retry_len ? sended_size : p->send_echo_retry_len;
+		if (p->type == SendMemTypeBinary) {
+			r = CommTextEcho(p->cv_, (PCHAR)p->send_echo_retry_ptr, (int)echo_size);
+		}
+		else {
+			r = CommTextEchoW(p->cv_, (wchar_t *)p->send_echo_retry_ptr, (int)(echo_size / sizeof(wchar_t)));
+			r *= sizeof(wchar_t);
+		}
+		p->send_echo_retry_len -= r;
+		if (p->send_echo_retry_len == 0) {
+			p->send_echo_retry_ptr = NULL;
+		}
+		else {
+			p->send_echo_retry_ptr += r;
+		}
+	}
+	if (p->send_out_retry_ptr != NULL || p->send_echo_retry_ptr != NULL) {
+		// \x82܂\xBE\x91S\x95\x94\x91\x97\x90M\x82ł\xAB\x82Ă\xA2\x82Ȃ\xA2
+		return;
+	}
+
+	// \x91\x97\x90M
+	for (;;) {
+		// \x8FI\x92[?
+		if (p->send_left == 0) {
+			// \x8FI\x97\xB9
+			EndPaste();
+			return;
+		}
+
+		// \x91\x97\x90M\x92\xB7
+		BOOL need_delay = FALSE;
+		size_t send_len;
+		if (p->delay_per_char > 0) {
+			// 1\x83L\x83\x83\x83\x89\x83N\x83^\x91\x97\x90M
+			need_delay = TRUE;
+			if (p->type == SendMemTypeBinary) {
+				send_len = 1;
+			}
+			else {
+				send_len = sizeof(wchar_t);
+			}
+		}
+		else if (p->delay_per_line > 0) {
+			// 1\x83\x89\x83C\x83\x93\x91\x97\x90M
+			need_delay = TRUE;
+
+			// 1\x8Ds\x8E\xE6\x82\xE8\x8Fo\x82\xB5(\x89\xFC\x8Ds\x83R\x81[\x83h\x82\xCD 0x0a \x82ɐ\xB3\x8BK\x89\xBB\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9)
+			const wchar_t *line_top = (wchar_t *)&p->send_ptr[p->send_index];
+			const wchar_t *line_end = wcschr(line_top, 0x0a);
+			if (line_end != NULL) {
+				// 0x0a \x82܂ő\x97\x90M
+				send_len = ((line_end - line_top) + 1) * sizeof(wchar_t);
+			}
+			else {
+				// \x89\xFC\x8Ds\x8C\xA9\x82‚\xA9\x82炸\x81A\x8DŌ\xE3\x82܂ő\x97\x90M
+				send_len = p->send_left;
+			}
+		}
+		else {
+			// \x91S\x97͑\x97\x90M
+			send_len = p->send_left;
+		}
+
+		// \x91\x97\x90M\x82\xB7\x82\xE9
+		const BYTE *send_ptr = (BYTE *)&p->send_ptr[p->send_index];
+		p->send_index += send_len;
+		p->send_left -= send_len;
+		size_t sended_len;
+		if (p->type == SendMemTypeBinary) {
+			sended_len = CommBinaryBuffOut(p->cv_, (PCHAR)send_ptr, (int)send_len);
+		}
+		else {
+			sended_len = CommTextOutW(p->cv_, (wchar_t *)send_ptr, (int)(send_len / sizeof(wchar_t)));
+			sended_len *= sizeof(wchar_t);
+		}
+		if ((sended_len != 0) && (p->local_echo_enable)) {
+			// \x91\x97\x90M\x82ł\xAB\x82\xBD\x95\xAAecho\x82\xB7\x82\xE9
+			size_t echo_len = sended_len;
+			size_t echoed_len;
+			if (p->type == SendMemTypeBinary) {
+				echoed_len = CommTextEcho(p->cv_, (PCHAR)send_ptr, (int)echo_len);
+			}
+			else {
+				echoed_len = CommTextEchoW(p->cv_, (wchar_t *)send_ptr, (int)(echo_len / sizeof(wchar_t)));
+				sended_len *= sizeof(wchar_t);
+			}
+			if (echoed_len != echo_len) {
+				p->send_out_retry_ptr = send_ptr + echoed_len;
+				p->send_out_retry_len = echo_len - echoed_len;
+			}
+		}
+		if (sended_len < send_len) {
+			// \x82\xB7\x82ׂđ\x97\x90M\x82ł\xAB\x82Ȃ\xA9\x82\xC1\x82\xBD
+			p->send_out_retry_ptr = send_ptr + sended_len;
+			p->send_out_retry_len = send_len - sended_len;
+		}
+		if (p->send_out_retry_ptr != NULL || p->send_echo_retry_ptr != NULL) {
+			// \x8Fo\x97͂ł\xAB\x82Ȃ\xAD\x82Ȃ\xC1\x82\xBD(\x8Fo\x97̓o\x83b\x83t\x83@\x82\xAA\x82\xA2\x82\xC1\x82ς\xA2?)
+			return;
+		}
+
+		// \x83_\x83C\x83A\x83\x8D\x83O\x8DX\x90V
+		p->dlg->RefreshNum(p->send_index, p->send_len);
+
+		if (need_delay) {
+			// wait\x82ɓ\xFC\x82\xE9
+			p->waited = TRUE;
+			p->last_send_tick = GetTickCount();
+			// \x83^\x83C\x83}\x81[\x82\xCDidle\x82𓮍삳\x82\xB9\x82邽\x82߂Ɏg\x97p\x82\xB5\x82Ă\xA2\x82\xE9
+			const DWORD delay = p->delay_per_line > 0 ? p->delay_per_line : p->delay_per_char;
+			SetTimer(p->hWnd, p->timer_id, delay, NULL);
+			break;
+		}
+	}
+}
+
+/*
+ *	\x89\xFC\x8Ds\x83R\x81[\x83h\x82\xF0LF(0x0a)\x82\xBE\x82\xAF\x82ɂ\xB7\x82\xE9
+ *
+ *	@param [in]	*src_		\x95\xB6\x8E\x9A\x97\xF1\x82ւ̃|\x83C\x83\x93\x83^
+ *	@param [in] *len		\x93\xFC\x97͕\xB6\x8E\x9A\x97\xF1\x92\xB7(0\x82̂Ƃ\xAB\x93\xE0\x95\x94\x82ŕ\xB6\x8E\x9A\x97񒷂𑪂\xE9)
+ *	@param [out] *len		\x8Fo\x97͕\xB6\x8E\x9A\x97\xF1\x92\xB7
+ *	@return					\x95ϊ\xB7\x8C㕶\x8E\x9A\x97\xF1(malloc\x82\xB3\x82ꂽ\x97̈\xE6)
+ */
+static wchar_t *NormalizeLineBreak(const wchar_t *src, size_t *len)
+{
+	size_t src_len = *len;
+	if (src_len == 0) {
+		return NULL;
+	}
+	wchar_t *dest_top = (wchar_t *)malloc(sizeof(wchar_t) * src_len);
+	if (dest_top == NULL) {
+		return NULL;
+	}
+
+	// LF(0x0a),CR(0x0d)\x82\xAA\x82\xA0\x82邩\x92\xB2\x82ׂ\xE9
+	int cr_count = 0;
+	int lf_count = 0;
+	const wchar_t *p = src;
+	for (size_t i = 0; i < src_len; i++) {
+		wchar_t c = *p++;
+		if (c == CR) {	// 0x0d
+			cr_count++;
+		} else if (c == LF) {	// 0x0d
+			lf_count++;
+		}
+	}
+
+	wchar_t *dest = dest_top;
+	if (lf_count == 0 && cr_count != 0) {
+		// LF\x82Ȃ\xB5\x81ACR\x82̂\xDD
+		// CR\x82\xF0LF\x82ɕϊ\xB7\x82\xB7\x82\xE9
+		for (size_t i = 0; i < src_len; i++) {
+			wchar_t c = *src++;
+			*dest++ = (c == CR) ? LF : c;
+		}
+	} else if (lf_count != 0 && cr_count != 0) {
+		// CR\x81ALF\x82Ƃ\xE0\x82\xA0\x82\xE8
+		// CR\x82\xF0\x8ÊĂ\xE9
+		for (size_t i = 0; i < src_len; i++) {
+			wchar_t c = *src++;
+			if (c == CR) {
+				continue;
+			}
+			*dest++ = c;
+		}
+	} else {
+		// CR\x82̂\xDD or \x89\xFC\x8Ds\x82\xAA\x91S\x82\xAD\x82Ȃ\xA2
+		// \x95ϊ\xB7\x95s\x97v
+		memcpy(dest , src, sizeof(wchar_t) * src_len);
+		dest += src_len;
+	}
+
+	*len = dest - dest_top;
+	return dest_top;
+}
+
+/**
+ *	\x83\x81\x83\x82\x83\x8A\x82ɂ\xA0\x82\xE9\x83f\x81[\x83^\x82𑗐M\x82\xB7\x82\xE9
+ *	\x83f\x81[\x83^\x82͑\x97\x90M\x8FI\x97\xB9\x8C\xE3\x82\xC9free()\x82\xB3\x82\xEA\x82\xE9
+ *
+ *	@param	ptr		\x83f\x81[\x83^\x82փ|\x83C\x83\x93\x83^(malloc()\x82\xB3\x82ꂽ\x97̈\xE6)
+ *					\x91\x97\x90M\x8C\xE3(\x92\x86\x92f\x8C\xE3)\x81A\x8E\xA9\x93\xAE\x93I\x82\xC9free()\x82\xB3\x82\xEA\x82\xE9
+ *	@param	len		\x83f\x81[\x83^\x92\xB7(byte)
+ *					\x95\xB6\x8E\x9A\x97\xF1(wchar_t)\x82̏ꍇ\x82\xE0byte\x90\x94
+ *	@param	type	\x95\xB6\x8E\x9A\x97\xF1(wchar_t,LF or CRLF or \x83o\x83C\x83i\x83\x8A)
+ */
+SendMem *SendMemInit(void *ptr, size_t len, SendMemType type)
+{
+	SendMem *p = (SendMem *)calloc(sizeof(*p), 1);
+	if (p == NULL) {
+		return NULL;
+	}
+	if (type == SendMemTypeTextCRLF || type == SendMemTypeTextLF) {
+		// \x89\xFC\x8Ds\x83R\x81[\x83h\x82𒲐\xAE\x82\xB5\x82Ă\xA8\x82\xAD
+		size_t new_len = len / sizeof(wchar_t);
+		p->send_ptr = (BYTE *)NormalizeLineBreak((wchar_t *)ptr, &new_len);
+		p->send_len = new_len * sizeof(wchar_t);
+		free(ptr);
+	} else {
+		p->send_ptr = (BYTE *)ptr;
+		p->send_len = len;
+	}
+	if (p->send_ptr == NULL) {
+		return NULL;
+	}
+	p->type = type;
+	p->local_echo_enable = FALSE;
+	p->delay_per_char = 0;  // (ms)
+	p->delay_per_line = 0;  // (ms)
+	p->cv_ = NULL;
+	p->hWnd = HVTWin;		// delay\x8E\x9E\x82Ɏg\x97p\x82\xB7\x82\xE9\x83^\x83C\x83}\x81[\x97p
+	p->timer_id = IdPasteDelayTimer;
+	p->hWndParent_ = NULL;
+	return p;
+}
+
+void SendMemInitEcho(SendMem *sm, BOOL echo)
+{
+	sm->local_echo_enable = echo;
+}
+
+void SendMemInitDelay(SendMem* sm, DWORD per_line, DWORD per_char)
+{
+	sm->delay_per_char = per_char;	// (ms)
+	sm->delay_per_line = per_line;
+}
+
+// \x83Z\x83b\x83g\x82\xB7\x82\xE9\x82ƃ_\x83C\x83A\x83\x8D\x83O\x82\xAA\x8Fo\x82\xE9
+void SendMemInitDialog(SendMem *sm, HINSTANCE hInstance, HWND hWndParent, const char *UILanguageFile)
+{
+	sm->hInst_ = hInstance;
+	sm->hWndParent_ = hWndParent;
+	sm->UILanguageFile = _strdup(UILanguageFile);
+}
+
+void SendMemInitDialogCaption(SendMem *sm, const wchar_t *caption)
+{
+	if (sm->dialog_caption != NULL)
+		free(sm->dialog_caption);
+	sm->dialog_caption = _wcsdup(caption);
+}
+
+void SendMemInitDialogFilename(SendMem *sm, const wchar_t *filename)
+{
+	if (sm->filename != NULL)
+		free(sm->filename);
+	sm->filename = _wcsdup(filename);
+}
+
+extern "C" TComVar cv;
+BOOL SendMemStart(SendMem *sm)
+{
+	// \x91\x97\x90M\x92\x86\x83`\x83F\x83b\x83N
+	if (sendmem_work != NULL) {
+		return FALSE;
+	}
+
+	sm->cv_ = &cv;		// TODO \x82Ȃ\xAD\x82\xB5\x82\xBD\x82\xA2
+	SendMemStart_i(sm);
+	return TRUE;
+}
+
+void SendMemFinish(SendMem *sm)
+{
+	free(sm->UILanguageFile);
+	free(sm);
+}

Copied: branches/unicode_buf/teraterm/teraterm/sendmem.h (from rev 8341, branches/unicode_buf/teraterm/teraterm/clipboar.h)
===================================================================
--- branches/unicode_buf/teraterm/teraterm/sendmem.h	                        (rev 0)
+++ branches/unicode_buf/teraterm/teraterm/sendmem.h	2019-10-29 13:04:33 UTC (rev 8342)
@@ -0,0 +1,59 @@
+/*
+ * (C) 2019 TeraTerm Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+#include <windows.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+	SendMemTypeTextLF,		// wchar_t 0x0a
+	SendMemTypeTextCRLF,	// wchar_t 0x0d + 0x0a
+	SendMemTypeBinary,
+} SendMemType;
+
+typedef struct SendMemTag SendMem;
+
+SendMem *SendMemInit(void *ptr, size_t len, SendMemType type);
+void SendMemInitEcho(SendMem *sm, BOOL echo);
+void SendMemInitDelay(SendMem *sm, DWORD per_line, DWORD per_char);
+void SendMemInitDialog(SendMem *sm, HINSTANCE hInstance, HWND hWndParent, const char *UILanguageFile);
+void SendMemInitDialogCaption(SendMem *sm, const wchar_t *caption);
+void SendMemInitDialogFilename(SendMem *sm, const wchar_t *filename);
+BOOL SendMemStart(SendMem *sm);		// \x91\x97\x90M\x8AJ\x8En
+void SendMemFinish(SendMem *sm);
+
+// idle\x82\xA9\x82\xE7\x82̑\x97\x90M\x97pAPI
+void SendMemContinuously(void);
+
+#ifdef __cplusplus
+}
+#endif
+

Modified: branches/unicode_buf/teraterm/teraterm/teraterm.cpp
===================================================================
--- branches/unicode_buf/teraterm/teraterm/teraterm.cpp	2019-10-29 13:04:14 UTC (rev 8341)
+++ branches/unicode_buf/teraterm/teraterm/teraterm.cpp	2019-10-29 13:04:33 UTC (rev 8342)
@@ -56,6 +56,9 @@
 #include "dlglib.h"
 #include "teraterml.h"
 #include "unicode_test.h"
+#if UNICODE_INTERNAL_BUFF
+#include "sendmem.h"
+#endif
 
 #if defined(_DEBUG) && defined(_MSC_VER)
 #define new ::new(_NORMAL_BLOCK, __FILE__, __LINE__)
@@ -206,15 +209,16 @@
 		/* Talker */
 		switch (TalkStatus) {
 		case IdTalkCB:
-#if UNICODE_INTERNAL_BUFF
-			CBSendW();
-#else
 			CBSend();
-#endif
 			break; /* clip board */
 		case IdTalkFile:
 			FileSend();
 			break; /* file */
+		case IdTalkSendMem:
+			SendMemContinuously();
+			break;
+		default:
+			break;
 		}
 
 		/* Receiver */

Modified: branches/unicode_buf/teraterm/teraterm/ttwinman.c
===================================================================
--- branches/unicode_buf/teraterm/teraterm/ttwinman.c	2019-10-29 13:04:14 UTC (rev 8341)
+++ branches/unicode_buf/teraterm/teraterm/ttwinman.c	2019-10-29 13:04:33 UTC (rev 8342)
@@ -43,7 +43,7 @@
 HWND HTEKWin = NULL;
 
 int ActiveWin = IdVT; /* IdVT, IdTEK */
-int TalkStatus = IdTalkKeyb; /* IdTalkKeyb, IdTalkCB, IdTalkTextFile */
+IdTalk TalkStatus = IdTalkKeyb; /* IdTalkKeyb, IdTalkCB, IdTalkTextFile */
 BOOL KeybEnabled = TRUE; /* keyboard switch */
 BOOL Connecting = FALSE;
 

Modified: branches/unicode_buf/teraterm/teraterm/ttwinman.h
===================================================================
--- branches/unicode_buf/teraterm/teraterm/ttwinman.h	2019-10-29 13:04:14 UTC (rev 8341)
+++ branches/unicode_buf/teraterm/teraterm/ttwinman.h	2019-10-29 13:04:33 UTC (rev 8342)
@@ -43,7 +43,8 @@
 extern HWND HVTWin;
 extern HWND HTEKWin;
 extern int ActiveWin; /* IdVT, IdTEK */
-extern int TalkStatus; /* IdTalkKeyb, IdTalkCB, IdTalkTextFile */
+//extern int TalkStatus; /* IdTalkKeyb, IdTalkCB, IdTalkTextFile */
+extern IdTalk TalkStatus;
 extern BOOL KeybEnabled; /* keyboard switch */
 extern BOOL Connecting;
 

Modified: branches/unicode_buf/teraterm/teraterm/vtterm.c
===================================================================
--- branches/unicode_buf/teraterm/teraterm/vtterm.c	2019-10-29 13:04:14 UTC (rev 8341)
+++ branches/unicode_buf/teraterm/teraterm/vtterm.c	2019-10-29 13:04:33 UTC (rev 8342)
@@ -4961,11 +4961,7 @@
 				}
 				strncpy_s(hdr, sizeof(hdr), "\033]52;", _TRUNCATE);
 				if (strncat_s(hdr, sizeof(hdr), buff, p - buff) == 0) {
-#if UNICODE_INTERNAL_BUFF
-					CBStartPasteB64W(HVTWin, hdr, "\033\\");
-#else
 					CBStartPasteB64(HVTWin, hdr, "\033\\");
-#endif
 				}
 			}
 			else if (ts.NotifyClipboardAccess) {

Modified: branches/unicode_buf/teraterm/teraterm/vtwin.cpp
===================================================================
--- branches/unicode_buf/teraterm/teraterm/vtwin.cpp	2019-10-29 13:04:14 UTC (rev 8341)
+++ branches/unicode_buf/teraterm/teraterm/vtwin.cpp	2019-10-29 13:04:33 UTC (rev 8342)
@@ -91,6 +91,8 @@
 #endif
 #include "codeconv.h"
 #include "layer_for_unicode.h"
+#include "sendmem.h"
+#include "../ttpmacro/fileread.h"
 
 #include "initguid.h"
 //#include "Usbiodef.h"
@@ -869,11 +871,8 @@
 	}
 
 	if (Paste) {
-#if UNICODE_INTERNAL_BUFF
-		CBStartPasteW(HVTWin, FALSE, BracketedPasteMode());
-#else
 		CBStartPaste(HVTWin, FALSE, BracketedPasteMode());
-#endif
+
 		// \x83X\x83N\x83\x8D\x81[\x83\x8B\x88ʒu\x82\xF0\x83\x8A\x83Z\x83b\x83g
 		if (WinOrgY != 0) {
 			DispVScroll(SCROLL_BOTTOM, 0);
@@ -4224,7 +4223,57 @@
 void CVTWindow::OnFileSend()
 {
 	HelpId = HlpFileSend;
+#if !UNICODE_INTERNAL_BUFF
 	FileSendStart();
+#else
+	{
+		char TempDir[MAXPATHLEN];
+		GetCurrentDirectory(sizeof(TempDir), TempDir);
+
+		char file_name[MAX_PATH];
+		file_name[0] = 0;
+		OPENFILENAME ofn;
+		memset(&ofn, 0, sizeof(OPENFILENAME));
+		ofn.lStructSize = get_OPENFILENAME_SIZE();
+		ofn.lStructSize = sizeof(ofn);
+		ofn.hwndOwner   = m_hWnd;
+		ofn.lpstrFile = file_name;
+		ofn.nMaxFile = sizeof(file_name);
+		ofn.nMaxFile = MAX_PATH;
+		ofn.lpstrFilter = 	TEXT("Text files {*.txt}\0*.txt\0")
+			TEXT("HTML files {*.htm}\0*.htm;*.html\0")
+			TEXT("All files {*.*}\0*.*\0\0");
+		ofn.nFilterIndex = 0;
+		ofn.lpstrTitle = "test";
+		ofn.Flags = OFN_FILEMUSTEXIST;
+		BOOL Ok = GetOpenFileName(&ofn);
+		DWORD err = GetLastError();
+
+		SetCurrentDirectory(TempDir);
+
+		if (Ok == FALSE) {
+			return;
+		}
+
+		size_t str_len;
+		wchar_t *str_ptr = LoadFileWA(file_name, &str_len);
+		if (str_ptr == NULL) {
+			return;
+		}
+		str_len *= sizeof(wchar_t);
+
+		{
+			SendMem *sm = SendMemInit(str_ptr, str_len, SendMemTypeTextLF);
+			SendMemInitDelay(sm, 10, 0);
+			SendMemInitDialog(sm, hInst, HVTWin, ts.UILanguageFile);
+			SendMemInitDialogCaption(sm, L"send file");
+			wchar_t *file_name_w = ToWcharA(file_name);
+			SendMemInitDialogFilename(sm, file_name_w);
+			free(file_name_w);
+			SendMemStart(sm);
+		}
+	}
+#endif
 }
 
 void CVTWindow::OnFileKermitRcv()
@@ -4376,12 +4425,9 @@
 
 void CVTWindow::OnEditPaste()
 {
-#if UNICODE_INTERNAL_BUFF
-	CBStartPasteW(HVTWin, FALSE, BracketedPasteMode());
-#else
 	// add confirm (2008.2.4 yutaka)
 	CBStartPaste(HVTWin, FALSE, BracketedPasteMode());
-#endif
+
 	// \x83X\x83N\x83\x8D\x81[\x83\x8B\x88ʒu\x82\xF0\x83\x8A\x83Z\x83b\x83g
 	if (WinOrgY != 0) {
 		DispVScroll(SCROLL_BOTTOM, 0);
@@ -4390,12 +4436,9 @@
 
 void CVTWindow::OnEditPasteCR()
 {
-#if UNICODE_INTERNAL_BUFF
-	CBStartPasteW(HVTWin, TRUE, BracketedPasteMode());
-#else
 	// add confirm (2008.3.11 maya)
 	CBStartPaste(HVTWin, TRUE, BracketedPasteMode());
-#endif
+
 	// \x83X\x83N\x83\x8D\x81[\x83\x8B\x88ʒu\x82\xF0\x83\x8A\x83Z\x83b\x83g
 	if (WinOrgY != 0) {
 		DispVScroll(SCROLL_BOTTOM, 0);
@@ -5557,7 +5600,7 @@
  * \x83u\x83\x8D\x81[\x83h\x83L\x83\x83\x83X\x83g\x91\x97\x90M\x82\xF0\x8Ds\x82\xA2\x81A\x8E\xF3\x90M\x91\xA4\x82Ń\x81\x83b\x83Z\x81[\x83W\x82\xF0\x8E\xE6\x8ȆI\x91\xF0\x82\xB7\x82\xE9\x81B
  * "sendmulticast"\x83}\x83N\x83\x8D\x83R\x83}\x83\x93\x83h\x82\xA9\x82\xE7\x82̂ݗ\x98\x97p\x82\xB3\x82\xEA\x82\xE9\x81B
  */
-void SendMulticastMessage(HWND HVTWin, HWND hWnd, char *name, char *buf, int buflen)
+void SendMulticastMessage(HWND hVTWin_, HWND hWnd, char *name, char *buf, int buflen)
 {
 	int i, count;
 	HWND hd;
@@ -5597,7 +5640,7 @@
 		}
 
 		// WM_COPYDATA\x82\xF0\x8Eg\x82\xC1\x82āA\x83v\x83\x8D\x83Z\x83X\x8AԒʐM\x82\xF0\x8Ds\x82\xA4\x81B
-		SendMessage(hd, WM_COPYDATA, (WPARAM)HVTWin, (LPARAM)&cds);
+		SendMessage(hd, WM_COPYDATA, (WPARAM)hVTWin_, (LPARAM)&cds);
 	}
 
 	free(msg);
@@ -6043,6 +6086,11 @@
 
 	// \x96\xA2\x91\x97\x90M\x83f\x81[\x83^\x82\xAA\x82\xA0\x82\xE9\x8Fꍇ\x82͐\xE6\x82ɑ\x97\x90M\x82\xB7\x82\xE9
 	// \x83f\x81[\x83^\x97ʂ\xAA\x91\xBD\x82\xA2\x8Fꍇ\x82͑\x97\x90M\x82\xB5\x82\xAB\x82\xEA\x82Ȃ\xA2\x89”\\x90\xAB\x82\xAA\x82\xA0\x82\xE9
+#if	UNICODE_INTERNAL_BUFF
+	if (TalkStatus == IdTalkSendMem) {
+		SendMemContinuously();
+	}
+#endif
 	if (TalkStatus == IdTalkCB) {
 		CBSend();
 	}

Modified: branches/unicode_buf/teraterm/ttptek/CMakeLists.txt
===================================================================
--- branches/unicode_buf/teraterm/ttptek/CMakeLists.txt	2019-10-29 13:04:14 UTC (rev 8341)
+++ branches/unicode_buf/teraterm/ttptek/CMakeLists.txt	2019-10-29 13:04:33 UTC (rev 8342)
@@ -1,8 +1,5 @@
 project(ttptek)
 
-include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_oniguruma.cmake)
-include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_SFMT.cmake)
-
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/")
 
 set(COMMON_SRC
@@ -32,14 +29,8 @@
 
 include_directories(
   ${CMAKE_CURRENT_SOURCE_DIR}/../common
-  ${ONIGURUMA_INCLUDE}
-  ${SFMT_INCLUDE_DIR}
   )
 
-link_directories(
-  ${SFMT_LIBRARY_DIRS}
-  )
-
 add_library(
   ttptek SHARED
   ${SRC}
@@ -56,8 +47,6 @@
 target_link_libraries(
   ttptek
   ttpcmn
-  debug sfmtd
-  optimized sfmt
   #
   iphlpapi
   gdi32


Ttssh2-commit メーリングリストの案内