From 0c7b5719cf246d1d47f8d16b708605a32d836678 Mon Sep 17 00:00:00 2001 From: zmatsuo <6488847+zmatsuo@users.noreply.github.com> Date: Wed, 27 Nov 2024 01:09:44 +0900 Subject: [PATCH] =?UTF-8?q?Send=20File=E3=83=80=E3=82=A4=E3=82=A2=E3=83=AD?= =?UTF-8?q?=E3=82=B0=E3=81=AE=E3=82=AA=E3=83=97=E3=82=B7=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E3=82=92=E8=A8=98=E6=86=B6=20#380?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Send Fileダイアログ - send size を dropdownlist から dropdown に変更した - コントロールを enable/disable するようにした - help/cancel/ok ボタンの順序を修正 - ファイル名長制限をなくした(MAX_PATH を使用しなくなった) - ini ファイルにファイル送信のパラメータを追加 --- doc/en/html/about/history.html | 1 + doc/en/html/menu/file-sendfile.html | 18 ++- doc/en/html/setup/teraterm-ini.html | 32 ++++- doc/en/html/setup/teraterm-trans.html | 19 +++ doc/en/html/setup/teraterm.html | 1 + doc/ja/html/about/history.html | 1 + doc/ja/html/menu/file-sendfile.html | 18 ++- doc/ja/html/setup/teraterm-ini.html | 32 ++++- doc/ja/html/setup/teraterm-trans.html | 20 +++ doc/ja/html/setup/teraterm.html | 1 + installer/release/TERATERM.INI | 12 ++ teraterm/common/i18n.h | 3 +- teraterm/common/i18n_static.c | 48 +++++-- teraterm/common/ttlib_static_cpp.cpp | 10 +- teraterm/common/tttypes.h | 5 + teraterm/teraterm/filesys.cpp | 4 + teraterm/teraterm/sendfiledlg.cpp | 183 ++++++++++++++++---------- teraterm/teraterm/sendfiledlg.h | 19 ++- teraterm/teraterm/ttermpro.rc | 21 +-- teraterm/teraterm/vtwin.cpp | 25 +++- teraterm/ttpset/ttset.c | 23 ++++ 21 files changed, 379 insertions(+), 117 deletions(-) diff --git a/doc/en/html/about/history.html b/doc/en/html/about/history.html index 5184414ea..246f5ea7b 100644 --- a/doc/en/html/about/history.html +++ b/doc/en/html/about/history.html @@ -51,6 +51,7 @@

YYYY.MM.DD (Ver 5.4 not released yet)

  • All available character codes can be specified using command line options.
  • Supports "COM%d" style serial ports of com0com (virtual serial port driver), which are not Ports class.
  • Changed initial directory for file select dialog of send file to File transfer folder.
  • +
  • SendFile options are saved in TERATERM.INI.
  • diff --git a/doc/en/html/menu/file-sendfile.html b/doc/en/html/menu/file-sendfile.html index 519006051..ae2590668 100644 --- a/doc/en/html/menu/file-sendfile.html +++ b/doc/en/html/menu/file-sendfile.html @@ -22,7 +22,7 @@

    "Send file" dialog box (to input the file name)

    By dropping a file into dialog, You can also enter file name. -
    Send in same way as Tera Term 4
    +
    Send in same way as Tera Term 4
    Checked(same way as Tera Term 4)
    @@ -38,14 +38,14 @@

    "Send file" dialog box (to input the file name)

    -
    Binary
    +
    Binary
    If you select this option, received characters are sent without any modifications. Otherwise, new-line codes are converted and control characters (except TAB, LF and CR) are stripped out.
    -
    delay type
    +
    delay type
    no delay
    @@ -71,17 +71,25 @@

    "Send file" dialog box (to input the file name)

    -
    send size
    +
    send size
    Send size (valid when delay type is "per sendsize")
    -
    delay time(ms)
    +
    delay time(ms)
    Delay time (valid when delay type is not "no delay")
    +

    Special options in the Tera Term setup file

    + See also the following settings + + +

    Send size

    diff --git a/doc/en/html/setup/teraterm-ini.html b/doc/en/html/setup/teraterm-ini.html index d23b5acf3..40a72b179 100644 --- a/doc/en/html/setup/teraterm-ini.html +++ b/doc/en/html/setup/teraterm-ini.html @@ -1069,6 +1069,36 @@

    Tera Term

    <- + + SendfileDelayTick + 0 + <- + + + + SendfileDelayType + NoDelay + <- + + + + SendfileMethod4 + off + <- + + + + SendfileSize + 4096 + <- + + + + SendfileSkipOptionDialog + off + <- + + ScpSendDir @@ -1298,7 +1328,7 @@

    Tera Term

    - TransBin + TransBin off <- diff --git a/doc/en/html/setup/teraterm-trans.html b/doc/en/html/setup/teraterm-trans.html index a3f556748..11594fee1 100644 --- a/doc/en/html/setup/teraterm-trans.html +++ b/doc/en/html/setup/teraterm-trans.html @@ -483,5 +483,24 @@

    High Speed File Transfer on Serial Connection

    +

    Skip Send file dialog

    + +

    +When [File]-[Send file...] is selected, Send file dialog box appears.
    +If same options are always used, you can send files only by file selection. +

    + +
    +SendfileSkipOptionDialog=on
    +
    + +
    +default:
    +SendfileSkipOptionDialog=off
    +
    + +When [File]-[Send file...] is selected with holding down CTRL key, +You can temporarily switch on/off behavior. + diff --git a/doc/en/html/setup/teraterm.html b/doc/en/html/setup/teraterm.html index f5d5a608e..c5ddae6a3 100644 --- a/doc/en/html/setup/teraterm.html +++ b/doc/en/html/setup/teraterm.html @@ -148,6 +148,7 @@

    File transfer

  • Confirmation of File Transfer by Drag & Drop
  • File Transfer Dialog is hidden
  • High Speed File Transfer on Serial Connection
  • +
  • Skip Send file dialog
  • Printing

    diff --git a/doc/ja/html/about/history.html b/doc/ja/html/about/history.html index 532492ca7..f29db8886 100644 --- a/doc/ja/html/about/history.html +++ b/doc/ja/html/about/history.html @@ -51,6 +51,7 @@

    YYYY.MM.DD (Ver 5.4 not released yet)

  • R}hCIvVŎgp”\R[hSĎwł悤ɂB
  • com0com(virtual serial port driver) Ports class ł͂Ȃ "COM%d" `̃VA|[gIł悤ɂB
  • Mt@CI_CAȌfBNgt@C]p̃tH_ɂȂ悤ɂB
  • +
  • t@CMIvVTERATERM.INIɕۑ悤ɂB
  • diff --git a/doc/ja/html/menu/file-sendfile.html b/doc/ja/html/menu/file-sendfile.html index 436d7e4d5..0b8418c6d 100644 --- a/doc/ja/html/menu/file-sendfile.html +++ b/doc/ja/html/menu/file-sendfile.html @@ -22,7 +22,7 @@ _CAOɃt@Chbv邱ƂŃt@C͂邱Ƃł܂B -
    Tera Term 4 Ɠ@őM
    +
    Tera Term 4 Ɠ@őM
    `FbNꂽƂ(Tera Term 4 Ɠ@)
    @@ -38,14 +38,14 @@
    -
    Binary
    +
    Binary
    t@C̓ê܂ܑMꍇ͑IĂB IȂꍇ́AR[hAsϊđMA TAB ($09), LF ($0A), CR ($0D)ȊO̐䕶͑M܂B
    -
    delay type
    +
    delay type
    no delay
    @@ -71,17 +71,25 @@
    -
    send size
    +
    send size
    MTCY(delay type "per sendsize"̂ƂL)
    -
    delay time(ms)
    +
    delay time(ms)
    fBC(delay type "no delay"ȊÔƂL)
    +

    ݒt@C̓ʃIvV

    + ̐ݒQƂ + + +

    MTCY

    diff --git a/doc/ja/html/setup/teraterm-ini.html b/doc/ja/html/setup/teraterm-ini.html index 7789e8771..ab8771158 100644 --- a/doc/ja/html/setup/teraterm-ini.html +++ b/doc/ja/html/setup/teraterm-ini.html @@ -1069,6 +1069,36 @@

    Tera Term

    <- + + SendfileDelayTick + 0 + <- + + + + SendfileDelayType + NoDelay + <- + + + + SendfileMethod4 + off + <- + + + + SendfileSize + 4096 + <- + + + + SendfileSkipOptionDialog + off + <- + + ScpSendDir @@ -1298,7 +1328,7 @@

    Tera Term

    - TransBin + TransBin off <- diff --git a/doc/ja/html/setup/teraterm-trans.html b/doc/ja/html/setup/teraterm-trans.html index 50aaf8ba5..b5240d116 100644 --- a/doc/ja/html/setup/teraterm-trans.html +++ b/doc/ja/html/setup/teraterm-trans.html @@ -523,5 +523,25 @@ +

    t@CM_CAOXLbv

    + +

    +([File]-[Send file...])IAt@CM_CAO\܂B
    +‚ݒgpꍇ́Â悤ɐݒ肷邱ƂŃt@CÎ݂Ńt@C𑗐Mł܂B +

    + +
    +SendfileSkipOptionDialog=on
    +
    + +
    +ȗ:
    +SendfileSkipOptionDialog=off
    +
    + +CTRLL[Ȃ[File]-[Send file...]I邱ƂŁA +̐ݒon/offւsƂł܂B + + diff --git a/doc/ja/html/setup/teraterm.html b/doc/ja/html/setup/teraterm.html index 41f63df36..838c84ffc 100644 --- a/doc/ja/html/setup/teraterm.html +++ b/doc/ja/html/setup/teraterm.html @@ -120,6 +120,7 @@
  • hbO&hbvɂt@CM̊mF
  • t@CM̓]󋵃_CAO\Ȃ
  • VAڑɂ鍂ȃt@C]
  • +
  • t@CM_CAOXLbv
  • diff --git a/installer/release/TERATERM.INI b/installer/release/TERATERM.INI index babc7d445..fc36e85e5 100644 --- a/installer/release/TERATERM.INI +++ b/installer/release/TERATERM.INI @@ -395,6 +395,15 @@ AcceptBroadcast=on ; Number of broadcast command history MaxBroadcatHistory=99 +; Sendfile DelayType NoDelay/PerChar/PerLine/PerSendSize +SendfileDelayType=NoDelay +; Sendfile Delay (ms) +SendfileDelayTick=0 +; Sendfile size when PerSendSize +SendfileSize=4096 +; Sendfile use Tera Term 4 Method +SendfileMethod4=off + ;------ special options (see Tera Term help) ; C1 (8-bit) control characters @@ -793,6 +802,9 @@ IniAutoBackup=on ; Wait time (ms) when Beep is Visual Bell BeepVBellWait=10 +; skip SendFile dialog +SendfileSkipOptionDialog=off + ;------ end of special options ; Unicode diff --git a/teraterm/common/i18n.h b/teraterm/common/i18n.h index 6f5048803..cc3facf0f 100644 --- a/teraterm/common/i18n.h +++ b/teraterm/common/i18n.h @@ -49,6 +49,7 @@ typedef struct { typedef struct { const char *key; // NULL̏ꍇ͏default_text gp const wchar_t *default_text; // key == NULL && default_text == NULL̏ꍇI[ + uintptr_t data; } I18nTextInfo; DllExport size_t WINAPI GetI18nStrW(const char *section, const char *key, wchar_t *buf, int buf_len, const wchar_t *def, const char *iniFile); @@ -76,7 +77,7 @@ void SetI18nMenuStrsW(HMENU hMenu, const char *section, const DlgTextInfo *infos void SetI18nMenuStrsA(HMENU hMenu, const char *section, const DlgTextInfo *infos, size_t infoCount, const char *UILanguageFile); void SetI18nListW(const char *section, HWND hDlg, int nIDDlgItem, const I18nTextInfo *infos, size_t infoCount, - const wchar_t *UILanguageFile, int nsel); + const wchar_t *UILanguageFile, uintptr_t nsel); void SetI18nList(const char *section, HWND hDlg, int nIDDlgItem, const I18nTextInfo *infos, size_t infoCount, const char *UILanguageFile, int nsel); int GetI18nLogfontAW(const char *section, const char *key, PLOGFONTA logfont, int ppi, const wchar_t *iniFile); diff --git a/teraterm/common/i18n_static.c b/teraterm/common/i18n_static.c index d5fbafd77..032a15857 100644 --- a/teraterm/common/i18n_static.c +++ b/teraterm/common/i18n_static.c @@ -121,28 +121,36 @@ void GetI18nStrU8(const char *section, const char *key, char *buf, int buf_len, * @param[in] I18nTextInfo eLXg * @param[in] infoCount eLXg * @param[in] UILanguageFile lng file - * @param[in] nsel CB_SETCURSEL ̈Ɠ - * -1 I - * 0` I + * @param[in] nsel I18nTextInfo data oZbgĂȂƂ + * CB_SETCURSEL ̈Ɠ + * -1 I + * 0` I + * I18nTextInfo data oZbgĂƂ + * data ̒lƓACeI + * lȂƂAŏ̒lI */ void SetI18nListW(const char *section, HWND hDlg, int nIDDlgItem, const I18nTextInfo *infos, size_t infoCount, - const wchar_t *UILanguageFile, int nsel) + const wchar_t *UILanguageFile, uintptr_t nsel) { UINT ADDSTRING; UINT SETCURSEL; + UINT SETITEMDATA; size_t i; char ClassName[32]; int r = GetClassNameA(GetDlgItem(hDlg, nIDDlgItem), ClassName, _countof(ClassName)); assert(r != 0); (void)r; + BOOL data_available = TRUE; if (strcmp(ClassName, "ListBox") == 0) { ADDSTRING = LB_ADDSTRING; + SETITEMDATA = LB_SETITEMDATA; SETCURSEL = LB_SETCURSEL; } else { // "ComboBox" ADDSTRING = CB_ADDSTRING; + SETITEMDATA = CB_SETITEMDATA; SETCURSEL = CB_SETCURSEL; } @@ -155,19 +163,39 @@ void SetI18nListW(const char *section, HWND hDlg, int nIDDlgItem, const I18nText infoCount = i; } + // dataɒlĂ? for (i = 0; i < infoCount; i++) { - if (infos->key != NULL) { + if (infos[i].data != 0) { + data_available = TRUE; + } + } + + for (i = 0; i < infoCount; i++) { + LRESULT index; + if (infos[i].key != NULL) { wchar_t *uimsg; - GetI18nStrWW(section, infos->key, infos->default_text, UILanguageFile, &uimsg); - SendDlgItemMessageW(hDlg, nIDDlgItem, ADDSTRING, 0, (LPARAM)uimsg); + GetI18nStrWW(section, infos[i].key, infos[i].default_text, UILanguageFile, &uimsg); + index = SendDlgItemMessageW(hDlg, nIDDlgItem, ADDSTRING, 0, (LPARAM)uimsg); free(uimsg); } else { - SendDlgItemMessageW(hDlg, nIDDlgItem, ADDSTRING, 0, (LPARAM)infos->default_text); + index = SendDlgItemMessageW(hDlg, nIDDlgItem, ADDSTRING, 0, (LPARAM)infos[i].default_text); } - infos++; + SendDlgItemMessageA(hDlg, nIDDlgItem, SETITEMDATA, index, infos[i].data); } - SendDlgItemMessageA(hDlg, nIDDlgItem, SETCURSEL, nsel, 0); + + if (data_available) { + uintptr_t sel = 0; + for (i = 0; i < infoCount; i++) { + if (infos[i].data == nsel) { + sel = i; + break; + } + } + nsel = sel; + } + + SendDlgItemMessageA(hDlg, nIDDlgItem, SETCURSEL, (WPARAM)nsel, 0); } void SetI18nList(const char *section, HWND hDlg, int nIDDlgItem, const I18nTextInfo *infos, size_t infoCount, diff --git a/teraterm/common/ttlib_static_cpp.cpp b/teraterm/common/ttlib_static_cpp.cpp index c88acc607..2d75acdab 100644 --- a/teraterm/common/ttlib_static_cpp.cpp +++ b/teraterm/common/ttlib_static_cpp.cpp @@ -1303,12 +1303,12 @@ BOOL IsRelativePathW(const wchar_t *path) return TRUE; } -BOOL IsRelativePathA(const char *path) +BOOL IsRelativePathA(const char *pathA) { - if (path[0] == '\\' || path[0] == '/' || (path[0] != '\0' && path[1] == ':')) { - return FALSE; - } - return TRUE; + wchar_t *pathW = ToWcharA(pathA); + BOOL r = IsRelativePathW(pathW); + free(pathW); + return r; } // OS w肳ꂽo[WƓ ǂ𔻕ʂB diff --git a/teraterm/common/tttypes.h b/teraterm/common/tttypes.h index bef8e3588..7366a7667 100644 --- a/teraterm/common/tttypes.h +++ b/teraterm/common/tttypes.h @@ -611,6 +611,11 @@ struct tttset { wchar_t *ViewlogEditorW; wchar_t *ViewlogEditorArg; int BeepVBellWait; + WORD SendfileDelayType; + WORD SendfileDelayTick; + DWORD SendfileSize; + WORD SendfileMethod4; + WORD SendfileSkipOptionDialog; // Experimental BYTE ExperimentalTreePropertySheetEnable; diff --git a/teraterm/teraterm/filesys.cpp b/teraterm/teraterm/filesys.cpp index a09112d1a..800181acf 100644 --- a/teraterm/teraterm/filesys.cpp +++ b/teraterm/teraterm/filesys.cpp @@ -170,6 +170,10 @@ static void FreeFileVar(PFileVar *pfv) /** * t@CM + * Tera Term 4 ̃t@CM + * + * @param filename t@C + * @param binaryy 0/1 = text / binary */ BOOL FileSendStart(const wchar_t *filename, int binary) { diff --git a/teraterm/teraterm/sendfiledlg.cpp b/teraterm/teraterm/sendfiledlg.cpp index 94ad31089..95026d8a6 100644 --- a/teraterm/teraterm/sendfiledlg.cpp +++ b/teraterm/teraterm/sendfiledlg.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include "i18n.h" #include "tt_res.h" @@ -41,10 +40,10 @@ #include "dlglib.h" #include "tttypes.h" // for WM_USER_DLGHELP2 #include "helpid.h" -#include "codeconv.h" #include "asprintf.h" #include "win32helper.h" #include "tipwin2.h" +#include "sendmem.h" #include "sendfiledlg.h" @@ -55,26 +54,79 @@ typedef struct { UINT MsgDlgHelp; } SendFileDlgWork_t; +static void ArrangeControls(HWND hDlgWnd) +{ + LRESULT index = SendDlgItemMessageA(hDlgWnd, IDC_SENDFILE_DELAYTYPE_DROPDOWN, CB_GETCURSEL, 0, 0); + SendMemDelayType sel = (SendMemDelayType)SendDlgItemMessageA(hDlgWnd, IDC_SENDFILE_DELAYTYPE_DROPDOWN, CB_GETITEMDATA, (WPARAM)index, 0); + + if (IsDlgButtonChecked(hDlgWnd, IDC_SENDFILE_CHECK_4) == BST_CHECKED) { + EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_DELAYTYPE_LABEL), FALSE); + EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_DELAYTYPE_DROPDOWN), FALSE); + EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_SEND_SIZE_LABEL), FALSE); + EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_SEND_SIZE_DROPDOWN), FALSE); + EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_DELAYTIME_LABEL), FALSE); + EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_DELAYTIME_EDIT), FALSE); + } + else { + EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_DELAYTYPE_LABEL), TRUE); + EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_DELAYTYPE_DROPDOWN), TRUE); + BOOL enable = (sel == SENDMEM_DELAYTYPE_PER_SENDSIZE) ? TRUE : FALSE; + EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_SEND_SIZE_LABEL), enable); + EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_SEND_SIZE_DROPDOWN), enable); + enable = (sel == SENDMEM_DELAYTYPE_NO_DELAY) ? FALSE : TRUE; + EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_DELAYTIME_LABEL), enable); + EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_DELAYTIME_EDIT), enable); + } +} + +static BOOL SelectFile(HWND hDlgWnd, const sendfiledlgdata *data, const wchar_t *filename_ini, wchar_t **filename) +{ + wchar_t *uimsg; + GetI18nStrWW("Tera Term", "FILEDLG_TRANS_TITLE_SENDFILE", L"Send file", data->UILanguageFileW, &uimsg); + wchar_t *title; + aswprintf(&title, L"Tera Term: %s", uimsg); + free(uimsg); + uimsg = NULL; + + wchar_t *filterW = GetCommonDialogFilterWW(data->filesend_filter, data->UILanguageFileW); + + TTOPENFILENAMEW ofn = {}; + ofn.hwndOwner = hDlgWnd; + ofn.lpstrFilter = filterW; + ofn.nFilterIndex = 0; + ofn.lpstrTitle = title; + ofn.lpstrFile = filename_ini; // t@C + ofn.lpstrInitialDir = data->initial_dir; // tH_ + ofn.Flags = OFN_FILEMUSTEXIST | OFN_SHOWHELP | OFN_HIDEREADONLY; + BOOL Ok = TTGetOpenFileNameW(&ofn, filename); + + free(filterW); + free(title); + + return Ok; +} + static INT_PTR CALLBACK SendFileDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp) { static const DlgTextInfo TextInfos[] = { - {0, "FILEDLG_TRANS_TITLE_SENDFILE"}, - {IDC_SENDFILE_FILENAME_TITLE, "DLG_SENDFILE_FILENAME_TITLE"}, - {IDC_SENDFILE_CHECK_BINARY, "DLG_FOPT_BINARY"}, - {IDC_SENDFILE_DELAYTYPE_LABEL, "DLG_SENDFILE_DELAYTYPE_TITLE"}, - {IDC_SENDFILE_SEND_SIZE_LABEL, "DLG_SENDFILE_SEND_SIZE_TITLE"}, - {IDC_SENDFILE_DELAYTIME_LABEL, "DLG_SENDFILE_DELAYTIME_TITLE"}, - {IDC_SENDFILE_CHECK_4, "DLG_SENDFILE_TERATERM4"}, - {IDCANCEL, "BTN_CANCEL"}, - {IDOK, "BTN_OK"}, + { 0, "FILEDLG_TRANS_TITLE_SENDFILE" }, + { IDC_SENDFILE_FILENAME_TITLE, "DLG_SENDFILE_FILENAME_TITLE" }, + { IDC_SENDFILE_CHECK_BINARY, "DLG_FOPT_BINARY" }, + { IDC_SENDFILE_DELAYTYPE_LABEL, "DLG_SENDFILE_DELAYTYPE_TITLE" }, + { IDC_SENDFILE_SEND_SIZE_LABEL, "DLG_SENDFILE_SEND_SIZE_TITLE" }, + { IDC_SENDFILE_DELAYTIME_LABEL, "DLG_SENDFILE_DELAYTIME_TITLE" }, + { IDC_SENDFILE_CHECK_4, "DLG_SENDFILE_TERATERM4" }, + { IDHELP, "BTN_HELP" }, + { IDCANCEL, "BTN_CANCEL" }, + { IDOK, "BTN_OK" }, }; static const I18nTextInfo delaytype_list[] = { - {"DLG_SENDFILE_DELAYTYPE_NO_DELAY", L"no delay"}, - {"DLG_SENDFILE_DELAYTYPE_PER_CHAR", L"per character"}, - {"DLG_SENDFILE_DELAYTYPE_PER_LINE", L"per line"}, - {"DLG_SENDFILE_DELAYTYPE_PER_SENDSIZE", L"per sendsize"}, + { "DLG_SENDFILE_DELAYTYPE_NO_DELAY", L"no delay", SENDMEM_DELAYTYPE_NO_DELAY }, + { "DLG_SENDFILE_DELAYTYPE_PER_CHAR", L"per character", SENDMEM_DELAYTYPE_PER_CHAR }, + { "DLG_SENDFILE_DELAYTYPE_PER_LINE", L"per line", SENDMEM_DELAYTYPE_PER_LINE }, + { "DLG_SENDFILE_DELAYTYPE_PER_SENDSIZE", L"per sendsize", SENDMEM_DELAYTYPE_PER_SENDSIZE }, }; - static const int send_size_list[] = {16, 256, 4 * 1024}; + static const size_t send_size_list[] = {16, 256, 4 * 1024}; SendFileDlgWork_t *work = (SendFileDlgWork_t *)GetWindowLongPtr(hDlgWnd, DWLP_USER); sendfiledlgdata *data = work != NULL ? work->create_param : NULL; @@ -90,19 +142,25 @@ static INT_PTR CALLBACK SendFileDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARA CenterWindow(hDlgWnd, GetParent(hDlgWnd)); SetI18nListW("Tera Term", hDlgWnd, IDC_SENDFILE_DELAYTYPE_DROPDOWN, delaytype_list, _countof(delaytype_list), - data->UILanguageFileW, 0); + data->UILanguageFileW, data->delay_type); + + if (data->initial_file != NULL) { + SetDlgItemTextW(hDlgWnd, IDC_SENDFILE_FILENAME_EDIT, data->initial_file); + } + // MTCY for (size_t i = 0; i < _countof(send_size_list); i++) { char buf[32]; - sprintf(buf, "%d", send_size_list[i]); + sprintf(buf, "%lu", (unsigned long)send_size_list[i]); SendDlgItemMessageA(hDlgWnd, IDC_SENDFILE_SEND_SIZE_DROPDOWN, CB_ADDSTRING, 0, (LPARAM)buf); } - SendDlgItemMessage(hDlgWnd, IDC_SENDFILE_SEND_SIZE_DROPDOWN, CB_SETCURSEL, _countof(send_size_list) - 1, 0); + SetDlgNum(hDlgWnd, IDC_SENDFILE_SEND_SIZE_DROPDOWN, (LONG)data->send_size); - SetDlgItemTextA(hDlgWnd, IDC_SENDFILE_DELAYTIME_EDIT, "1"); + SetDlgNum(hDlgWnd, IDC_SENDFILE_DELAYTIME_EDIT, data->delay_tick); + CheckDlgButton(hDlgWnd, IDC_SENDFILE_CHECK_BINARY, data->binary ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hDlgWnd, IDC_SENDFILE_CHECK_4, data->method_4 ? BST_CHECKED : BST_UNCHECKED); - EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_SEND_SIZE_DROPDOWN), FALSE); - EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_DELAYTIME_EDIT), FALSE); + ArrangeControls(hDlgWnd); TipWin2 *tip = TipWin2Create(NULL, hDlgWnd); work->tip = tip; @@ -112,8 +170,6 @@ static INT_PTR CALLBACK SendFileDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARA TipWin2SetTextW(tip, IDC_SENDFILE_CHECK_4, text); free(text); } - //TipWin2SetTextW(tip, IDC_SENDFILE_FILENAME_EDIT, L"t@C"); // test - //TipWin2SetTextW(tip, IDC_SENDFILE_FILENAME_BUTTON, L"t@CI"); // test return TRUE; } @@ -146,14 +202,12 @@ static INT_PTR CALLBACK SendFileDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARA } data->filename = filename; - data->binary = - SendMessage(GetDlgItem(hDlgWnd, IDC_SENDFILE_CHECK_BINARY), BM_GETCHECK, 0, 0) == BST_CHECKED - ? TRUE - : FALSE; - data->delay_type = (int)SendDlgItemMessage(hDlgWnd, IDC_SENDFILE_DELAYTYPE_DROPDOWN, CB_GETCURSEL, 0, 0); + data->binary = IsDlgButtonChecked(hDlgWnd, IDC_SENDFILE_CHECK_BINARY) == BST_CHECKED ? TRUE : FALSE; + LRESULT index = SendDlgItemMessageA(hDlgWnd, IDC_SENDFILE_DELAYTYPE_DROPDOWN, CB_GETCURSEL, 0, 0); + data->delay_type = (SendMemDelayType)SendDlgItemMessageA(hDlgWnd, IDC_SENDFILE_DELAYTYPE_DROPDOWN, CB_GETITEMDATA, (WPARAM)index, 0); data->delay_tick = GetDlgItemInt(hDlgWnd, IDC_SENDFILE_DELAYTIME_EDIT, NULL, FALSE); data->send_size = GetDlgItemInt(hDlgWnd, IDC_SENDFILE_SEND_SIZE_DROPDOWN, NULL, FALSE); - data->method_4 = IsDlgButtonChecked(hDlgWnd, IDC_SENDFILE_CHECK_4); + data->method_4 = IsDlgButtonChecked(hDlgWnd, IDC_SENDFILE_CHECK_4) == BST_CHECKED ? TRUE : FALSE; TTEndDialog(hDlgWnd, IDOK); return TRUE; @@ -168,51 +222,29 @@ static INT_PTR CALLBACK SendFileDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARA TTEndDialog(hDlgWnd, IDCANCEL); return TRUE; + case IDC_SENDFILE_CHECK_4 | (BN_CLICKED << 16): + ArrangeControls(hDlgWnd); + break; + case IDC_SENDFILE_FILENAME_BUTTON | (BN_CLICKED << 16): { - wchar_t TempDir[MAX_PATH]; - GetCurrentDirectoryW(_countof(TempDir), TempDir); - - wchar_t *uimsg; - GetI18nStrWW("Tera Term", "FILEDLG_TRANS_TITLE_SENDFILE", L"Send file", data->UILanguageFileW, &uimsg); - wchar_t *title; - aswprintf(&title, L"Tera Term: %s", uimsg); - free(uimsg); - uimsg = NULL; - - TTTSet *ts = data->pts; - wchar_t *FileDir = GetFileDir(ts); - wchar_t *filterW = GetCommonDialogFilterWW(data->filesend_filter, data->UILanguageFileW); - wchar_t filename[MAX_PATH]; - filename[0] = 0; - OPENFILENAMEW ofn = {}; - ofn.lStructSize = get_OPENFILENAME_SIZEW(); - ofn.hwndOwner = hDlgWnd; - ofn.lpstrFile = filename; - ofn.nMaxFile = MAX_PATH; - ofn.lpstrFilter = filterW; - ofn.nFilterIndex = 0; - ofn.lpstrTitle = title; - ofn.lpstrInitialDir = FileDir; - ofn.Flags = OFN_FILEMUSTEXIST | OFN_SHOWHELP | OFN_HIDEREADONLY; - BOOL Ok = GetOpenFileNameW(&ofn); - free(FileDir); - free(filterW); - free(title); - - SetCurrentDirectoryW(TempDir); + wchar_t *filename_ini; + hGetDlgItemTextW(hDlgWnd, IDC_SENDFILE_FILENAME_EDIT, &filename_ini); + + wchar_t *filename; + BOOL Ok = SelectFile(hDlgWnd,data, filename_ini, &filename); + free(filename_ini); if (Ok) { SetDlgItemTextW(hDlgWnd, IDC_SENDFILE_FILENAME_EDIT, filename); PostMessage(hDlgWnd, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlgWnd, IDOK), TRUE); + free(filename); } return TRUE; } case IDC_SENDFILE_DELAYTYPE_DROPDOWN | (CBN_SELCHANGE << 16): { - int sel = (int)SendDlgItemMessage(hDlgWnd, IDC_SENDFILE_DELAYTYPE_DROPDOWN, CB_GETCURSEL, 0, 0); - EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_SEND_SIZE_DROPDOWN), sel != 3 ? FALSE : TRUE); - EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_DELAYTIME_EDIT), sel == 0 ? FALSE : TRUE); + ArrangeControls(hDlgWnd); return TRUE; } @@ -251,8 +283,23 @@ static INT_PTR CALLBACK SendFileDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARA INT_PTR sendfiledlg(HINSTANCE hInstance, HWND hWndParent, sendfiledlgdata *data) { - INT_PTR ret; - data->method_4 = FALSE; - ret = TTDialogBoxParam(hInstance, MAKEINTRESOURCEW(IDD_SENDFILEDLG), hWndParent, SendFileDlgProc, (LPARAM)data); - return ret; + BOOL skip_dialog = data->skip_dialog; + if ((GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0) { + skip_dialog = !skip_dialog; + } + + if (!skip_dialog) { + INT_PTR ret; + ret = TTDialogBoxParam(hInstance, MAKEINTRESOURCEW(IDD_SENDFILEDLG), hWndParent, SendFileDlgProc, (LPARAM)data); + return ret; + } + else { + wchar_t *filename_ini = data->filename; + wchar_t *filename; + BOOL Ok = SelectFile(hWndParent, data, filename_ini, &filename); + if (Ok) { + data->filename = filename; + } + return Ok ? (INT_PTR)IDOK : (INT_PTR)IDCANCEL; + } } diff --git a/teraterm/teraterm/sendfiledlg.h b/teraterm/teraterm/sendfiledlg.h index 558da3f61..f6a3371d9 100644 --- a/teraterm/teraterm/sendfiledlg.h +++ b/teraterm/teraterm/sendfiledlg.h @@ -29,22 +29,27 @@ #pragma once #include +#include "sendmem.h" + #ifdef __cplusplus extern "C" { #endif typedef struct { // in - const wchar_t* UILanguageFileW; + const wchar_t *UILanguageFileW; const wchar_t *filesend_filter; - TTTSet *pts; - // out - wchar_t* filename; // IDOKAIt@CԂ,gpfree()邱 - BOOL binary; // TRUE/FALSE = oCi/eLXg - int delay_type; + const wchar_t *initial_dir; + const wchar_t *initial_file; // t@C, NULL=wȂ + // in/out + BOOL skip_dialog; + BOOL binary; // TRUE/FALSE = oCi/eLXg + SendMemDelayType delay_type; DWORD delay_tick; size_t send_size; - BOOL method_4; // Tera Term 4 ̃[`gp + BOOL method_4; // Tera Term 4 ̃[`gp + // out + wchar_t *filename; // IDOKAIt@CԂ,gpfree()邱 } sendfiledlgdata; INT_PTR sendfiledlg(HINSTANCE hInstance, HWND hWndParent, sendfiledlgdata *data); diff --git a/teraterm/teraterm/ttermpro.rc b/teraterm/teraterm/ttermpro.rc index 70bb4a0b1..e311cc848 100644 --- a/teraterm/teraterm/ttermpro.rc +++ b/teraterm/teraterm/ttermpro.rc @@ -341,26 +341,26 @@ BEGIN PUSHBUTTON "Help",IDHELP,313,127,50,14 END -IDD_SENDFILEDLG DIALOGEX 0, 0, 271, 188 +IDD_SENDFILEDLG DIALOGEX 0, 0, 271, 199 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Send file" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN LTEXT "&Filename (drop file in this dialog)",IDC_SENDFILE_FILENAME_TITLE,9,7,172,8 - EDITTEXT IDC_SENDFILE_FILENAME_EDIT,18,21,224,14,ES_AUTOHSCROLL - PUSHBUTTON "...",IDC_SENDFILE_FILENAME_BUTTON,245,21,14,14 + EDITTEXT IDC_SENDFILE_FILENAME_EDIT,18,21,228,14,ES_AUTOHSCROLL + PUSHBUTTON "...",IDC_SENDFILE_FILENAME_BUTTON,251,21,14,14 CONTROL "Send in same way as Tera Term 4",IDC_SENDFILE_CHECK_4, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,42,124,10 CONTROL "&Binary",IDC_SENDFILE_CHECK_BINARY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,59,72,10 LTEXT "delay type",IDC_SENDFILE_DELAYTYPE_LABEL,9,76,74,11 - COMBOBOX IDC_SENDFILE_DELAYTYPE_DROPDOWN,18,90,64,53,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SENDFILE_DELAYTYPE_DROPDOWN,18,90,64,53,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP LTEXT "send size(bytes)",IDC_SENDFILE_SEND_SIZE_LABEL,9,107,75,8 - COMBOBOX IDC_SENDFILE_SEND_SIZE_DROPDOWN,18,121,65,47,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SENDFILE_SEND_SIZE_DROPDOWN,18,121,65,47,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP LTEXT "delay time(ms)",IDC_SENDFILE_DELAYTIME_LABEL,9,139,75,8 EDITTEXT IDC_SENDFILE_DELAYTIME_EDIT,18,154,40,14,ES_AUTOHSCROLL - PUSHBUTTON "Help",IDHELP,104,166,50,14 - DEFPUSHBUTTON "OK",IDOK,160,166,50,14 - PUSHBUTTON "Cancel",IDCANCEL,215,166,50,14 + PUSHBUTTON "Help",IDHELP,104,179,50,14 + PUSHBUTTON "Cancel",IDCANCEL,160,179,50,14 + DEFPUSHBUTTON "OK",IDOK,215,179,50,14 END IDD_TABSHEET_THEME DIALOGEX 0, 0, 307, 162 @@ -493,9 +493,12 @@ BEGIN IDD_SENDFILEDLG, DIALOG BEGIN + LEFTMARGIN, 9 + RIGHTMARGIN, 265 VERTGUIDE, 9 VERTGUIDE, 18 - BOTTOMMARGIN, 180 + TOPMARGIN, 7 + BOTTOMMARGIN, 193 END IDD_TABSHEET_THEME, DIALOG diff --git a/teraterm/teraterm/vtwin.cpp b/teraterm/teraterm/vtwin.cpp index 3e23f932c..1ced1df21 100644 --- a/teraterm/teraterm/vtwin.cpp +++ b/teraterm/teraterm/vtwin.cpp @@ -3965,28 +3965,43 @@ void CVTWindow::OnReplayLog() void CVTWindow::OnFileSend() { - // new file send SetDialogFont(ts.DialogFontNameW, ts.DialogFontPoint, ts.DialogFontCharSet, ts.UILanguageFileW, "Tera Term", "DLG_TAHOMA_FONT"); - sendfiledlgdata data; + sendfiledlgdata data = {}; data.UILanguageFileW = ts.UILanguageFileW; wchar_t *filterW = ToWcharA(ts.FileSendFilter); data.filesend_filter = filterW; - data.pts = &ts; + wchar_t *initial_dir = GetFileDir(&ts); + data.initial_dir = initial_dir; + data.skip_dialog = (BOOL)ts.SendfileSkipOptionDialog; + data.binary = ts.TransBin; + data.delay_type = (SendMemDelayType)ts.SendfileDelayType; + data.delay_tick = ts.SendfileDelayTick; + data.send_size = ts.SendfileSize; + data.method_4 = ts.SendfileMethod4; + INT_PTR ok = sendfiledlg(m_hInst, m_hWnd, &data); + free(initial_dir); free(filterW); if (ok != IDOK) { return; } + ts.SendfileSkipOptionDialog = data.skip_dialog; + ts.TransBin = data.binary; + ts.SendfileDelayType = data.delay_type; + ts.SendfileDelayTick = data.delay_tick; + ts.SendfileSize = data.send_size; + ts.SendfileMethod4 = data.method_4; wchar_t *filename = data.filename; if (!data.method_4) { - SendMemSendFile(filename, data.binary, (SendMemDelayType)data.delay_type, data.delay_tick, data.send_size); + // new file send + SendMemSendFile(filename, data.binary, data.delay_type, data.delay_tick, data.send_size); } else { // file send same as teraterm 4 HelpId = HlpFileSend; - FileSendStart(filename, 0); + FileSendStart(filename, data.binary); } free(filename); } diff --git a/teraterm/ttpset/ttset.c b/teraterm/ttpset/ttset.c index 870deaf4b..48d2c3722 100644 --- a/teraterm/ttpset/ttset.c +++ b/teraterm/ttpset/ttset.c @@ -2005,6 +2005,17 @@ void PASCAL _ReadIniFile(const wchar_t *FName, PTTSet ts) ts->BracketedSupport = GetOnOff(Section, "BracketedSupport", FName, TRUE); ts->BracketedControlOnly = GetOnOff(Section, "BracketedControlOnly", FName, FALSE); + // Sendfile + GetPrivateProfileString(Section, "SendfileDelayType", "NoDelay", Temp, sizeof(Temp), FName); + ts->SendfileDelayType = + (_stricmp(Temp, "PerChar") == 0) ? 1 : + (_stricmp(Temp, "PerLine") == 0) ? 2 : + (_stricmp(Temp, "PerSendSize") == 0) ? 3 : /*NoDelay*/ 0; + ts->SendfileDelayTick = GetPrivateProfileInt(Section, "SendfileDelayTick", 0, FName); + ts->SendfileSize = GetPrivateProfileInt(Section, "SendfileSize", 4096, FName); + ts->SendfileMethod4 = GetOnOff(Section, "SendfileMethod4", FName, FALSE); + ts->SendfileSkipOptionDialog = GetOnOff(Section, "SendfileSkipOptionDialog", FName, FALSE); + // Experimental ts->ExperimentalTreePropertySheetEnable = GetOnOff("Experimental", "TreeProprtySheet", FName, FALSE); ts->ExperimentalTreePropertySheetEnable = GetOnOff("Experimental", "TreePropertySheet", FName, ts->ExperimentalTreePropertySheetEnable); @@ -3260,6 +3271,18 @@ void PASCAL _WriteIniFile(const wchar_t *FName, PTTSet ts) // Bracketed paste mode WriteOnOff(Section, "BracketedSupport", FName, ts->BracketedSupport); WriteOnOff(Section, "BracketedControlOnly", FName, ts->BracketedControlOnly); + + // Sendfile + WritePrivateProfileString(Section, "SendfileDelayType", + ts->SendfileDelayType == 1 ? "PerChar" : + ts->SendfileDelayType == 2 ? "PerLine" : + ts->SendfileDelayType == 3 ? "PerSendSize" : + "NoDelay", + FName); + WriteInt(Section, "SendfileDelayTick", FName, 2); + WriteInt(Section, "SendfileSize", FName, ts->SendfileSize); + WriteOnOff(Section, "SendfileMethod4", FName, ts->SendfileMethod4); + WriteOnOff(Section, "SendfileSkipOptionDialog", FName, ts->SendfileSkipOptionDialog); } void PASCAL _CopySerialList(const wchar_t *IniSrc, const wchar_t *IniDest, const wchar_t *section,