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 7594 - (hide annotations) (download) (as text)
Wed Apr 17 15:09:14 2019 UTC (4 years, 11 months ago) by zmatsuo
Original Path: trunk/teraterm/teraterm/teraterm.cpp
File MIME type: text/x-c++src
File size: 7846 byte(s)
高DPI対応enable/disableをiniファイルでできるようにした
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 7457 #if 0
58     //#ifdef _DEBUG
59     //#define new DEBUG_NEW
60     //#undef THIS_FILE
61     //static char THIS_FILE[] = __FILE__;
62     #define new ::new(_NORMAL_BLOCK, __FILE__, __LINE__)
63 maya 3227 #endif
64    
65 zmatsuo 7457 static BOOL AddFontFlag;
66     static TCHAR TSpecialFont[MAX_PATH];
67    
68     static void LoadSpecialFont()
69     {
70 zmatsuo 7509 if (!IsExistFontA("Tera Special", SYMBOL_CHARSET, TRUE)) {
71 zmatsuo 7457 int r;
72    
73     if (GetModuleFileName(NULL, TSpecialFont,_countof(TSpecialFont)) == 0) {
74     AddFontFlag = FALSE;
75     return;
76 doda 6793 }
77 zmatsuo 7457 *_tcsrchr(TSpecialFont, _T('\\')) = 0;
78     _tcscat_s(TSpecialFont, _T("\\TSPECIAL1.TTF"));
79    
80     if (pAddFontResourceEx != NULL) {
81     // teraterm.exe�������L�����t�H���g�������B
82     // remove�����������I��������OS������������
83     r = pAddFontResourceEx(TSpecialFont, FR_PRIVATE, NULL);
84     } else {
85     // �V�X�e���S�����g�����t�H���g������
86     // remove��������OS������������������
87     r = AddFontResource(TSpecialFont);
88 doda 6793 }
89 zmatsuo 7457 if (r != 0) {
90     AddFontFlag = TRUE;
91     }
92 doda 6793 }
93 maya 3227 }
94    
95 zmatsuo 7457 static void UnloadSpecialFont()
96     {
97     if (AddFontFlag) {
98     if (pRemoveFontResourceEx != NULL) {
99     pRemoveFontResourceEx(TSpecialFont, FR_PRIVATE, NULL);
100     } else {
101     RemoveFontResource(TSpecialFont);
102     }
103     }
104     }
105    
106 zmatsuo 7509 static void init()
107 zmatsuo 7457 {
108     #ifdef _DEBUG
109     ::_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
110     #endif
111     DLLInit();
112     WinCompatInit();
113 zmatsuo 7509 LoadSpecialFont();
114 zmatsuo 7457 }
115    
116 maya 3227 // Tera Term main engine
117 zmatsuo 7528 static BOOL OnIdle(LONG lCount)
118 maya 3227 {
119     static int Busy = 2;
120     int Change, nx, ny;
121     BOOL Size;
122    
123     if (lCount==0) Busy = 2;
124    
125     if (cv.Ready)
126     {
127     /* Sender */
128     CommSend(&cv);
129    
130     /* Parser */
131     if ((cv.HLogBuf!=NULL) && (cv.LogBuf==NULL))
132     cv.LogBuf = (PCHAR)GlobalLock(cv.HLogBuf);
133    
134     if ((cv.HBinBuf!=NULL) && (cv.BinBuf==NULL))
135     cv.BinBuf = (PCHAR)GlobalLock(cv.HBinBuf);
136    
137     if ((TelStatus==TelIdle) && cv.TelMode)
138     TelStatus = TelIAC;
139    
140     if (TelStatus != TelIdle)
141     {
142     ParseTel(&Size,&nx,&ny);
143     if (Size) {
144     LockBuffer();
145     ChangeTerminalSize(nx,ny);
146     UnlockBuffer();
147     }
148     }
149     else {
150     if (cv.ProtoFlag) Change = ProtoDlgParse();
151     else {
152     switch (ActiveWin) {
153 doda 6435 case IdVT:
154     Change = ((CVTWindow*)pVTWin)->Parse();
155 maya 3227 // TEK window���A�N�e�B�u���� pause ���g�����ACPU�g�p��100%������
156     // ���������b�������B(2006.2.6 yutaka)
157     // �����������������A�R���e�L�X�g�X�C�b�`�����������B(2006.3.20 yutaka)
158     Sleep(0);
159     break;
160    
161     case IdTEK:
162     if (pTEKWin != NULL) {
163     Change = ((CTEKWindow*)pTEKWin)->Parse();
164     // TEK window���A�N�e�B�u���� pause ���g�����ACPU�g�p��100%������
165     // ���������b�������B(2006.2.6 yutaka)
166     Sleep(1);
167     }
168 maya 3392 else {
169 maya 3227 Change = IdVT;
170 maya 3392 }
171 maya 3227 break;
172    
173     default:
174     Change = 0;
175     }
176    
177     switch (Change) {
178 maya 3392 case IdVT:
179     VTActivate();
180     break;
181     case IdTEK:
182     ((CVTWindow*)pVTWin)->OpenTEK();
183     break;
184 maya 3227 }
185     }
186     }
187    
188     if (cv.LogBuf!=NULL)
189     {
190 maya 3392 if (FileLog) {
191     LogToFile();
192     }
193     if (DDELog && AdvFlag) {
194     DDEAdv();
195     }
196 maya 3227 GlobalUnlock(cv.HLogBuf);
197     cv.LogBuf = NULL;
198     }
199    
200     if (cv.BinBuf!=NULL)
201     {
202 maya 3392 if (BinLog) {
203     LogToFile();
204     }
205 maya 3227 GlobalUnlock(cv.HBinBuf);
206     cv.BinBuf = NULL;
207     }
208    
209     /* Talker */
210     switch (TalkStatus) {
211 maya 3392 case IdTalkCB:
212     CBSend();
213     break; /* clip board */
214     case IdTalkFile:
215     FileSend();
216     break; /* file */
217 maya 3227 }
218    
219     /* Receiver */
220     if (DDELog && cv.DCount >0) {
221     // ���O�o�b�t�@������DDE�N���C�A���g�����������������������A
222     // TCP�p�P�b�g�����M���s�������B
223     // �A���������M���s�����A���O�o�b�t�@�����E���h���r�������������M���f�[�^��
224     // �������������������\���������B(2007.6.14 yutaka)
225    
226     } else {
227     CommReceive(&cv);
228     }
229    
230     }
231    
232     if (cv.Ready &&
233 doda 3494 (cv.RRQ || (cv.OutBuffCount>0) || (cv.InBuffCount>0) || (cv.FlushLen>0) || (cv.LCount>0) || (cv.BCount>0) || (cv.DCount>0)) ) {
234 maya 3227 Busy = 2;
235 maya 3392 }
236     else {
237 maya 3227 Busy--;
238 maya 3392 }
239 maya 3227
240     return (Busy>0);
241     }
242    
243 zmatsuo 7528 BOOL CallOnIdle(LONG lCount)
244 maya 3227 {
245 zmatsuo 7528 return OnIdle(lCount);
246     }
247    
248     HINSTANCE GetInstance()
249     {
250     return hInst;
251     }
252    
253     static HWND main_window;
254     HWND GetHWND()
255     {
256     return main_window;
257     }
258    
259     static HWND hModalWnd;
260    
261     void AddModalHandle(HWND hWnd)
262     {
263     hModalWnd = hWnd;
264     }
265    
266     void RemoveModalHandle(HWND hWnd)
267     {
268     hModalWnd = 0;
269     }
270    
271     int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst,
272     LPSTR lpszCmdLine, int nCmdShow)
273     {
274     #ifdef _DEBUG
275     ::_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
276     #endif
277    
278     LONG lCount = 0;
279     DWORD SleepTick = 1;
280     init();
281     hInst = hInstance;
282     CVTWindow *m_pMainWnd = new CVTWindow();
283     pVTWin = m_pMainWnd;
284     main_window = m_pMainWnd->m_hWnd;
285 zmatsuo 7589 // [Tera Term]�Z�N�V������DLG_SYSTEM_FONT�������������Z�b�g����
286     SetDialogFont(ts.SetupFName, ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT");
287 zmatsuo 7528
288     MSG msg;
289     while (GetMessage(&msg, NULL, 0, 0)) {
290     if (hModalWnd != 0) {
291     if (IsDialogMessage(hModalWnd, &msg)) {
292     continue;
293     }
294     }
295    
296     bool message_processed = false;
297    
298     if (m_pMainWnd->m_hAccel != NULL) {
299     if (!MetaKey(ts.MetaKey)) {
300     // matakey����������������
301     if (TranslateAccelerator(m_pMainWnd->m_hWnd , m_pMainWnd->m_hAccel, &msg)) {
302     // �A�N�Z�����[�^�[�L�[����������
303     message_processed = true;
304     }
305     }
306     }
307    
308     if (!message_processed) {
309     TranslateMessage(&msg);
310     DispatchMessage(&msg);
311     }
312    
313     while (!PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE)) {
314     // ���b�Z�[�W������
315     if (!OnIdle(lCount)) {
316     // idle�s�v
317     if (SleepTick < 500) { // ���� 501ms����
318     SleepTick += 2;
319     }
320     lCount = 0;
321     Sleep(SleepTick);
322     } else {
323     // �vidle
324     SleepTick = 0;
325     lCount++;
326     }
327     }
328 maya 3392 }
329 zmatsuo 7528 delete m_pMainWnd;
330     m_pMainWnd = NULL;
331    
332     UnloadSpecialFont();
333     DLLExit();
334    
335     return msg.wParam;
336 maya 3227 }

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