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 9138 - (hide annotations) (download) (as text)
Wed Jan 27 14:41:03 2021 UTC (3 years, 2 months ago) by zmatsuo
Original Path: trunk/teraterm/teraterm/teraterm.cpp
File MIME type: text/x-c++src
File size: 8848 byte(s)
現在は使用していない従来のクリップボードに関連する部分を削除

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

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