Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /branches/ttcomtester/teraterm/teraterm/teraterm.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7706 - (hide annotations) (download) (as text)
Tue May 21 15:20:52 2019 UTC (4 years, 10 months ago) by zmatsuo
Original Path: trunk/teraterm/teraterm/teraterm.cpp
File MIME type: text/x-c++src
File size: 7742 byte(s)
ダイアログフォントの設定をメモリに持つようにした

- common/tttype.h に ダイアログフォントに関するメンバを追加
- SetDialogFont()#common/dlglib_cpp.cpp の仕様を変更
- CVTWindow::OnSetupDlgFont#teraterm/vtwin.cpp
  ダイアログフォント設定でiniファイルに書き込まないようにした
- ReadIniFile(),WriteIniFile()#ttpset/ttset.cで読み,書き追加
1 doda 6806 /*
2     * Copyright (C) 1994-1998 T. Teranishi
3 zmatsuo 7528 * (C) 2006-2019 TeraTerm Project
4 doda 6806 * All rights reserved.
5     *
6 doda 6841 * Redistribution and use in source and binary forms, with or without
7     * modification, are permitted provided that the following conditions
8     * are met:
9 doda 6806 *
10 doda 6841 * 1. Redistributions of source code must retain the above copyright
11     * notice, this list of conditions and the following disclaimer.
12     * 2. Redistributions in binary form must reproduce the above copyright
13     * notice, this list of conditions and the following disclaimer in the
14     * documentation and/or other materials provided with the distribution.
15     * 3. The name of the author may not be used to endorse or promote products
16     * derived from this software without specific prior written permission.
17 doda 6806 *
18 doda 6841 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
19     * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20     * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21     * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22     * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23     * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24     * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27     * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 doda 6806 */
29 maya 3227
30     /* TERATERM.EXE, main */
31    
32 zmatsuo 7554 #include "teraterm_conf.h"
33    
34 zmatsuo 7528 #include <crtdbg.h>
35     #include <tchar.h>
36 maya 3227 #include "teraterm.h"
37     #include "tttypes.h"
38     #include "commlib.h"
39     #include "ttwinman.h"
40     #include "buffer.h"
41     #include "vtterm.h"
42     #include "vtwin.h"
43     #include "clipboar.h"
44     #include "ttftypes.h"
45     #include "filesys.h"
46     #include "telnet.h"
47     #include "tektypes.h"
48     #include "tekwin.h"
49     #include "ttdde.h"
50 doda 4414 #include "keyboard.h"
51 zmatsuo 7457 #include "dllutil.h"
52     #include "compat_win.h"
53 maya 3227 #include "compat_w95.h"
54 zmatsuo 7509 #include "dlglib.h"
55 zmatsuo 7528 #include "teraterml.h"
56 maya 3227
57 zmatsuo 7656 #if defined(_DEBUG) && defined(_MSC_VER)
58 zmatsuo 7457 #define new ::new(_NORMAL_BLOCK, __FILE__, __LINE__)
59 maya 3227 #endif
60    
61 zmatsuo 7457 static BOOL AddFontFlag;
62     static TCHAR TSpecialFont[MAX_PATH];
63    
64     static void LoadSpecialFont()
65     {
66 zmatsuo 7509 if (!IsExistFontA("Tera Special", SYMBOL_CHARSET, TRUE)) {
67 zmatsuo 7457 int r;
68    
69     if (GetModuleFileName(NULL, TSpecialFont,_countof(TSpecialFont)) == 0) {
70     AddFontFlag = FALSE;
71     return;
72 doda 6793 }
73 zmatsuo 7457 *_tcsrchr(TSpecialFont, _T('\\')) = 0;
74     _tcscat_s(TSpecialFont, _T("\\TSPECIAL1.TTF"));
75    
76     if (pAddFontResourceEx != NULL) {
77     // teraterm.exe�������L�����t�H���g�������B
78     // remove�����������I��������OS������������
79     r = pAddFontResourceEx(TSpecialFont, FR_PRIVATE, NULL);
80     } else {
81     // �V�X�e���S�����g�����t�H���g������
82     // remove��������OS������������������
83     r = AddFontResource(TSpecialFont);
84 doda 6793 }
85 zmatsuo 7457 if (r != 0) {
86     AddFontFlag = TRUE;
87     }
88 doda 6793 }
89 maya 3227 }
90    
91 zmatsuo 7457 static void UnloadSpecialFont()
92     {
93     if (AddFontFlag) {
94     if (pRemoveFontResourceEx != NULL) {
95     pRemoveFontResourceEx(TSpecialFont, FR_PRIVATE, NULL);
96     } else {
97     RemoveFontResource(TSpecialFont);
98     }
99     }
100     }
101    
102 zmatsuo 7509 static void init()
103 zmatsuo 7457 {
104     DLLInit();
105     WinCompatInit();
106 zmatsuo 7509 LoadSpecialFont();
107 zmatsuo 7457 }
108    
109 maya 3227 // Tera Term main engine
110 zmatsuo 7528 static BOOL OnIdle(LONG lCount)
111 maya 3227 {
112     static int Busy = 2;
113     int Change, nx, ny;
114     BOOL Size;
115    
116     if (lCount==0) Busy = 2;
117    
118     if (cv.Ready)
119     {
120     /* Sender */
121     CommSend(&cv);
122    
123     /* Parser */
124     if ((cv.HLogBuf!=NULL) && (cv.LogBuf==NULL))
125     cv.LogBuf = (PCHAR)GlobalLock(cv.HLogBuf);
126    
127     if ((cv.HBinBuf!=NULL) && (cv.BinBuf==NULL))
128     cv.BinBuf = (PCHAR)GlobalLock(cv.HBinBuf);
129    
130     if ((TelStatus==TelIdle) && cv.TelMode)
131     TelStatus = TelIAC;
132    
133     if (TelStatus != TelIdle)
134     {
135     ParseTel(&Size,&nx,&ny);
136     if (Size) {
137     LockBuffer();
138     ChangeTerminalSize(nx,ny);
139     UnlockBuffer();
140     }
141     }
142     else {
143     if (cv.ProtoFlag) Change = ProtoDlgParse();
144     else {
145     switch (ActiveWin) {
146 doda 6435 case IdVT:
147     Change = ((CVTWindow*)pVTWin)->Parse();
148 maya 3227 // TEK window���A�N�e�B�u���� pause ���g�����ACPU�g�p��100%������
149     // ���������b�������B(2006.2.6 yutaka)
150     // �����������������A�R���e�L�X�g�X�C�b�`�����������B(2006.3.20 yutaka)
151     Sleep(0);
152     break;
153    
154     case IdTEK:
155     if (pTEKWin != NULL) {
156     Change = ((CTEKWindow*)pTEKWin)->Parse();
157     // TEK window���A�N�e�B�u���� pause ���g�����ACPU�g�p��100%������
158     // ���������b�������B(2006.2.6 yutaka)
159     Sleep(1);
160     }
161 maya 3392 else {
162 maya 3227 Change = IdVT;
163 maya 3392 }
164 maya 3227 break;
165    
166     default:
167     Change = 0;
168     }
169    
170     switch (Change) {
171 maya 3392 case IdVT:
172     VTActivate();
173     break;
174     case IdTEK:
175     ((CVTWindow*)pVTWin)->OpenTEK();
176     break;
177 maya 3227 }
178     }
179     }
180    
181     if (cv.LogBuf!=NULL)
182     {
183 maya 3392 if (FileLog) {
184     LogToFile();
185     }
186     if (DDELog && AdvFlag) {
187     DDEAdv();
188     }
189 maya 3227 GlobalUnlock(cv.HLogBuf);
190     cv.LogBuf = NULL;
191     }
192    
193     if (cv.BinBuf!=NULL)
194     {
195 maya 3392 if (BinLog) {
196     LogToFile();
197     }
198 maya 3227 GlobalUnlock(cv.HBinBuf);
199     cv.BinBuf = NULL;
200     }
201    
202     /* Talker */
203     switch (TalkStatus) {
204 maya 3392 case IdTalkCB:
205     CBSend();
206     break; /* clip board */
207     case IdTalkFile:
208     FileSend();
209     break; /* file */
210 maya 3227 }
211    
212     /* Receiver */
213     if (DDELog && cv.DCount >0) {
214     // ���O�o�b�t�@������DDE�N���C�A���g�����������������������A
215     // TCP�p�P�b�g�����M���s�������B
216     // �A���������M���s�����A���O�o�b�t�@�����E���h���r�������������M���f�[�^��
217     // �������������������\���������B(2007.6.14 yutaka)
218    
219     } else {
220     CommReceive(&cv);
221     }
222    
223     }
224    
225     if (cv.Ready &&
226 doda 3494 (cv.RRQ || (cv.OutBuffCount>0) || (cv.InBuffCount>0) || (cv.FlushLen>0) || (cv.LCount>0) || (cv.BCount>0) || (cv.DCount>0)) ) {
227 maya 3227 Busy = 2;
228 maya 3392 }
229     else {
230 maya 3227 Busy--;
231 maya 3392 }
232 maya 3227
233     return (Busy>0);
234     }
235    
236 zmatsuo 7528 BOOL CallOnIdle(LONG lCount)
237 maya 3227 {
238 zmatsuo 7528 return OnIdle(lCount);
239     }
240    
241     HINSTANCE GetInstance()
242     {
243     return hInst;
244     }
245    
246     static HWND main_window;
247     HWND GetHWND()
248     {
249     return main_window;
250     }
251    
252     static HWND hModalWnd;
253    
254     void AddModalHandle(HWND hWnd)
255     {
256     hModalWnd = hWnd;
257     }
258    
259     void RemoveModalHandle(HWND hWnd)
260     {
261     hModalWnd = 0;
262     }
263    
264     int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst,
265     LPSTR lpszCmdLine, int nCmdShow)
266     {
267     #ifdef _DEBUG
268 zmatsuo 7656 _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
269 zmatsuo 7528 #endif
270    
271     LONG lCount = 0;
272     DWORD SleepTick = 1;
273     init();
274     hInst = hInstance;
275     CVTWindow *m_pMainWnd = new CVTWindow();
276     pVTWin = m_pMainWnd;
277     main_window = m_pMainWnd->m_hWnd;
278 zmatsuo 7589 // [Tera Term]�Z�N�V������DLG_SYSTEM_FONT�������������Z�b�g����
279 zmatsuo 7706 SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet,
280     ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT");
281 zmatsuo 7528
282     MSG msg;
283     while (GetMessage(&msg, NULL, 0, 0)) {
284     if (hModalWnd != 0) {
285     if (IsDialogMessage(hModalWnd, &msg)) {
286     continue;
287     }
288     }
289    
290     bool message_processed = false;
291    
292     if (m_pMainWnd->m_hAccel != NULL) {
293     if (!MetaKey(ts.MetaKey)) {
294     // matakey����������������
295     if (TranslateAccelerator(m_pMainWnd->m_hWnd , m_pMainWnd->m_hAccel, &msg)) {
296     // �A�N�Z�����[�^�[�L�[����������
297     message_processed = true;
298     }
299     }
300     }
301    
302     if (!message_processed) {
303     TranslateMessage(&msg);
304     DispatchMessage(&msg);
305     }
306    
307     while (!PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE)) {
308     // ���b�Z�[�W������
309     if (!OnIdle(lCount)) {
310     // idle�s�v
311     if (SleepTick < 500) { // ���� 501ms����
312     SleepTick += 2;
313     }
314     lCount = 0;
315     Sleep(SleepTick);
316     } else {
317     // �vidle
318     SleepTick = 0;
319     lCount++;
320     }
321     }
322 maya 3392 }
323 zmatsuo 7528 delete m_pMainWnd;
324     m_pMainWnd = NULL;
325    
326     UnloadSpecialFont();
327     DLLExit();
328    
329     return msg.wParam;
330 maya 3227 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26