Revision: 7706 https://osdn.net/projects/ttssh2/scm/svn/commits/7706 Author: zmatsuo Date: 2019-05-22 00:20:52 +0900 (Wed, 22 May 2019) Log Message: ----------- ダイアログフォントの設定をメモリに持つようにした - common/tttype.h に ダイアログフォントに関するメンバを追加 - SetDialogFont()#common/dlglib_cpp.cpp の仕様を変更 - CVTWindow::OnSetupDlgFont#teraterm/vtwin.cpp ダイアログフォント設定でiniファイルに書き込まないようにした - ReadIniFile(),WriteIniFile()#ttpset/ttset.cで読み,書き追加 Modified Paths: -------------- trunk/TTProxy/TTProxy.h trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.c trunk/TTXSamples/TTXViewMode/TTXViewMode.c trunk/teraterm/common/dlglib.h trunk/teraterm/common/dlglib_cpp.cpp trunk/teraterm/common/tttypes.h trunk/teraterm/teraterm/tekwin.cpp trunk/teraterm/teraterm/teraterm.cpp trunk/teraterm/teraterm/vtwin.cpp trunk/teraterm/ttpmacro/ttmacro.cpp trunk/teraterm/ttpset/ttset.c trunk/ttssh2/ttxssh/ttxssh.c -------------- next part -------------- Modified: trunk/TTProxy/TTProxy.h =================================================================== --- trunk/TTProxy/TTProxy.h 2019-05-21 15:20:38 UTC (rev 7705) +++ trunk/TTProxy/TTProxy.h 2019-05-21 15:20:52 UTC (rev 7706) @@ -249,16 +249,14 @@ switch (cmd) { case ID_ABOUTMENU: copy_UILanguageFile(); - SetDialogFont(getInstance().ts->SetupFName, - getInstance().ts->UILanguageFile, - "TTProxy", "DLG_TAHOMA_FONT"); + SetDialogFont(getInstance().ts->DialogFontName, getInstance().ts->DialogFontPoint, getInstance().ts->DialogFontCharSet, + getInstance().ts->UILanguageFile, "TTProxy", "DLG_TAHOMA_FONT"); ProxyWSockHook::aboutDialog(hWin); return 1; case ID_PROXYSETUPMENU: copy_UILanguageFile(); - SetDialogFont(getInstance().ts->SetupFName, - getInstance().ts->UILanguageFile, - "TTProxy", "DLG_TAHOMA_FONT"); + SetDialogFont(getInstance().ts->DialogFontName, getInstance().ts->DialogFontPoint, getInstance().ts->DialogFontCharSet, + getInstance().ts->UILanguageFile, "TTProxy", "DLG_TAHOMA_FONT"); ProxyWSockHook::setupDialog(hWin); return 1; case ID_ASYNCMESSAGEBOX: Modified: trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.c =================================================================== --- trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.c 2019-05-21 15:20:38 UTC (rev 7705) +++ trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.c 2019-05-21 15:20:52 UTC (rev 7706) @@ -582,9 +582,8 @@ static int PASCAL TTXProcessCommand(HWND hWin, WORD cmd) { switch (cmd) { case ID_MENU_SETUP: - SetDialogFont(pvar->ts->SetupFName, - pvar->ts->UILanguageFile, - SECTION, "DLG_TAHOMA_FONT"); + SetDialogFont(pvar->ts->DialogFontName, pvar->ts->DialogFontPoint, pvar->ts->DialogFontCharSet, + pvar->ts->UILanguageFile, SECTION, "DLG_TAHOMA_FONT"); switch (TTDialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SETUP_RECURRINGCOMMAND), hWin, RecurringCommandSetting, (LPARAM)NULL)) { case IDOK: Modified: trunk/TTXSamples/TTXViewMode/TTXViewMode.c =================================================================== --- trunk/TTXSamples/TTXViewMode/TTXViewMode.c 2019-05-21 15:20:38 UTC (rev 7705) +++ trunk/TTXSamples/TTXViewMode/TTXViewMode.c 2019-05-21 15:20:52 UTC (rev 7706) @@ -223,8 +223,8 @@ case ID_MENU_VIEWMODE: if (pvar->enable) { if (strcmp(pvar->password, "") != 0) { - SetDialogFont(pvar->ts->SetupFName, pvar->ts->UILanguageFile, - "TTXViewMode", "DLG_TAHOMA_FONT"); + SetDialogFont(pvar->ts->DialogFontName, pvar->ts->DialogFontPoint, pvar->ts->DialogFontCharSet, + pvar->ts->UILanguageFile, "TTXViewMode", "DLG_TAHOMA_FONT"); switch (TTDialogBoxParam(hInst, MAKEINTRESOURCE(IDD_INPUT_PASSWORD), hWin, ViewModeInputPass, (LPARAM)NULL)) { case IDOK: pvar->enable = FALSE; @@ -250,8 +250,8 @@ } return 1; case ID_MENU_SETPASS: - SetDialogFont(pvar->ts->SetupFName, pvar->ts->UILanguageFile, - "TTXViewMode", "DLG_TAHOMA_FONT"); + SetDialogFont(pvar->ts->DialogFontName, pvar->ts->DialogFontPoint, pvar->ts->DialogFontCharSet, + pvar->ts->UILanguageFile, "TTXViewMode", "DLG_TAHOMA_FONT"); switch (TTDialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SET_PASSWORD), hWin, ViewModeSetPass, (LPARAM)NULL)) { case IDOK: break; Modified: trunk/teraterm/common/dlglib.h =================================================================== --- trunk/teraterm/common/dlglib.h 2019-05-21 15:20:38 UTC (rev 7705) +++ trunk/teraterm/common/dlglib.h 2019-05-21 15:20:52 UTC (rev 7706) @@ -87,7 +87,7 @@ LPCTSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc); -void SetDialogFont(const char *SetupFName, +void SetDialogFont(const char *FontName, int FontHeight, int FontCharSet, const char *UILanguageFile, const char *Section, const char *Key); HFONT SetDlgFonts(HWND hDlg, const int nIDDlgItems[], int nIDDlgItemCount, const char *UILanguageFile, PCHAR key); Modified: trunk/teraterm/common/dlglib_cpp.cpp =================================================================== --- trunk/teraterm/common/dlglib_cpp.cpp 2019-05-21 15:20:38 UTC (rev 7705) +++ trunk/teraterm/common/dlglib_cpp.cpp 2019-05-21 15:20:52 UTC (rev 7706) @@ -250,35 +250,26 @@ } /** - * \x8Eg\x97p\x82\xB7\x82\xE9\x83_\x83C\x83A\x83\x8D\x83O\x83t\x83H\x83\x93\x83g\x82\xF0\x8C\x88\x92肷\x82\xE9 + * \x83_\x83C\x83A\x83\x8D\x83O\x83t\x83H\x83\x93\x83g\x82\xF0\x90ݒ肷\x82\xE9 */ -void SetDialogFont(const char *SetupFName, +void SetDialogFont(const char *FontName, int FontPoint, int FontCharSet, const char *UILanguageFile, const char *Section, const char *Key) { LOGFONTA logfont; BOOL result; - // teraterm.ini\x82̎w\x92\xE8 - if (SetupFName != NULL) { - result = GetI18nLogfont("Tera Term", "DlgFont", &logfont, 0, SetupFName); + // \x8Ew\x92\xE8\x83t\x83H\x83\x93\x83g\x82\xF0\x83Z\x83b\x83g + if (FontName != NULL && FontName[0] != 0) { + // \x91\xB6\x8D݃`\x83F\x83b\x83N + result = IsExistFontA(FontName, FontCharSet, TRUE); if (result == TRUE) { - result = IsExistFontA(logfont.lfFaceName, logfont.lfCharSet, TRUE); - if (result == TRUE) { - TTSetDlgFontA(logfont.lfFaceName, logfont.lfHeight, logfont.lfCharSet); - return; - } + TTSetDlgFontA(FontName, FontPoint, FontCharSet); + return; } } // .lng\x82̎w\x92\xE8 if (UILanguageFile != NULL && Section != NULL && Key != NULL) { -#if 0 - static const char *dlg_font_keys[] = { - "DLG_FONT", - "DLG_TAHOMA_FONT", - "DLG_SYSTEM_FONT", - }; -#endif result = GetI18nLogfont(Section, Key, &logfont, 0, UILanguageFile); if (result == TRUE) { if (IsExistFontA(logfont.lfFaceName, logfont.lfCharSet, TRUE)) { Modified: trunk/teraterm/common/tttypes.h =================================================================== --- trunk/teraterm/common/tttypes.h 2019-05-21 15:20:38 UTC (rev 7705) +++ trunk/teraterm/common/tttypes.h 2019-05-21 15:20:52 UTC (rev 7706) @@ -684,6 +684,9 @@ char LogTimestampFormat[48]; int TerminalInputSpeed; int TerminalOutputSpeed; + char DialogFontName[LF_FACESIZE]; + int DialogFontPoint; + int DialogFontCharSet; }; typedef struct tttset TTTSet, *PTTSet; Modified: trunk/teraterm/teraterm/tekwin.cpp =================================================================== --- trunk/teraterm/teraterm/tekwin.cpp 2019-05-21 15:20:38 UTC (rev 7705) +++ trunk/teraterm/teraterm/tekwin.cpp 2019-05-21 15:20:52 UTC (rev 7706) @@ -789,7 +789,7 @@ return; } OldEmu = ts.TEKColorEmu; - SetDialogFont(ts.SetupFName, + SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet, ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT"); Ok = (*SetupWin)(HTEKWin, &ts); FreeTTDLG(); @@ -832,7 +832,7 @@ if (! LoadTTDLG()) { return; } - SetDialogFont(ts.SetupFName, + SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet, ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT"); (*WindowWindow)(HTEKWin,&Close); FreeTTDLG(); Modified: trunk/teraterm/teraterm/teraterm.cpp =================================================================== --- trunk/teraterm/teraterm/teraterm.cpp 2019-05-21 15:20:38 UTC (rev 7705) +++ trunk/teraterm/teraterm/teraterm.cpp 2019-05-21 15:20:52 UTC (rev 7706) @@ -276,7 +276,8 @@ pVTWin = m_pMainWnd; main_window = m_pMainWnd->m_hWnd; // [Tera Term]\x83Z\x83N\x83V\x83\x87\x83\x93\x82\xCCDLG_SYSTEM_FONT\x82\xF0\x82Ƃ肠\x82\xA6\x82\xB8\x83Z\x83b\x83g\x82\xB7\x82\xE9 - SetDialogFont(ts.SetupFName, ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT"); + SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet, + ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT"); MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { Modified: trunk/teraterm/teraterm/vtwin.cpp =================================================================== --- trunk/teraterm/teraterm/vtwin.cpp 2019-05-21 15:20:38 UTC (rev 7705) +++ trunk/teraterm/teraterm/vtwin.cpp 2019-05-21 15:20:52 UTC (rev 7706) @@ -2253,7 +2253,7 @@ if (!DoSameProcess) { bool DoSameProcessNextDrop; bool DoNotShowDialog = !DefaultShowDialog; - SetDialogFont(ts.SetupFName, + SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet, ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT"); DropType = ShowDropDialogBox(hInst, HVTWin, @@ -3909,7 +3909,7 @@ return; } - SetDialogFont(ts.SetupFName, + SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet, ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT"); if ((*GetHostName)(HVTWin,&GetHNRec)) { if ((GetHNRec.PortType==IdTCPIP) && LoadTTSET()) { @@ -4467,7 +4467,7 @@ if (! LoadTTDLG()) { return; } - SetDialogFont(ts.SetupFName, + SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet, ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT"); (*ChangeDirectory)(HVTWin,ts.FileDir); FreeTTDLG(); @@ -4605,7 +4605,7 @@ { DWORD ret; - SetDialogFont(ts.SetupFName, + SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet, ts.UILanguageFile, "Tera Term", "DLG_TAHOMA_FONT"); CAddSettingPropSheetDlg CAddSetting(hInst, _T("Tera Term: Additional settings"), HVTWin); ret = CAddSetting.DoModal(); @@ -4658,7 +4658,7 @@ if (! LoadTTDLG()) { return; } - SetDialogFont(ts.SetupFName, + SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet, ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT"); Ok = (*SetupTerminal)(HVTWin, &ts); FreeTTDLG(); @@ -4680,7 +4680,7 @@ return; } - SetDialogFont(ts.SetupFName, + SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet, ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT"); strncpy_s(orgTitle, sizeof(orgTitle), ts.Title, _TRUNCATE); Ok = (*SetupWin)(HVTWin, &ts); @@ -4733,15 +4733,16 @@ CHOOSEFONTA cf; BOOL result; - // LogFont.lfHeight \x82\xCD point - result = GetI18nLogfont("Tera Term", "DlgFont", &LogFont, 0, ts.SetupFName); - if (result == TRUE) { - // pixel\x82ɕϊ\xB7 - LogFont.lfHeight = -GetFontPixelFromPoint(m_hWnd, LogFont.lfHeight); - } else { + // LOGFONT\x8F\x80\x94\xF5 + memset(&LogFont, 0, sizeof(LogFont)); + strncpy_s(LogFont.lfFaceName, sizeof(LogFont.lfFaceName), ts.DialogFontName, _TRUNCATE); + LogFont.lfHeight = -GetFontPixelFromPoint(m_hWnd, ts.DialogFontPoint); + LogFont.lfCharSet = ts.DialogFontCharSet; + if (LogFont.lfFaceName[0] == 0) { GetMessageboxFont(&LogFont); } + // \x83_\x83C\x83A\x83\x8D\x83O\x95\\x8E\xA6 memset(&cf, 0, sizeof(cf)); cf.lStructSize = sizeof(cf); cf.hwndOwner = HVTWin; @@ -4758,14 +4759,12 @@ cf.hInstance = hInst; HelpId = HlpSetupFont; result = ChooseFontA(&cf); + if (result) { - char Temp[80]; - int font_point = cf.iPointSize / 10; // point \x82ŕۑ\xB6\x82\xB7\x82\xE9 - _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%s,%d,%d", - LogFont.lfFaceName, - font_point, - LogFont.lfCharSet); - WritePrivateProfileStringA("Tera Term", "DlgFont", Temp, ts.SetupFName); + // \x90ݒ\xE8 + strncpy_s(ts.DialogFontName, sizeof(ts.DialogFontName), LogFont.lfFaceName, _TRUNCATE); + ts.DialogFontPoint = cf.iPointSize / 10; + ts.DialogFontCharSet = LogFont.lfCharSet; } } @@ -4782,7 +4781,7 @@ if (! LoadTTDLG()) { return; } - SetDialogFont(ts.SetupFName, + SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet, ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT"); Ok = (*SetupKeyboard)(HVTWin, &ts); FreeTTDLG(); @@ -4801,7 +4800,7 @@ if (! LoadTTDLG()) { return; } - SetDialogFont(ts.SetupFName, + SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet, ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT"); Ok = (*SetupSerialPort)(HVTWin, &ts); FreeTTDLG(); @@ -4828,7 +4827,7 @@ if (! LoadTTDLG()) { return; } - SetDialogFont(ts.SetupFName, + SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet, ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT"); if ((*SetupTCPIP)(HVTWin, &ts)) { TelUpdateKeepAliveInterval(); @@ -4842,7 +4841,7 @@ if (! LoadTTDLG()) { return; } - SetDialogFont(ts.SetupFName, + SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet, ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT"); if ((*SetupGeneral)(HVTWin,&ts)) { ResetCharSet(); @@ -6228,7 +6227,7 @@ if (! LoadTTDLG()) { return; } - SetDialogFont(ts.SetupFName, + SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet, ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT"); (*WindowWindow)(HVTWin,&Close); FreeTTDLG(); @@ -6277,7 +6276,7 @@ if (! LoadTTDLG()) { return; } - SetDialogFont(ts.SetupFName, + SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet, ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT"); (*AboutDialog)(HVTWin); FreeTTDLG(); Modified: trunk/teraterm/ttpmacro/ttmacro.cpp =================================================================== --- trunk/teraterm/ttpmacro/ttmacro.cpp 2019-05-21 15:20:38 UTC (rev 7705) +++ trunk/teraterm/ttpmacro/ttmacro.cpp 2019-05-21 15:20:52 UTC (rev 7706) @@ -74,6 +74,7 @@ static void init() { char UILanguageFileRel[MAX_PATH]; + LOGFONTA logfont; GetHomeDir(hInst, HomeDir, sizeof(HomeDir)); GetDefaultFName(HomeDir, "TERATERM.INI", SetupFName, sizeof(SetupFName)); @@ -97,7 +98,9 @@ } // UILanguageFile\x82\xCC "Tera Term" \x83Z\x83N\x83V\x83\x87\x83\x93 "DLG_SYSTEM_FONT" \x82̃t\x83H\x83\x93\x83g\x82ɐݒ肷\x82\xE9 - SetDialogFont(SetupFName, UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT"); + GetI18nLogfont("Tera Term", "DlgFont", &logfont, 0, SetupFName); + SetDialogFont(logfont.lfFaceName, logfont.lfHeight, logfont.lfCharSet, + UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT"); } // TTMACRO main engine Modified: trunk/teraterm/ttpset/ttset.c =================================================================== --- trunk/teraterm/ttpset/ttset.c 2019-05-21 15:20:38 UTC (rev 7705) +++ trunk/teraterm/ttpset/ttset.c 2019-05-21 15:20:52 UTC (rev 7706) @@ -250,15 +250,37 @@ FontName[0] = 0; FontSize->x = 0; FontSize->y = 0; - FontCharSet = 0; + *FontCharSet = 0; } else { GetNthString(Temp, 1, FontNameLen, FontName); GetNthNum(Temp, 2, &(FontSize->x)); GetNthNum(Temp, 3, &(FontSize->y)); GetNthNum(Temp, 4, FontCharSet); + // TODO \x82\xBF\x82\xE1\x82\xF1\x82ƃp\x81[\x83X\x82\xB7\x82\xE9 } } +// \x83t\x83H\x83\x93\x83g\x8F\xEE\x95\xF1\x93ǂݍ\x9E\x82݁A3\x83p\x83\x89\x83\x81\x81[\x83^\x94\xC5 +static void ReadFont3( + const char *Sect, const char *Key, const char *Default, const char *FName, + char *FontName, size_t FontNameLen, int *FontPoint, int *FontCharSet) +{ + char Temp[MAX_PATH]; + GetPrivateProfileString(Sect, Key, Default, + Temp, _countof(Temp), FName); + if (Temp[0] == 0) { + // \x83f\x83t\x83H\x83\x8B\x83g\x82\xAA\x83Z\x83b\x83g\x82\xB3\x82\xEA\x82Ă\xA2\x82Ȃ\xA2 & ini\x82ɃG\x83\x93\x83g\x83\x8A\x81[\x82\xAA\x82Ȃ\xA2\x8Fꍇ + FontName[0] = 0; + *FontPoint = 0; + *FontCharSet = 0; + } else { + GetNthString(Temp, 1, FontNameLen, FontName); + GetNthNum(Temp, 2, FontPoint); + GetNthNum(Temp, 3, FontCharSet); + // TODO \x82\xBF\x82\xE1\x82\xF1\x82ƃp\x81[\x83X\x82\xB7\x82\xE9 + } +} + #define CYGTERM_FILE "cygterm.cfg" // CygTerm configuration file #define CYGTERM_FILE_MAXLINE 100 @@ -2060,6 +2082,11 @@ // CygTerm Configuration File ReadCygtermConfFile(ts); + + // dialog font + ReadFont3("Tera Term", "DlgFont", NULL, FName, + ts->DialogFontName, sizeof(ts->DialogFontName), + &ts->DialogFontPoint, &ts->DialogFontCharSet); } void PASCAL WriteIniFile(PCHAR FName, PTTSet ts) @@ -3401,6 +3428,13 @@ // CygTerm Configuration File WriteCygtermConfFile(ts); + + // dialog font + _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%s,%d,%d", + ts->DialogFontName, + ts->DialogFontPoint, + ts->DialogFontCharSet); + WritePrivateProfileStringA("Tera Term", "DlgFont", Temp, FName); } #define VTEditor "VT editor keypad" Modified: trunk/ttssh2/ttxssh/ttxssh.c =================================================================== --- trunk/ttssh2/ttxssh/ttxssh.c 2019-05-21 15:20:38 UTC (rev 7705) +++ trunk/ttssh2/ttxssh/ttxssh.c 2019-05-21 15:20:52 UTC (rev 7706) @@ -1638,12 +1638,13 @@ static void UTIL_SetDialogFont() { - SetDialogFont(pvar->ts->SetupFName, pvar->ts->UILanguageFile, "TTSSH", "DLG_TAHOMA_FONT"); + SetDialogFont(pvar->ts->DialogFontName, pvar->ts->DialogFontPoint, pvar->ts->DialogFontCharSet, + pvar->ts->UILanguageFile, "TTSSH", "DLG_TAHOMA_FONT"); } static BOOL PASCAL TTXGetHostName(HWND parent, PGetHNRec rec) { - SetDialogFont(pvar->ts->SetupFName, + SetDialogFont(pvar->ts->DialogFontName, pvar->ts->DialogFontPoint, pvar->ts->DialogFontCharSet, pvar->ts->UILanguageFile, "TTSSH", "DLG_SYSTEM_FONT"); return (BOOL) DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_HOSTDLG), parent, TTXHostDlg, (LPARAM)rec);