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 7554 - (hide annotations) (download) (as text)
Sat Apr 6 15:40:46 2019 UTC (5 years ago) by zmatsuo
Original Path: trunk/teraterm/teraterm/teraterm.cpp
File MIME type: text/x-c++src
File size: 8084 byte(s)
VS2005pro+SDK7.0でビルドが通らなかったので修正
teraterm_conf.h を追加 _WIN32_WINNT などを定義
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 7510 #if defined(DPIAWARENESS)
114 zmatsuo 7545 //SetProcessDPIAware();
115     if (pSetThreadDpiAwarenessContext != NULL) {
116     // Windows 10 Version 1703���~������?
117 zmatsuo 7509 pSetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
118     }
119     #endif
120     LoadSpecialFont();
121 zmatsuo 7457 }
122    
123 maya 3227 // Tera Term main engine
124 zmatsuo 7528 static BOOL OnIdle(LONG lCount)
125 maya 3227 {
126     static int Busy = 2;
127     int Change, nx, ny;
128     BOOL Size;
129    
130     if (lCount==0) Busy = 2;
131    
132     if (cv.Ready)
133     {
134     /* Sender */
135     CommSend(&cv);
136    
137     /* Parser */
138     if ((cv.HLogBuf!=NULL) && (cv.LogBuf==NULL))
139     cv.LogBuf = (PCHAR)GlobalLock(cv.HLogBuf);
140    
141     if ((cv.HBinBuf!=NULL) && (cv.BinBuf==NULL))
142     cv.BinBuf = (PCHAR)GlobalLock(cv.HBinBuf);
143    
144     if ((TelStatus==TelIdle) && cv.TelMode)
145     TelStatus = TelIAC;
146    
147     if (TelStatus != TelIdle)
148     {
149     ParseTel(&Size,&nx,&ny);
150     if (Size) {
151     LockBuffer();
152     ChangeTerminalSize(nx,ny);
153     UnlockBuffer();
154     }
155     }
156     else {
157     if (cv.ProtoFlag) Change = ProtoDlgParse();
158     else {
159     switch (ActiveWin) {
160 doda 6435 case IdVT:
161     Change = ((CVTWindow*)pVTWin)->Parse();
162 maya 3227 // TEK window���A�N�e�B�u���� pause ���g�����ACPU�g�p��100%������
163     // ���������b�������B(2006.2.6 yutaka)
164     // �����������������A�R���e�L�X�g�X�C�b�`�����������B(2006.3.20 yutaka)
165     Sleep(0);
166     break;
167    
168     case IdTEK:
169     if (pTEKWin != NULL) {
170     Change = ((CTEKWindow*)pTEKWin)->Parse();
171     // TEK window���A�N�e�B�u���� pause ���g�����ACPU�g�p��100%������
172     // ���������b�������B(2006.2.6 yutaka)
173     Sleep(1);
174     }
175 maya 3392 else {
176 maya 3227 Change = IdVT;
177 maya 3392 }
178 maya 3227 break;
179    
180     default:
181     Change = 0;
182     }
183    
184     switch (Change) {
185 maya 3392 case IdVT:
186     VTActivate();
187     break;
188     case IdTEK:
189     ((CVTWindow*)pVTWin)->OpenTEK();
190     break;
191 maya 3227 }
192     }
193     }
194    
195     if (cv.LogBuf!=NULL)
196     {
197 maya 3392 if (FileLog) {
198     LogToFile();
199     }
200     if (DDELog && AdvFlag) {
201     DDEAdv();
202     }
203 maya 3227 GlobalUnlock(cv.HLogBuf);
204     cv.LogBuf = NULL;
205     }
206    
207     if (cv.BinBuf!=NULL)
208     {
209 maya 3392 if (BinLog) {
210     LogToFile();
211     }
212 maya 3227 GlobalUnlock(cv.HBinBuf);
213     cv.BinBuf = NULL;
214     }
215    
216     /* Talker */
217     switch (TalkStatus) {
218 maya 3392 case IdTalkCB:
219     CBSend();
220     break; /* clip board */
221     case IdTalkFile:
222     FileSend();
223     break; /* file */
224 maya 3227 }
225    
226     /* Receiver */
227     if (DDELog && cv.DCount >0) {
228     // ���O�o�b�t�@������DDE�N���C�A���g�����������������������A
229     // TCP�p�P�b�g�����M���s�������B
230     // �A���������M���s�����A���O�o�b�t�@�����E���h���r�������������M���f�[�^��
231     // �������������������\���������B(2007.6.14 yutaka)
232    
233     } else {
234     CommReceive(&cv);
235     }
236    
237     }
238    
239     if (cv.Ready &&
240 doda 3494 (cv.RRQ || (cv.OutBuffCount>0) || (cv.InBuffCount>0) || (cv.FlushLen>0) || (cv.LCount>0) || (cv.BCount>0) || (cv.DCount>0)) ) {
241 maya 3227 Busy = 2;
242 maya 3392 }
243     else {
244 maya 3227 Busy--;
245 maya 3392 }
246 maya 3227
247     return (Busy>0);
248     }
249    
250 zmatsuo 7528 BOOL CallOnIdle(LONG lCount)
251 maya 3227 {
252 zmatsuo 7528 return OnIdle(lCount);
253     }
254    
255     HINSTANCE GetInstance()
256     {
257     return hInst;
258     }
259    
260     static HWND main_window;
261     HWND GetHWND()
262     {
263     return main_window;
264     }
265    
266     static HWND hModalWnd;
267    
268     void AddModalHandle(HWND hWnd)
269     {
270     hModalWnd = hWnd;
271     }
272    
273     void RemoveModalHandle(HWND hWnd)
274     {
275     hModalWnd = 0;
276     }
277    
278     int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst,
279     LPSTR lpszCmdLine, int nCmdShow)
280     {
281     #ifdef _DEBUG
282     ::_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
283     #endif
284    
285     LONG lCount = 0;
286     DWORD SleepTick = 1;
287     init();
288     hInst = hInstance;
289     CVTWindow *m_pMainWnd = new CVTWindow();
290     pVTWin = m_pMainWnd;
291     main_window = m_pMainWnd->m_hWnd;
292     // [Tera Term]�Z�N�V������DlgFont=������������
293     // [TTSSH]�Z�N�V�������t�H���g�������g�p����
294     SetDialogFont(ts.SetupFName, ts.UILanguageFile, "TTSSH");
295    
296     MSG msg;
297     while (GetMessage(&msg, NULL, 0, 0)) {
298     if (hModalWnd != 0) {
299     if (IsDialogMessage(hModalWnd, &msg)) {
300     continue;
301     }
302     }
303    
304     bool message_processed = false;
305    
306     if (m_pMainWnd->m_hAccel != NULL) {
307     if (!MetaKey(ts.MetaKey)) {
308     // matakey����������������
309     if (TranslateAccelerator(m_pMainWnd->m_hWnd , m_pMainWnd->m_hAccel, &msg)) {
310     // �A�N�Z�����[�^�[�L�[����������
311     message_processed = true;
312     }
313     }
314     }
315    
316     if (!message_processed) {
317     TranslateMessage(&msg);
318     DispatchMessage(&msg);
319     }
320    
321     while (!PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE)) {
322     // ���b�Z�[�W������
323     if (!OnIdle(lCount)) {
324     // idle�s�v
325     if (SleepTick < 500) { // ���� 501ms����
326     SleepTick += 2;
327     }
328     lCount = 0;
329     Sleep(SleepTick);
330     } else {
331     // �vidle
332     SleepTick = 0;
333     lCount++;
334     }
335     }
336 maya 3392 }
337 zmatsuo 7528 delete m_pMainWnd;
338     m_pMainWnd = NULL;
339    
340     UnloadSpecialFont();
341     DLLExit();
342    
343     return msg.wParam;
344 maya 3227 }

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