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 9319 - (hide annotations) (download) (as text)
Tue Jun 29 15:19:33 2021 UTC (2 years, 9 months ago) by zmatsuo
Original Path: trunk/teraterm/teraterm/teraterm.cpp
File MIME type: text/x-c++src
File size: 8783 byte(s)
_HtmlHelpW() を layer_for_unicode.cpp から compat_win.cpp へ移動

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

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