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 7510 - (hide annotations) (download) (as text)
Mon Mar 25 13:53:31 2019 UTC (5 years ago) by zmatsuo
Original Path: trunk/teraterm/teraterm/teraterm.cpp
File MIME type: text/x-c++src
File size: 6916 byte(s)
ENABLE_DPIAWARENESS オプションを追加した
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 zmatsuo 7509 #include "dlglib.h"
55 maya 3227
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 static BOOL AddFontFlag;
70     static TCHAR TSpecialFont[MAX_PATH];
71    
72     static void LoadSpecialFont()
73     {
74 zmatsuo 7509 if (!IsExistFontA("Tera Special", SYMBOL_CHARSET, TRUE)) {
75 zmatsuo 7457 int r;
76    
77     if (GetModuleFileName(NULL, TSpecialFont,_countof(TSpecialFont)) == 0) {
78     AddFontFlag = FALSE;
79     return;
80 doda 6793 }
81 zmatsuo 7457 *_tcsrchr(TSpecialFont, _T('\\')) = 0;
82     _tcscat_s(TSpecialFont, _T("\\TSPECIAL1.TTF"));
83    
84     if (pAddFontResourceEx != NULL) {
85     // teraterm.exe�������L�����t�H���g�������B
86     // remove�����������I��������OS������������
87     r = pAddFontResourceEx(TSpecialFont, FR_PRIVATE, NULL);
88     } else {
89     // �V�X�e���S�����g�����t�H���g������
90     // remove��������OS������������������
91     r = AddFontResource(TSpecialFont);
92 doda 6793 }
93 zmatsuo 7457 if (r != 0) {
94     AddFontFlag = TRUE;
95     }
96 doda 6793 }
97 maya 3227 }
98    
99 zmatsuo 7457 static void UnloadSpecialFont()
100     {
101     if (AddFontFlag) {
102     if (pRemoveFontResourceEx != NULL) {
103     pRemoveFontResourceEx(TSpecialFont, FR_PRIVATE, NULL);
104     } else {
105     RemoveFontResource(TSpecialFont);
106     }
107     }
108     }
109    
110 zmatsuo 7509 static void init()
111 zmatsuo 7457 {
112     #ifdef _DEBUG
113     ::_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
114     #endif
115     DLLInit();
116     WinCompatInit();
117 zmatsuo 7510 #if defined(DPIAWARENESS)
118 zmatsuo 7509 if (pSetThreadDpiAwarenessContext) {
119     pSetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
120     }
121     #endif
122     LoadSpecialFont();
123 zmatsuo 7457 }
124    
125 zmatsuo 7509 CTeraApp::CTeraApp()
126     {
127     init();
128     }
129    
130 maya 3227 // CTeraApp instance
131     CTeraApp theApp;
132    
133    
134    
135    
136    
137     // CTeraApp initialization
138     BOOL CTeraApp::InitInstance()
139     {
140 maya 3392 hInst = m_hInstance;
141     m_pMainWnd = new CVTWindow();
142     pVTWin = m_pMainWnd;
143 zmatsuo 7509 // [Tera Term]�Z�N�V������DlgFont=������������
144     // [TTSH]�Z�N�V�������t�H���g�������g�p����
145     SetDialogFont(ts.SetupFName, ts.UILanguageFile, "TTSSH");
146 maya 3392 return TRUE;
147 maya 3227 }
148    
149     int CTeraApp::ExitInstance()
150     {
151 zmatsuo 7457 UnloadSpecialFont();
152     DLLExit();
153 maya 3392 return CWinApp::ExitInstance();
154 maya 3227 }
155    
156     // Tera Term main engine
157     BOOL CTeraApp::OnIdle(LONG lCount)
158     {
159     static int Busy = 2;
160     int Change, nx, ny;
161     BOOL Size;
162    
163     if (lCount==0) Busy = 2;
164    
165     if (cv.Ready)
166     {
167     /* Sender */
168     CommSend(&cv);
169    
170     /* Parser */
171     if ((cv.HLogBuf!=NULL) && (cv.LogBuf==NULL))
172     cv.LogBuf = (PCHAR)GlobalLock(cv.HLogBuf);
173    
174     if ((cv.HBinBuf!=NULL) && (cv.BinBuf==NULL))
175     cv.BinBuf = (PCHAR)GlobalLock(cv.HBinBuf);
176    
177     if ((TelStatus==TelIdle) && cv.TelMode)
178     TelStatus = TelIAC;
179    
180     if (TelStatus != TelIdle)
181     {
182     ParseTel(&Size,&nx,&ny);
183     if (Size) {
184     LockBuffer();
185     ChangeTerminalSize(nx,ny);
186     UnlockBuffer();
187     }
188     }
189     else {
190     if (cv.ProtoFlag) Change = ProtoDlgParse();
191     else {
192     switch (ActiveWin) {
193 doda 6435 case IdVT:
194     Change = ((CVTWindow*)pVTWin)->Parse();
195 maya 3227 // TEK window���A�N�e�B�u���� pause ���g�����ACPU�g�p��100%������
196     // ���������b�������B(2006.2.6 yutaka)
197     // �����������������A�R���e�L�X�g�X�C�b�`�����������B(2006.3.20 yutaka)
198     Sleep(0);
199     break;
200    
201     case IdTEK:
202     if (pTEKWin != NULL) {
203     Change = ((CTEKWindow*)pTEKWin)->Parse();
204     // TEK window���A�N�e�B�u���� pause ���g�����ACPU�g�p��100%������
205     // ���������b�������B(2006.2.6 yutaka)
206     Sleep(1);
207     }
208 maya 3392 else {
209 maya 3227 Change = IdVT;
210 maya 3392 }
211 maya 3227 break;
212    
213     default:
214     Change = 0;
215     }
216    
217     switch (Change) {
218 maya 3392 case IdVT:
219     VTActivate();
220     break;
221     case IdTEK:
222     ((CVTWindow*)pVTWin)->OpenTEK();
223     break;
224 maya 3227 }
225     }
226     }
227    
228     if (cv.LogBuf!=NULL)
229     {
230 maya 3392 if (FileLog) {
231     LogToFile();
232     }
233     if (DDELog && AdvFlag) {
234     DDEAdv();
235     }
236 maya 3227 GlobalUnlock(cv.HLogBuf);
237     cv.LogBuf = NULL;
238     }
239    
240     if (cv.BinBuf!=NULL)
241     {
242 maya 3392 if (BinLog) {
243     LogToFile();
244     }
245 maya 3227 GlobalUnlock(cv.HBinBuf);
246     cv.BinBuf = NULL;
247     }
248    
249     /* Talker */
250     switch (TalkStatus) {
251 maya 3392 case IdTalkCB:
252     CBSend();
253     break; /* clip board */
254     case IdTalkFile:
255     FileSend();
256     break; /* file */
257 maya 3227 }
258    
259     /* Receiver */
260     if (DDELog && cv.DCount >0) {
261     // ���O�o�b�t�@������DDE�N���C�A���g�����������������������A
262     // TCP�p�P�b�g�����M���s�������B
263     // �A���������M���s�����A���O�o�b�t�@�����E���h���r�������������M���f�[�^��
264     // �������������������\���������B(2007.6.14 yutaka)
265    
266     } else {
267     CommReceive(&cv);
268     }
269    
270     }
271    
272     if (cv.Ready &&
273 doda 3494 (cv.RRQ || (cv.OutBuffCount>0) || (cv.InBuffCount>0) || (cv.FlushLen>0) || (cv.LCount>0) || (cv.BCount>0) || (cv.DCount>0)) ) {
274 maya 3227 Busy = 2;
275 maya 3392 }
276     else {
277 maya 3227 Busy--;
278 maya 3392 }
279 maya 3227
280     return (Busy>0);
281     }
282    
283     BOOL CTeraApp::PreTranslateMessage(MSG* pMsg)
284     {
285 doda 4414 if (MetaKey(ts.MetaKey)) {
286 maya 3392 return FALSE; /* ignore accelerator keys */
287     }
288     else {
289     return CWinApp::PreTranslateMessage(pMsg);
290     }
291 maya 3227 }

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