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

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