svnno****@sourc*****
svnno****@sourc*****
2014年 8月 18日 (月) 19:04:04 JST
Revision: 5647 http://sourceforge.jp/projects/ttssh2/scm/svn/commits/5647 Author: doda Date: 2014-08-18 19:04:00 +0900 (Mon, 18 Aug 2014) Log Message: ----------- メニュー項目として画面の高さ/幅いっぱいというのを設定できるようにした。 設定で-1を指定すると画面いっぱいとして扱う。 # 0で変更無し、-1で画面いっぱいというのは判り辛そうだが、いい案が思い浮かばず Modified Paths: -------------- trunk/TTXSamples/TTXResizeMenu/ReadMe-ja.txt trunk/TTXSamples/TTXResizeMenu/ReadMe.txt trunk/TTXSamples/TTXResizeMenu/TTXResizeMenu.c trunk/doc/en/html/about/history.html trunk/doc/en/html/usage/resizemenu.html trunk/doc/ja/html/about/history.html trunk/doc/ja/html/usage/resizemenu.html -------------- next part -------------- Modified: trunk/TTXSamples/TTXResizeMenu/ReadMe-ja.txt =================================================================== --- trunk/TTXSamples/TTXResizeMenu/ReadMe-ja.txt 2014-08-12 13:50:47 UTC (rev 5646) +++ trunk/TTXSamples/TTXResizeMenu/ReadMe-ja.txt 2014-08-18 10:04:00 UTC (rev 5647) @@ -14,6 +14,8 @@ \x8D쐬\x82\xB5\x81AResizeMenuN = X, Y \x82̌`\x8E\xAE\x82Ŏw\x92肵\x82ĉ\xBA\x82\xB3\x82\xA2\x81BN \x82\xCD 1 \x82\xA9\x82\xE7\x82̘A\x94Ԃł\xB7\x81B X \x82܂\xBD\x82\xCD Y \x82̂\xA2\x82\xB8\x82ꂩ\x82\xAA 0 \x82̎\x9E\x82́A\x82\xBB\x82̗v\x91f\x82͕ύX\x82\xB3\x82\xEA\x82܂\xB9\x82\xF1\x81B\x97Ⴆ\x82\xCE 0, 37 \x82\xCC \x8E\x9E\x82́A\x89\xA1\x95\x9D\x82͕ύX\x82\xB9\x82\xB8\x82ɏc\x95\x9D\x82\xF0 37 \x8Ds\x82ɕύX\x82\xB5\x82܂\xB7\x81B + X \x82܂\xBD\x82\xCD Y \x82̒l\x82\xF0 -1 \x82ɂ\xB5\x82\xBD\x8Fꍇ\x81A\x89\xE6\x96ʃT\x83C\x83Y\x82\xA6\x82Ȃ\xA2\x94͈͂ł̍ő\xE5\x92l\x82Ƃ\xB5\x82\xC4 + \x88\xB5\x82\xED\x82\xEA\x82܂\xB7\x81B \x83\x81\x83j\x83\x85\x81[\x82̍\x80\x96ڐ\x94\x82͍ő\xE5\x82\xC5 20 \x82ł\xB7\x81B\x8Dő吔\x82𑝂₵\x82\xBD\x82\xA2\x8E\x9E\x82\xCD TTXResizeMenu.c \x82\xCC MAX_MENU_ITEMS \x82𑝂₵\x82Ă\xA9\x82\xE7\x83r\x83\x8B\x83h\x82\xB5\x92\xBC\x82\xB5\x82Ă\xAD\x82\xBE\x82\xB3\x82\xA2\x81B Modified: trunk/TTXSamples/TTXResizeMenu/ReadMe.txt =================================================================== --- trunk/TTXSamples/TTXResizeMenu/ReadMe.txt 2014-08-12 13:50:47 UTC (rev 5646) +++ trunk/TTXSamples/TTXResizeMenu/ReadMe.txt 2014-08-18 10:04:00 UTC (rev 5647) @@ -2,13 +2,23 @@ Feature: This feature adds Resize menu. - If a user selects the Resize menu item, Tera Term VT window is changed to the specified size. + If a user selects the Resize menu item, Tera Term VT window is changed to + the specified size. Description: TTXResizeMenu is based on TTXResizeWin plugin. - Please refer to TTXResizeWin plugin description about the detail implementation of TTXResizeMenu plugin. + Please refer to TTXResizeWin plugin description about the detail + implementation of TTXResizeMenu plugin. - If you want to change the menu items, change resize_list and recompile this plugin soure code. + Basically, the [Resize] menu does not display after the plugin is installed. + Next, a user must register the menu entry in the teraterm.ini file. + Add a [Resize Menu] section in the teraterm.ini file, and describe the + "ResizeMenuN = X, Y" entry. N is an 1-origin number. + When X or Y equals zero, the value is not changed. For example, + (X, Y)=(0, 37) means that the width is not changed and the height is changed + into 37 lines. + These value maximum is 20. + ToDo: To configure with TERATERM.INI file againt Resize menu item. Modified: trunk/TTXSamples/TTXResizeMenu/TTXResizeMenu.c =================================================================== --- trunk/TTXSamples/TTXResizeMenu/TTXResizeMenu.c 2014-08-12 13:50:47 UTC (rev 5646) +++ trunk/TTXSamples/TTXResizeMenu/TTXResizeMenu.c 2014-08-18 10:04:00 UTC (rev 5647) @@ -21,6 +21,7 @@ PComVar cv; HMENU ResizeMenu; BOOL ReplaceTermDlg; + BOOL useMultiMonitorAPI; PReadIniFile origReadIniFile; int MenuItems; int ResizeList[MAX_MENU_ITEMS][2]; @@ -31,8 +32,76 @@ /* WIN32 allows multiple instances of a DLL */ static TInstVar InstVar; +BOOL GetMonitorSizeByChar(int *width, int *height) { + RECT rc_dsk, rc_wnd, rc_cl; + + if (width) { + *width = 0; + } + if (height) { + *height = 0; + } + + if (pvar->useMultiMonitorAPI) { + HMONITOR hm; + MONITORINFO mi; + + hm = MonitorFromWindow(pvar->cv->HWin, MONITOR_DEFAULTTONEAREST); + mi.cbSize = sizeof(MONITORINFO); + if (! GetMonitorInfo(hm, &mi)) { + return FALSE; + } + rc_dsk = mi.rcWork; + } + else { + SystemParametersInfo(SPI_GETWORKAREA, 0, &rc_dsk, 0); + } + + if (!GetWindowRect(pvar->cv->HWin, &rc_wnd) || !GetClientRect(pvar->cv->HWin, &rc_cl)) { + return FALSE; + } + + + if (width) { + int margin_w, cell_w; + + margin_w = (rc_wnd.right - rc_wnd.left) - (rc_cl.right - rc_cl.left); + cell_w = (rc_cl.right - rc_cl.left) / pvar->ts->TerminalWidth; + + *width = (rc_dsk.right - rc_dsk.left - margin_w) / cell_w; + } + if (height) { + int margin_h, cell_h; + + margin_h = (rc_wnd.bottom - rc_wnd.top) - (rc_cl.bottom - rc_cl.top); + cell_h = (rc_cl.bottom - rc_cl.top) / pvar->ts->TerminalHeight; + + *height = (rc_dsk.bottom - rc_dsk.top - margin_h) / cell_h; + } + + return TRUE; +} + +int mkMenuEntry(char *buff, size_t buffsize, int x, int y, int c) { + char tmp[20]; + + if (x == 0) + _snprintf_s(tmp, sizeof(tmp), _TRUNCATE, "height: %d", y); + else if (y == 0) + _snprintf_s(tmp, sizeof(tmp), _TRUNCATE, "width: %d", x); + else + _snprintf_s(tmp, sizeof(tmp), _TRUNCATE, "%dx%d", x, y); + + if (c < 15) + return _snprintf_s(buff, buffsize, _TRUNCATE, "%s(&%x)", tmp, c+1); + else if (c < 35) + return _snprintf_s(buff, buffsize, _TRUNCATE, "%s(&%c)", tmp, 'a' + 1 - 9); + else + return _snprintf_s(buff, buffsize, _TRUNCATE, "%s", tmp); +} + void InitMenu() { - int i, x, y; + int i, x, y, full_w, full_h; char tmp[20]; if (pvar->ResizeMenu != NULL) { @@ -40,35 +109,18 @@ } if (pvar->MenuItems > 0) { + GetMonitorSizeByChar(&full_w, &full_h); pvar->ResizeMenu = CreateMenu(); for (i=0; i < pvar->MenuItems; i++) { x = pvar->ResizeList[i][0]; + if (x == -1) + x = full_w; y = pvar->ResizeList[i][1]; - if (i < 15) { - if (x == 0) - _snprintf_s(tmp, sizeof(tmp), _TRUNCATE, "height: %d(&%x)", y, i+1); - else if (y == 0) - _snprintf_s(tmp, sizeof(tmp), _TRUNCATE, "width: %d(&%x)", x, i+1); - else - _snprintf_s(tmp, sizeof(tmp), _TRUNCATE, "%dx%d(&%x)", x, y, i+1); - } - else if (i < 35) { - if (x == 0) - _snprintf_s(tmp, sizeof(tmp), _TRUNCATE, "height: %d(&%c)", y, 'a' + i - 9); - else if (y == 0) - _snprintf_s(tmp, sizeof(tmp), _TRUNCATE, "width: %d(&%c)", x, 'a' + i - 9); - else - _snprintf_s(tmp, sizeof(tmp), _TRUNCATE, "%dx%d(&%c)", x, y, 'a' + i - 9); - } - else { - if (x == 0) - _snprintf_s(tmp, sizeof(tmp), _TRUNCATE, "height: %d", y); - else if (y == 0) - _snprintf_s(tmp, sizeof(tmp), _TRUNCATE, "width: %d", x); - else - _snprintf_s(tmp, sizeof(tmp), _TRUNCATE, "%dx%d", x, y); - } + if (y == -1) + y = full_h; + + mkMenuEntry(tmp, sizeof(tmp), x, y, i); InsertMenu(pvar->ResizeMenu, -1, MF_BYPOSITION, ID_MENUID_BASE+i, tmp); } } @@ -77,12 +129,47 @@ } } +void UpdateMenu() { + int i, x, y, full_w, full_h; + char tmp[20]; + + if (pvar->ResizeMenu == NULL) + return; + + GetMonitorSizeByChar(&full_w, &full_h); + + for (i=0; i < pvar->MenuItems; i++) { + x = pvar->ResizeList[i][0]; + y = pvar->ResizeList[i][1]; + if (x == -1 || y == -1) { + if (x == -1) + x = full_w; + if (y == -1) + y = full_h; + mkMenuEntry(tmp, sizeof(tmp), (x==-1)?full_w:x, (y==-1)?full_h:y, i); + ModifyMenu(pvar->ResizeMenu, i, MF_BYPOSITION, ID_MENUID_BASE+i, tmp); + } + } +} + static void PASCAL FAR TTXInit(PTTSet ts, PComVar cv) { + OSVERSIONINFO osvi; + pvar->ts = ts; pvar->cv = cv; pvar->ReplaceTermDlg = FALSE; pvar->ResizeMenu = NULL; pvar->MenuItems = 0; + + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&osvi); + if ((osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion == 4) || + (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS && osvi.dwMinorVersion < 10)) { + pvar->useMultiMonitorAPI = FALSE; + } + else { + pvar->useMultiMonitorAPI = TRUE; + } } static BOOL FAR PASCAL TTXSetupTerminal(HWND parent, PTTSet ts) { @@ -108,11 +195,11 @@ GetPrivateProfileString(SECTION, Key, "\n", Buff, sizeof(Buff), fn); if (sscanf_s(Buff, "%d , %d", &x, &y) == 2) { - if (x < 0 ) { + if (x < -1 ) { x = 0; } - if (y < 0 ) { + if (y < -1 ) { y = 0; } @@ -160,18 +247,33 @@ } } -static int PASCAL FAR TTXProcessCommand(HWND hWin, WORD cmd) { - int num; +static void PASCAL FAR TTXModifyPopupMenu(HMENU menu) { + if (menu == pvar->ResizeMenu) { + UpdateMenu(); + } +} + +static int PASCAL FAR TTXProcessCommand(HWND HWin, WORD cmd) { + int num, full_h, full_w; if (cmd >= ID_MENUID_BASE && cmd < ID_MENUID_BASE + pvar->MenuItems) { + GetMonitorSizeByChar(&full_w, &full_h); num = cmd - ID_MENUID_BASE; - if (pvar->ResizeList[num][0] > 0) + if (pvar->ResizeList[num][0] > 0) { pvar->ts->TerminalWidth = pvar->ResizeList[num][0]; - if (pvar->ResizeList[num][1] > 0) + } + else if (pvar->ResizeList[num][0] == -1 && full_w > 0) { + pvar->ts->TerminalWidth = full_w; + } + if (pvar->ResizeList[num][1] > 0) { pvar->ts->TerminalHeight = pvar->ResizeList[num][1]; + } + else if (pvar->ResizeList[num][1] == -1 && full_h > 0) { + pvar->ts->TerminalHeight = full_h; + } pvar->ReplaceTermDlg = TRUE; // Call Setup-Terminal dialog - SendMessage(hWin, WM_COMMAND, MAKELONG(ID_SETUP_TERMINAL, 0), 0); + SendMessage(HWin, WM_COMMAND, MAKELONG(ID_SETUP_TERMINAL, 0), 0); return 1; } return 0; @@ -188,7 +290,7 @@ NULL, // TTXCloseTCP, NULL, // TTXSetWinSize, TTXModifyMenu, - NULL, // TTXModifyPopupMenu, + TTXModifyPopupMenu, TTXProcessCommand, NULL, // TTXEnd }; Modified: trunk/doc/en/html/about/history.html =================================================================== --- trunk/doc/en/html/about/history.html 2014-08-12 13:50:47 UTC (rev 5646) +++ trunk/doc/en/html/about/history.html 2014-08-18 10:04:00 UTC (rev 5647) @@ -51,6 +51,7 @@ <li>added support for Microsoft Windows Server 2012 R2.</li> <li>upgraded TTSSH to <a href="#ttssh_2.70">2.70</a></li> <li>upgraded TeraTerm Menu to <a href="#ttmenu_1.12">1.12</a></li> + <li>upgraded TTXResizeMenu Plugin to <a href="#resizemenu_1.03">1.03</a></li> <li>upgraded LogMeTT to 2.10.2</li> </ul> </li> @@ -3834,6 +3835,12 @@ </ul> <h2><a name="resizemenu">TTXResizeMenu</a></h2> +<h3><a name="resizemenu_1.03">2014.xx.xx (Ver 1.03)</a></h3> +<ul class="history"> + <!-- li>\x83\x81\x83j\x83\x85\x81[\x8D\x80\x96ڂƂ\xB5\x82āA\x89\xE6\x96ʂ̍\x82\x82\xB3/\x95\x9D\x82\xA2\x82\xC1\x82ς\xA2\x82Ƃ\xA2\x82\xA4\x82̂\xF0\x90ݒ\xE8\x82ł\xAB\x82\xE9\x82悤\x82ɂ\xB5\x82\xBD\x81B</li --> +</ul> + +<h2><a name="resizemenu">TTXResizeMenu</a></h2> <h3><a name="resizemenu_1.02">2013.02.28 (Ver 1.02)</a></h3> <ul class="history"> <li>increased max height of window from 200 lines to 500 lines.</li> Modified: trunk/doc/en/html/usage/resizemenu.html =================================================================== --- trunk/doc/en/html/usage/resizemenu.html 2014-08-12 13:50:47 UTC (rev 5646) +++ trunk/doc/en/html/usage/resizemenu.html 2014-08-18 10:04:00 UTC (rev 5647) @@ -30,11 +30,12 @@ Add a [Resize Menu] section in the teraterm.ini file, and describe the "ResizeMenuN = X, Y" entry. N is an 1-origin number.<br> When X or Y equals zero, the value is not changed. For example, (X, Y)=(0, 37) means that the width is not changed and the height is changed into 37 lines.<br> +<!-- X \x82܂\xBD\x82\xCD Y \x82̒l\x82\xF0 -1 \x82ɂ\xB5\x82\xBD\x8Fꍇ\x81A\x89\xE6\x96ʃT\x83C\x83Y\x82\xA6\x82Ȃ\xA2\x94͈͂ł̍ő\xE5\x92l\x82Ƃ\xB5\x82Ĉ\xB5\x82\xED\x82\xEA\x82܂\xB7\x81B<br> --> These value maximum is 20. </p> <h2>Example</h2> -<pre> +<pre class="macro-example"> [Resize Menu] ; ; width 80 columns, height 37 rows Modified: trunk/doc/ja/html/about/history.html =================================================================== --- trunk/doc/ja/html/about/history.html 2014-08-12 13:50:47 UTC (rev 5646) +++ trunk/doc/ja/html/about/history.html 2014-08-18 10:04:00 UTC (rev 5647) @@ -51,6 +51,7 @@ <li>\x91Ή\x9E\x82\xB7\x82铮\x8D\xEC\x8A\xAB\x82\xC9Windows Server 2012 R2\x82\xF0\x92lj\xC1\x82\xB5\x82\xBD\x81B</li> <li><a href="#ttssh_2.70">TTSSH(2.70)</a>\x82֍\xB7\x82\xB5\x91ւ\xA6\x82\xBD\x81B</li> <li><a href="#ttmenu_1.12">TeraTerm Menu(1.12)</a>\x82֍\xB7\x82\xB5\x91ւ\xA6\x82\xBD\x81B</li> + <li><a href="#resizemenu_1.03">TTXResizeMenu Plugin(1.03)</a>\x82֍\xB7\x82\xB5\x91ւ\xA6\x82\xBD\x81B</li> <li>LogMeTT 2.10.2 \x82֍\xB7\x82\xB5\x91ւ\xA6\x82\xBD\x81B</li> </ul> </li> @@ -3841,6 +3842,11 @@ </ul> <h2><a name="resizemenu">TTXResizeMenu</a></h2> +<h3><a name="resizemenu_1.03">2014.xx.xx (Ver 1.03)</a></h3> +<ul class="history"> + <li>\x83\x81\x83j\x83\x85\x81[\x8D\x80\x96ڂƂ\xB5\x82āA\x89\xE6\x96ʂ̍\x82\x82\xB3/\x95\x9D\x82\xA2\x82\xC1\x82ς\xA2\x82Ƃ\xA2\x82\xA4\x82̂\xF0\x90ݒ\xE8\x82ł\xAB\x82\xE9\x82悤\x82ɂ\xB5\x82\xBD\x81B</li> +</ul> + <h3><a name="resizemenu_1.02">2013.02.28 (Ver 1.02)</a></h3> <ul class="history"> <li>\x92[\x96\x96\x82̍\x82\x82\xB3\x82Ƃ\xB5\x82Ďt\x82\xAF\x82\xE9\x92l\x82\xF0200\x82\xA9\x82\xE7500\x82֑\x9D\x82₵\x82\xBD\x81B</li> Modified: trunk/doc/ja/html/usage/resizemenu.html =================================================================== --- trunk/doc/ja/html/usage/resizemenu.html 2014-08-12 13:50:47 UTC (rev 5646) +++ trunk/doc/ja/html/usage/resizemenu.html 2014-08-18 10:04:00 UTC (rev 5647) @@ -29,11 +29,12 @@ \x83\x81\x83j\x83\x85\x81[\x93\xE0\x82̍\x80\x96ڂ\xF0\x95ύX\x82\xB5\x82\xBD\x82\xA2\x8Fꍇ\x82́ATERATERM.INI \x82\xC9 [Resize Menu] \x83Z\x83N\x83V\x83\x87\x83\x93\x82\xF0\x8D쐬\x82\xB5\x81A"ResizeMenuN = X, Y" \x82̌`\x8E\xAE\x82Ŏw\x92肵\x82ĉ\xBA\x82\xB3\x82\xA2\x81BN \x82\xCD 1 \x82\xA9\x82\xE7\x82̘A\x94Ԃł\xB7\x81B<br> X \x82܂\xBD\x82\xCD Y \x82̂\xA2\x82\xB8\x82ꂩ\x82\xAA 0 \x82̎\x9E\x82́A\x82\xBB\x82̗v\x91f\x82͕ύX\x82\xB3\x82\xEA\x82܂\xB9\x82\xF1\x81B\x97Ⴆ\x82\xCE 0, 37 \x82̎\x9E\x82́A\x89\xA1\x95\x9D\x82͕ύX\x82\xB9\x82\xB8\x82ɏc\x95\x9D\x82\xF0 37 \x8Ds\x82ɕύX\x82\xB5\x82܂\xB7\x81B<br> +X \x82܂\xBD\x82\xCD Y \x82̒l\x82\xF0 -1 \x82ɂ\xB5\x82\xBD\x8Fꍇ\x81A\x89\xE6\x96ʃT\x83C\x83Y\x82\xA6\x82Ȃ\xA2\x94͈͂ł̍ő\xE5\x92l\x82Ƃ\xB5\x82Ĉ\xB5\x82\xED\x82\xEA\x82܂\xB7\x81B<br> \x83\x81\x83j\x83\x85\x81[\x82̍\x80\x96ڐ\x94\x82͍ő\xE5\x82\xC5 20 \x82ł\xB7\x81B </p> <h2>\x90ݒ\xE8\x97\xE1</h2> -<pre> +<pre class="macro-example"> [Resize Menu] ; ; \x89\xA1\x95\x9D 80\x8C\x85, \x8Fc\x95\x9D 37\x8Ds