• R/O
  • SSH
  • HTTPS

ttssh2: コミット


コミットメタ情報

リビジョン7158 (tree)
日時2018-07-18 23:33:38
作者zmatsuo

ログメッセージ

drap and drop dialog の editbox で CTRL+f,b などが使えるようにした
- combobox、editboxで CTRL+f,b を簡単に利用できるようにした
- プロジェクトの依存関係調整

変更サマリ

差分

--- trunk/teraterm/common/dlglib.h (revision 7157)
+++ trunk/teraterm/common/dlglib.h (revision 7158)
@@ -1,6 +1,6 @@
11 /*
22 * Copyright (C) 1994-1998 T. Teranishi
3- * (C) 2005-2017 TeraTerm Project
3+ * (C) 2005-2018 TeraTerm Project
44 * All rights reserved.
55 *
66 * Redistribution and use in source and binary forms, with or without
@@ -40,9 +40,10 @@
4040 void SetDlgNum(HWND HDlg, int id_Item, LONG Num);
4141 void SetDlgPercent(HWND HDlg, int id_Item, int id_Progress, LONG a, LONG b, int *prog);
4242 void SetDlgTime(HWND HDlg, int id_Item, DWORD elapsed, int bytes);
43-void SetDropDownList(HWND HDlg, int Id_Item, PCHAR far *List, int nsel);
43+void SetDropDownList(HWND HDlg, int Id_Item, const TCHAR **List, int nsel);
4444 LONG GetCurSel(HWND HDlg, int Id_Item);
4545 void InitDlgProgress(HWND HDlg, int id_Progress, int *CurProgStat);
46+void SetEditboxSubclass(HWND hDlg, int nID, BOOL ComboBox);
4647
4748 #ifdef __cplusplus
4849 }
--- trunk/teraterm/common/dlglib.c (revision 7157)
+++ trunk/teraterm/common/dlglib.c (revision 7158)
@@ -1,6 +1,6 @@
11 /*
22 * Copyright (C) 1994-1998 T. Teranishi
3- * (C) 2008-2017 TeraTerm Project
3+ * (C) 2008-2018 TeraTerm Project
44 * All rights reserved.
55 *
66 * Redistribution and use in source and binary forms, with or without
@@ -174,7 +174,7 @@
174174 SetDlgItemText(HDlg, id_Item, buff);
175175 }
176176
177-void SetDropDownList(HWND HDlg, int Id_Item, PCHAR far *List, int nsel)
177+void SetDropDownList(HWND HDlg, int Id_Item, const TCHAR **List, int nsel)
178178 {
179179 int i;
180180
@@ -201,3 +201,152 @@
201201
202202 return n;
203203 }
204+
205+typedef struct {
206+ WNDPROC OrigProc; // Original window procedure
207+ LONG_PTR OrigUser; // DWLP_USER
208+ BOOL ComboBox;
209+} EditSubclassData;
210+
211+// C-n/C-p のためにサブクラス化 (2007.9.4 maya)
212+// C-p/C-n/C-b/C-f/C-a/C-e をサポート (2007.9.5 maya)
213+// C-d/C-k をサポート (2007.10.3 yutaka)
214+// ドロップダウンの中のエディットコントロールを
215+// サブクラス化するためのウインドウプロシージャ
216+static LRESULT CALLBACK HostnameEditProc(HWND dlg, UINT msg,
217+ WPARAM wParam, LPARAM lParam)
218+{
219+ EditSubclassData *data = (EditSubclassData *)GetWindowLong(dlg, GWLP_USERDATA);
220+ int max, select, len;
221+ char *str, *orgstr;
222+
223+ switch (msg) {
224+ // キーが押されたのを検知する
225+ case WM_KEYDOWN:
226+ if (GetKeyState(VK_CONTROL) < 0) {
227+ switch (wParam) {
228+ case 0x50: // Ctrl+p ... up
229+ if (data->ComboBox) {
230+ HWND parent = GetParent(dlg);
231+ select = SendMessage(parent, CB_GETCURSEL, 0, 0);
232+ if (select > 0) {
233+ PostMessage(parent, CB_SETCURSEL, select - 1, 0);
234+ }
235+ return 0;
236+ }
237+ break;
238+ case 0x4e: // Ctrl+n ... down
239+ if (data->ComboBox) {
240+ HWND parent = GetParent(dlg);
241+ max = SendMessage(parent, CB_GETCOUNT, 0, 0);
242+ select = SendMessage(parent, CB_GETCURSEL, 0, 0);
243+ if (select < max - 1) {
244+ PostMessage(parent, CB_SETCURSEL, select + 1, 0);
245+ }
246+ return 0;
247+ }
248+ break;
249+ case 0x42: // Ctrl+b ... left
250+ SendMessage(dlg, EM_GETSEL, 0, (LPARAM)&select);
251+ PostMessage(dlg, EM_SETSEL, select-1, select-1);
252+ return 0;
253+ case 0x46: // Ctrl+f ... right
254+ SendMessage(dlg, EM_GETSEL, 0, (LPARAM)&select);
255+ max = GetWindowTextLength(dlg) ;
256+ PostMessage(dlg, EM_SETSEL, select+1, select+1);
257+ return 0;
258+ case 0x41: // Ctrl+a ... home
259+ PostMessage(dlg, EM_SETSEL, 0, 0);
260+ return 0;
261+ case 0x45: // Ctrl+e ... end
262+ max = GetWindowTextLength(dlg) ;
263+ PostMessage(dlg, EM_SETSEL, max, max);
264+ return 0;
265+
266+ case 0x44: // Ctrl+d
267+ case 0x4b: // Ctrl+k
268+ case 0x55: // Ctrl+u
269+ SendMessage(dlg, EM_GETSEL, 0, (LPARAM)&select);
270+ max = GetWindowTextLength(dlg);
271+ max++; // '\0'
272+ orgstr = str = malloc(max);
273+ if (str != NULL) {
274+ len = GetWindowText(dlg, str, max);
275+ if (select >= 0 && select < len) {
276+ if (wParam == 0x44) { // カーソル配下の文字のみを削除する
277+ memmove(&str[select], &str[select + 1], len - select - 1);
278+ str[len - 1] = '\0';
279+
280+ } else if (wParam == 0x4b) { // カーソルから行末まで削除する
281+ str[select] = '\0';
282+
283+ }
284+ }
285+
286+ if (wParam == 0x55) { // カーソルより左側をすべて消す
287+ if (select >= len) {
288+ str[0] = '\0';
289+ } else {
290+ str = &str[select];
291+ }
292+ select = 0;
293+ }
294+
295+ SetWindowText(dlg, str);
296+ SendMessage(dlg, EM_SETSEL, select, select);
297+ free(orgstr);
298+ return 0;
299+ }
300+ break;
301+ }
302+ }
303+ break;
304+
305+ // 上のキーを押した結果送られる文字で音が鳴るので捨てる
306+ case WM_CHAR:
307+ switch (wParam) {
308+ case 0x01:
309+ case 0x02:
310+ case 0x04:
311+ case 0x05:
312+ case 0x06:
313+ case 0x0b:
314+ case 0x0e:
315+ case 0x10:
316+ case 0x15:
317+ return 0;
318+ }
319+ break;
320+ }
321+
322+ SetWindowLong(dlg, GWL_WNDPROC, (LONG_PTR)data->OrigProc);
323+ SetWindowLong(dlg, GWLP_USERDATA, (LONG_PTR)data->OrigUser);
324+ LRESULT Result = CallWindowProc(data->OrigProc, dlg, msg, wParam, lParam);
325+ SetWindowLong(dlg, GWL_WNDPROC, (LONG_PTR)HostnameEditProc);
326+ SetWindowLong(dlg, GWLP_USERDATA, (LONG_PTR)data);
327+
328+ switch (msg) {
329+ case WM_DESTROY:
330+ SetWindowLong(dlg, GWL_WNDPROC, (LONG_PTR)data->OrigProc);
331+ SetWindowLong(dlg, GWLP_USERDATA, (LONG_PTR)data->OrigUser);
332+ free(data);
333+ break;
334+ }
335+
336+ return Result;
337+}
338+
339+// C-n/C-p のためにサブクラス化
340+void SetEditboxSubclass(HWND hDlg, int nID, BOOL ComboBox)
341+{
342+ HWND hWndEdit = GetDlgItem(hDlg, nID);
343+ if (ComboBox) {
344+ hWndEdit = GetWindow(hWndEdit, GW_CHILD);
345+ }
346+ EditSubclassData *data = (EditSubclassData *)malloc(sizeof(EditSubclassData));
347+ data->OrigProc = (WNDPROC)GetWindowLong(hWndEdit, GWL_WNDPROC);
348+ data->OrigUser = (LONG_PTR)GetWindowLong(hWndEdit, GWLP_USERDATA);
349+ data->ComboBox = ComboBox;
350+ SetWindowLong(hWndEdit, GWL_WNDPROC, (LONG_PTR)HostnameEditProc);
351+ SetWindowLong(hWndEdit, GWLP_USERDATA, (LONG_PTR)data);
352+}
--- trunk/teraterm/ttpdlg/ttdlg.c (revision 7157)
+++ trunk/teraterm/ttpdlg/ttdlg.c (revision 7158)
@@ -1879,113 +1879,6 @@
18791879 return FALSE;
18801880 }
18811881
1882-// C-p/C-n/C-b/C-f/C-a/C-e をサポート (2007.9.5 maya)
1883-// C-d/C-k をサポート (2007.10.3 yutaka)
1884-// ドロップダウンの中のエディットコントロールを
1885-// サブクラス化するためのウインドウプロシージャ
1886-WNDPROC OrigHostnameEditProc; // Original window procedure
1887-LRESULT CALLBACK HostnameEditProc(HWND dlg, UINT msg,
1888- WPARAM wParam, LPARAM lParam)
1889-{
1890- HWND parent;
1891- int max, select, len;
1892- char *str, *orgstr;
1893-
1894- switch (msg) {
1895- // キーが押されたのを検知する
1896- case WM_KEYDOWN:
1897- if (GetKeyState(VK_CONTROL) < 0) {
1898- switch (wParam) {
1899- case 0x50: // Ctrl+p ... up
1900- parent = GetParent(dlg);
1901- select = SendMessage(parent, CB_GETCURSEL, 0, 0);
1902- if (select > 0) {
1903- PostMessage(parent, CB_SETCURSEL, select - 1, 0);
1904- }
1905- return 0;
1906- case 0x4e: // Ctrl+n ... down
1907- parent = GetParent(dlg);
1908- max = SendMessage(parent, CB_GETCOUNT, 0, 0);
1909- select = SendMessage(parent, CB_GETCURSEL, 0, 0);
1910- if (select < max - 1) {
1911- PostMessage(parent, CB_SETCURSEL, select + 1, 0);
1912- }
1913- return 0;
1914- case 0x42: // Ctrl+b ... left
1915- SendMessage(dlg, EM_GETSEL, 0, (LPARAM)&select);
1916- PostMessage(dlg, EM_SETSEL, select-1, select-1);
1917- return 0;
1918- case 0x46: // Ctrl+f ... right
1919- SendMessage(dlg, EM_GETSEL, 0, (LPARAM)&select);
1920- max = GetWindowTextLength(dlg) ;
1921- PostMessage(dlg, EM_SETSEL, select+1, select+1);
1922- return 0;
1923- case 0x41: // Ctrl+a ... home
1924- PostMessage(dlg, EM_SETSEL, 0, 0);
1925- return 0;
1926- case 0x45: // Ctrl+e ... end
1927- max = GetWindowTextLength(dlg) ;
1928- PostMessage(dlg, EM_SETSEL, max, max);
1929- return 0;
1930-
1931- case 0x44: // Ctrl+d
1932- case 0x4b: // Ctrl+k
1933- case 0x55: // Ctrl+u
1934- SendMessage(dlg, EM_GETSEL, 0, (LPARAM)&select);
1935- max = GetWindowTextLength(dlg);
1936- max++; // '\0'
1937- orgstr = str = malloc(max);
1938- if (str != NULL) {
1939- len = GetWindowText(dlg, str, max);
1940- if (select >= 0 && select < len) {
1941- if (wParam == 0x44) { // カーソル配下の文字のみを削除する
1942- memmove(&str[select], &str[select + 1], len - select - 1);
1943- str[len - 1] = '\0';
1944-
1945- } else if (wParam == 0x4b) { // カーソルから行末まで削除する
1946- str[select] = '\0';
1947-
1948- }
1949- }
1950-
1951- if (wParam == 0x55) { // カーソルより左側をすべて消す
1952- if (select >= len) {
1953- str[0] = '\0';
1954- } else {
1955- str = &str[select];
1956- }
1957- select = 0;
1958- }
1959-
1960- SetWindowText(dlg, str);
1961- SendMessage(dlg, EM_SETSEL, select, select);
1962- free(orgstr);
1963- return 0;
1964- }
1965- break;
1966- }
1967- }
1968- break;
1969-
1970- // 上のキーを押した結果送られる文字で音が鳴るので捨てる
1971- case WM_CHAR:
1972- switch (wParam) {
1973- case 0x01:
1974- case 0x02:
1975- case 0x04:
1976- case 0x05:
1977- case 0x06:
1978- case 0x0b:
1979- case 0x0e:
1980- case 0x10:
1981- case 0x15:
1982- return 0;
1983- }
1984- }
1985-
1986- return CallWindowProc(OrigHostnameEditProc, dlg, msg, wParam, lParam);
1987-}
1988-
19891882 BOOL CALLBACK HostDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
19901883 {
19911884 PGetHNRec GetHNRec;
@@ -1999,8 +1892,6 @@
19991892 char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG];
20001893 LOGFONT logfont;
20011894 HFONT font;
2002- static HWND hwndHostname = NULL; // HOSTNAME dropdown
2003- static HWND hwndHostnameEdit = NULL; // Edit control on HOSTNAME dropdown
20041895
20051896 switch (Message) {
20061897 case WM_INITDIALOG:
@@ -2081,11 +1972,7 @@
20811972
20821973 SendDlgItemMessage(Dialog, IDC_HOSTNAME, CB_SETCURSEL,0,0);
20831974
2084- // C-n/C-p のためにサブクラス化 (2007.9.4 maya)
2085- hwndHostname = GetDlgItem(Dialog, IDC_HOSTNAME);
2086- hwndHostnameEdit = GetWindow(hwndHostname, GW_CHILD);
2087- OrigHostnameEditProc = (WNDPROC)GetWindowLong(hwndHostnameEdit, GWL_WNDPROC);
2088- SetWindowLong(hwndHostnameEdit, GWL_WNDPROC, (LONG)HostnameEditProc);
1975+ SetEditboxSubclass(Dialog, IDC_HOSTNAME, TRUE);
20891976
20901977 SetRB(Dialog,GetHNRec->Telnet,IDC_HOSTTELNET,IDC_HOSTTELNET);
20911978 SendDlgItemMessage(Dialog, IDC_HOSTTCPPORT, EM_LIMITTEXT,5,0);
@@ -2201,7 +2088,6 @@
22012088 GetHNRec->ComPort = 1;
22022089 }
22032090 }
2204- SetWindowLong(hwndHostnameEdit, GWL_WNDPROC, (LONG)OrigHostnameEditProc);
22052091 EndDialog(Dialog, 1);
22062092 if (DlgHostFont != NULL) {
22072093 DeleteObject(DlgHostFont);
@@ -2209,7 +2095,6 @@
22092095 return TRUE;
22102096
22112097 case IDCANCEL:
2212- SetWindowLong(hwndHostnameEdit, GWL_WNDPROC, (LONG)OrigHostnameEditProc);
22132098 EndDialog(Dialog, 0);
22142099 if (DlgHostFont != NULL) {
22152100 DeleteObject(DlgHostFont);
--- trunk/teraterm/teraterm/dnddlg.cpp (revision 7157)
+++ trunk/teraterm/teraterm/dnddlg.cpp (revision 7158)
@@ -163,6 +163,7 @@
163163 EnableWindow(GetDlgItem(hDlgWnd, IDC_SCP_PATH), FALSE);
164164 EnableWindow(GetDlgItem(hDlgWnd, IDC_SCP_PATH_NOTE), FALSE);
165165 }
166+ SetEditboxSubclass(hDlgWnd, IDC_SCP_PATH, FALSE);
166167
167168 // Send File
168169 if (Param->DropType == DROP_TYPE_SEND_FILE_BINARY) {
旧リポジトリブラウザで表示