• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision7706 (tree)
Time2019-05-22 00:20:52
Authorzmatsuo

Log Message

ダイアログフォントの設定をメモリに持つようにした

- common/tttype.h に ダイアログフォントに関するメンバを追加
- SetDialogFont()#common/dlglib_cpp.cpp の仕様を変更
- CVTWindow::OnSetupDlgFont#teraterm/vtwin.cpp

ダイアログフォント設定でiniファイルに書き込まないようにした

- ReadIniFile(),WriteIniFile()#ttpset/ttset.cで読み,書き追加

Change Summary

Incremental Difference

--- trunk/TTProxy/TTProxy.h (revision 7705)
+++ trunk/TTProxy/TTProxy.h (revision 7706)
@@ -249,16 +249,14 @@
249249 switch (cmd) {
250250 case ID_ABOUTMENU:
251251 copy_UILanguageFile();
252- SetDialogFont(getInstance().ts->SetupFName,
253- getInstance().ts->UILanguageFile,
254- "TTProxy", "DLG_TAHOMA_FONT");
252+ SetDialogFont(getInstance().ts->DialogFontName, getInstance().ts->DialogFontPoint, getInstance().ts->DialogFontCharSet,
253+ getInstance().ts->UILanguageFile, "TTProxy", "DLG_TAHOMA_FONT");
255254 ProxyWSockHook::aboutDialog(hWin);
256255 return 1;
257256 case ID_PROXYSETUPMENU:
258257 copy_UILanguageFile();
259- SetDialogFont(getInstance().ts->SetupFName,
260- getInstance().ts->UILanguageFile,
261- "TTProxy", "DLG_TAHOMA_FONT");
258+ SetDialogFont(getInstance().ts->DialogFontName, getInstance().ts->DialogFontPoint, getInstance().ts->DialogFontCharSet,
259+ getInstance().ts->UILanguageFile, "TTProxy", "DLG_TAHOMA_FONT");
262260 ProxyWSockHook::setupDialog(hWin);
263261 return 1;
264262 case ID_ASYNCMESSAGEBOX:
--- trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.c (revision 7705)
+++ trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.c (revision 7706)
@@ -582,9 +582,8 @@
582582 static int PASCAL TTXProcessCommand(HWND hWin, WORD cmd) {
583583 switch (cmd) {
584584 case ID_MENU_SETUP:
585- SetDialogFont(pvar->ts->SetupFName,
586- pvar->ts->UILanguageFile,
587- SECTION, "DLG_TAHOMA_FONT");
585+ SetDialogFont(pvar->ts->DialogFontName, pvar->ts->DialogFontPoint, pvar->ts->DialogFontCharSet,
586+ pvar->ts->UILanguageFile, SECTION, "DLG_TAHOMA_FONT");
588587 switch (TTDialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SETUP_RECURRINGCOMMAND),
589588 hWin, RecurringCommandSetting, (LPARAM)NULL)) {
590589 case IDOK:
--- trunk/TTXSamples/TTXViewMode/TTXViewMode.c (revision 7705)
+++ trunk/TTXSamples/TTXViewMode/TTXViewMode.c (revision 7706)
@@ -223,8 +223,8 @@
223223 case ID_MENU_VIEWMODE:
224224 if (pvar->enable) {
225225 if (strcmp(pvar->password, "") != 0) {
226- SetDialogFont(pvar->ts->SetupFName, pvar->ts->UILanguageFile,
227- "TTXViewMode", "DLG_TAHOMA_FONT");
226+ SetDialogFont(pvar->ts->DialogFontName, pvar->ts->DialogFontPoint, pvar->ts->DialogFontCharSet,
227+ pvar->ts->UILanguageFile, "TTXViewMode", "DLG_TAHOMA_FONT");
228228 switch (TTDialogBoxParam(hInst, MAKEINTRESOURCE(IDD_INPUT_PASSWORD), hWin, ViewModeInputPass, (LPARAM)NULL)) {
229229 case IDOK:
230230 pvar->enable = FALSE;
@@ -250,8 +250,8 @@
250250 }
251251 return 1;
252252 case ID_MENU_SETPASS:
253- SetDialogFont(pvar->ts->SetupFName, pvar->ts->UILanguageFile,
254- "TTXViewMode", "DLG_TAHOMA_FONT");
253+ SetDialogFont(pvar->ts->DialogFontName, pvar->ts->DialogFontPoint, pvar->ts->DialogFontCharSet,
254+ pvar->ts->UILanguageFile, "TTXViewMode", "DLG_TAHOMA_FONT");
255255 switch (TTDialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SET_PASSWORD), hWin, ViewModeSetPass, (LPARAM)NULL)) {
256256 case IDOK:
257257 break;
--- trunk/teraterm/common/dlglib.h (revision 7705)
+++ trunk/teraterm/common/dlglib.h (revision 7706)
@@ -87,7 +87,7 @@
8787 LPCTSTR lpTemplateName,
8888 HWND hWndParent,
8989 DLGPROC lpDialogFunc);
90-void SetDialogFont(const char *SetupFName,
90+void SetDialogFont(const char *FontName, int FontHeight, int FontCharSet,
9191 const char *UILanguageFile, const char *Section, const char *Key);
9292 HFONT SetDlgFonts(HWND hDlg, const int nIDDlgItems[], int nIDDlgItemCount,
9393 const char *UILanguageFile, PCHAR key);
--- trunk/teraterm/common/dlglib_cpp.cpp (revision 7705)
+++ trunk/teraterm/common/dlglib_cpp.cpp (revision 7706)
@@ -250,35 +250,26 @@
250250 }
251251
252252 /**
253- * 使用するダイアログフォントを決定する
253+ * ダイアログフォントを設定する
254254 */
255-void SetDialogFont(const char *SetupFName,
255+void SetDialogFont(const char *FontName, int FontPoint, int FontCharSet,
256256 const char *UILanguageFile, const char *Section, const char *Key)
257257 {
258258 LOGFONTA logfont;
259259 BOOL result;
260260
261- // teraterm.iniの指定
262- if (SetupFName != NULL) {
263- result = GetI18nLogfont("Tera Term", "DlgFont", &logfont, 0, SetupFName);
261+ // 指定フォントをセット
262+ if (FontName != NULL && FontName[0] != 0) {
263+ // 存在チェック
264+ result = IsExistFontA(FontName, FontCharSet, TRUE);
264265 if (result == TRUE) {
265- result = IsExistFontA(logfont.lfFaceName, logfont.lfCharSet, TRUE);
266- if (result == TRUE) {
267- TTSetDlgFontA(logfont.lfFaceName, logfont.lfHeight, logfont.lfCharSet);
268- return;
269- }
266+ TTSetDlgFontA(FontName, FontPoint, FontCharSet);
267+ return;
270268 }
271269 }
272270
273271 // .lngの指定
274272 if (UILanguageFile != NULL && Section != NULL && Key != NULL) {
275-#if 0
276- static const char *dlg_font_keys[] = {
277- "DLG_FONT",
278- "DLG_TAHOMA_FONT",
279- "DLG_SYSTEM_FONT",
280- };
281-#endif
282273 result = GetI18nLogfont(Section, Key, &logfont, 0, UILanguageFile);
283274 if (result == TRUE) {
284275 if (IsExistFontA(logfont.lfFaceName, logfont.lfCharSet, TRUE)) {
--- trunk/teraterm/common/tttypes.h (revision 7705)
+++ trunk/teraterm/common/tttypes.h (revision 7706)
@@ -684,6 +684,9 @@
684684 char LogTimestampFormat[48];
685685 int TerminalInputSpeed;
686686 int TerminalOutputSpeed;
687+ char DialogFontName[LF_FACESIZE];
688+ int DialogFontPoint;
689+ int DialogFontCharSet;
687690 };
688691
689692 typedef struct tttset TTTSet, *PTTSet;
--- trunk/teraterm/teraterm/tekwin.cpp (revision 7705)
+++ trunk/teraterm/teraterm/tekwin.cpp (revision 7706)
@@ -789,7 +789,7 @@
789789 return;
790790 }
791791 OldEmu = ts.TEKColorEmu;
792- SetDialogFont(ts.SetupFName,
792+ SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet,
793793 ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT");
794794 Ok = (*SetupWin)(HTEKWin, &ts);
795795 FreeTTDLG();
@@ -832,7 +832,7 @@
832832 if (! LoadTTDLG()) {
833833 return;
834834 }
835- SetDialogFont(ts.SetupFName,
835+ SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet,
836836 ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT");
837837 (*WindowWindow)(HTEKWin,&Close);
838838 FreeTTDLG();
--- trunk/teraterm/teraterm/teraterm.cpp (revision 7705)
+++ trunk/teraterm/teraterm/teraterm.cpp (revision 7706)
@@ -276,7 +276,8 @@
276276 pVTWin = m_pMainWnd;
277277 main_window = m_pMainWnd->m_hWnd;
278278 // [Tera Term]セクションのDLG_SYSTEM_FONTをとりあえずセットする
279- SetDialogFont(ts.SetupFName, ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT");
279+ SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet,
280+ ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT");
280281
281282 MSG msg;
282283 while (GetMessage(&msg, NULL, 0, 0)) {
--- trunk/teraterm/teraterm/vtwin.cpp (revision 7705)
+++ trunk/teraterm/teraterm/vtwin.cpp (revision 7706)
@@ -2253,7 +2253,7 @@
22532253 if (!DoSameProcess) {
22542254 bool DoSameProcessNextDrop;
22552255 bool DoNotShowDialog = !DefaultShowDialog;
2256- SetDialogFont(ts.SetupFName,
2256+ SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet,
22572257 ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT");
22582258 DropType =
22592259 ShowDropDialogBox(hInst, HVTWin,
@@ -3909,7 +3909,7 @@
39093909 return;
39103910 }
39113911
3912- SetDialogFont(ts.SetupFName,
3912+ SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet,
39133913 ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT");
39143914 if ((*GetHostName)(HVTWin,&GetHNRec)) {
39153915 if ((GetHNRec.PortType==IdTCPIP) && LoadTTSET()) {
@@ -4467,7 +4467,7 @@
44674467 if (! LoadTTDLG()) {
44684468 return;
44694469 }
4470- SetDialogFont(ts.SetupFName,
4470+ SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet,
44714471 ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT");
44724472 (*ChangeDirectory)(HVTWin,ts.FileDir);
44734473 FreeTTDLG();
@@ -4605,7 +4605,7 @@
46054605 {
46064606 DWORD ret;
46074607
4608- SetDialogFont(ts.SetupFName,
4608+ SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet,
46094609 ts.UILanguageFile, "Tera Term", "DLG_TAHOMA_FONT");
46104610 CAddSettingPropSheetDlg CAddSetting(hInst, _T("Tera Term: Additional settings"), HVTWin);
46114611 ret = CAddSetting.DoModal();
@@ -4658,7 +4658,7 @@
46584658 if (! LoadTTDLG()) {
46594659 return;
46604660 }
4661- SetDialogFont(ts.SetupFName,
4661+ SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet,
46624662 ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT");
46634663 Ok = (*SetupTerminal)(HVTWin, &ts);
46644664 FreeTTDLG();
@@ -4680,7 +4680,7 @@
46804680 return;
46814681 }
46824682
4683- SetDialogFont(ts.SetupFName,
4683+ SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet,
46844684 ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT");
46854685 strncpy_s(orgTitle, sizeof(orgTitle), ts.Title, _TRUNCATE);
46864686 Ok = (*SetupWin)(HVTWin, &ts);
@@ -4733,15 +4733,16 @@
47334733 CHOOSEFONTA cf;
47344734 BOOL result;
47354735
4736- // LogFont.lfHeight は point
4737- result = GetI18nLogfont("Tera Term", "DlgFont", &LogFont, 0, ts.SetupFName);
4738- if (result == TRUE) {
4739- // pixelに変換
4740- LogFont.lfHeight = -GetFontPixelFromPoint(m_hWnd, LogFont.lfHeight);
4741- } else {
4736+ // LOGFONT準備
4737+ memset(&LogFont, 0, sizeof(LogFont));
4738+ strncpy_s(LogFont.lfFaceName, sizeof(LogFont.lfFaceName), ts.DialogFontName, _TRUNCATE);
4739+ LogFont.lfHeight = -GetFontPixelFromPoint(m_hWnd, ts.DialogFontPoint);
4740+ LogFont.lfCharSet = ts.DialogFontCharSet;
4741+ if (LogFont.lfFaceName[0] == 0) {
47424742 GetMessageboxFont(&LogFont);
47434743 }
47444744
4745+ // ダイアログ表示
47454746 memset(&cf, 0, sizeof(cf));
47464747 cf.lStructSize = sizeof(cf);
47474748 cf.hwndOwner = HVTWin;
@@ -4758,14 +4759,12 @@
47584759 cf.hInstance = hInst;
47594760 HelpId = HlpSetupFont;
47604761 result = ChooseFontA(&cf);
4762+
47614763 if (result) {
4762- char Temp[80];
4763- int font_point = cf.iPointSize / 10; // point で保存する
4764- _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%s,%d,%d",
4765- LogFont.lfFaceName,
4766- font_point,
4767- LogFont.lfCharSet);
4768- WritePrivateProfileStringA("Tera Term", "DlgFont", Temp, ts.SetupFName);
4764+ // 設定
4765+ strncpy_s(ts.DialogFontName, sizeof(ts.DialogFontName), LogFont.lfFaceName, _TRUNCATE);
4766+ ts.DialogFontPoint = cf.iPointSize / 10;
4767+ ts.DialogFontCharSet = LogFont.lfCharSet;
47694768 }
47704769 }
47714770
@@ -4782,7 +4781,7 @@
47824781 if (! LoadTTDLG()) {
47834782 return;
47844783 }
4785- SetDialogFont(ts.SetupFName,
4784+ SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet,
47864785 ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT");
47874786 Ok = (*SetupKeyboard)(HVTWin, &ts);
47884787 FreeTTDLG();
@@ -4801,7 +4800,7 @@
48014800 if (! LoadTTDLG()) {
48024801 return;
48034802 }
4804- SetDialogFont(ts.SetupFName,
4803+ SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet,
48054804 ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT");
48064805 Ok = (*SetupSerialPort)(HVTWin, &ts);
48074806 FreeTTDLG();
@@ -4828,7 +4827,7 @@
48284827 if (! LoadTTDLG()) {
48294828 return;
48304829 }
4831- SetDialogFont(ts.SetupFName,
4830+ SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet,
48324831 ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT");
48334832 if ((*SetupTCPIP)(HVTWin, &ts)) {
48344833 TelUpdateKeepAliveInterval();
@@ -4842,7 +4841,7 @@
48424841 if (! LoadTTDLG()) {
48434842 return;
48444843 }
4845- SetDialogFont(ts.SetupFName,
4844+ SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet,
48464845 ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT");
48474846 if ((*SetupGeneral)(HVTWin,&ts)) {
48484847 ResetCharSet();
@@ -6228,7 +6227,7 @@
62286227 if (! LoadTTDLG()) {
62296228 return;
62306229 }
6231- SetDialogFont(ts.SetupFName,
6230+ SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet,
62326231 ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT");
62336232 (*WindowWindow)(HVTWin,&Close);
62346233 FreeTTDLG();
@@ -6277,7 +6276,7 @@
62776276 if (! LoadTTDLG()) {
62786277 return;
62796278 }
6280- SetDialogFont(ts.SetupFName,
6279+ SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet,
62816280 ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT");
62826281 (*AboutDialog)(HVTWin);
62836282 FreeTTDLG();
--- trunk/teraterm/ttpmacro/ttmacro.cpp (revision 7705)
+++ trunk/teraterm/ttpmacro/ttmacro.cpp (revision 7706)
@@ -74,6 +74,7 @@
7474 static void init()
7575 {
7676 char UILanguageFileRel[MAX_PATH];
77+ LOGFONTA logfont;
7778
7879 GetHomeDir(hInst, HomeDir, sizeof(HomeDir));
7980 GetDefaultFName(HomeDir, "TERATERM.INI", SetupFName, sizeof(SetupFName));
@@ -97,7 +98,9 @@
9798 }
9899
99100 // UILanguageFileの "Tera Term" セクション "DLG_SYSTEM_FONT" のフォントに設定する
100- SetDialogFont(SetupFName, UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT");
101+ GetI18nLogfont("Tera Term", "DlgFont", &logfont, 0, SetupFName);
102+ SetDialogFont(logfont.lfFaceName, logfont.lfHeight, logfont.lfCharSet,
103+ UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT");
101104 }
102105
103106 // TTMACRO main engine
--- trunk/teraterm/ttpset/ttset.c (revision 7705)
+++ trunk/teraterm/ttpset/ttset.c (revision 7706)
@@ -250,15 +250,37 @@
250250 FontName[0] = 0;
251251 FontSize->x = 0;
252252 FontSize->y = 0;
253- FontCharSet = 0;
253+ *FontCharSet = 0;
254254 } else {
255255 GetNthString(Temp, 1, FontNameLen, FontName);
256256 GetNthNum(Temp, 2, &(FontSize->x));
257257 GetNthNum(Temp, 3, &(FontSize->y));
258258 GetNthNum(Temp, 4, FontCharSet);
259+ // TODO ちゃんとパースする
259260 }
260261 }
261262
263+// フォント情報読み込み、3パラメータ版
264+static void ReadFont3(
265+ const char *Sect, const char *Key, const char *Default, const char *FName,
266+ char *FontName, size_t FontNameLen, int *FontPoint, int *FontCharSet)
267+{
268+ char Temp[MAX_PATH];
269+ GetPrivateProfileString(Sect, Key, Default,
270+ Temp, _countof(Temp), FName);
271+ if (Temp[0] == 0) {
272+ // デフォルトがセットされていない & iniにエントリーがない場合
273+ FontName[0] = 0;
274+ *FontPoint = 0;
275+ *FontCharSet = 0;
276+ } else {
277+ GetNthString(Temp, 1, FontNameLen, FontName);
278+ GetNthNum(Temp, 2, FontPoint);
279+ GetNthNum(Temp, 3, FontCharSet);
280+ // TODO ちゃんとパースする
281+ }
282+}
283+
262284 #define CYGTERM_FILE "cygterm.cfg" // CygTerm configuration file
263285 #define CYGTERM_FILE_MAXLINE 100
264286
@@ -2060,6 +2082,11 @@
20602082
20612083 // CygTerm Configuration File
20622084 ReadCygtermConfFile(ts);
2085+
2086+ // dialog font
2087+ ReadFont3("Tera Term", "DlgFont", NULL, FName,
2088+ ts->DialogFontName, sizeof(ts->DialogFontName),
2089+ &ts->DialogFontPoint, &ts->DialogFontCharSet);
20632090 }
20642091
20652092 void PASCAL WriteIniFile(PCHAR FName, PTTSet ts)
@@ -3401,6 +3428,13 @@
34013428
34023429 // CygTerm Configuration File
34033430 WriteCygtermConfFile(ts);
3431+
3432+ // dialog font
3433+ _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%s,%d,%d",
3434+ ts->DialogFontName,
3435+ ts->DialogFontPoint,
3436+ ts->DialogFontCharSet);
3437+ WritePrivateProfileStringA("Tera Term", "DlgFont", Temp, FName);
34043438 }
34053439
34063440 #define VTEditor "VT editor keypad"
--- trunk/ttssh2/ttxssh/ttxssh.c (revision 7705)
+++ trunk/ttssh2/ttxssh/ttxssh.c (revision 7706)
@@ -1638,12 +1638,13 @@
16381638
16391639 static void UTIL_SetDialogFont()
16401640 {
1641- SetDialogFont(pvar->ts->SetupFName, pvar->ts->UILanguageFile, "TTSSH", "DLG_TAHOMA_FONT");
1641+ SetDialogFont(pvar->ts->DialogFontName, pvar->ts->DialogFontPoint, pvar->ts->DialogFontCharSet,
1642+ pvar->ts->UILanguageFile, "TTSSH", "DLG_TAHOMA_FONT");
16421643 }
16431644
16441645 static BOOL PASCAL TTXGetHostName(HWND parent, PGetHNRec rec)
16451646 {
1646- SetDialogFont(pvar->ts->SetupFName,
1647+ SetDialogFont(pvar->ts->DialogFontName, pvar->ts->DialogFontPoint, pvar->ts->DialogFontCharSet,
16471648 pvar->ts->UILanguageFile, "TTSSH", "DLG_SYSTEM_FONT");
16481649 return (BOOL) DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_HOSTDLG),
16491650 parent, TTXHostDlg, (LPARAM)rec);
Show on old repository browser