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 7496 - (hide annotations) (download) (as text)
Mon Mar 18 14:01:33 2019 UTC (5 years ago) by zmatsuo
Original Path: trunk/teraterm/teraterm/teraterm.cpp
File MIME type: text/x-c++src
File size: 7526 byte(s)
高速化テスト(Ttssh2-devel 3598)
1 doda 6806 /*
2     * Copyright (C) 1994-1998 T. Teranishi
3     * (C) 2006-2017 TeraTerm Project
4     * 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     #include "stdafx.h"
33     #include "teraterm.h"
34     #include "tttypes.h"
35     #include "commlib.h"
36     #include "ttwinman.h"
37     #include "buffer.h"
38     #include "vtterm.h"
39     #include "vtwin.h"
40     #include "clipboar.h"
41     #include "ttftypes.h"
42     #include "filesys.h"
43     #include "telnet.h"
44     #include "tektypes.h"
45     #include "tekwin.h"
46     #include "ttdde.h"
47 doda 4414 #include "keyboard.h"
48 zmatsuo 7457 #include "dllutil.h"
49     #include "compat_win.h"
50 zmatsuo 7496 #include "vtdisp_delay.h"
51 maya 3227
52     #include "teraapp.h"
53    
54     #include "compat_w95.h"
55    
56 zmatsuo 7457 #if 0
57     //#ifdef _DEBUG
58     //#define new DEBUG_NEW
59     //#undef THIS_FILE
60     //static char THIS_FILE[] = __FILE__;
61     #define new ::new(_NORMAL_BLOCK, __FILE__, __LINE__)
62 maya 3227 #endif
63    
64     BEGIN_MESSAGE_MAP(CTeraApp, CWinApp)
65     //{{AFX_MSG_MAP(CTeraApp)
66     //}}AFX_MSG_MAP
67     END_MESSAGE_MAP()
68    
69 zmatsuo 7457 typedef struct {
70     const TCHAR *FaceName;
71     bool found;
72     } EnumFontInfo;
73    
74     static int CALLBACK EnumFontExProc(
75     ENUMLOGFONT* lpelf, NEWTEXTMETRIC* lpntm,
76     int nFontType, LPARAM lParam)
77 maya 3227 {
78 zmatsuo 7457 EnumFontInfo *info = (EnumFontInfo *)lParam;
79     if (nFontType == DEVICE_FONTTYPE) {
80     // �����������f�o�C�X(�v�����^����)�����t�H���g
81     return 1;
82     }
83     const TCHAR *FaceName = lpelf->elfLogFont.lfFaceName;
84     if (_tcscmp(info->FaceName, FaceName) == 0) {
85     info->found = true;
86     return 0;
87     }
88     return 1;
89     }
90 doda 6793
91 zmatsuo 7457 BOOL isExistFont(const TCHAR *FaceName)
92     {
93     HDC hDC = GetDC(NULL);
94     LOGFONT lf;
95     memset(&lf, 0, sizeof(lf));
96     lf.lfCharSet = DEFAULT_CHARSET;// SHIFTJIS_CHARSET;
97     lf.lfPitchAndFamily = 0;
98 doda 6793
99 zmatsuo 7457 EnumFontInfo info;
100     info.FaceName = FaceName;
101     info.found = false;
102     EnumFontFamiliesEx(hDC, &lf, (FONTENUMPROC)EnumFontExProc, (LPARAM)&info, 0);
103     ReleaseDC(NULL, hDC);
104     return info.found;
105     }
106    
107     static BOOL AddFontFlag;
108     static TCHAR TSpecialFont[MAX_PATH];
109    
110     static void LoadSpecialFont()
111     {
112     if (!isExistFont(_T("Tera Special"))) {
113     int r;
114    
115     if (GetModuleFileName(NULL, TSpecialFont,_countof(TSpecialFont)) == 0) {
116     AddFontFlag = FALSE;
117     return;
118 doda 6793 }
119 zmatsuo 7457 *_tcsrchr(TSpecialFont, _T('\\')) = 0;
120     _tcscat_s(TSpecialFont, _T("\\TSPECIAL1.TTF"));
121    
122     if (pAddFontResourceEx != NULL) {
123     // teraterm.exe�������L�����t�H���g�������B
124     // remove�����������I��������OS������������
125     r = pAddFontResourceEx(TSpecialFont, FR_PRIVATE, NULL);
126     } else {
127     // �V�X�e���S�����g�����t�H���g������
128     // remove��������OS������������������
129     r = AddFontResource(TSpecialFont);
130 doda 6793 }
131 zmatsuo 7457 if (r != 0) {
132     AddFontFlag = TRUE;
133     }
134 doda 6793 }
135 maya 3227 }
136    
137 zmatsuo 7457 static void UnloadSpecialFont()
138     {
139     if (AddFontFlag) {
140     if (pRemoveFontResourceEx != NULL) {
141     pRemoveFontResourceEx(TSpecialFont, FR_PRIVATE, NULL);
142     } else {
143     RemoveFontResource(TSpecialFont);
144     }
145     }
146     }
147    
148     CTeraApp::CTeraApp()
149     {
150     #ifdef _DEBUG
151     ::_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
152     #endif
153    
154     DLLInit();
155     WinCompatInit();
156     }
157    
158 maya 3227 // CTeraApp instance
159     CTeraApp theApp;
160    
161    
162    
163    
164    
165     // CTeraApp initialization
166     BOOL CTeraApp::InitInstance()
167     {
168 zmatsuo 7457 LoadSpecialFont();
169 maya 3392 hInst = m_hInstance;
170     m_pMainWnd = new CVTWindow();
171     pVTWin = m_pMainWnd;
172     return TRUE;
173 maya 3227 }
174    
175     int CTeraApp::ExitInstance()
176     {
177 zmatsuo 7457 UnloadSpecialFont();
178     DLLExit();
179 maya 3392 return CWinApp::ExitInstance();
180 maya 3227 }
181    
182     // Tera Term main engine
183     BOOL CTeraApp::OnIdle(LONG lCount)
184     {
185     static int Busy = 2;
186     int Change, nx, ny;
187     BOOL Size;
188    
189     if (lCount==0) Busy = 2;
190    
191     if (cv.Ready)
192     {
193     /* Sender */
194     CommSend(&cv);
195    
196     /* Parser */
197     if ((cv.HLogBuf!=NULL) && (cv.LogBuf==NULL))
198     cv.LogBuf = (PCHAR)GlobalLock(cv.HLogBuf);
199    
200     if ((cv.HBinBuf!=NULL) && (cv.BinBuf==NULL))
201     cv.BinBuf = (PCHAR)GlobalLock(cv.HBinBuf);
202    
203     if ((TelStatus==TelIdle) && cv.TelMode)
204     TelStatus = TelIAC;
205    
206     if (TelStatus != TelIdle)
207     {
208     ParseTel(&Size,&nx,&ny);
209     if (Size) {
210     LockBuffer();
211     ChangeTerminalSize(nx,ny);
212     UnlockBuffer();
213     }
214     }
215     else {
216     if (cv.ProtoFlag) Change = ProtoDlgParse();
217     else {
218     switch (ActiveWin) {
219 doda 6435 case IdVT:
220     Change = ((CVTWindow*)pVTWin)->Parse();
221 maya 3227 // TEK window���A�N�e�B�u���� pause ���g�����ACPU�g�p��100%������
222     // ���������b�������B(2006.2.6 yutaka)
223     // �����������������A�R���e�L�X�g�X�C�b�`�����������B(2006.3.20 yutaka)
224     Sleep(0);
225     break;
226    
227     case IdTEK:
228     if (pTEKWin != NULL) {
229     Change = ((CTEKWindow*)pTEKWin)->Parse();
230     // TEK window���A�N�e�B�u���� pause ���g�����ACPU�g�p��100%������
231     // ���������b�������B(2006.2.6 yutaka)
232     Sleep(1);
233     }
234 maya 3392 else {
235 maya 3227 Change = IdVT;
236 maya 3392 }
237 maya 3227 break;
238    
239     default:
240     Change = 0;
241     }
242    
243     switch (Change) {
244 maya 3392 case IdVT:
245     VTActivate();
246     break;
247     case IdTEK:
248     ((CVTWindow*)pVTWin)->OpenTEK();
249     break;
250 maya 3227 }
251     }
252     }
253    
254     if (cv.LogBuf!=NULL)
255     {
256 maya 3392 if (FileLog) {
257     LogToFile();
258     }
259     if (DDELog && AdvFlag) {
260     DDEAdv();
261     }
262 maya 3227 GlobalUnlock(cv.HLogBuf);
263     cv.LogBuf = NULL;
264     }
265    
266     if (cv.BinBuf!=NULL)
267     {
268 maya 3392 if (BinLog) {
269     LogToFile();
270     }
271 maya 3227 GlobalUnlock(cv.HBinBuf);
272     cv.BinBuf = NULL;
273     }
274    
275     /* Talker */
276     switch (TalkStatus) {
277 maya 3392 case IdTalkCB:
278     CBSend();
279     break; /* clip board */
280     case IdTalkFile:
281     FileSend();
282     break; /* file */
283 maya 3227 }
284    
285     /* Receiver */
286     if (DDELog && cv.DCount >0) {
287     // ���O�o�b�t�@������DDE�N���C�A���g�����������������������A
288     // TCP�p�P�b�g�����M���s�������B
289     // �A���������M���s�����A���O�o�b�t�@�����E���h���r�������������M���f�[�^��
290     // �������������������\���������B(2007.6.14 yutaka)
291    
292     } else {
293     CommReceive(&cv);
294     }
295    
296     }
297    
298     if (cv.Ready &&
299 doda 3494 (cv.RRQ || (cv.OutBuffCount>0) || (cv.InBuffCount>0) || (cv.FlushLen>0) || (cv.LCount>0) || (cv.BCount>0) || (cv.DCount>0)) ) {
300 maya 3227 Busy = 2;
301 maya 3392 }
302     else {
303 maya 3227 Busy--;
304 maya 3392 }
305 maya 3227
306 zmatsuo 7496 if (Busy == 0) {
307     if (IsUpdateTerm()) {
308     Busy++;
309     }
310     }
311    
312 maya 3227 return (Busy>0);
313     }
314    
315     BOOL CTeraApp::PreTranslateMessage(MSG* pMsg)
316     {
317 doda 4414 if (MetaKey(ts.MetaKey)) {
318 maya 3392 return FALSE; /* ignore accelerator keys */
319     }
320     else {
321     return CWinApp::PreTranslateMessage(pMsg);
322     }
323 maya 3227 }

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