Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /trunk/teraterm/teraterm/ttwinman.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10935 - (hide annotations) (download) (as text)
Sat Sep 16 14:32:12 2023 UTC (6 months, 3 weeks ago) by zmatsuo
File MIME type: text/x-csrc
File size: 8199 byte(s)
リモートタイトルがセットされていないときタイトルが正しく表示されなかった

- タイトル = ウィンドウタイトル
- 「設定」-「ウィンドウ」の「タイトル」の設定が使われずに "-" となっていた
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 zmatsuo 10787 const wchar_t *title_remote = cv.TitleRemoteW;
98 zmatsuo 10935 if (Connecting || !cv.Ready || title_remote == NULL || title_remote[0] == 0) {
99     // �����[�g�^�C�g�����g�p������ or ����������������
100 zmatsuo 8520 wcsncpy_s(TempTitleWithRemote, _countof(TempTitleWithRemote), title, _TRUNCATE);
101     wcsncpy_s(TempTitle, _countof(TempTitle), title, _TRUNCATE);
102 maya 3227 }
103     else {
104 zmatsuo 8520 // �����[�g�������^�C�g������������ (2008.11.1 maya)
105     if (ts.AcceptTitleChangeRequest == IdTitleChangeRequestOff) {
106     wcsncpy_s(TempTitleWithRemote, _countof(TempTitleWithRemote), title, _TRUNCATE);
107     }
108     else if (ts.AcceptTitleChangeRequest == IdTitleChangeRequestAhead) {
109     _snwprintf_s(TempTitleWithRemote, _countof(TempTitleWithRemote), _TRUNCATE,
110     L"%s %s", title_remote, title);
111     }
112     else if (ts.AcceptTitleChangeRequest == IdTitleChangeRequestLast) {
113     _snwprintf_s(TempTitleWithRemote, _countof(TempTitleWithRemote), _TRUNCATE,
114     L"%s %s", title, title_remote);
115     }
116     else {
117     wcsncpy_s(TempTitleWithRemote, _countof(TempTitleWithRemote), title_remote, _TRUNCATE);
118     }
119     wcsncpy_s(TempTitle, _countof(TempTitle), TempTitleWithRemote, _TRUNCATE);
120 maya 3227 }
121 zmatsuo 8520 free(title);
122 maya 3227 }
123    
124     if ((ts.TitleFormat & 1)!=0)
125     { // host name
126 zmatsuo 10617 wchar_t *UIMsg;
127 zmatsuo 8520 wcsncat_s(TempTitle,_countof(TempTitle), L" - ",_TRUNCATE);
128 maya 3227 if (Connecting) {
129 zmatsuo 10617 GetI18nStrWW("Tera Term", "DLG_MAIN_TITLE_CONNECTING", L"[connecting...]", ts.UILanguageFileW, &UIMsg);
130 zmatsuo 8520 wcsncat_s(TempTitle,_countof(TempTitle), UIMsg,_TRUNCATE);
131 zmatsuo 10617 free(UIMsg);
132 maya 3227 }
133     else if (! cv.Ready) {
134 zmatsuo 10617 GetI18nStrWW("Tera Term", "DLG_MAIN_TITLE_DISCONNECTED", L"[disconnected]", ts.UILanguageFileW, &UIMsg);
135 zmatsuo 8520 wcsncat_s(TempTitle,_countof(TempTitle), UIMsg,_TRUNCATE);
136 zmatsuo 10617 free(UIMsg);
137 maya 3227 }
138     else if (cv.PortType==IdSerial)
139     {
140     // COM5 over������
141 zmatsuo 8520 wchar_t str[24]; // COMxxxx:xxxxxxxxxxbps
142 maya 3227 if (ts.TitleFormat & 32) {
143 zmatsuo 8520 _snwprintf_s(str, _countof(str), _TRUNCATE, L"COM%d:%ubps", ts.ComPort, ts.Baud);
144 maya 3227 }
145     else {
146 zmatsuo 8520 _snwprintf_s(str, _countof(str), _TRUNCATE, L"COM%d", ts.ComPort);
147 maya 3227 }
148    
149     if (ts.TitleFormat & 8) {
150 zmatsuo 8520 _snwprintf_s(TempTitle, _countof(TempTitle), _TRUNCATE, L"%s - %s", str, TempTitleWithRemote);
151 maya 3227 } else {
152 zmatsuo 8520 wcsncat_s(TempTitle, _countof(TempTitle), str, _TRUNCATE);
153 maya 3227 }
154     }
155 yutakapon 4857 else if (cv.PortType == IdNamedPipe)
156     {
157 zmatsuo 8520 wchar_t str[_countof(TempTitle)];
158     wchar_t *host_name = ToWcharA(ts.HostName);
159     wcsncpy_s(str, _countof(str), host_name, _TRUNCATE);
160     free(host_name);
161 yutakapon 4857
162     if (ts.TitleFormat & 8) {
163     // format ID = 13(8 + 5): <hots/port> - <title>
164 zmatsuo 8520 _snwprintf_s(TempTitle, _countof(TempTitle), _TRUNCATE, L"%s - %s", str, TempTitleWithRemote);
165 yutakapon 4857 }
166     else {
167 zmatsuo 8520 wcsncat_s(TempTitle, _countof(TempTitle), str, _TRUNCATE);
168 yutakapon 4857 }
169     }
170 maya 3227 else {
171 zmatsuo 8520 wchar_t str[_countof(TempTitle)];
172     wchar_t *host_name = ToWcharA(ts.HostName);
173 maya 3227 if (ts.TitleFormat & 16) {
174 zmatsuo 8520 _snwprintf_s(str, _countof(str), _TRUNCATE, L"%s:%d", host_name, ts.TCPPort);
175 maya 3227 }
176     else {
177 zmatsuo 8520 wcsncpy_s(str, _countof(str), host_name, _TRUNCATE);
178 maya 3227 }
179 zmatsuo 8520 free(host_name);
180 maya 3227
181     if (ts.TitleFormat & 8) {
182     // format ID = 13(8 + 5): <hots/port> - <title>
183 zmatsuo 8520 _snwprintf_s(TempTitle, _countof(TempTitle), _TRUNCATE, L"%s - %s", str, TempTitleWithRemote);
184 maya 3227 }
185     else {
186 zmatsuo 8520 wcsncat_s(TempTitle, _countof(TempTitle), str, _TRUNCATE);
187 maya 3227 }
188     }
189     }
190    
191     if ((ts.TitleFormat & 2)!=0)
192     { // serial no.
193 zmatsuo 8520 wchar_t Num[11];
194     wcsncat_s(TempTitle,_countof(TempTitle),L" (",_TRUNCATE);
195     _snwprintf_s(Num,_countof(Num),_TRUNCATE,L"%u",SerialNo);
196     wcsncat_s(TempTitle,_countof(TempTitle),Num,_TRUNCATE);
197     wcsncat_s(TempTitle,_countof(TempTitle),L")",_TRUNCATE);
198 maya 3227 }
199    
200     if ((ts.TitleFormat & 4)!=0) // VT
201 zmatsuo 8520 wcsncat_s(TempTitle,_countof(TempTitle),L" VT",_TRUNCATE);
202 maya 3227
203 zmatsuo 9324 SetWindowTextW(HVTWin,TempTitle);
204 maya 3227
205     if (HTEKWin!=0)
206     {
207     if ((ts.TitleFormat & 4)!=0) // TEK
208     {
209 zmatsuo 8520 wcsncat_s(TempTitle,_countof(TempTitle),L" TEK",_TRUNCATE);
210 maya 3227 }
211 zmatsuo 9324 SetWindowTextW(HTEKWin,TempTitle);
212 maya 3227 }
213     }
214    
215     void SwitchMenu()
216     {
217     HWND H1, H2;
218    
219     if (ActiveWin==IdVT)
220     {
221     H1 = HTEKWin;
222     H2 = HVTWin;
223     }
224     else {
225     H1 = HVTWin;
226     H2 = HTEKWin;
227     }
228    
229     if (H1!=0)
230     PostMessage(H1,WM_USER_CHANGEMENU,0,0);
231     if (H2!=0)
232     PostMessage(H2,WM_USER_CHANGEMENU,0,0);
233     }
234    
235     void SwitchTitleBar()
236     {
237     HWND H1, H2;
238    
239     if (ActiveWin==IdVT)
240     {
241     H1 = HTEKWin;
242     H2 = HVTWin;
243     }
244     else {
245     H1 = HVTWin;
246     H2 = HTEKWin;
247     }
248    
249     if (H1!=0)
250     PostMessage(H1,WM_USER_CHANGETBAR,0,0);
251     if (H2!=0)
252     PostMessage(H2,WM_USER_CHANGETBAR,0,0);
253     }
254 doda 6792
255 zmatsuo 9335 HMODULE LoadHomeDLL(const wchar_t *DLLname)
256 doda 6792 {
257 zmatsuo 9335 HMODULE handle;
258     wchar_t *DLLpath;
259 zmatsuo 9501 aswprintf(&DLLpath, L"%s\\%s", ts.ExeDirW, DLLname);
260 zmatsuo 9335 handle = LoadLibraryW(DLLpath);
261     free(DLLpath);
262     return handle;
263 doda 6792 }

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