Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /branches/ttcomtester/teraterm/teraterm/ttwinman.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10521 - (hide annotations) (download) (as text)
Fri Jan 20 16:03:38 2023 UTC (14 months, 2 weeks ago) by zmatsuo
File MIME type: text/x-csrc
File size: 8283 byte(s)
add communication test tool
1 doda 6806 /*
2     * Copyright (C) 1994-1998 T. Teranishi
3 nmaya 9048 * (C) 2005- 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, variables, flags related to VT win and TEK win */
31    
32     #include "teraterm.h"
33     #include "tttypes.h"
34     #include <stdio.h>
35     #include <string.h>
36     #include <malloc.h>
37     #include "ttlib.h"
38     #include "helpid.h"
39     #include "i18n.h"
40     #include "commlib.h"
41 zmatsuo 8520 #include "codeconv.h"
42 zmatsuo 9335 #include "asprintf.h"
43 maya 3227
44     HWND HVTWin = NULL;
45     HWND HTEKWin = NULL;
46 maya 3597
47 maya 3227 int ActiveWin = IdVT; /* IdVT, IdTEK */
48 doda 8445 IdTalk TalkStatus = IdTalkKeyb; /* IdTalkKeyb, IdTalkCB, IdTalkTextFile */
49 maya 3227 BOOL KeybEnabled = TRUE; /* keyboard switch */
50     BOOL Connecting = FALSE;
51    
52     /* 'help' button on dialog box */
53     WORD MsgDlgHelp;
54    
55     TTTSet ts;
56     TComVar cv;
57    
58     /* pointers to window objects */
59     void* pTEKWin = NULL;
60     /* instance handle */
61     HINSTANCE hInst;
62    
63     int SerialNo;
64    
65     void VTActivate()
66     {
67     ActiveWin = IdVT;
68     ShowWindow(HVTWin, SW_SHOWNORMAL);
69     SetFocus(HVTWin);
70     }
71    
72     // �L���v�V���������X
73     //
74     // (2005.2.19 yutaka) format ID=13���V�K�����ACOM5�������\��������
75     // (2005.3.13 yutaka) �^�C�g����SJIS���������i���{���j������
76     // (2006.6.15 maya) ts.KanjiCode��EUC�����ASJIS����EUC������
77     // �������������������A������������������
78     // (2007.7.19 maya) TCP �|�[�g���� �� �V���A���|�[�g���{�[���[�g���\��������
79     /*
80     * TitleFormat
81     * 0 0 0 0 0 0 (2)
82     * | | | | | +----- displays TCP host/serial port
83     * | | | | +------- displays session no
84     * | | | +--------- displays VT/TEK
85     * | | +----------- displays TCP host/serial port first
86     * | +------------- displays TCP port number
87 doda 7096 * +--------------- displays speed of serial port
88 maya 3227 */
89 zmatsuo 10496 void ChangeTitle(void)
90 maya 3227 {
91 zmatsuo 10496 #define HostNameMaxLength 1024 // �z�X�g�������� TODO �������������� or ������������������
92 zmatsuo 8520 wchar_t TempTitle[HostNameMaxLength + TitleBuffSize * 2 + 1]; // �o�b�t�@�g��
93     wchar_t TempTitleWithRemote[TitleBuffSize * 2];
94 maya 3227
95 zmatsuo 8520 {
96     wchar_t *title = ToWcharA(ts.Title);
97     wchar_t *title_remote = ToWcharA(cv.TitleRemote);
98 zmatsuo 8673 if (title_remote == NULL) {
99     // TODO cv.TitleRemote �� strncpy_s() ���s���������������������� NULL ������
100     title_remote = _wcsdup(L"-");
101     }
102 zmatsuo 8520 if (Connecting || !cv.Ready || wcslen(title_remote) == 0) {
103     wcsncpy_s(TempTitleWithRemote, _countof(TempTitleWithRemote), title, _TRUNCATE);
104     wcsncpy_s(TempTitle, _countof(TempTitle), title, _TRUNCATE);
105 maya 3227 }
106     else {
107 zmatsuo 8520 // �����[�g�������^�C�g������������ (2008.11.1 maya)
108     if (ts.AcceptTitleChangeRequest == IdTitleChangeRequestOff) {
109     wcsncpy_s(TempTitleWithRemote, _countof(TempTitleWithRemote), title, _TRUNCATE);
110     }
111     else if (ts.AcceptTitleChangeRequest == IdTitleChangeRequestAhead) {
112     _snwprintf_s(TempTitleWithRemote, _countof(TempTitleWithRemote), _TRUNCATE,
113     L"%s %s", title_remote, title);
114     }
115     else if (ts.AcceptTitleChangeRequest == IdTitleChangeRequestLast) {
116     _snwprintf_s(TempTitleWithRemote, _countof(TempTitleWithRemote), _TRUNCATE,
117     L"%s %s", title, title_remote);
118     }
119     else {
120     wcsncpy_s(TempTitleWithRemote, _countof(TempTitleWithRemote), title_remote, _TRUNCATE);
121     }
122     wcsncpy_s(TempTitle, _countof(TempTitle), TempTitleWithRemote, _TRUNCATE);
123 maya 3227 }
124 zmatsuo 8520 free(title);
125     free(title_remote);
126 maya 3227 }
127    
128     if ((ts.TitleFormat & 1)!=0)
129     { // host name
130 zmatsuo 8520 wchar_t UIMsg[MAX_UIMSG];
131     wcsncat_s(TempTitle,_countof(TempTitle), L" - ",_TRUNCATE);
132 maya 3227 if (Connecting) {
133 zmatsuo 8520 get_lang_msgW("DLG_MAIN_TITLE_CONNECTING", UIMsg, _countof(UIMsg), L"[connecting...]", ts.UILanguageFile);
134     wcsncat_s(TempTitle,_countof(TempTitle), UIMsg,_TRUNCATE);
135 maya 3227 }
136     else if (! cv.Ready) {
137 zmatsuo 8520 get_lang_msgW("DLG_MAIN_TITLE_DISCONNECTED", UIMsg, _countof(UIMsg), L"[disconnected]", ts.UILanguageFile);
138     wcsncat_s(TempTitle,_countof(TempTitle), UIMsg,_TRUNCATE);
139 maya 3227 }
140     else if (cv.PortType==IdSerial)
141     {
142     // COM5 over������
143 zmatsuo 8520 wchar_t str[24]; // COMxxxx:xxxxxxxxxxbps
144 maya 3227 if (ts.TitleFormat & 32) {
145 zmatsuo 8520 _snwprintf_s(str, _countof(str), _TRUNCATE, L"COM%d:%ubps", ts.ComPort, ts.Baud);
146 maya 3227 }
147     else {
148 zmatsuo 8520 _snwprintf_s(str, _countof(str), _TRUNCATE, L"COM%d", ts.ComPort);
149 maya 3227 }
150    
151     if (ts.TitleFormat & 8) {
152 zmatsuo 8520 _snwprintf_s(TempTitle, _countof(TempTitle), _TRUNCATE, L"%s - %s", str, TempTitleWithRemote);
153 maya 3227 } else {
154 zmatsuo 8520 wcsncat_s(TempTitle, _countof(TempTitle), str, _TRUNCATE);
155 maya 3227 }
156     }
157 yutakapon 4857 else if (cv.PortType == IdNamedPipe)
158     {
159 zmatsuo 8520 wchar_t str[_countof(TempTitle)];
160     wchar_t *host_name = ToWcharA(ts.HostName);
161     wcsncpy_s(str, _countof(str), host_name, _TRUNCATE);
162     free(host_name);
163 yutakapon 4857
164     if (ts.TitleFormat & 8) {
165     // format ID = 13(8 + 5): <hots/port> - <title>
166 zmatsuo 8520 _snwprintf_s(TempTitle, _countof(TempTitle), _TRUNCATE, L"%s - %s", str, TempTitleWithRemote);
167 yutakapon 4857 }
168     else {
169 zmatsuo 8520 wcsncat_s(TempTitle, _countof(TempTitle), str, _TRUNCATE);
170 yutakapon 4857 }
171     }
172 maya 3227 else {
173 zmatsuo 8520 wchar_t str[_countof(TempTitle)];
174     wchar_t *host_name = ToWcharA(ts.HostName);
175 maya 3227 if (ts.TitleFormat & 16) {
176 zmatsuo 8520 _snwprintf_s(str, _countof(str), _TRUNCATE, L"%s:%d", host_name, ts.TCPPort);
177 maya 3227 }
178     else {
179 zmatsuo 8520 wcsncpy_s(str, _countof(str), host_name, _TRUNCATE);
180 maya 3227 }
181 zmatsuo 8520 free(host_name);
182 maya 3227
183     if (ts.TitleFormat & 8) {
184     // format ID = 13(8 + 5): <hots/port> - <title>
185 zmatsuo 8520 _snwprintf_s(TempTitle, _countof(TempTitle), _TRUNCATE, L"%s - %s", str, TempTitleWithRemote);
186 maya 3227 }
187     else {
188 zmatsuo 8520 wcsncat_s(TempTitle, _countof(TempTitle), str, _TRUNCATE);
189 maya 3227 }
190     }
191     }
192    
193     if ((ts.TitleFormat & 2)!=0)
194     { // serial no.
195 zmatsuo 8520 wchar_t Num[11];
196     wcsncat_s(TempTitle,_countof(TempTitle),L" (",_TRUNCATE);
197     _snwprintf_s(Num,_countof(Num),_TRUNCATE,L"%u",SerialNo);
198     wcsncat_s(TempTitle,_countof(TempTitle),Num,_TRUNCATE);
199     wcsncat_s(TempTitle,_countof(TempTitle),L")",_TRUNCATE);
200 maya 3227 }
201    
202     if ((ts.TitleFormat & 4)!=0) // VT
203 zmatsuo 8520 wcsncat_s(TempTitle,_countof(TempTitle),L" VT",_TRUNCATE);
204 maya 3227
205 zmatsuo 9324 SetWindowTextW(HVTWin,TempTitle);
206 maya 3227
207     if (HTEKWin!=0)
208     {
209     if ((ts.TitleFormat & 4)!=0) // TEK
210     {
211 zmatsuo 8520 wcsncat_s(TempTitle,_countof(TempTitle),L" TEK",_TRUNCATE);
212 maya 3227 }
213 zmatsuo 9324 SetWindowTextW(HTEKWin,TempTitle);
214 maya 3227 }
215     }
216    
217     void SwitchMenu()
218     {
219     HWND H1, H2;
220    
221     if (ActiveWin==IdVT)
222     {
223     H1 = HTEKWin;
224     H2 = HVTWin;
225     }
226     else {
227     H1 = HVTWin;
228     H2 = HTEKWin;
229     }
230    
231     if (H1!=0)
232     PostMessage(H1,WM_USER_CHANGEMENU,0,0);
233     if (H2!=0)
234     PostMessage(H2,WM_USER_CHANGEMENU,0,0);
235     }
236    
237     void SwitchTitleBar()
238     {
239     HWND H1, H2;
240    
241     if (ActiveWin==IdVT)
242     {
243     H1 = HTEKWin;
244     H2 = HVTWin;
245     }
246     else {
247     H1 = HVTWin;
248     H2 = HTEKWin;
249     }
250    
251     if (H1!=0)
252     PostMessage(H1,WM_USER_CHANGETBAR,0,0);
253     if (H2!=0)
254     PostMessage(H2,WM_USER_CHANGETBAR,0,0);
255     }
256 doda 6792
257 zmatsuo 9335 HMODULE LoadHomeDLL(const wchar_t *DLLname)
258 doda 6792 {
259 zmatsuo 9335 HMODULE handle;
260     wchar_t *DLLpath;
261 zmatsuo 9501 aswprintf(&DLLpath, L"%s\\%s", ts.ExeDirW, DLLname);
262 zmatsuo 9335 handle = LoadLibraryW(DLLpath);
263     free(DLLpath);
264     return handle;
265 doda 6792 }

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