Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /trunk/teraterm/ttpset/ttset.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2660 - (hide annotations) (download) (as text)
Tue Feb 17 13:53:24 2009 UTC (15 years, 1 month ago) by maya
Original Path: teraterm/trunk/ttpset/ttset.c
File MIME type: text/x-csrc
File size: 91340 byte(s)
* Windows 95
- Winsock2 が必須
- ttermpro の起動に IE4 以上が必須
- ヘルプの表示に IE5 以上が必須
- LogMeTTc は動かない
- TTLEdit はボタンの色がうまく出ない

* NT 4.0
- ヘルプの表示に IE5 以上が必須
- LogMeTT, TTLEdit の起動に SP4(?)以上 が必須
- LogMeTTc の起動に SP6 以上が必須

1 maya 2476 /* Tera Term
2     Copyright(C) 1994-1998 T. Teranishi
3     All rights reserved. */
4     /* IPv6 modification is Copyright(C) 2000 Jun-ya kato <kato@win6.jp> */
5    
6     /* TTSET.DLL, setup file routines*/
7     #ifndef NO_INET6
8     #include <winsock2.h>
9     #include <ws2tcpip.h>
10     #endif /* NO_INET6 */
11     #include "teraterm.h"
12     #include "tttypes.h"
13     #include <stdio.h>
14     #include <string.h>
15     #include <direct.h>
16     #include "ttlib.h"
17 doda 2497 #include "tt_res.h"
18 maya 2476
19 maya 2660 // VS2005でビルドされたバイナリが Windows95 でも起動できるようにするために、
20     // IsDebuggerPresent()のシンボル定義を追加する。
21     //
22     // cf.http://jet2.u-abel.net/program/tips/forceimp.htm
23     // 装飾された名前のアドレスを作るための仮定義
24     // (これだけでインポートを横取りしている)
25     EXTERN_C int WINAPI _imp__IsDebuggerPresent()
26     { return PtrToInt((void*) &_imp__IsDebuggerPresent); }
27     // 実際に横取り処理を行う関数
28     EXTERN_C BOOL WINAPI Cover_IsDebuggerPresent()
29     { return FALSE; }
30     // 関数が実際に呼び出されたときに備えて
31     // 横取り処理関数を呼び出させるための下準備
32     EXTERN_C void __stdcall DoCover_IsDebuggerPresent()
33     {
34     DWORD dw;
35     DWORD_PTR FAR* lpdw;
36     // 横取り関数を設定するアドレスを取得
37     lpdw = (DWORD_PTR FAR*) &_imp__IsDebuggerPresent;
38     // このアドレスを書き込めるように設定
39     // (同じプログラム内なので障害なく行える)
40     VirtualProtect(lpdw, sizeof(DWORD_PTR), PAGE_READWRITE, &dw);
41     // 横取り関数を設定
42     *lpdw = (DWORD_PTR)(FARPROC) Cover_IsDebuggerPresent;
43     // 読み書きの状態を元に戻す
44     VirtualProtect(lpdw, sizeof(DWORD_PTR), dw, NULL);
45     }
46     // アプリケーションが初期化される前に下準備を呼び出す
47     // ※ かなり早くに初期化したいときは、このコードを
48     // ファイルの末尾に書いて「#pragma init_seg(lib)」を、
49     // この変数宣言の手前に書きます。
50     // 初期化を急ぐ必要が無い場合は WinMain 内から
51     // DoCover_IsDebuggerPresent を呼び出して構いません。
52     EXTERN_C int s_DoCover_IsDebuggerPresent
53     = (int) (DoCover_IsDebuggerPresent(), 0);
54    
55 maya 2476 #define Section "Tera Term"
56    
57     static PCHAR far TermList[] =
58     { "VT100", "VT100J", "VT101", "VT102", "VT102J", "VT220J", "VT282",
59     "VT320", "VT382", NULL };
60     // expansion (2005.11.30 yutaka)
61     static PCHAR BaudList[] =
62     { "110", "300", "600", "1200", "2400", "4800", "9600",
63     "14400", "19200", "38400", "57600", "115200",
64     "230400", "460800", "921600", NULL
65     };
66    
67     static PCHAR far RussList[] =
68     { "Windows", "KOI8-R", "CP-866", "ISO-8859-5", NULL };
69     static PCHAR far RussList2[] = { "Windows", "KOI8-R", NULL };
70    
71     WORD str2id(PCHAR far * List, PCHAR str, WORD DefId)
72     {
73     WORD i;
74     i = 0;
75     while ((List[i] != NULL) && (_stricmp(List[i], str) != 0))
76     i++;
77     if (List[i] == NULL)
78     i = DefId;
79     else
80     i++;
81    
82     return i;
83     }
84    
85     void id2str(PCHAR far * List, WORD Id, WORD DefId, PCHAR str, int destlen)
86     {
87     int i;
88    
89     if (Id == 0)
90     i = DefId - 1;
91     else {
92     i = 0;
93     while ((List[i] != NULL) && (i < Id - 1))
94     i++;
95     if (List[i] == NULL)
96     i = DefId - 1;
97     }
98     strncpy_s(str, destlen, List[i], _TRUNCATE);
99     }
100    
101 doda 2497 int IconName2IconId(const char *name) {
102     int id;
103    
104     if (_stricmp(name, "tterm") == 0) {
105     id = IDI_TTERM;
106     }
107     else if (_stricmp(name, "vt") == 0) {
108     id = IDI_VT;
109     }
110     else if (_stricmp(name, "tek") == 0) {
111     id = IDI_TEK;
112     }
113     else if (_stricmp(name, "tterm_classic") == 0) {
114     id = IDI_TTERM_CLASSIC;
115     }
116     else if (_stricmp(name, "vt_classic") == 0) {
117     id = IDI_VT_CLASSIC;
118     }
119     else if (_stricmp(name, "cygterm") == 0) {
120     id = IDI_CYGTERM;
121     }
122     else {
123     id = IdIconDefault;
124     }
125     return id;
126     }
127    
128     void IconId2IconName(char *name, int len, int id) {
129     char *icon;
130     switch (id) {
131     case IDI_TTERM:
132     icon = "tterm";
133     break;
134     case IDI_VT:
135     icon = "vt";
136     break;
137     case IDI_TEK:
138     icon = "tek";
139     break;
140     case IDI_TTERM_CLASSIC:
141     icon = "tterm_classic";
142     break;
143     case IDI_VT_CLASSIC:
144     icon = "vt_classic";
145     break;
146     case IDI_CYGTERM:
147     icon = "cygterm";
148     break;
149     default:
150     icon = "Default";
151     }
152     strncpy_s(name, len, icon, _TRUNCATE);
153     }
154    
155 maya 2476 WORD GetOnOff(PCHAR Sect, PCHAR Key, PCHAR FName, BOOL Default)
156     {
157     char Temp[4];
158     GetPrivateProfileString(Sect, Key, "", Temp, sizeof(Temp), FName);
159     if (Default) {
160     if (_stricmp(Temp, "off") == 0)
161     return 0;
162     else
163     return 1;
164     }
165     else {
166     if (_stricmp(Temp, "on") == 0)
167     return 1;
168     else
169     return 0;
170     }
171     }
172    
173     void WriteOnOff(PCHAR Sect, PCHAR Key, PCHAR FName, WORD Flag)
174     {
175     char Temp[4];
176    
177     if (Flag != 0)
178     strncpy_s(Temp, sizeof(Temp), "on", _TRUNCATE);
179     else
180     strncpy_s(Temp, sizeof(Temp), "off", _TRUNCATE);
181     WritePrivateProfileString(Sect, Key, Temp, FName);
182     }
183    
184     void WriteInt(PCHAR Sect, PCHAR Key, PCHAR FName, int i)
185     {
186     char Temp[15];
187     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", i);
188     WritePrivateProfileString(Sect, Key, Temp, FName);
189     }
190    
191     void WriteUint(PCHAR Sect, PCHAR Key, PCHAR FName, UINT i)
192     {
193     char Temp[15];
194     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%u", i);
195     WritePrivateProfileString(Sect, Key, Temp, FName);
196     }
197    
198     void WriteInt2(PCHAR Sect, PCHAR Key, PCHAR FName, int i1, int i2)
199     {
200     char Temp[32];
201     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d", i1, i2);
202     WritePrivateProfileString(Sect, Key, Temp, FName);
203     }
204    
205     void WriteInt4(PCHAR Sect, PCHAR Key, PCHAR FName,
206     int i1, int i2, int i3, int i4)
207     {
208     char Temp[64];
209     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d,%d,%d",
210     i1, i2, i3, i4);
211     WritePrivateProfileString(Sect, Key, Temp, FName);
212     }
213    
214     void WriteInt6(PCHAR Sect, PCHAR Key, PCHAR FName,
215     int i1, int i2, int i3, int i4, int i5, int i6)
216     {
217     char Temp[96];
218     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d,%d,%d,%d,%d",
219     i1, i2,i3, i4, i5, i6);
220     WritePrivateProfileString(Sect, Key, Temp, FName);
221     }
222    
223     void WriteFont(PCHAR Sect, PCHAR Key, PCHAR FName,
224     PCHAR Name, int x, int y, int charset)
225     {
226     char Temp[80];
227     if (Name[0] != 0)
228     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%s,%d,%d,%d",
229     Name, x, y, charset);
230     else
231     Temp[0] = 0;
232     WritePrivateProfileString(Sect, Key, Temp, FName);
233     }
234    
235     void FAR PASCAL ReadIniFile(PCHAR FName, PTTSet ts)
236     {
237     int i;
238     HDC TmpDC;
239     char Temp[MAXPATHLEN];
240    
241     ts->Minimize = 0;
242     ts->HideWindow = 0;
243     ts->LogFlag = 0; // Log flags
244     ts->FTFlag = 0; // File transfer flags
245     ts->MenuFlag = 0; // Menu flags
246     ts->TermFlag = 0; // Terminal flag
247     ts->ColorFlag = 0; // ANSI color flags
248     ts->PortFlag = 0; // Port flags
249     ts->TelPort = 23;
250    
251     /* Version number */
252     /* GetPrivateProfileString(Section,"Version","",
253     Temp,sizeof(Temp),FName); */
254    
255     /* Language */
256     GetPrivateProfileString(Section, "Language", "",
257     Temp, sizeof(Temp), FName);
258     if (_stricmp(Temp, "Japanese") == 0)
259     ts->Language = IdJapanese;
260     else if (_stricmp(Temp, "Russian") == 0)
261     ts->Language = IdRussian;
262     else if (_stricmp(Temp, "English") == 0)
263     ts->Language = IdEnglish;
264 yutakapon 2556 else if (_stricmp(Temp,"Korean") == 0) // HKS
265     ts->Language = IdKorean;
266 maya 2476 else {
267     switch (PRIMARYLANGID(GetSystemDefaultLangID())) {
268     case LANG_JAPANESE:
269     ts->Language = IdJapanese;
270     break;
271     case LANG_RUSSIAN:
272     ts->Language = IdRussian;
273     break;
274 yutakapon 2556 case LANG_KOREAN: // HKS
275     ts->Language = IdKorean;
276     break;
277 maya 2476 default:
278     ts->Language = IdEnglish;
279     }
280     }
281    
282     /* Port type */
283     GetPrivateProfileString(Section, "Port", "",
284     Temp, sizeof(Temp), FName);
285     if (_stricmp(Temp, "tcpip") == 0)
286     ts->PortType = IdTCPIP;
287     else if (_stricmp(Temp, "serial") == 0)
288     ts->PortType = IdSerial;
289     else {
290     ts->PortType = IdTCPIP;
291     }
292    
293     /* VT win position */
294     GetPrivateProfileString(Section, "VTPos", "-2147483648,-2147483648", Temp, sizeof(Temp), FName); /* default: random position */
295     GetNthNum(Temp, 1, (int far *) (&ts->VTPos.x));
296     GetNthNum(Temp, 2, (int far *) (&ts->VTPos.y));
297    
298     /* TEK win position */
299     GetPrivateProfileString(Section, "TEKPos", "-2147483648,-2147483648", Temp, sizeof(Temp), FName); /* default: random position */
300     GetNthNum(Temp, 1, (int far *) &(ts->TEKPos.x));
301     GetNthNum(Temp, 2, (int far *) &(ts->TEKPos.y));
302    
303     /* Save VT Window position */
304     ts->SaveVTWinPos = GetOnOff(Section, "SaveVTWinPos", FName, FALSE);
305    
306     /* VT terminal size */
307     GetPrivateProfileString(Section, "TerminalSize", "80,24",
308     Temp, sizeof(Temp), FName);
309     GetNthNum(Temp, 1, &ts->TerminalWidth);
310     GetNthNum(Temp, 2, &ts->TerminalHeight);
311     if (ts->TerminalWidth < 0)
312     ts->TerminalWidth = 1;
313     if (ts->TerminalHeight < 0)
314     ts->TerminalHeight = 1;
315    
316     /* Terminal size = Window size */
317     ts->TermIsWin = GetOnOff(Section, "TermIsWin", FName, FALSE);
318    
319     /* Auto window resize flag */
320     ts->AutoWinResize = GetOnOff(Section, "AutoWinResize", FName, FALSE);
321    
322     /* CR Receive */
323     GetPrivateProfileString(Section, "CRReceive", "",
324     Temp, sizeof(Temp), FName);
325     if (_stricmp(Temp, "CRLF") == 0) {
326     ts->CRReceive = IdCRLF;
327     }
328     else if (_stricmp(Temp, "LF") == 0) {
329     ts->CRReceive = IdLF;
330     }
331     else {
332     ts->CRReceive = IdCR;
333     }
334     /* CR Send */
335     GetPrivateProfileString(Section, "CRSend", "",
336     Temp, sizeof(Temp), FName);
337     if (_stricmp(Temp, "CRLF") == 0)
338     ts->CRSend = IdCRLF;
339     else
340     ts->CRSend = IdCR;
341 maya 2482 ts->CRSend_ini = ts->CRSend;
342 maya 2476
343     /* Local echo */
344     ts->LocalEcho = GetOnOff(Section, "LocalEcho", FName, FALSE);
345 maya 2482 ts->LocalEcho_ini = ts->LocalEcho;
346 maya 2476
347     /* Answerback */
348     GetPrivateProfileString(Section, "Answerback", "", Temp,
349     sizeof(Temp), FName);
350     ts->AnswerbackLen =
351     Hex2Str(Temp, ts->Answerback, sizeof(ts->Answerback));
352    
353     /* Kanji Code (receive) */
354     GetPrivateProfileString(Section, "KanjiReceive", "",
355     Temp, sizeof(Temp), FName);
356     if (_stricmp(Temp, "EUC") == 0)
357     ts->KanjiCode = IdEUC;
358     else if (_stricmp(Temp, "JIS") == 0)
359     ts->KanjiCode = IdJIS;
360     else if (_stricmp(Temp, "UTF-8") == 0)
361     ts->KanjiCode = IdUTF8;
362     else if (_stricmp(Temp, "UTF-8m") == 0)
363     ts->KanjiCode = IdUTF8m;
364     else
365     ts->KanjiCode = IdSJIS;
366    
367     /* Katakana (receive) */
368     GetPrivateProfileString(Section, "KatakanaReceive", "",
369     Temp, sizeof(Temp), FName);
370     if (_stricmp(Temp, "7") == 0)
371     ts->JIS7Katakana = 1;
372     else
373     ts->JIS7Katakana = 0;
374    
375     /* Kanji Code (transmit) */
376     GetPrivateProfileString(Section, "KanjiSend", "",
377     Temp, sizeof(Temp), FName);
378     if (_stricmp(Temp, "EUC") == 0)
379     ts->KanjiCodeSend = IdEUC;
380     else if (_stricmp(Temp, "JIS") == 0)
381     ts->KanjiCodeSend = IdJIS;
382     else if (_stricmp(Temp, "UTF-8") == 0)
383     ts->KanjiCodeSend = IdUTF8;
384     else
385     ts->KanjiCodeSend = IdSJIS;
386    
387     /* Katakana (receive) */
388     GetPrivateProfileString(Section, "KatakanaSend", "",
389     Temp, sizeof(Temp), FName);
390     if (_stricmp(Temp, "7") == 0)
391     ts->JIS7KatakanaSend = 1;
392     else
393     ts->JIS7KatakanaSend = 0;
394    
395     /* KanjiIn */
396     GetPrivateProfileString(Section, "KanjiIn", "",
397     Temp, sizeof(Temp), FName);
398     if (_stricmp(Temp, "@") == 0)
399     ts->KanjiIn = IdKanjiInA;
400     else
401     ts->KanjiIn = IdKanjiInB;
402    
403     /* KanjiOut */
404     GetPrivateProfileString(Section, "KanjiOut", "",
405     Temp, sizeof(Temp), FName);
406     if (_stricmp(Temp, "B") == 0)
407     ts->KanjiOut = IdKanjiOutB;
408     else if (_stricmp(Temp, "H") == 0)
409     ts->KanjiOut = IdKanjiOutH;
410     else
411     ts->KanjiOut = IdKanjiOutJ;
412    
413     /* Auto Win Switch VT<->TEK */
414     ts->AutoWinSwitch = GetOnOff(Section, "AutoWinSwitch", FName, FALSE);
415    
416     /* Terminal ID */
417     GetPrivateProfileString(Section, "TerminalID", "",
418     Temp, sizeof(Temp), FName);
419     ts->TerminalID = str2id(TermList, Temp, IdVT100);
420    
421     /* Russian character set (host) */
422     GetPrivateProfileString(Section, "RussHost", "",
423     Temp, sizeof(Temp), FName);
424     ts->RussHost = str2id(RussList, Temp, IdKOI8);
425    
426     /* Russian character set (client) */
427     GetPrivateProfileString(Section, "RussClient", "",
428     Temp, sizeof(Temp), FName);
429     ts->RussClient = str2id(RussList, Temp, IdWindows);
430    
431     /* Title String */
432     GetPrivateProfileString(Section, "Title", "Tera Term",
433     ts->Title, sizeof(ts->Title), FName);
434    
435     /* Cursor shape */
436     GetPrivateProfileString(Section, "CursorShape", "",
437     Temp, sizeof(Temp), FName);
438     if (_stricmp(Temp, "vertical") == 0)
439     ts->CursorShape = IdVCur;
440     else if (_stricmp(Temp, "horizontal") == 0)
441     ts->CursorShape = IdHCur;
442     else
443     ts->CursorShape = IdBlkCur;
444    
445     /* Hide title */
446     ts->HideTitle = GetOnOff(Section, "HideTitle", FName, FALSE);
447    
448     /* Popup menu */
449     ts->PopupMenu = GetOnOff(Section, "PopupMenu", FName, FALSE);
450    
451     /* PC-Style bold color mapping */
452     ts->ColorFlag |=
453     CF_PCBOLD16 * GetOnOff(Section, "PcBoldColor", FName, FALSE);
454    
455     /* aixterm style 16 colors mode */
456     ts->ColorFlag |=
457     CF_AIXTERM16 * GetOnOff(Section, "Aixterm16Color", FName, FALSE);
458    
459     /* xterm style 256 colors mode */
460     ts->ColorFlag |=
461     CF_XTERM256 * GetOnOff(Section, "Xterm256Color", FName, TRUE);
462    
463     /* Enable scroll buffer */
464     ts->EnableScrollBuff =
465     GetOnOff(Section, "EnableScrollBuff", FName, TRUE);
466    
467     /* Scroll buffer size */
468     ts->ScrollBuffSize =
469     GetPrivateProfileInt(Section, "ScrollBuffSize", 100, FName);
470    
471     /* VT Color */
472     GetPrivateProfileString(Section, "VTColor", "0,0,0,255,255,255",
473     Temp, sizeof(Temp), FName);
474     for (i = 0; i <= 5; i++)
475     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
476     for (i = 0; i <= 1; i++)
477     ts->VTColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
478     (BYTE) ts->TmpColor[0][i * 3 + 1],
479     (BYTE) ts->TmpColor[0][i * 3 + 2]);
480    
481     /* VT Bold Color */
482     GetPrivateProfileString(Section, "VTBoldColor", "0,0,255,255,255,255",
483     Temp, sizeof(Temp), FName);
484     for (i = 0; i <= 5; i++)
485     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
486     for (i = 0; i <= 1; i++)
487     ts->VTBoldColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
488     (BYTE) ts->TmpColor[0][i * 3 + 1],
489     (BYTE) ts->TmpColor[0][i * 3 + 2]);
490    
491     /* VT Blink Color */
492     GetPrivateProfileString(Section, "VTBlinkColor", "255,0,0,255,255,255",
493     Temp, sizeof(Temp), FName);
494     for (i = 0; i <= 5; i++)
495     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
496     for (i = 0; i <= 1; i++)
497     ts->VTBlinkColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
498     (BYTE) ts->TmpColor[0][i * 3 + 1],
499     (BYTE) ts->TmpColor[0][i * 3 + 2]);
500    
501 doda 2640 /* VT Reverse Color */
502     GetPrivateProfileString(Section, "VTReverseColor", "255,255,255,0,0,0",
503     Temp, sizeof(Temp), FName);
504     for (i = 0; i <= 5; i++)
505     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
506     for (i = 0; i <= 1; i++)
507     ts->VTReverseColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
508     (BYTE) ts->TmpColor[0][i * 3 + 1],
509     (BYTE) ts->TmpColor[0][i * 3 + 2]);
510    
511 maya 2476 /* begin - ishizaki */
512     ts->EnableClickableUrl =
513     GetOnOff(Section, "EnableClickableUrl", FName, FALSE);
514    
515     /* URL Color */
516     GetPrivateProfileString(Section, "URLColor", "0,255,0,255,255,255",
517     Temp, sizeof(Temp), FName);
518     for (i = 0; i <= 5; i++)
519     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
520     for (i = 0; i <= 1; i++)
521     ts->URLColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
522     (BYTE) ts->TmpColor[0][i * 3 + 1],
523     (BYTE) ts->TmpColor[0][i * 3 + 2]);
524     /* end - ishizaki */
525    
526     /* TEK Color */
527     GetPrivateProfileString(Section, "TEKColor", "0,0,0,255,255,255",
528     Temp, sizeof(Temp), FName);
529     for (i = 0; i <= 5; i++)
530     GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
531     for (i = 0; i <= 1; i++)
532     ts->TEKColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
533     (BYTE) ts->TmpColor[0][i * 3 + 1],
534     (BYTE) ts->TmpColor[0][i * 3 + 2]);
535    
536     #ifndef NO_ANSI_COLOR_EXTENSION
537     /* ANSI color definition (in the case FullColor=on) -- special option
538     o UseTextColor should be off, or the background and foreground color of
539     VTColor are assigned to color-number 0 and 7 respectively, even if
540     they are specified in ANSIColor.
541     o ANSIColor is a set of 4 values that are color-number(0--15),
542     red-value(0--255), green-value(0--255) and blue-value(0--255). */
543     GetPrivateProfileString(Section, "ANSIColor",
544     " 0, 0, 0, 0,"
545     " 1,255, 0, 0,"
546     " 2, 0,255, 0,"
547     " 3,255,255, 0,"
548     " 4, 0, 0,255,"
549     " 5,255, 0,255,"
550     " 6, 0,255,255,"
551     " 7,255,255,255,"
552     " 8,128,128,128,"
553     " 9,128, 0, 0,"
554     "10, 0,128, 0,"
555     "11,128,128, 0,"
556     "12, 0, 0,128,"
557     "13,128, 0,128,"
558     "14, 0,128,128,"
559     "15,192,192,192", Temp, sizeof(Temp), FName);
560     {
561     char *t;
562     int n = 1;
563     for (t = Temp; *t; t++)
564     if (*t == ',')
565     n++;
566     n /= 4;
567     for (i = 0; i <= n; i++) {
568     int colorid, r, g, b;
569     GetNthNum(Temp, i * 4 + 1, (int far *) &colorid);
570     GetNthNum(Temp, i * 4 + 2, (int far *) &r);
571     GetNthNum(Temp, i * 4 + 3, (int far *) &g);
572     GetNthNum(Temp, i * 4 + 4, (int far *) &b);
573     ts->ANSIColor[colorid & 15] =
574     RGB((BYTE) r, (BYTE) g, (BYTE) b);
575     }
576     }
577 doda 2496 #endif /* NO_ANSI_COLOR_EXTENSION */
578 maya 2476
579     TmpDC = GetDC(0); /* Get screen device context */
580     for (i = 0; i <= 1; i++)
581     ts->VTColor[i] = GetNearestColor(TmpDC, ts->VTColor[i]);
582     for (i = 0; i <= 1; i++)
583     ts->VTBoldColor[i] = GetNearestColor(TmpDC, ts->VTBoldColor[i]);
584     for (i = 0; i <= 1; i++)
585     ts->VTBlinkColor[i] = GetNearestColor(TmpDC, ts->VTBlinkColor[i]);
586     for (i = 0; i <= 1; i++)
587     ts->TEKColor[i] = GetNearestColor(TmpDC, ts->TEKColor[i]);
588     /* begin - ishizaki */
589     for (i = 0; i <= 1; i++)
590     ts->URLColor[i] = GetNearestColor(TmpDC, ts->URLColor[i]);
591     /* end - ishizaki */
592     #ifndef NO_ANSI_COLOR_EXTENSION
593     for (i = 0; i < 16; i++)
594     ts->ANSIColor[i] = GetNearestColor(TmpDC, ts->ANSIColor[i]);
595 doda 2496 #endif /* NO_ANSI_COLOR_EXTENSION */
596 maya 2476 ReleaseDC(0, TmpDC);
597    
598     /* TEK color emulation */
599     ts->TEKColorEmu = GetOnOff(Section, "TEKColorEmulation", FName, FALSE);
600    
601     /* VT Font */
602     GetPrivateProfileString(Section, "VTFont", "Terminal,0,-13,1",
603     Temp, sizeof(Temp), FName);
604     GetNthString(Temp, 1, sizeof(ts->VTFont), ts->VTFont);
605     GetNthNum(Temp, 2, (int far *) &(ts->VTFontSize.x));
606     GetNthNum(Temp, 3, (int far *) &(ts->VTFontSize.y));
607     GetNthNum(Temp, 4, &(ts->VTFontCharSet));
608    
609     /* Bold font flag */
610     ts->EnableBold = GetOnOff(Section, "EnableBold", FName, TRUE);
611    
612     /* Russian character set (font) */
613     GetPrivateProfileString(Section, "RussFont", "",
614     Temp, sizeof(Temp), FName);
615     ts->RussFont = str2id(RussList, Temp, IdWindows);
616    
617     /* TEK Font */
618     GetPrivateProfileString(Section, "TEKFont", "Courier,0,-13,0",
619     Temp, sizeof(Temp), FName);
620     GetNthString(Temp, 1, sizeof(ts->TEKFont), ts->TEKFont);
621     GetNthNum(Temp, 2, (int far *) &(ts->TEKFontSize.x));
622     GetNthNum(Temp, 3, (int far *) &(ts->TEKFontSize.y));
623     GetNthNum(Temp, 4, &(ts->TEKFontCharSet));
624    
625     /* BS key */
626     GetPrivateProfileString(Section, "BSKey", "",
627     Temp, sizeof(Temp), FName);
628     if (_stricmp(Temp, "DEL") == 0)
629     ts->BSKey = IdDEL;
630     else
631     ts->BSKey = IdBS;
632     /* Delete key */
633     ts->DelKey = GetOnOff(Section, "DeleteKey", FName, FALSE);
634    
635     /* Meta Key */
636     ts->MetaKey = GetOnOff(Section, "MetaKey", FName, FALSE);
637    
638     /* Application Keypad */
639 doda 2496 ts->DisableAppKeypad =
640     GetOnOff(Section, "DisableAppKeypad", FName, FALSE);
641 maya 2476
642     /* Application Cursor */
643 doda 2496 ts->DisableAppCursor =
644     GetOnOff(Section, "DisableAppCursor", FName, FALSE);
645 maya 2476
646     /* Russian keyboard type */
647     GetPrivateProfileString(Section, "RussKeyb", "",
648     Temp, sizeof(Temp), FName);
649     ts->RussKeyb = str2id(RussList2, Temp, IdWindows);
650    
651     /* Serial port ID */
652     ts->ComPort = GetPrivateProfileInt(Section, "ComPort", 1, FName);
653    
654     /* Baud rate */
655     GetPrivateProfileString(Section, "BaudRate", "9600",
656     Temp, sizeof(Temp), FName);
657     ts->Baud = str2id(BaudList, Temp, IdBaud9600);
658    
659     /* Parity */
660     GetPrivateProfileString(Section, "Parity", "",
661     Temp, sizeof(Temp), FName);
662     if (_stricmp(Temp, "even") == 0)
663     ts->Parity = IdParityEven;
664     else if (_stricmp(Temp, "odd") == 0)
665     ts->Parity = IdParityOdd;
666     else
667     ts->Parity = IdParityNone;
668    
669     /* Data bit */
670     GetPrivateProfileString(Section, "DataBit", "",
671     Temp, sizeof(Temp), FName);
672     if (_stricmp(Temp, "7") == 0)
673     ts->DataBit = IdDataBit7;
674     else
675     ts->DataBit = IdDataBit8;
676    
677     /* Stop bit */
678     GetPrivateProfileString(Section, "StopBit", "",
679     Temp, sizeof(Temp), FName);
680     if (_stricmp(Temp, "2") == 0)
681     ts->StopBit = IdStopBit2;
682     else
683     ts->StopBit = IdStopBit1;
684    
685     /* Flow control */
686     GetPrivateProfileString(Section, "FlowCtrl", "",
687     Temp, sizeof(Temp), FName);
688     if (_stricmp(Temp, "x") == 0)
689     ts->Flow = IdFlowX;
690     else if (_stricmp(Temp, "hard") == 0)
691     ts->Flow = IdFlowHard;
692     else
693     ts->Flow = IdFlowNone;
694    
695     /* Delay per character */
696     ts->DelayPerChar =
697     GetPrivateProfileInt(Section, "DelayPerChar", 0, FName);
698    
699     /* Delay per line */
700     ts->DelayPerLine =
701     GetPrivateProfileInt(Section, "DelayPerLine", 0, FName);
702    
703     /* Telnet flag */
704     ts->Telnet = GetOnOff(Section, "Telnet", FName, TRUE);
705    
706     /* Telnet terminal type */
707     GetPrivateProfileString(Section, "TermType", "xterm", ts->TermType,
708 doda 2496 sizeof(ts->TermType), FName);
709 maya 2476
710     /* TCP port num */
711     ts->TCPPort =
712     GetPrivateProfileInt(Section, "TCPPort", ts->TelPort, FName);
713    
714     /* Auto window close flag */
715     ts->AutoWinClose = GetOnOff(Section, "AutoWinClose", FName, TRUE);
716    
717     /* History list */
718     ts->HistoryList = GetOnOff(Section, "HistoryList", FName, FALSE);
719    
720     /* File transfer binary flag */
721     ts->TransBin = GetOnOff(Section, "TransBin", FName, FALSE);
722    
723     /* Log append */
724     ts->Append = GetOnOff(Section, "LogAppend", FName, FALSE);
725    
726     /* Log plain text (2005.5.7 yutaka) */
727     ts->LogTypePlainText =
728     GetOnOff(Section, "LogTypePlainText", FName, FALSE);
729    
730     /* Log with timestamp (2006.7.23 maya) */
731     ts->LogTimestamp = GetOnOff(Section, "LogTimestamp", FName, FALSE);
732    
733     /* Log without transfer dialog */
734     ts->LogHideDialog = GetOnOff(Section, "LogHideDialog", FName, FALSE);
735    
736     /* Default Log file name (2006.8.28 maya) */
737     GetPrivateProfileString(Section, "LogDefaultName", "teraterm.log",
738     ts->LogDefaultName, sizeof(ts->LogDefaultName),
739     FName);
740    
741     /* Default Log file path (2007.5.30 maya) */
742     GetPrivateProfileString(Section, "LogDefaultPath", "",
743     ts->LogDefaultPath, sizeof(ts->LogDefaultPath),
744     FName);
745    
746     /* Auto start logging (2007.5.31 maya) */
747     ts->LogAutoStart = GetOnOff(Section, "LogAutoStart", FName, FALSE);
748    
749     /* XMODEM option */
750     GetPrivateProfileString(Section, "XmodemOpt", "",
751     Temp, sizeof(Temp), FName);
752     if (_stricmp(Temp, "crc") == 0)
753     ts->XmodemOpt = XoptCRC;
754     else if (_stricmp(Temp, "1k") == 0)
755     ts->XmodemOpt = Xopt1K;
756     else
757     ts->XmodemOpt = XoptCheck;
758    
759     /* XMODEM binary file */
760     ts->XmodemBin = GetOnOff(Section, "XmodemBin", FName, TRUE);
761    
762     /* XMODEM 受信コマンド (2007.12.21 yutaka) */
763 yutakapon 2478 GetPrivateProfileString(Section, "XModemRcvCommand", "",
764 doda 2496 ts->XModemRcvCommand,
765     sizeof(ts->XModemRcvCommand), FName);
766 maya 2476
767     /* Default directory for file transfer */
768     GetPrivateProfileString(Section, "FileDir", "",
769     ts->FileDir, sizeof(ts->FileDir), FName);
770     if (strlen(ts->FileDir) == 0)
771     strncpy_s(ts->FileDir, sizeof(ts->FileDir), ts->HomeDir, _TRUNCATE);
772     else {
773     _getcwd(Temp, sizeof(Temp));
774     if (_chdir(ts->FileDir) != 0)
775     strncpy_s(ts->FileDir, sizeof(ts->FileDir), ts->HomeDir, _TRUNCATE);
776     _chdir(Temp);
777     }
778    
779     /* filter on file send (2007.6.5 maya) */
780     GetPrivateProfileString(Section, "FileSendFilter", "",
781     ts->FileSendFilter, sizeof(ts->FileSendFilter),
782     FName);
783    
784     /*--------------------------------------------------*/
785     /* 8 bit control code flag -- special option */
786     ts->TermFlag |=
787     TF_ACCEPT8BITCTRL *
788     GetOnOff(Section, "Accept8BitCtrl", FName, TRUE);
789    
790     /* Wrong sequence flag -- special option */
791     ts->TermFlag |=
792     TF_ALLOWWRONGSEQUENCE *
793     GetOnOff(Section, "AllowWrongSequence", FName, FALSE);
794    
795     if (((ts->TermFlag & TF_ALLOWWRONGSEQUENCE) == 0) &&
796     (ts->KanjiOut == IdKanjiOutH))
797     ts->KanjiOut = IdKanjiOutJ;
798    
799     // Auto file renaming --- special option
800     ts->FTFlag |=
801     FT_RENAME * GetOnOff(Section, "AutoFileRename", FName, FALSE);
802    
803     // Auto invoking (character set->G0->GL) --- special option
804     ts->TermFlag |=
805     TF_AUTOINVOKE * GetOnOff(Section, "AutoInvoke", FName, FALSE);
806    
807     // Auto text copy --- special option
808     ts->AutoTextCopy = GetOnOff(Section, "AutoTextCopy", FName, TRUE);
809    
810     /* Back wrap -- special option */
811     ts->TermFlag |=
812     TF_BACKWRAP * GetOnOff(Section, "BackWrap", FName, FALSE);
813    
814     /* Beep type -- special option */
815 doda 2554 GetPrivateProfileString(Section, "Beep", "", Temp, sizeof(Temp), FName);
816     if (_stricmp(Temp, "off") == 0)
817     ts->Beep = IdBeepOff;
818     else if (_stricmp(Temp, "visual") == 0)
819     ts->Beep = IdBeepVisual;
820     else
821     ts->Beep = IdBeepOn;
822 maya 2476
823     /* Beep on connection & disconnection -- special option */
824     ts->PortFlag |=
825     PF_BEEPONCONNECT * GetOnOff(Section, "BeepOnConnect", FName,
826 doda 2496 FALSE);
827 maya 2476
828     /* Auto B-Plus activation -- special option */
829     ts->FTFlag |= FT_BPAUTO * GetOnOff(Section, "BPAuto", FName, FALSE);
830     if ((ts->FTFlag & FT_BPAUTO) != 0) { /* Answerback */
831     strncpy_s(ts->Answerback, sizeof(ts->Answerback), "\020++\0200",
832     _TRUNCATE);
833     ts->AnswerbackLen = 5;
834     }
835    
836     /* B-Plus ESCCTL flag -- special option */
837     ts->FTFlag |=
838     FT_BPESCCTL * GetOnOff(Section, "BPEscCtl", FName, FALSE);
839    
840     /* B-Plus log -- special option */
841     ts->LogFlag |= LOG_BP * GetOnOff(Section, "BPLog", FName, FALSE);
842    
843     /* Clear serial port buffer when port opening -- special option */
844 doda 2496 ts->ClearComBuffOnOpen =
845     GetOnOff(Section, "ClearComBuffOnOpen", FName, TRUE);
846 maya 2476
847     /* Confirm disconnection -- special option */
848     ts->PortFlag |=
849 doda 2496 PF_CONFIRMDISCONN * GetOnOff(Section, "ConfirmDisconnect",
850     FName, TRUE);
851 maya 2476
852     /* Ctrl code in Kanji -- special option */
853     ts->TermFlag |=
854     TF_CTRLINKANJI * GetOnOff(Section, "CtrlInKanji", FName, TRUE);
855    
856     /* Debug flag -- special option */
857     ts->Debug = GetOnOff(Section, "Debug", FName, FALSE);
858    
859     /* Delimiter list -- special option */
860     GetPrivateProfileString(Section, "DelimList",
861     "$20!\"#$24%&\'()*+,-./:;<=>?@[\\]^`{|}~",
862     Temp, sizeof(Temp), FName);
863     Hex2Str(Temp, ts->DelimList, sizeof(ts->DelimList));
864    
865     /* regard DBCS characters as delimiters -- special option */
866     ts->DelimDBCS = GetOnOff(Section, "DelimDBCS", FName, TRUE);
867    
868     // Enable popup menu -- special option
869     if (GetOnOff(Section, "EnablePopupMenu", FName, TRUE) == 0)
870     ts->MenuFlag |= MF_NOPOPUP;
871    
872     // Enable "Show menu" -- special option
873     if (GetOnOff(Section, "EnableShowMenu", FName, TRUE) == 0)
874     ts->MenuFlag |= MF_NOSHOWMENU;
875    
876     // Enable the status line -- special option
877     ts->TermFlag |=
878     TF_ENABLESLINE * GetOnOff(Section, "EnableStatusLine", FName, TRUE);
879    
880     // fixed JIS --- special
881     ts->TermFlag |=
882     TF_FIXEDJIS * GetOnOff(Section, "FixedJIS", FName, FALSE);
883    
884     /* IME Flag -- special option */
885     ts->UseIME = GetOnOff(Section, "IME", FName, TRUE);
886    
887     /* IME-inline Flag -- special option */
888     ts->IMEInline = GetOnOff(Section, "IMEInline", FName, TRUE);
889    
890     /* Kermit log -- special option */
891     ts->LogFlag |= LOG_KMT * GetOnOff(Section, "KmtLog", FName, FALSE);
892    
893     // Enable language selection -- special option
894     if (GetOnOff(Section, "LanguageSelection", FName, TRUE) == 0)
895     ts->MenuFlag |= MF_NOLANGUAGE;
896    
897     /* Maximum scroll buffer size -- special option */
898     ts->ScrollBuffMax =
899     GetPrivateProfileInt(Section, "MaxBuffSize", 10000, FName);
900     if (ts->ScrollBuffMax < 24)
901     ts->ScrollBuffMax = 10000;
902    
903     /* Max com port number -- special option */
904     ts->MaxComPort = GetPrivateProfileInt(Section, "MaxComPort", 4, FName);
905     if (ts->MaxComPort < 4)
906     ts->MaxComPort = 4;
907     // COM16から99へ拡張 (2005.11.30 yutaka)
908     // 99から200へ拡張 (2007.7.23 maya)
909     if (ts->MaxComPort > MAXCOMPORT)
910     ts->MaxComPort = MAXCOMPORT;
911     if ((ts->ComPort < 1) || (ts->ComPort > ts->MaxComPort))
912     ts->ComPort = 1;
913    
914     /* Non-blinking cursor -- special option */
915     ts->NonblinkingCursor =
916     GetOnOff(Section, "NonblinkingCursor", FName, FALSE);
917    
918     // フォーカス無効時のポリゴンカーソル (2008.1.24 yutaka)
919     ts->KillFocusCursor =
920     GetOnOff(Section, "KillFocusCursor", FName, TRUE);
921    
922     /* Delay for pass-thru printing activation */
923     /* -- special option */
924     ts->PassThruDelay =
925     GetPrivateProfileInt(Section, "PassThruDelay", 3, FName);
926    
927     /* Printer port for pass-thru printing */
928     /* -- special option */
929     GetPrivateProfileString(Section, "PassThruPort", "",
930 doda 2496 ts->PrnDev, sizeof(ts->PrnDev), FName);
931 maya 2476
932     /* Printer Font --- special option */
933     GetPrivateProfileString(Section, "PrnFont", "",
934     Temp, sizeof(Temp), FName);
935     if (strlen(Temp) == 0) {
936     ts->PrnFont[0] = 0;
937     ts->PrnFontSize.x = 0;
938     ts->PrnFontSize.y = 0;
939     ts->PrnFontCharSet = 0;
940     }
941     else {
942     GetNthString(Temp, 1, sizeof(ts->PrnFont), ts->PrnFont);
943     GetNthNum(Temp, 2, (int far *) &(ts->PrnFontSize.x));
944     GetNthNum(Temp, 3, (int far *) &(ts->PrnFontSize.y));
945     GetNthNum(Temp, 4, &(ts->PrnFontCharSet));
946     }
947    
948     // Page margins (left, right, top, bottom) for printing
949     // -- special option
950     GetPrivateProfileString(Section, "PrnMargin", "50,50,50,50",
951     Temp, sizeof(Temp), FName);
952     for (i = 0; i <= 3; i++)
953     GetNthNum(Temp, 1 + i, &ts->PrnMargin[i]);
954    
955     /* Quick-VAN log -- special option */
956     ts->LogFlag |= LOG_QV * GetOnOff(Section, "QVLog", FName, FALSE);
957    
958     /* Quick-VAN window size -- special */
959     ts->QVWinSize = GetPrivateProfileInt(Section, "QVWinSize", 8, FName);
960    
961     /* Russian character set (print) -- special option */
962     GetPrivateProfileString(Section, "RussPrint", "",
963     Temp, sizeof(Temp), FName);
964     ts->RussPrint = str2id(RussList, Temp, IdWindows);
965    
966     /* Scroll threshold -- special option */
967     ts->ScrollThreshold =
968     GetPrivateProfileInt(Section, "ScrollThreshold", 12, FName);
969    
970     ts->MouseWheelScrollLine =
971     GetPrivateProfileInt(Section, "MouseWheelScrollLine", 3, FName);
972    
973     // Select on activate -- special option
974     ts->SelOnActive = GetOnOff(Section, "SelectOnActivate", FName, TRUE);
975    
976     /* Send 8bit control sequence -- special option */
977     ts->Send8BitCtrl = GetOnOff(Section, "Send8BitCtrl", FName, FALSE);
978    
979     /* Startup macro -- special option */
980     GetPrivateProfileString(Section, "StartupMacro", "",
981     ts->MacroFN, sizeof(ts->MacroFN), FName);
982    
983     /* TEK GIN Mouse keycode -- special option */
984     ts->GINMouseCode =
985     GetPrivateProfileInt(Section, "TEKGINMouseCode", 32, FName);
986    
987     /* Telnet Auto Detect -- special option */
988     ts->TelAutoDetect = GetOnOff(Section, "TelAutoDetect", FName, TRUE);
989    
990     /* Telnet binary flag -- special option */
991     ts->TelBin = GetOnOff(Section, "TelBin", FName, FALSE);
992    
993     /* Telnet Echo flag -- special option */
994     ts->TelEcho = GetOnOff(Section, "TelEcho", FName, FALSE);
995    
996     /* Telnet log -- special option */
997     ts->LogFlag |= LOG_TEL * GetOnOff(Section, "TelLog", FName, FALSE);
998    
999     /* TCP port num for telnet -- special option */
1000     ts->TelPort = GetPrivateProfileInt(Section, "TelPort", 23, FName);
1001    
1002     /* Telnet keep-alive packet(NOP command) interval -- special option */
1003     ts->TelKeepAliveInterval =
1004     GetPrivateProfileInt(Section, "TelKeepAliveInterval", 300, FName);
1005    
1006     /* Max number of broadcast commad history */
1007     ts->MaxBroadcatHistory =
1008     GetPrivateProfileInt(Section, "MaxBroadcatHistory", 99, FName);
1009    
1010     /* Local echo for non-telnet */
1011     ts->TCPLocalEcho = GetOnOff(Section, "TCPLocalEcho", FName, FALSE);
1012    
1013     /* "new-line (transmit)" option for non-telnet -- special option */
1014     GetPrivateProfileString(Section, "TCPCRSend", "",
1015     Temp, sizeof(Temp), FName);
1016     if (_stricmp(Temp, "CR") == 0)
1017     ts->TCPCRSend = IdCR;
1018     else if (_stricmp(Temp, "CRLF") == 0)
1019     ts->TCPCRSend = IdCRLF;
1020     else
1021     ts->TCPCRSend = 0; // disabled
1022    
1023     /* Use text (background) color for "white (black)"
1024     --- special option */
1025     ts->ColorFlag |=
1026     CF_USETEXTCOLOR * GetOnOff(Section, "UseTextColor", FName, FALSE);
1027    
1028     /* Title format -- special option */
1029     ts->TitleFormat =
1030     GetPrivateProfileInt(Section, "TitleFormat", 5, FName);
1031    
1032     /* VT Compatible Tab -- special option */
1033     ts->VTCompatTab = GetOnOff(Section, "VTCompatTab", FName, FALSE);
1034    
1035     /* VT Font space --- special option */
1036     GetPrivateProfileString(Section, "VTFontSpace", "0,0,0,0",
1037     Temp, sizeof(Temp), FName);
1038     GetNthNum(Temp, 1, &ts->FontDX);
1039     GetNthNum(Temp, 2, &ts->FontDW);
1040     GetNthNum(Temp, 3, &ts->FontDY);
1041     GetNthNum(Temp, 4, &ts->FontDH);
1042     if (ts->FontDX < 0)
1043     ts->FontDX = 0;
1044     if (ts->FontDW < 0)
1045     ts->FontDW = 0;
1046     ts->FontDW = ts->FontDW + ts->FontDX;
1047     if (ts->FontDY < 0)
1048     ts->FontDY = 0;
1049     if (ts->FontDH < 0)
1050     ts->FontDH = 0;
1051     ts->FontDH = ts->FontDH + ts->FontDY;
1052    
1053     // VT-print scaling factors (pixels per inch) --- special option
1054     GetPrivateProfileString(Section, "VTPPI", "0,0",
1055     Temp, sizeof(Temp), FName);
1056     GetNthNum(Temp, 1, (int far *) &ts->VTPPI.x);
1057     GetNthNum(Temp, 2, (int far *) &ts->VTPPI.y);
1058    
1059     // TEK-print scaling factors (pixels per inch) --- special option
1060     GetPrivateProfileString(Section, "TEKPPI", "0,0",
1061     Temp, sizeof(Temp), FName);
1062     GetNthNum(Temp, 1, (int far *) &ts->TEKPPI.x);
1063     GetNthNum(Temp, 2, (int far *) &ts->TEKPPI.y);
1064    
1065     // Show "Window" menu -- special option
1066     ts->MenuFlag |=
1067     MF_SHOWWINMENU * GetOnOff(Section, "WindowMenu", FName, TRUE);
1068    
1069     /* XMODEM log -- special option */
1070     ts->LogFlag |= LOG_X * GetOnOff(Section, "XmodemLog", FName, FALSE);
1071    
1072 yutakapon 2539 /* YMODEM log -- special option */
1073     ts->LogFlag |= LOG_Y * GetOnOff(Section, "YmodemLog", FName, FALSE);
1074    
1075 maya 2476 /* Auto ZMODEM activation -- special option */
1076     ts->FTFlag |= FT_ZAUTO * GetOnOff(Section, "ZmodemAuto", FName, FALSE);
1077    
1078     /* ZMODEM data subpacket length for sending -- special */
1079     ts->ZmodemDataLen =
1080     GetPrivateProfileInt(Section, "ZmodemDataLen", 1024, FName);
1081     /* ZMODEM window size for sending -- special */
1082     ts->ZmodemWinSize =
1083     GetPrivateProfileInt(Section, "ZmodemWinSize", 32767, FName);
1084    
1085     /* ZMODEM ESCCTL flag -- special option */
1086     ts->FTFlag |=
1087     FT_ZESCCTL * GetOnOff(Section, "ZmodemEscCtl", FName, FALSE);
1088    
1089     /* ZMODEM log -- special option */
1090     ts->LogFlag |= LOG_Z * GetOnOff(Section, "ZmodemLog", FName, FALSE);
1091    
1092     /* ZMODEM 受信コマンド (2007.12.21 yutaka) */
1093     GetPrivateProfileString(Section, "ZModemRcvCommand", "rz",
1094     ts->ZModemRcvCommand, sizeof(ts->ZModemRcvCommand), FName);
1095    
1096     #ifndef NO_COPYLINE_FIX
1097    
1098     /* Enable continued-line copy -- special option */
1099     ts->EnableContinuedLineCopy =
1100     GetOnOff(Section, "EnableContinuedLineCopy", FName, FALSE);
1101     #endif /* NO_COPYLINE_FIX */
1102    
1103     ts->DisablePasteMouseRButton =
1104     GetOnOff(Section, "DisablePasteMouseRButton", FName, FALSE);
1105    
1106     // added DisablePasteMouseMButton (2008.3.2 maya)
1107     ts->DisablePasteMouseMButton =
1108     GetOnOff(Section, "DisablePasteMouseMButton", FName, TRUE);
1109    
1110     // added ConfirmPasteMouseRButton (2007.3.17 maya)
1111     ts->ConfirmPasteMouseRButton =
1112     GetOnOff(Section, "ConfirmPasteMouseRButton", FName, FALSE);
1113    
1114     // added ConfirmChangePaste (2008.2.3 yutaka)
1115     ts->ConfirmChangePaste =
1116     GetOnOff(Section, "ConfirmChangePaste", FName, FALSE);
1117    
1118 yutakapon 2498 // added ScrollWindowClearScreen (2008.5.3 yutaka)
1119     ts->ScrollWindowClearScreen =
1120     GetOnOff(Section, "ScrollWindowClearScreen", FName, TRUE);
1121    
1122 maya 2476 // added SelectOnlyByLButton (2007.11.20 maya)
1123     ts->SelectOnlyByLButton =
1124     GetOnOff(Section, "SelectOnlyByLButton", FName, TRUE);
1125    
1126     // added DisableAcceleratorSendBreak (2007.3.17 maya)
1127     ts->DisableAcceleratorSendBreak =
1128     GetOnOff(Section, "DisableAcceleratorSendBreak", FName, FALSE);
1129    
1130     // WinSock connecting timeout value (2007.1.11 yutaka)
1131     ts->ConnectingTimeout =
1132     GetPrivateProfileInt(Section, "ConnectingTimeout", 0, FName);
1133    
1134     // mouse cursor
1135     GetPrivateProfileString(Section, "MouseCursor", "IBEAM",
1136     Temp, sizeof(Temp), FName);
1137     strncpy_s(ts->MouseCursorName, sizeof(ts->MouseCursorName), Temp,
1138     _TRUNCATE);
1139    
1140     // Translucent window
1141     ts->AlphaBlend =
1142     GetPrivateProfileInt(Section, "AlphaBlend ", 255, FName);
1143     ts->AlphaBlend = max(0, ts->AlphaBlend);
1144     ts->AlphaBlend = min(255, ts->AlphaBlend);
1145    
1146     // Cygwin install path
1147     GetPrivateProfileString(Section, "CygwinDirectory ", "c:\\cygwin",
1148     Temp, sizeof(Temp), FName);
1149     strncpy_s(ts->CygwinDirectory, sizeof(ts->CygwinDirectory), Temp,
1150 doda 2496 _TRUNCATE);
1151 maya 2476
1152     // Viewlog Editor path
1153     GetPrivateProfileString(Section, "ViewlogEditor ", "notepad.exe",
1154     Temp, sizeof(Temp), FName);
1155     strncpy_s(ts->ViewlogEditor, sizeof(ts->ViewlogEditor), Temp,
1156 doda 2496 _TRUNCATE);
1157 maya 2476
1158     // Locale for UTF-8
1159     GetPrivateProfileString(Section, "Locale ", DEFAULT_LOCALE,
1160     Temp, sizeof(Temp), FName);
1161     strncpy_s(ts->Locale, sizeof(ts->Locale), Temp, _TRUNCATE);
1162    
1163     // CodePage
1164     ts->CodePage =
1165     GetPrivateProfileInt(Section, "CodePage ", DEFAULT_CODEPAGE,
1166     FName);
1167    
1168     // UI language message file
1169     GetPrivateProfileString(Section, "UILanguageFile", "lang\\Default.lng",
1170     Temp, sizeof(Temp), FName);
1171     {
1172     char CurDir[MAX_PATH];
1173    
1174     // フルパス化する前に読み込み時の設定を取っておく
1175     strncpy_s(ts->UILanguageFile_ini, sizeof(ts->UILanguageFile_ini), Temp, _TRUNCATE);
1176    
1177     GetCurrentDirectory(sizeof(CurDir), CurDir);
1178     SetCurrentDirectory(ts->HomeDir);
1179     _fullpath(ts->UILanguageFile, Temp, sizeof(ts->UILanguageFile));
1180     SetCurrentDirectory(CurDir);
1181     }
1182    
1183     // Broadcast Command History (2007.3.3 maya)
1184     ts->BroadcastCommandHistory =
1185     GetOnOff(Section, "BroadcastCommandHistory", FName, FALSE);
1186    
1187     // 337: 2007/03/20 Accept Broadcast
1188     ts->AcceptBroadcast =
1189     GetOnOff(Section, "AcceptBroadcast", FName, TRUE);
1190    
1191     // Confirm send a file when drag and drop (2007.12.28 maya)
1192     ts->ConfirmFileDragAndDrop =
1193     GetOnOff(Section, "ConfirmFileDragAndDrop", FName, TRUE);
1194    
1195     // Translate mouse wheel to cursor key when application cursor mode
1196     ts->TranslateWheelToCursor =
1197     GetOnOff(Section, "TranslateWheelToCursor", FName, TRUE);
1198    
1199     // Display "New Connection" dialog on startup (2008.1.18 maya)
1200     ts->HostDialogOnStartup =
1201     GetOnOff(Section, "HostDialogOnStartup", FName, TRUE);
1202    
1203     // Mouse event tracking
1204     ts->MouseEventTracking =
1205     GetOnOff(Section, "MouseEventTracking", FName, TRUE);
1206    
1207     // Maximized bug tweak
1208     ts->MaximizedBugTweak =
1209     GetOnOff(Section, "MaximizedBugTweak", FName, TRUE);
1210    
1211 doda 2535 // Convert Unicode symbol characters to DEC Special characters
1212     ts->UnicodeDecSpMapping =
1213     GetPrivateProfileInt(Section, "UnicodeToDecSpMapping", 3, FName);
1214 doda 2496
1215 doda 2497 // VT Window Icon
1216     GetPrivateProfileString(Section, "VTIcon", "Default",
1217     Temp, sizeof(Temp), FName);
1218     ts->VTIcon = IconName2IconId(Temp);
1219    
1220     // Tek Window Icon
1221 doda 2506 GetPrivateProfileString(Section, "TEKIcon", "Default",
1222 doda 2497 Temp, sizeof(Temp), FName);
1223 doda 2506 ts->TEKIcon = IconName2IconId(Temp);
1224 doda 2497
1225 doda 2510 // Unknown Unicode Character
1226     ts->UnknownUnicodeCharaAsWide =
1227 doda 2518 GetOnOff(Section, "UnknownUnicodeCharacterAsWide", FName, FALSE);
1228 doda 2510
1229 maya 2476 #ifdef USE_NORMAL_BGCOLOR
1230     // UseNormalBGColor
1231     ts->UseNormalBGColor =
1232     GetOnOff(Section, "UseNormalBGColor", FName, FALSE);
1233     // 2006/03/11 by 337
1234     if (ts->UseNormalBGColor) {
1235     ts->VTBoldColor[1] =
1236     ts->VTBlinkColor[1] = ts->URLColor[1] = ts->VTColor[1];
1237     }
1238     #endif
1239 yutakapon 2499
1240     // AutoScrollOnlyInBottomLine
1241     ts->AutoScrollOnlyInBottomLine =
1242     GetOnOff(Section, "AutoScrollOnlyInBottomLine", FName, FALSE);
1243 doda 2558
1244     // Accept remote-controlled window title changing
1245 maya 2605 GetPrivateProfileString(Section, "AcceptTitleChangeRequest", "overwrite",
1246 maya 2603 Temp, sizeof(Temp), FName);
1247 maya 2604 if (_stricmp(Temp, "overwrite") == 0 || _stricmp(Temp, "on") == 0)
1248 maya 2603 ts->AcceptTitleChangeRequest = IdTitleChangeRequestOverwrite;
1249 maya 2608 else if (_stricmp(Temp, "ahead") == 0)
1250     ts->AcceptTitleChangeRequest = IdTitleChangeRequestAhead;
1251     else if (_stricmp(Temp, "last") == 0)
1252     ts->AcceptTitleChangeRequest = IdTitleChangeRequestLast;
1253 maya 2603 else
1254     ts->AcceptTitleChangeRequest = IdTitleChangeRequestOff;
1255 doda 2558
1256 maya 2565 // Size of paste confirm dialog
1257     GetPrivateProfileString(Section, "PasteDialogSize", "330,220",
1258     Temp, sizeof(Temp), FName);
1259     GetNthNum(Temp, 1, &ts->PasteDialogSize.cx);
1260     GetNthNum(Temp, 2, &ts->PasteDialogSize.cy);
1261     if (ts->PasteDialogSize.cx < 0)
1262     ts->PasteDialogSize.cx = 330;
1263     if (ts->PasteDialogSize.cy < 0)
1264     ts->PasteDialogSize.cy = 220;
1265    
1266 doda 2628 // Disable mouse event tracking when Control-Key is pressed.
1267     ts->DisableMouseTrackingByCtrl =
1268     GetOnOff(Section, "DisableMouseTrackingByCtrl", FName, FALSE);
1269 doda 2631
1270     // Disable TranslateWheelToCursor setting when Control-Key is pressed.
1271     ts->DisableWheelToCursorByCtrl =
1272     GetOnOff(Section, "DisableWheelToCursorByCtrl", FName, FALSE);
1273 doda 2643
1274     // Strict Key Mapping.
1275     ts->StrictKeyMapping =
1276     GetOnOff(Section, "StrictKeyMapping", FName, FALSE);
1277 maya 2476 }
1278    
1279     void FAR PASCAL WriteIniFile(PCHAR FName, PTTSet ts)
1280     {
1281     int i;
1282     char Temp[MAXPATHLEN];
1283     char buf[20];
1284    
1285     /* version */
1286     WritePrivateProfileString(Section, "Version", "2.3", FName);
1287    
1288     /* Language */
1289     if (ts->Language == IdJapanese)
1290     strncpy_s(Temp, sizeof(Temp), "Japanese", _TRUNCATE);
1291     else if (ts->Language == IdRussian)
1292     strncpy_s(Temp, sizeof(Temp), "Russian", _TRUNCATE);
1293 yutakapon 2556 else if (ts->Language == IdKorean) //HKS
1294     strncpy_s(Temp, sizeof(Temp), "Korean", _TRUNCATE);
1295 maya 2476 else
1296     strncpy_s(Temp, sizeof(Temp), "English", _TRUNCATE);
1297     WritePrivateProfileString(Section, "Language", Temp, FName);
1298    
1299     /* Port type */
1300     if (ts->PortType == IdSerial)
1301     strncpy_s(Temp, sizeof(Temp), "serial", _TRUNCATE);
1302     else /* IdFile -> IdTCPIP */
1303     strncpy_s(Temp, sizeof(Temp), "tcpip", _TRUNCATE);
1304    
1305     WritePrivateProfileString(Section, "Port", Temp, FName);
1306    
1307     /* Save win position */
1308     if (ts->SaveVTWinPos) {
1309     /* VT win position */
1310     WriteInt2(Section, "VTPos", FName, ts->VTPos.x, ts->VTPos.y);
1311     }
1312    
1313     /* VT terminal size */
1314     WriteInt2(Section, "TerminalSize", FName,
1315     ts->TerminalWidth, ts->TerminalHeight);
1316    
1317     /* Terminal size = Window size */
1318     WriteOnOff(Section, "TermIsWin", FName, ts->TermIsWin);
1319    
1320     /* Auto window resize flag */
1321     WriteOnOff(Section, "AutoWinResize", FName, ts->AutoWinResize);
1322    
1323     /* CR Receive */
1324     if (ts->CRReceive == IdCRLF) {
1325     strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
1326     }
1327     else if (ts->CRReceive == IdLF) {
1328     strncpy_s(Temp, sizeof(Temp), "LF", _TRUNCATE);
1329     }
1330     else {
1331     strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
1332     }
1333     WritePrivateProfileString(Section, "CRReceive", Temp, FName);
1334    
1335     /* CR Send */
1336     if (ts->CRSend == IdCRLF)
1337     strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
1338     else
1339     strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
1340     WritePrivateProfileString(Section, "CRSend", Temp, FName);
1341    
1342     /* Local echo */
1343     WriteOnOff(Section, "LocalEcho", FName, ts->LocalEcho);
1344    
1345     /* Answerback */
1346     if ((ts->FTFlag & FT_BPAUTO) == 0) {
1347     Str2Hex(ts->Answerback, Temp, ts->AnswerbackLen,
1348     sizeof(Temp) - 1, TRUE);
1349     WritePrivateProfileString(Section, "Answerback", Temp, FName);
1350     }
1351    
1352     /* Kanji Code (receive) */
1353     switch (ts->KanjiCode) {
1354     case IdEUC:
1355     strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE);
1356     break;
1357     case IdJIS:
1358     strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE);
1359     break;
1360     case IdUTF8:
1361     strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
1362     break;
1363     case IdUTF8m:
1364     strncpy_s(Temp, sizeof(Temp), "UTF-8m", _TRUNCATE);
1365     break;
1366     default:
1367     strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
1368     }
1369     WritePrivateProfileString(Section, "KanjiReceive", Temp, FName);
1370    
1371     /* Katakana (receive) */
1372     if (ts->JIS7Katakana == 1)
1373     strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
1374     else
1375     strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
1376    
1377     WritePrivateProfileString(Section, "KatakanaReceive", Temp, FName);
1378    
1379     /* Kanji Code (transmit) */
1380     switch (ts->KanjiCodeSend) {
1381     case IdEUC:
1382     strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE);
1383     break;
1384     case IdJIS:
1385     strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE);
1386     break;
1387     case IdUTF8:
1388     strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
1389     break;
1390     default:
1391     strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
1392     }
1393     WritePrivateProfileString(Section, "KanjiSend", Temp, FName);
1394    
1395     /* Katakana (transmit) */
1396     if (ts->JIS7KatakanaSend == 1)
1397     strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
1398     else
1399     strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
1400    
1401     WritePrivateProfileString(Section, "KatakanaSend", Temp, FName);
1402    
1403     /* KanjiIn */
1404     if (ts->KanjiIn == IdKanjiInA)
1405     strncpy_s(Temp, sizeof(Temp), "@", _TRUNCATE);
1406     else
1407     strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);
1408    
1409     WritePrivateProfileString(Section, "KanjiIn", Temp, FName);
1410    
1411     /* KanjiOut */
1412     switch (ts->KanjiOut) {
1413     case IdKanjiOutB:
1414     strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);
1415     break;
1416     case IdKanjiOutH:
1417     strncpy_s(Temp, sizeof(Temp), "H", _TRUNCATE);
1418     break;
1419     default:
1420     strncpy_s(Temp, sizeof(Temp), "J", _TRUNCATE);
1421     }
1422     WritePrivateProfileString(Section, "KanjiOut", Temp, FName);
1423    
1424     // new configuration
1425     WriteInt(Section, "ConnectingTimeout", FName, ts->ConnectingTimeout);
1426    
1427     WriteOnOff(Section, "DisablePasteMouseRButton", FName,
1428     ts->DisablePasteMouseRButton);
1429    
1430     // added DisablePasteMouseMButton (2008.3.2 maya)
1431     WriteOnOff(Section, "DisablePasteMouseMButton", FName,
1432     ts->DisablePasteMouseMButton);
1433    
1434     // added ConfirmPasteMouseRButton (2007.3.17 maya)
1435     WriteOnOff(Section, "ConfirmPasteMouseRButton", FName,
1436     ts->ConfirmPasteMouseRButton);
1437    
1438     // added ConfirmChangePaste
1439     WriteOnOff(Section, "ConfirmChangePaste", FName,
1440 doda 2496 ts->ConfirmChangePaste);
1441 maya 2476
1442 yutakapon 2498 // added ScrollWindowClearScreen
1443     WriteOnOff(Section, "ScrollWindowClearScreen", FName,
1444     ts->ScrollWindowClearScreen);
1445    
1446 maya 2476 // added SelectOnlyByLButton (2007.11.20 maya)
1447     WriteOnOff(Section, "SelectOnlyByLButton", FName,
1448     ts->SelectOnlyByLButton);
1449     // added DisableAcceleratorSendBreak (2007.3.17 maya)
1450     WriteOnOff(Section, "DisableAcceleratorSendBreak", FName,
1451     ts->DisableAcceleratorSendBreak);
1452     WriteOnOff(Section, "EnableContinuedLineCopy", FName,
1453     ts->EnableContinuedLineCopy);
1454     WritePrivateProfileString(Section, "MouseCursor", ts->MouseCursorName,
1455     FName);
1456     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->AlphaBlend);
1457     WritePrivateProfileString(Section, "AlphaBlend", Temp, FName);
1458     WritePrivateProfileString(Section, "CygwinDirectory",
1459     ts->CygwinDirectory, FName);
1460     WritePrivateProfileString(Section, "ViewlogEditor", ts->ViewlogEditor,
1461     FName);
1462     WritePrivateProfileString(Section, "Locale", ts->Locale, FName);
1463     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->CodePage);
1464     WritePrivateProfileString(Section, "CodePage", Temp, FName);
1465    
1466     // ANSI color(2004.9.5 yutaka)
1467     Temp[0] = '\0';
1468     for (i = 0; i < 15; i++) {
1469     _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d,%d,%d,%d, ",
1470     i,
1471     GetRValue(ts->ANSIColor[i]),
1472     GetGValue(ts->ANSIColor[i]),
1473     GetBValue(ts->ANSIColor[i])
1474     );
1475     strncat_s(Temp, sizeof(Temp), buf, _TRUNCATE);
1476     }
1477     i = 15;
1478     _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d,%d,%d,%d",
1479     i,
1480     GetRValue(ts->ANSIColor[i]),
1481     GetGValue(ts->ANSIColor[i]),
1482     GetBValue(ts->ANSIColor[i])
1483     );
1484     strncat_s(Temp, sizeof(Temp), buf, _TRUNCATE);
1485     WritePrivateProfileString(Section, "ANSIColor", Temp, FName);
1486    
1487     /* AutoWinChange VT<->TEK */
1488     WriteOnOff(Section, "AutoWinSwitch", FName, ts->AutoWinSwitch);
1489    
1490     /* Terminal ID */
1491     id2str(TermList, ts->TerminalID, IdVT100, Temp, sizeof(Temp));
1492     WritePrivateProfileString(Section, "TerminalID", Temp, FName);
1493    
1494     /* Russian character set (host) */
1495     id2str(RussList, ts->RussHost, IdKOI8, Temp, sizeof(Temp));
1496     WritePrivateProfileString(Section, "RussHost", Temp, FName);
1497    
1498     /* Russian character set (client) */
1499     id2str(RussList, ts->RussClient, IdWindows, Temp, sizeof(Temp));
1500     WritePrivateProfileString(Section, "RussClient", Temp, FName);
1501    
1502     /* Title text */
1503     WritePrivateProfileString(Section, "Title", ts->Title, FName);
1504    
1505     /* Cursor shape */
1506     switch (ts->CursorShape) {
1507     case IdVCur:
1508     strncpy_s(Temp, sizeof(Temp), "vertical", _TRUNCATE);
1509     break;
1510     case IdHCur:
1511     strncpy_s(Temp, sizeof(Temp), "horizontal", _TRUNCATE);
1512     break;
1513     default:
1514     strncpy_s(Temp, sizeof(Temp), "block", _TRUNCATE);
1515     }
1516     WritePrivateProfileString(Section, "CursorShape", Temp, FName);
1517    
1518     /* Hide title */
1519     WriteOnOff(Section, "HideTitle", FName, ts->HideTitle);
1520    
1521     /* Popup menu */
1522     WriteOnOff(Section, "PopupMenu", FName, ts->PopupMenu);
1523    
1524     /* PC-Style bold color mapping */
1525     WriteOnOff(Section, "PcBoldColor", FName,
1526     (WORD) (ts->ColorFlag & CF_PCBOLD16));
1527    
1528     /* aixterm 16 colors mode */
1529     WriteOnOff(Section, "Aixterm16Color", FName,
1530     (WORD) (ts->ColorFlag & CF_AIXTERM16));
1531    
1532     /* xterm 256 colors mode */
1533     WriteOnOff(Section, "Xterm256Color", FName,
1534     (WORD) (ts->ColorFlag & CF_XTERM256));
1535    
1536     /* Enable scroll buffer */
1537     WriteOnOff(Section, "EnableScrollBuff", FName, ts->EnableScrollBuff);
1538    
1539     /* Scroll buffer size */
1540     WriteInt(Section, "ScrollBuffSize", FName, ts->ScrollBuffSize);
1541    
1542     /* VT Color */
1543     for (i = 0; i <= 1; i++) {
1544     ts->TmpColor[0][i * 3] = GetRValue(ts->VTColor[i]);
1545     ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[i]);
1546     ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[i]);
1547     }
1548     WriteInt6(Section, "VTColor", FName,
1549 doda 2496 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
1550     ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
1551 maya 2476
1552 doda 2640 /* VT Bold Color */
1553 maya 2476 for (i = 0; i <= 1; i++) {
1554     ts->TmpColor[0][i * 3] = GetRValue(ts->VTBoldColor[i]);
1555     ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBoldColor[i]);
1556     ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBoldColor[i]);
1557     }
1558     WriteInt6(Section, "VTBoldColor", FName,
1559 doda 2496 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
1560     ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
1561 maya 2476
1562 doda 2640 /* VT Blink Color */
1563 maya 2476 for (i = 0; i <= 1; i++) {
1564     ts->TmpColor[0][i * 3] = GetRValue(ts->VTBlinkColor[i]);
1565     ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBlinkColor[i]);
1566     ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBlinkColor[i]);
1567     }
1568     WriteInt6(Section, "VTBlinkColor", FName,
1569 doda 2496 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
1570     ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
1571 maya 2476
1572 doda 2640 /* VT Reverse Color */
1573     for (i = 0; i <= 1; i++) {
1574     ts->TmpColor[0][i * 3] = GetRValue(ts->VTReverseColor[i]);
1575     ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTReverseColor[i]);
1576     ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTReverseColor[i]);
1577     }
1578 maya 2656 WriteInt6(Section, "VTReverseColor", FName,
1579 doda 2640 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
1580     ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
1581    
1582 maya 2476 /* start - ishizaki */
1583     WriteOnOff(Section, "EnableClickableUrl", FName,
1584 doda 2496 ts->EnableClickableUrl);
1585 maya 2476
1586     /* URL color */
1587     for (i = 0; i <= 1; i++) {
1588     ts->TmpColor[0][i * 3] = GetRValue(ts->URLColor[i]);
1589     ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->URLColor[i]);
1590     ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->URLColor[i]);
1591     }
1592     WriteInt6(Section, "URLColor", FName,
1593 doda 2496 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
1594     ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
1595 maya 2476 /* end - ishizaki */
1596    
1597     /* TEK Color */
1598     for (i = 0; i <= 1; i++) {
1599     ts->TmpColor[0][i * 3] = GetRValue(ts->TEKColor[i]);
1600     ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->TEKColor[i]);
1601     ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->TEKColor[i]);
1602     }
1603     WriteInt6(Section, "TEKColor", FName,
1604     ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
1605 doda 2496 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
1606 maya 2476
1607     /* TEK color emulation */
1608     WriteOnOff(Section, "TEKColorEmulation", FName, ts->TEKColorEmu);
1609    
1610     /* VT Font */
1611     WriteFont(Section, "VTFont", FName,
1612     ts->VTFont, ts->VTFontSize.x, ts->VTFontSize.y,
1613     ts->VTFontCharSet);
1614    
1615     /* Enable bold font flag */
1616     WriteOnOff(Section, "EnableBold", FName, ts->EnableBold);
1617    
1618     /* Russian character set (font) */
1619     id2str(RussList, ts->RussFont, IdWindows, Temp, sizeof(Temp));
1620     WritePrivateProfileString(Section, "RussFont", Temp, FName);
1621    
1622     /* TEK Font */
1623     WriteFont(Section, "TEKFont", FName,
1624     ts->TEKFont, ts->TEKFontSize.x, ts->TEKFontSize.y,
1625     ts->TEKFontCharSet);
1626    
1627     /* BS key */
1628     if (ts->BSKey == IdDEL)
1629     strncpy_s(Temp, sizeof(Temp), "DEL", _TRUNCATE);
1630     else
1631     strncpy_s(Temp, sizeof(Temp), "BS", _TRUNCATE);
1632     WritePrivateProfileString(Section, "BSKey", Temp, FName);
1633    
1634     /* Delete key */
1635     WriteOnOff(Section, "DeleteKey", FName, ts->DelKey);
1636    
1637     /* Meta key */
1638     WriteOnOff(Section, "MetaKey", FName, ts->MetaKey);
1639    
1640     /* Application Keypad */
1641     WriteOnOff(Section, "DisableAppKeypad", FName, ts->DisableAppKeypad);
1642    
1643     /* Application Cursor */
1644     WriteOnOff(Section, "DisableAppCursor", FName, ts->DisableAppCursor);
1645    
1646     /* Russian keyboard type */
1647     id2str(RussList2, ts->RussKeyb, IdWindows, Temp, sizeof(Temp));
1648     WritePrivateProfileString(Section, "RussKeyb", Temp, FName);
1649    
1650     /* Serial port ID */
1651     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->ComPort);
1652     WritePrivateProfileString(Section, "ComPort", Temp, FName);
1653    
1654     /* Baud rate */
1655     id2str(BaudList, ts->Baud, IdBaud9600, Temp, sizeof(Temp));
1656     WritePrivateProfileString(Section, "BaudRate", Temp, FName);
1657    
1658     /* Parity */
1659     switch (ts->Parity) {
1660     case IdParityEven:
1661     strncpy_s(Temp, sizeof(Temp), "even", _TRUNCATE);
1662     break;
1663     case IdParityOdd:
1664     strncpy_s(Temp, sizeof(Temp), "odd", _TRUNCATE);
1665     break;
1666     default:
1667     strncpy_s(Temp, sizeof(Temp), "none", _TRUNCATE);
1668     }
1669     WritePrivateProfileString(Section, "Parity", Temp, FName);
1670    
1671     /* Data bit */
1672     if (ts->DataBit == IdDataBit7)
1673     strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
1674     else
1675     strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
1676    
1677     WritePrivateProfileString(Section, "DataBit", Temp, FName);
1678    
1679     /* Stop bit */
1680     if (ts->StopBit == IdStopBit2)
1681     strncpy_s(Temp, sizeof(Temp), "2", _TRUNCATE);
1682     else
1683     strncpy_s(Temp, sizeof(Temp), "1", _TRUNCATE);
1684    
1685     WritePrivateProfileString(Section, "StopBit", Temp, FName);
1686    
1687     /* Flow control */
1688     switch (ts->Flow) {
1689     case IdFlowX:
1690     strncpy_s(Temp, sizeof(Temp), "x", _TRUNCATE);
1691     break;
1692     case IdFlowHard:
1693     strncpy_s(Temp, sizeof(Temp), "hard", _TRUNCATE);
1694     break;
1695     default:
1696     strncpy_s(Temp, sizeof(Temp), "none", _TRUNCATE);
1697     }
1698     WritePrivateProfileString(Section, "FlowCtrl", Temp, FName);
1699    
1700     /* Delay per character */
1701     WriteInt(Section, "DelayPerChar", FName, ts->DelayPerChar);
1702    
1703     /* Delay per line */
1704     WriteInt(Section, "DelayPerLine", FName, ts->DelayPerLine);
1705    
1706     /* Telnet flag */
1707     WriteOnOff(Section, "Telnet", FName, ts->Telnet);
1708    
1709     /* Telnet terminal type */
1710     WritePrivateProfileString(Section, "TermType", ts->TermType, FName);
1711    
1712     /* TCP port num for non-telnet */
1713     WriteUint(Section, "TCPPort", FName, ts->TCPPort);
1714    
1715     /* Auto close flag */
1716     WriteOnOff(Section, "AutoWinClose", FName, ts->AutoWinClose);
1717    
1718     /* History list */
1719     WriteOnOff(Section, "Historylist", FName, ts->HistoryList);
1720    
1721     /* File transfer binary flag */
1722     WriteOnOff(Section, "TransBin", FName, ts->TransBin);
1723    
1724     /* Log append */
1725     WriteOnOff(Section, "LogAppend", FName, ts->Append);
1726    
1727     /* File transfer binary flag */
1728     WriteOnOff(Section, "LogTypePlainText", FName, ts->LogTypePlainText);
1729    
1730     /* Log with timestamp (2006.7.23 maya) */
1731     WriteOnOff(Section, "LogTimestamp", FName, ts->LogTimestamp);
1732    
1733     /* Log without transfer dialog */
1734     WriteOnOff(Section, "LogHideDialog", FName, ts->LogHideDialog);
1735    
1736     /* Default Log file name (2006.8.28 maya) */
1737     WritePrivateProfileString(Section, "LogDefaultName",
1738 doda 2496 ts->LogDefaultName, FName);
1739 maya 2476
1740     /* Default Log file path (2007.5.30 maya) */
1741     WritePrivateProfileString(Section, "LogDefaultPath",
1742 doda 2496 ts->LogDefaultPath, FName);
1743 maya 2476
1744     /* Auto start logging (2007.5.31 maya) */
1745     WriteOnOff(Section, "LogAutoStart", FName, ts->LogAutoStart);
1746    
1747     /* XMODEM option */
1748     switch (ts->XmodemOpt) {
1749     case XoptCRC:
1750     strncpy_s(Temp, sizeof(Temp), "crc", _TRUNCATE);
1751     break;
1752     case Xopt1K:
1753     strncpy_s(Temp, sizeof(Temp), "1k", _TRUNCATE);
1754     break;
1755     default:
1756     strncpy_s(Temp, sizeof(Temp), "checksum", _TRUNCATE);
1757     }
1758     WritePrivateProfileString(Section, "XmodemOpt", Temp, FName);
1759    
1760     /* XMODEM binary flag */
1761     WriteOnOff(Section, "XmodemBin", FName, ts->XmodemBin);
1762    
1763     /* XMODEM 受信コマンド (2007.12.21 yutaka) */
1764 doda 2496 WritePrivateProfileString(Section, "XmodemRcvCommand",
1765     ts->XModemRcvCommand, FName);
1766 maya 2476
1767     /* Default directory for file transfer */
1768     WritePrivateProfileString(Section, "FileDir", ts->FileDir, FName);
1769    
1770     /* filter on file send (2007.6.5 maya) */
1771     WritePrivateProfileString(Section, "FileSendFilter",
1772 doda 2496 ts->FileSendFilter, FName);
1773 maya 2476
1774     /*------------------------------------------------------------------*/
1775     /* 8 bit control code flag -- special option */
1776     WriteOnOff(Section, "Accept8BitCtrl", FName,
1777 doda 2496 (WORD) (ts->TermFlag & TF_ACCEPT8BITCTRL));
1778 maya 2476
1779     /* Wrong sequence flag -- special option */
1780     WriteOnOff(Section, "AllowWrongSequence", FName,
1781 doda 2496 (WORD) (ts->TermFlag & TF_ALLOWWRONGSEQUENCE));
1782 maya 2476
1783     /* Auto file renaming --- special option */
1784     WriteOnOff(Section, "AutoFileRename", FName,
1785 doda 2496 (WORD) (ts->FTFlag & FT_RENAME));
1786 maya 2476
1787     /* Auto text copy --- special option */
1788     WriteOnOff(Section, "AutoTextCopy", FName, ts->AutoTextCopy);
1789    
1790     /* Back wrap -- special option */
1791     WriteOnOff(Section, "BackWrap", FName,
1792     (WORD) (ts->TermFlag & TF_BACKWRAP));
1793    
1794     /* Beep type -- special option */
1795     WriteOnOff(Section, "Beep", FName, ts->Beep);
1796 doda 2554 switch (ts->Beep) {
1797     case IdBeepOff:
1798     WritePrivateProfileString(Section, "Beep", "Off", FName);
1799     break;
1800     case IdBeepOn:
1801     WritePrivateProfileString(Section, "Beep", "On", FName);
1802     break;
1803     case IdBeepVisual:
1804     WritePrivateProfileString(Section, "Beep", "Visual", FName);
1805     break;
1806     }
1807 maya 2476
1808     /* Beep on connection & disconnection -- special option */
1809     WriteOnOff(Section, "BeepOnConnect", FName,
1810     (WORD) (ts->PortFlag & PF_BEEPONCONNECT));
1811    
1812     /* Auto B-Plus activation -- special option */
1813     WriteOnOff(Section, "BPAuto", FName, (WORD) (ts->FTFlag & FT_BPAUTO));
1814    
1815     /* B-Plus ESCCTL flag -- special option */
1816     WriteOnOff(Section, "BPEscCtl", FName,
1817     (WORD) (ts->FTFlag & FT_BPESCCTL));
1818    
1819     /* B-Plus log -- special option */
1820     WriteOnOff(Section, "BPLog", FName, (WORD) (ts->LogFlag & LOG_BP));
1821    
1822     /* Clear serial port buffer when port opening -- special option */
1823     WriteOnOff(Section, "ClearComBuffOnOpen", FName, ts->ClearComBuffOnOpen);
1824    
1825     /* Confirm disconnection -- special option */
1826     WriteOnOff(Section, "ConfirmDisconnect", FName,
1827     (WORD) (ts->PortFlag & PF_CONFIRMDISCONN));
1828    
1829     /* Ctrl code in Kanji -- special option */
1830     WriteOnOff(Section, "CtrlInKanji", FName,
1831     (WORD) (ts->TermFlag & TF_CTRLINKANJI));
1832    
1833     /* Debug flag -- special option */
1834     WriteOnOff(Section, "Debug", FName, ts->Debug);
1835    
1836     /* Delimiter list -- special option */
1837     Str2Hex(ts->DelimList, Temp, strlen(ts->DelimList),
1838     sizeof(Temp) - 1, TRUE);
1839     WritePrivateProfileString(Section, "DelimList", Temp, FName);
1840    
1841     /* regard DBCS characters as delimiters -- special option */
1842     WriteOnOff(Section, "DelimDBCS", FName, ts->DelimDBCS);
1843    
1844     // Enable popup menu -- special option
1845     if ((ts->MenuFlag & MF_NOPOPUP) == 0)
1846     WriteOnOff(Section, "EnablePopupMenu", FName, 1);
1847     else
1848     WriteOnOff(Section, "EnablePopupMenu", FName, 0);
1849    
1850     // Enable "Show menu" -- special option
1851     if ((ts->MenuFlag & MF_NOSHOWMENU) == 0)
1852     WriteOnOff(Section, "EnableShowMenu", FName, 1);
1853     else
1854     WriteOnOff(Section, "EnableShowMenu", FName, 0);
1855    
1856     /* Enable the status line -- special option */
1857     WriteOnOff(Section, "EnableStatusLine", FName,
1858     (WORD) (ts->TermFlag & TF_ENABLESLINE));
1859    
1860     /* IME Flag -- special option */
1861     WriteOnOff(Section, "IME", FName, ts->UseIME);
1862    
1863     /* IME-inline Flag -- special option */
1864     WriteOnOff(Section, "IMEInline", FName, ts->IMEInline);
1865    
1866     /* Kermit log -- special option */
1867     WriteOnOff(Section, "KmtLog", FName, (WORD) (ts->LogFlag & LOG_KMT));
1868    
1869     // Enable language selection -- special option
1870     if ((ts->MenuFlag & MF_NOLANGUAGE) == 0)
1871     WriteOnOff(Section, "LanguageSelection", FName, 1);
1872     else
1873     WriteOnOff(Section, "LanguageSelection", FName, 0);
1874    
1875     /* Maximum scroll buffer size -- special option */
1876     WriteInt(Section, "MaxBuffSize", FName, ts->ScrollBuffMax);
1877    
1878     /* Max com port number -- special option */
1879     WriteInt(Section, "MaxComPort", FName, ts->MaxComPort);
1880    
1881     /* Non-blinking cursor -- special option */
1882     WriteOnOff(Section, "NonblinkingCursor", FName, ts->NonblinkingCursor);
1883    
1884     WriteOnOff(Section, "KillFocusCursor", FName, ts->KillFocusCursor);
1885    
1886     /* Delay for pass-thru printing activation */
1887     /* -- special option */
1888     WriteUint(Section, "PassThruDelay", FName, ts->PassThruDelay);
1889    
1890     /* Printer port for pass-thru printing */
1891     /* -- special option */
1892     WritePrivateProfileString(Section, "PassThruPort", ts->PrnDev, FName);
1893    
1894     /* Printer Font --- special option */
1895     WriteFont(Section, "PrnFont", FName,
1896     ts->PrnFont, ts->PrnFontSize.x, ts->PrnFontSize.y,
1897     ts->PrnFontCharSet);
1898    
1899     // Page margins (left, right, top, bottom) for printing
1900     // -- special option
1901     WriteInt4(Section, "PrnMargin", FName,
1902     ts->PrnMargin[0], ts->PrnMargin[1],
1903     ts->PrnMargin[2], ts->PrnMargin[3]);
1904    
1905     /* Quick-VAN log -- special option */
1906     WriteOnOff(Section, "QVLog", FName, (WORD) (ts->LogFlag & LOG_QV));
1907    
1908     /* Quick-VAN window size -- special */
1909     WriteInt(Section, "QVWinSize", FName, ts->QVWinSize);
1910    
1911     /* Russian character set (print) -- special option */
1912     id2str(RussList, ts->RussPrint, IdWindows, Temp, sizeof(Temp));
1913     WritePrivateProfileString(Section, "RussPrint", Temp, FName);
1914    
1915     /* Scroll threshold -- special option */
1916     WriteInt(Section, "ScrollThreshold", FName, ts->ScrollThreshold);
1917    
1918     WriteInt(Section, "MouseWheelScrollLine", FName, ts->MouseWheelScrollLine);
1919    
1920     // Select on activate -- special option
1921     WriteOnOff(Section, "SelectOnActivate", FName, ts->SelOnActive);
1922    
1923     /* Send 8bit control sequence -- special option */
1924     WriteOnOff(Section, "Send8BitCtrl", FName, ts->Send8BitCtrl);
1925    
1926     /* Startup macro -- special option */
1927     WritePrivateProfileString(Section, "StartupMacro", ts->MacroFN, FName);
1928    
1929     /* TEK GIN Mouse keycode -- special option */
1930     WriteInt(Section, "TEKGINMouseCode", FName, ts->GINMouseCode);
1931    
1932     /* Telnet Auto Detect -- special option */
1933     WriteOnOff(Section, "TelAutoDetect", FName, ts->TelAutoDetect);
1934    
1935     /* Telnet binary flag -- special option */
1936     WriteOnOff(Section, "TelBin", FName, ts->TelBin);
1937    
1938     /* Telnet Echo flag -- special option */
1939     WriteOnOff(Section, "TelEcho", FName, ts->TelEcho);
1940    
1941     /* Telnet log -- special option */
1942     WriteOnOff(Section, "TelLog", FName, (WORD) (ts->LogFlag & LOG_TEL));
1943    
1944     /* TCP port num for telnet -- special option */
1945     WriteUint(Section, "TelPort", FName, ts->TelPort);
1946    
1947     /* Telnet keep-alive packet(NOP command) interval -- special option */
1948     WriteUint(Section, "TelKeepAliveInterval", FName,
1949     ts->TelKeepAliveInterval);
1950    
1951     /* Max number of broadcast commad history */
1952     WriteUint(Section, "MaxBroadcatHistory", FName,
1953     ts->MaxBroadcatHistory);
1954    
1955     /* Local echo for non-telnet */
1956     WriteOnOff(Section, "TCPLocalEcho", FName, ts->TCPLocalEcho);
1957    
1958     /* "new-line (transmit)" option for non-telnet -- special option */
1959     if (ts->TCPCRSend == IdCRLF)
1960     strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
1961     else if (ts->TCPCRSend == IdCR)
1962     strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
1963     else
1964     Temp[0] = 0;
1965     WritePrivateProfileString(Section, "TCPCRSend", Temp, FName);
1966    
1967     /* Use text (background) color for "white (black)"
1968     --- special option */
1969     WriteOnOff(Section, "UseTextColor", FName,
1970     (WORD) (ts->ColorFlag & CF_USETEXTCOLOR));
1971    
1972     /* Title format -- special option */
1973     WriteUint(Section, "TitleFormat", FName, ts->TitleFormat);
1974    
1975     /* VT Compatible Tab -- special option */
1976     WriteOnOff(Section, "VTCompatTab", FName, ts->VTCompatTab);
1977    
1978     /* VT Font space --- special option */
1979     WriteInt4(Section, "VTFontSpace", FName,
1980     ts->FontDX, ts->FontDW - ts->FontDX,
1981     ts->FontDY, ts->FontDH - ts->FontDY);
1982    
1983     // VT-print scaling factors (pixels per inch) --- special option
1984     WriteInt2(Section, "VTPPI", FName, ts->VTPPI.x, ts->VTPPI.y);
1985    
1986     // TEK-print scaling factors (pixels per inch) --- special option
1987     WriteInt2(Section, "TEKPPI", FName, ts->TEKPPI.x, ts->TEKPPI.y);
1988    
1989     // Show "Window" menu -- special option
1990     WriteOnOff(Section, "WindowMenu", FName,
1991     (WORD) (ts->MenuFlag & MF_SHOWWINMENU));
1992    
1993     /* XMODEM log -- special option */
1994     WriteOnOff(Section, "XmodemLog", FName, (WORD) (ts->LogFlag & LOG_X));
1995    
1996 yutakapon 2539 /* YMODEM log -- special option */
1997     WriteOnOff(Section, "YmodemLog", FName, (WORD) (ts->LogFlag & LOG_Y));
1998    
1999 maya 2476 /* Auto ZMODEM activation -- special option */
2000     WriteOnOff(Section, "ZmodemAuto", FName,
2001     (WORD) (ts->FTFlag & FT_ZAUTO));
2002    
2003     /* ZMODEM data subpacket length for sending -- special */
2004     WriteInt(Section, "ZmodemDataLen", FName, ts->ZmodemDataLen);
2005     /* ZMODEM window size for sending -- special */
2006     WriteInt(Section, "ZmodemWinSize", FName, ts->ZmodemWinSize);
2007    
2008     /* ZMODEM ESCCTL flag -- special option */
2009     WriteOnOff(Section, "ZmodemEscCtl", FName,
2010     (WORD) (ts->FTFlag & FT_ZESCCTL));
2011    
2012     /* ZMODEM log -- special option */
2013     WriteOnOff(Section, "ZmodemLog", FName, (WORD) (ts->LogFlag & LOG_Z));
2014    
2015     /* ZMODEM 受信コマンド (2007.12.21 yutaka) */
2016     WritePrivateProfileString(Section, "ZmodemRcvCommand", ts->ZModemRcvCommand, FName);
2017    
2018     /* update file */
2019     WritePrivateProfileString(NULL, NULL, NULL, FName);
2020    
2021     // Eterm lookfeel alphablend (2005.4.24 yutaka)
2022     #define ETERM_SECTION "BG"
2023     WriteOnOff(ETERM_SECTION, "BGEnable", FName,
2024     ts->EtermLookfeel.BGEnable);
2025     WriteOnOff(ETERM_SECTION, "BGUseAlphaBlendAPI", FName,
2026     ts->EtermLookfeel.BGUseAlphaBlendAPI);
2027     WritePrivateProfileString(ETERM_SECTION, "BGSPIPath",
2028     ts->EtermLookfeel.BGSPIPath, FName);
2029     WriteOnOff(ETERM_SECTION, "BGFastSizeMove", FName,
2030     ts->EtermLookfeel.BGFastSizeMove);
2031     WriteOnOff(ETERM_SECTION, "BGFlickerlessMove", FName,
2032     ts->EtermLookfeel.BGNoCopyBits);
2033     WriteOnOff(ETERM_SECTION, "BGNoFrame", FName,
2034     ts->EtermLookfeel.BGNoFrame);
2035     WritePrivateProfileString(ETERM_SECTION, "BGThemeFile",
2036     ts->EtermLookfeel.BGThemeFile, FName);
2037    
2038     #ifdef USE_NORMAL_BGCOLOR
2039     // UseNormalBGColor
2040     WriteOnOff(Section, "UseNormalBGColor", FName, ts->UseNormalBGColor);
2041     #endif
2042    
2043     // UI language message file
2044     WritePrivateProfileString(Section, "UILanguageFile",
2045     ts->UILanguageFile_ini, FName);
2046    
2047     // Broadcast Command History (2007.3.3 maya)
2048     WriteOnOff(Section, "BroadcastCommandHistory", FName,
2049     ts->BroadcastCommandHistory);
2050    
2051     // 337: 2007/03/20 Accept Broadcast
2052     WriteOnOff(Section, "AcceptBroadcast", FName, ts->AcceptBroadcast);
2053    
2054     // Confirm send a file when drag and drop (2007.12.28 maya)
2055     WriteOnOff(Section, "ConfirmFileDragAndDrop", FName,
2056     ts->ConfirmFileDragAndDrop);
2057    
2058     // Translate mouse wheel to cursor key when application cursor mode
2059     WriteOnOff(Section, "TranslateWheelToCursor", FName,
2060     ts->TranslateWheelToCursor);
2061    
2062     // Display "New Connection" dialog on startup (2008.1.18 maya)
2063     WriteOnOff(Section, "HostDialogOnStartup", FName,
2064     ts->HostDialogOnStartup);
2065    
2066     // Mouse event tracking
2067     WriteOnOff(Section, "MouseEventTracking", FName,
2068     ts->MouseEventTracking);
2069    
2070     // Maximized bug tweak
2071 doda 2496 WriteOnOff(Section, "MaximizedBugTweak", FName, ts->MaximizedBugTweak);
2072    
2073 doda 2535 // Convert Unicode symbol characters to DEC Special characters
2074     WriteUint(Section, "UnicodeToDecSpMapping", FName, ts->UnicodeDecSpMapping);
2075 doda 2497
2076     // VT Window Icon
2077     IconId2IconName(Temp, sizeof(Temp), ts->VTIcon);
2078     WritePrivateProfileString(Section, "VTIcon", Temp, FName);
2079    
2080     // Tek Window Icon
2081 doda 2506 IconId2IconName(Temp, sizeof(Temp), ts->TEKIcon);
2082     WritePrivateProfileString(Section, "TEKIcon", Temp, FName);
2083 yutakapon 2499
2084     // AutoScrollOnlyInBottomLine
2085     WriteOnOff(Section, "AutoScrollOnlyInBottomLine", FName,
2086     ts->AutoScrollOnlyInBottomLine);
2087 doda 2510
2088     // Unknown Unicode Character
2089     WriteOnOff(Section, "UnknownUnicodeCharacterAsWide", FName,
2090     ts->UnknownUnicodeCharaAsWide);
2091 doda 2558
2092     // Accept remote-controlled window title changing
2093 maya 2603 if (ts->AcceptTitleChangeRequest == IdTitleChangeRequestOff)
2094     strncpy_s(Temp, sizeof(Temp), "off", _TRUNCATE);
2095     else if (ts->AcceptTitleChangeRequest == IdTitleChangeRequestOverwrite)
2096     strncpy_s(Temp, sizeof(Temp), "overwrite", _TRUNCATE);
2097 maya 2608 else if (ts->AcceptTitleChangeRequest == IdTitleChangeRequestAhead)
2098     strncpy_s(Temp, sizeof(Temp), "ahead", _TRUNCATE);
2099     else if (ts->AcceptTitleChangeRequest == IdTitleChangeRequestLast)
2100     strncpy_s(Temp, sizeof(Temp), "last", _TRUNCATE);
2101 maya 2603 else
2102     Temp[0] = 0;
2103     WritePrivateProfileString(Section, "AcceptTitleChangeRequest", Temp, FName);
2104 maya 2565
2105     // Size of paste confirm dialog
2106     WriteInt2(Section, "PasteDialogSize", FName,
2107     ts->PasteDialogSize.cx, ts->PasteDialogSize.cy);
2108 doda 2628
2109     // Disable mouse event tracking when Control-Key is pressed.
2110     WriteOnOff(Section, "DisableMouseTrackingByCtrl", FName,
2111     ts->DisableMouseTrackingByCtrl);
2112 doda 2631
2113     // Disable TranslateWHeelToCursor when Control-Key is pressed.
2114     WriteOnOff(Section, "DisableWheelToCursorByCtrl", FName,
2115     ts->DisableWheelToCursorByCtrl);
2116 doda 2643
2117     // Strict Key Mapping.
2118     WriteOnOff(Section, "StrictKeyMapping", FName,
2119     ts->StrictKeyMapping);
2120 maya 2476 }
2121    
2122     #define VTEditor "VT editor keypad"
2123     #define VTNumeric "VT numeric keypad"
2124     #define VTFunction "VT function keys"
2125     #define XFunction "X function keys"
2126     #define ShortCut "Shortcut keys"
2127    
2128     void GetInt(PKeyMap KeyMap, int KeyId, PCHAR Sect, PCHAR Key, PCHAR FName)
2129     {
2130     char Temp[11];
2131     WORD Num;
2132    
2133     GetPrivateProfileString(Sect, Key, "", Temp, sizeof(Temp), FName);
2134     if (Temp[0] == 0)
2135     Num = 0xFFFF;
2136     else if (_stricmp(Temp, "off") == 0)
2137     Num = 0xFFFF;
2138     else if (sscanf(Temp, "%d", &Num) != 1)
2139     Num = 0xFFFF;
2140    
2141     KeyMap->Map[KeyId - 1] = Num;
2142     }
2143    
2144     void FAR PASCAL ReadKeyboardCnf
2145     (PCHAR FName, PKeyMap KeyMap, BOOL ShowWarning) {
2146     int i, j, Ptr;
2147     char EntName[7];
2148     char TempStr[221];
2149     char KStr[201];
2150    
2151     // clear key map
2152     for (i = 0; i <= IdKeyMax - 1; i++)
2153     KeyMap->Map[i] = 0xFFFF;
2154     for (i = 0; i <= NumOfUserKey - 1; i++) {
2155     KeyMap->UserKeyPtr[i] = 0;
2156     KeyMap->UserKeyLen[i] = 0;
2157     }
2158    
2159     // VT editor keypad
2160     GetInt(KeyMap, IdUp, VTEditor, "Up", FName);
2161    
2162     GetInt(KeyMap, IdDown, VTEditor, "Down", FName);
2163    
2164     GetInt(KeyMap, IdRight, VTEditor, "Right", FName);
2165    
2166     GetInt(KeyMap, IdLeft, VTEditor, "Left", FName);
2167    
2168     GetInt(KeyMap, IdFind, VTEditor, "Find", FName);
2169    
2170     GetInt(KeyMap, IdInsert, VTEditor, "Insert", FName);
2171    
2172     GetInt(KeyMap, IdRemove, VTEditor, "Remove", FName);
2173    
2174     GetInt(KeyMap, IdSelect, VTEditor, "Select", FName);
2175    
2176     GetInt(KeyMap, IdPrev, VTEditor, "Prev", FName);
2177    
2178     GetInt(KeyMap, IdNext, VTEditor, "Next", FName);
2179    
2180     // VT numeric keypad
2181     GetInt(KeyMap, Id0, VTNumeric, "Num0", FName);
2182    
2183     GetInt(KeyMap, Id1, VTNumeric, "Num1", FName);
2184    
2185     GetInt(KeyMap, Id2, VTNumeric, "Num2", FName);
2186    
2187     GetInt(KeyMap, Id3, VTNumeric, "Num3", FName);
2188    
2189     GetInt(KeyMap, Id4, VTNumeric, "Num4", FName);
2190    
2191     GetInt(KeyMap, Id5, VTNumeric, "Num5", FName);
2192    
2193     GetInt(KeyMap, Id6, VTNumeric, "Num6", FName);
2194    
2195     GetInt(KeyMap, Id7, VTNumeric, "Num7", FName);
2196    
2197     GetInt(KeyMap, Id8, VTNumeric, "Num8", FName);
2198    
2199     GetInt(KeyMap, Id9, VTNumeric, "Num9", FName);
2200    
2201     GetInt(KeyMap, IdMinus, VTNumeric, "NumMinus", FName);
2202    
2203     GetInt(KeyMap, IdComma, VTNumeric, "NumComma", FName);
2204    
2205     GetInt(KeyMap, IdPeriod, VTNumeric, "NumPeriod", FName);
2206    
2207     GetInt(KeyMap, IdEnter, VTNumeric, "NumEnter", FName);
2208    
2209     GetInt(KeyMap, IdSlash, VTNumeric, "NumSlash", FName);
2210    
2211     GetInt(KeyMap, IdAsterisk, VTNumeric, "NumAsterisk", FName);
2212    
2213     GetInt(KeyMap, IdPlus, VTNumeric, "NumPlus", FName);
2214    
2215     GetInt(KeyMap, IdPF1, VTNumeric, "PF1", FName);
2216    
2217     GetInt(KeyMap, IdPF2, VTNumeric, "PF2", FName);
2218    
2219     GetInt(KeyMap, IdPF3, VTNumeric, "PF3", FName);
2220    
2221     GetInt(KeyMap, IdPF4, VTNumeric, "PF4", FName);
2222    
2223     // VT function keys
2224     GetInt(KeyMap, IdHold, VTFunction, "Hold", FName);
2225    
2226     GetInt(KeyMap, IdPrint, VTFunction, "Print", FName);
2227    
2228     GetInt(KeyMap, IdBreak, VTFunction, "Break", FName);
2229    
2230     GetInt(KeyMap, IdF6, VTFunction, "F6", FName);
2231    
2232     GetInt(KeyMap, IdF7, VTFunction, "F7", FName);
2233    
2234     GetInt(KeyMap, IdF8, VTFunction, "F8", FName);
2235    
2236     GetInt(KeyMap, IdF9, VTFunction, "F9", FName);
2237    
2238     GetInt(KeyMap, IdF10, VTFunction, "F10", FName);
2239    
2240     GetInt(KeyMap, IdF11, VTFunction, "F11", FName);
2241    
2242     GetInt(KeyMap, IdF12, VTFunction, "F12", FName);
2243    
2244     GetInt(KeyMap, IdF13, VTFunction, "F13", FName);
2245    
2246     GetInt(KeyMap, IdF14, VTFunction, "F14", FName);
2247    
2248     GetInt(KeyMap, IdHelp, VTFunction, "Help", FName);
2249    
2250     GetInt(KeyMap, IdDo, VTFunction, "Do", FName);
2251    
2252     GetInt(KeyMap, IdF17, VTFunction, "F17", FName);
2253    
2254     GetInt(KeyMap, IdF18, VTFunction, "F18", FName);
2255    
2256     GetInt(KeyMap, IdF19, VTFunction, "F19", FName);
2257    
2258     GetInt(KeyMap, IdF20, VTFunction, "F20", FName);
2259    
2260     // UDK
2261     GetInt(KeyMap, IdUDK6, VTFunction, "UDK6", FName);
2262    
2263     GetInt(KeyMap, IdUDK7, VTFunction, "UDK7", FName);
2264    
2265     GetInt(KeyMap, IdUDK8, VTFunction, "UDK8", FName);
2266    
2267     GetInt(KeyMap, IdUDK9, VTFunction, "UDK9", FName);
2268    
2269     GetInt(KeyMap, IdUDK10, VTFunction, "UDK10", FName);
2270    
2271     GetInt(KeyMap, IdUDK11, VTFunction, "UDK11", FName);
2272    
2273     GetInt(KeyMap, IdUDK12, VTFunction, "UDK12", FName);
2274    
2275     GetInt(KeyMap, IdUDK13, VTFunction, "UDK13", FName);
2276    
2277     GetInt(KeyMap, IdUDK14, VTFunction, "UDK14", FName);
2278    
2279     GetInt(KeyMap, IdUDK15, VTFunction, "UDK15", FName);
2280    
2281     GetInt(KeyMap, IdUDK16, VTFunction, "UDK16"