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 8897 - (hide annotations) (download) (as text)
Tue Aug 18 15:27:54 2020 UTC (3 years, 7 months ago) by zmatsuo
Original Path: trunk/teraterm/teraterm/teraterm.cpp
File MIME type: text/x-c++src
File size: 9090 byte(s)
ログに関するコードを filesys_log.c に移動した

- ログ用構造体(TFileVar_#filesys_log.c)から不要メンバ削除
- OnCommOpen()#vtwin.cpp で log,dde(macro)用バッファを作成していたが、作成済みのため削除
1 doda 6806 /*
2     * Copyright (C) 1994-1998 T. Teranishi
3 zmatsuo 8582 * (C) 2006-2020 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 doda 8445 #include <stdio.h>
35 zmatsuo 7528 #include <crtdbg.h>
36 doda 8445 #include <io.h> // for access()
37 zmatsuo 8582 #include <windows.h>
38     #include <htmlhelp.h>
39 maya 3227 #include "teraterm.h"
40     #include "tttypes.h"
41     #include "commlib.h"
42     #include "ttwinman.h"
43     #include "buffer.h"
44     #include "vtterm.h"
45     #include "vtwin.h"
46     #include "clipboar.h"
47     #include "ttftypes.h"
48     #include "filesys.h"
49     #include "telnet.h"
50     #include "tektypes.h"
51     #include "tekwin.h"
52     #include "ttdde.h"
53 doda 4414 #include "keyboard.h"
54 zmatsuo 7457 #include "dllutil.h"
55     #include "compat_win.h"
56 maya 3227 #include "compat_w95.h"
57 zmatsuo 7509 #include "dlglib.h"
58 zmatsuo 7528 #include "teraterml.h"
59 doda 8445 #include "unicode_test.h"
60     #if UNICODE_INTERNAL_BUFF
61     #include "sendmem.h"
62     #endif
63 zmatsuo 8518 #include "layer_for_unicode.h"
64 maya 3227
65 zmatsuo 7656 #if defined(_DEBUG) && defined(_MSC_VER)
66 zmatsuo 7457 #define new ::new(_NORMAL_BLOCK, __FILE__, __LINE__)
67 maya 3227 #endif
68    
69 zmatsuo 7457 static BOOL AddFontFlag;
70 zmatsuo 8518 static wchar_t TSpecialFont[MAX_PATH];
71 zmatsuo 7935 static CVTWindow* pVTWin;
72 zmatsuo 8582 static DWORD HtmlHelpCookie;
73 zmatsuo 7457
74     static void LoadSpecialFont()
75     {
76 zmatsuo 8518 if (IsExistFontA("Tera Special", SYMBOL_CHARSET, TRUE)) {
77     // ���������������������[�h������
78     return;
79     }
80 zmatsuo 7457
81 zmatsuo 8843 if (_GetModuleFileNameW(NULL, TSpecialFont, _countof(TSpecialFont)) == 0) {
82 zmatsuo 8518 AddFontFlag = FALSE;
83     return;
84     }
85     *wcsrchr(TSpecialFont, L'\\') = 0;
86     wcscat_s(TSpecialFont, L"\\TSPECIAL1.TTF");
87 zmatsuo 7457
88 zmatsuo 8518 // teraterm.exe�������L�����t�H���g�������B
89     // remove�����������I��������OS������������
90     int r = _AddFontResourceExW(TSpecialFont, FR_PRIVATE, NULL);
91     if (r == 0) {
92     // AddFontResourceEx() ���g����������
93     // �V�X�e���S�����g�����t�H���g������
94     // remove��������OS������������������
95     r = _AddFontResourceW(TSpecialFont);
96 doda 6793 }
97 zmatsuo 8518 if (r != 0) {
98     AddFontFlag = TRUE;
99     }
100 maya 3227 }
101    
102 zmatsuo 7457 static void UnloadSpecialFont()
103     {
104 zmatsuo 8518 if (!AddFontFlag) {
105     return;
106 zmatsuo 7457 }
107 zmatsuo 8518 int r = _RemoveFontResourceExW(TSpecialFont, FR_PRIVATE, NULL);
108     if (r == 0) {
109     _RemoveFontResourceW(TSpecialFont);
110     }
111 zmatsuo 7457 }
112    
113 zmatsuo 7509 static void init()
114 zmatsuo 7457 {
115     DLLInit();
116     WinCompatInit();
117 zmatsuo 7509 LoadSpecialFont();
118 zmatsuo 7457 }
119    
120 maya 3227 // Tera Term main engine
121 zmatsuo 7528 static BOOL OnIdle(LONG lCount)
122 maya 3227 {
123     static int Busy = 2;
124 zmatsuo 8857 int nx, ny;
125 maya 3227 BOOL Size;
126    
127     if (lCount==0) Busy = 2;
128    
129     if (cv.Ready)
130     {
131     /* Sender */
132     CommSend(&cv);
133    
134     /* Parser */
135     if ((cv.HLogBuf!=NULL) && (cv.LogBuf==NULL))
136     cv.LogBuf = (PCHAR)GlobalLock(cv.HLogBuf);
137    
138     if ((cv.HBinBuf!=NULL) && (cv.BinBuf==NULL))
139     cv.BinBuf = (PCHAR)GlobalLock(cv.HBinBuf);
140    
141     if ((TelStatus==TelIdle) && cv.TelMode)
142     TelStatus = TelIAC;
143    
144     if (TelStatus != TelIdle)
145     {
146     ParseTel(&Size,&nx,&ny);
147     if (Size) {
148     LockBuffer();
149     ChangeTerminalSize(nx,ny);
150     UnlockBuffer();
151     }
152     }
153     else {
154 zmatsuo 8857 int Change;
155 maya 3227 if (cv.ProtoFlag) Change = ProtoDlgParse();
156     else {
157     switch (ActiveWin) {
158 doda 6435 case IdVT:
159 zmatsuo 7935 Change = pVTWin->Parse();
160 maya 3227 // TEK window���A�N�e�B�u���� pause ���g�����ACPU�g�p��100%������
161     // ���������b�������B(2006.2.6 yutaka)
162     // �����������������A�R���e�L�X�g�X�C�b�`�����������B(2006.3.20 yutaka)
163     Sleep(0);
164     break;
165    
166     case IdTEK:
167     if (pTEKWin != NULL) {
168     Change = ((CTEKWindow*)pTEKWin)->Parse();
169     // TEK window���A�N�e�B�u���� pause ���g�����ACPU�g�p��100%������
170     // ���������b�������B(2006.2.6 yutaka)
171     Sleep(1);
172     }
173 maya 3392 else {
174 maya 3227 Change = IdVT;
175 maya 3392 }
176 maya 3227 break;
177    
178     default:
179     Change = 0;
180     }
181    
182     switch (Change) {
183 maya 3392 case IdVT:
184     VTActivate();
185     break;
186     case IdTEK:
187 zmatsuo 7935 pVTWin->OpenTEK();
188 maya 3392 break;
189 maya 3227 }
190     }
191     }
192    
193 zmatsuo 8897 FLogWriteFile();
194 maya 3227
195 zmatsuo 8860 if (DDELog && AdvFlag) {
196     DDEAdv();
197     }
198 maya 3227
199     /* Talker */
200     switch (TalkStatus) {
201 maya 3392 case IdTalkCB:
202     CBSend();
203     break; /* clip board */
204     case IdTalkFile:
205     FileSend();
206     break; /* file */
207 doda 8445 case IdTalkSendMem:
208     SendMemContinuously();
209     break;
210     default:
211     break;
212 maya 3227 }
213    
214     /* Receiver */
215 zmatsuo 8860 if (DDELog && DDEGetCount() > 0) {
216 maya 3227 // ���O�o�b�t�@������DDE�N���C�A���g�����������������������A
217     // TCP�p�P�b�g�����M���s�������B
218     // �A���������M���s�����A���O�o�b�t�@�����E���h���r�������������M���f�[�^��
219     // �������������������\���������B(2007.6.14 yutaka)
220    
221     } else {
222     CommReceive(&cv);
223     }
224    
225     }
226    
227     if (cv.Ready &&
228 zmatsuo 8897 (cv.RRQ || (cv.OutBuffCount>0) || (cv.InBuffCount>0) || (cv.FlushLen>0) || FLogGetCount() > 0 || (DDEGetCount()>0)) ) {
229 maya 3227 Busy = 2;
230 maya 3392 }
231     else {
232 maya 3227 Busy--;
233 maya 3392 }
234 maya 3227
235     return (Busy>0);
236     }
237    
238 zmatsuo 7528 static HWND main_window;
239     HWND GetHWND()
240     {
241     return main_window;
242     }
243    
244 zmatsuo 7915 static HWND hModelessDlg;
245 zmatsuo 7528
246 zmatsuo 7915 void AddModelessHandle(HWND hWnd)
247 zmatsuo 7528 {
248 zmatsuo 7915 hModelessDlg = hWnd;
249 zmatsuo 7528 }
250    
251 zmatsuo 7915 void RemoveModelessHandle(HWND hWnd)
252 zmatsuo 7528 {
253 zmatsuo 7914 (void)hWnd;
254 zmatsuo 7915 hModelessDlg = 0;
255 zmatsuo 7528 }
256    
257 zmatsuo 7914 static UINT nMsgLast;
258     static POINT ptCursorLast;
259    
260     /**
261     * idle��������������������
262     */
263     static BOOL IsIdleMessage(const MSG* pMsg)
264     {
265     if (pMsg->message == WM_MOUSEMOVE ||
266     pMsg->message == WM_NCMOUSEMOVE)
267     {
268     if (pMsg->message == nMsgLast &&
269     pMsg->pt.x == ptCursorLast.x &&
270     pMsg->pt.y == ptCursorLast.y)
271     { // �������u��������idle������������
272     return FALSE;
273     }
274    
275     ptCursorLast = pMsg->pt;
276     nMsgLast = pMsg->message;
277     return TRUE;
278     }
279    
280     if (pMsg->message == WM_PAINT ||
281     pMsg->message == 0x0118/*WM_SYSTIMER*/)
282     {
283     return FALSE;
284     }
285    
286     return TRUE;
287     }
288    
289 zmatsuo 7528 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst,
290     LPSTR lpszCmdLine, int nCmdShow)
291     {
292 zmatsuo 7914 (void)hPreInst;
293     (void)lpszCmdLine;
294     (void)nCmdShow;
295 zmatsuo 7528 #ifdef _DEBUG
296 zmatsuo 7656 _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
297 zmatsuo 7528 #endif
298 doda 8445
299 zmatsuo 8582 _HtmlHelpW(NULL, NULL, HH_INITIALIZE, (DWORD_PTR)&HtmlHelpCookie);
300 zmatsuo 7528 init();
301     hInst = hInstance;
302 zmatsuo 7916 CVTWindow *m_pMainWnd = new CVTWindow(hInstance);
303 zmatsuo 7528 pVTWin = m_pMainWnd;
304     main_window = m_pMainWnd->m_hWnd;
305 zmatsuo 7589 // [Tera Term]�Z�N�V������DLG_SYSTEM_FONT�������������Z�b�g����
306 zmatsuo 7706 SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet,
307     ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT");
308 zmatsuo 7528
309 zmatsuo 7914 BOOL bIdle = TRUE; // idle������?
310     LONG lCount = 0;
311 zmatsuo 7528 MSG msg;
312 zmatsuo 7914 for (;;) {
313     // idle���������b�Z�[�W����������
314     while (bIdle) {
315     if (::PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE) != FALSE) {
316     // ���b�Z�[�W����������
317     break;
318 zmatsuo 7528 }
319 zmatsuo 7914
320     const BOOL continue_idle = OnIdle(lCount++);
321     if (!continue_idle) {
322     // FALSE��������������idle�������s�v
323     bIdle = FALSE;
324     break;
325     }
326 zmatsuo 7528 }
327    
328 zmatsuo 7914 // ���b�Z�[�W����������������������
329     for(;;) {
330     // ���b�Z�[�W���������������AGetMessage()���u���b�N��������������
331     if (::GetMessage(&msg, NULL, 0, 0) == FALSE) {
332     // WM_QUIT
333     goto exit_message_loop;
334     }
335 zmatsuo 7528
336 zmatsuo 7915 if (hModelessDlg == 0 ||
337     ::IsDialogMessage(hModelessDlg, &msg) == FALSE)
338 zmatsuo 7914 {
339     bool message_processed = false;
340    
341     if (m_pMainWnd->m_hAccel != NULL) {
342     if (!MetaKey(ts.MetaKey)) {
343     // matakey����������������
344     if (::TranslateAccelerator(m_pMainWnd->m_hWnd , m_pMainWnd->m_hAccel, &msg)) {
345     // �A�N�Z�����[�^�[�L�[����������
346     message_processed = true;
347     }
348     }
349 zmatsuo 7528 }
350 zmatsuo 7914
351     if (!message_processed) {
352     ::TranslateMessage(&msg);
353     ::DispatchMessage(&msg);
354     }
355 zmatsuo 7528 }
356    
357 zmatsuo 7914 // idle������������?
358     if (IsIdleMessage(&msg)) {
359     bIdle = TRUE;
360 zmatsuo 7528 lCount = 0;
361     }
362 zmatsuo 7914
363     if (::PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE) == FALSE) {
364     // ���b�Z�[�W������������
365     break;
366     }
367 zmatsuo 7528 }
368 maya 3392 }
369 zmatsuo 7914 exit_message_loop:
370    
371 zmatsuo 7528 delete m_pMainWnd;
372     m_pMainWnd = NULL;
373    
374 zmatsuo 8582 _HtmlHelpW(NULL, NULL, HH_CLOSE_ALL, 0);
375     _HtmlHelpW(NULL, NULL, HH_UNINITIALIZE, HtmlHelpCookie);
376    
377 zmatsuo 7528 UnloadSpecialFont();
378     DLLExit();
379    
380 zmatsuo 7914 return (int)msg.wParam;
381 maya 3227 }

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