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 3441 - (hide annotations) (download) (as text)
Fri Jun 5 07:00:43 2009 UTC (14 years, 10 months ago) by doda
File MIME type: text/x-csrc
File size: 98658 byte(s)
AltキーでMSBをセットした文字を送信できるようにした。
使用するためには MetaKey=on かつ Meta8Bit=on に設定する必要あり。

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