/
DebugWorldInputDlg.cpp
227 lines (173 loc) · 7.12 KB
/
DebugWorldInputDlg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
// DebugWorldInputDlg.cpp : implementation file
//
#include "stdafx.h"
#include "..\mushclient.h"
#include "DebugWorldInputDlg.h"
#include "InsertUnicodeDlg.h"
#include "..\doc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDebugWorldInputDlg dialog
CDebugWorldInputDlg::CDebugWorldInputDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDebugWorldInputDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDebugWorldInputDlg)
m_strText = _T("");
//}}AFX_DATA_INIT
}
void CDebugWorldInputDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDebugWorldInputDlg)
DDX_Control(pDX, IDC_INSERT_SPECIAL, m_ctlSpecials);
DDX_Control(pDX, IDC_TEXT, m_ctlText);
DDX_Text(pDX, IDC_TEXT, m_strText);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDebugWorldInputDlg, CDialog)
//{{AFX_MSG_MAP(CDebugWorldInputDlg)
ON_BN_CLICKED(IDC_SPECIAL, OnSpecial)
ON_BN_CLICKED(IDC_INSERT_UNICODE, OnInsertUnicode)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_KICKIDLE, OnKickIdle)
ON_UPDATE_COMMAND_UI(IDC_SPECIAL, OnUpdateNeedSelection)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDebugWorldInputDlg message handlers
BOOL CDebugWorldInputDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CDC dc;
dc.CreateCompatibleDC (NULL);
int lfHeight = -MulDiv(App.m_iFixedPitchFontSize, dc.GetDeviceCaps(LOGPIXELSY), 72);
m_font.CreateFont(lfHeight, // int nHeight,
0, // int nWidth,
0, // int nEscapement,
0, // int nOrientation,
FW_DONTCARE, // int nWeight,
0, // BYTE bItalic,
0, // BYTE bUnderline,
0, // BYTE cStrikeOut,
MUSHCLIENT_FONT_CHARSET, // BYTE nCharSet,
0, // BYTE nOutPrecision,
0, // BYTE nClipPrecision,
0, // BYTE nQuality,
MUSHCLIENT_FONT_FAMILY, // BYTE nPitchAndFamily,
App.m_strFixedPitchFont);// LPCTSTR lpszFacename );
// Get the metrics of the font.
dc.SelectObject(&m_font);
m_ctlText.SendMessage (WM_SETFONT,
(WPARAM) m_font.m_hObject,
MAKELPARAM (TRUE, 0));
m_ctlSpecials.AddString ("Backslash - \\\\");
AddOtherSpecial ("New Line", '\n');
AddOtherSpecial ("IAC", IAC);
AddOtherSpecial ("ESC", ESC);
AddOtherSpecial ("DO", DO);
AddOtherSpecial ("DONT", DONT);
AddOtherSpecial ("WILL", WILL);
AddOtherSpecial ("WONT", WONT);
AddOtherSpecial ("SB", SB);
AddOtherSpecial ("SE", SE);
m_ctlSpecials.AddString (CFormat ("IAC SB xx IAC SE - \\%02X\\%02Xxx\\%02X\\%02X",IAC, SB, IAC, SE));
m_ctlSpecials.AddString (CFormat ("IAC WILL xx - \\%02X\\%02Xxx",IAC, WILL));
m_ctlSpecials.AddString (CFormat ("IAC WONT xx - \\%02X\\%02Xxx",IAC, WONT));
m_ctlSpecials.AddString (CFormat ("IAC DO xx - \\%02X\\%02Xxx",IAC, DO));
m_ctlSpecials.AddString (CFormat ("IAC DONT xx - \\%02X\\%02Xxx",IAC, DONT));
AddAnsiSpecial ("Reset", ANSI_RESET);
AddAnsiSpecial ("Bold", ANSI_BOLD);
AddAnsiSpecial ("Blink", ANSI_BLINK);
AddAnsiSpecial ("Underline", ANSI_UNDERLINE);
AddAnsiSpecial ("Slow Blink", ANSI_SLOW_BLINK);
AddAnsiSpecial ("Fast Blink", ANSI_FAST_BLINK);
AddAnsiSpecial ("Inverse", ANSI_INVERSE);
AddAnsiSpecial ("Cancel Bold", ANSI_CANCEL_BOLD);
AddAnsiSpecial ("Cancel Blink", ANSI_CANCEL_BLINK);
AddAnsiSpecial ("Cancel Underline", ANSI_CANCEL_UNDERLINE);
AddAnsiSpecial ("Cancel Slow Blink", ANSI_CANCEL_SLOW_BLINK);
AddAnsiSpecial ("Cancel Inverse", ANSI_CANCEL_INVERSE);
AddAnsiSpecial ("Text Black", ANSI_TEXT_BLACK);
AddAnsiSpecial ("Text Red", ANSI_TEXT_RED);
AddAnsiSpecial ("Text Green", ANSI_TEXT_GREEN);
AddAnsiSpecial ("Text Yellow", ANSI_TEXT_YELLOW);
AddAnsiSpecial ("Text Blue", ANSI_TEXT_BLUE);
AddAnsiSpecial ("Text Magenta", ANSI_TEXT_MAGENTA);
AddAnsiSpecial ("Text Cyan", ANSI_TEXT_CYAN);
AddAnsiSpecial ("Text White", ANSI_TEXT_WHITE);
AddAnsiSpecial ("Back Black", ANSI_BACK_BLACK);
AddAnsiSpecial ("Back Red", ANSI_BACK_RED);
AddAnsiSpecial ("Back Green", ANSI_BACK_GREEN);
AddAnsiSpecial ("Back Yellow", ANSI_BACK_YELLOW);
AddAnsiSpecial ("Back Blue", ANSI_BACK_BLUE);
AddAnsiSpecial ("Back Magenta", ANSI_BACK_MAGENTA);
AddAnsiSpecial ("Back Cyan", ANSI_BACK_CYAN);
AddAnsiSpecial ("Back White", ANSI_BACK_WHITE);
AddAnsiSpecial ("Set Foreground Default", ANSI_SET_FOREGROUND_DEFAULT);
AddAnsiSpecial ("Set Background Default", ANSI_SET_BACKGROUND_DEFAULT);
AddMXPSpecial ("Open", eMXP_open);
AddMXPSpecial ("Secure", eMXP_secure);
AddMXPSpecial ("Locked", eMXP_locked);
AddMXPSpecial ("Reset", eMXP_reset);
AddMXPSpecial ("Secure Once", eMXP_secure_once);
AddMXPSpecial ("Permanent Open", eMXP_perm_open);
AddMXPSpecial ("Permanent Secure", eMXP_perm_secure);
AddMXPSpecial ("Permanent Locked", eMXP_perm_locked);
m_ctlSpecials.SetCurSel (0);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDebugWorldInputDlg::AddAnsiSpecial (const char * sName, const int iCode)
{
m_ctlSpecials.AddString (CFormat ("ANSI %s - \\1B[%im", sName, iCode));
} // end of CDebugWorldInputDlg::AddAnsiSpecial
void CDebugWorldInputDlg::AddMXPSpecial (const char * sName, const int iCode)
{
m_ctlSpecials.AddString (CFormat ("MXP %s - \\1B[%iz", sName, iCode));
} // end of CDebugWorldInputDlg::AddMXPSpecial
void CDebugWorldInputDlg::AddOtherSpecial (const char * sName, const int iCode)
{
m_ctlSpecials.AddString (CFormat ("%s - \\%02X", sName, iCode));
} // end of CDebugWorldInputDlg::AddOtherSpecial
void CDebugWorldInputDlg::OnSpecial()
{
int nItem = m_ctlSpecials.GetCurSel ();
if (nItem == LB_ERR)
return;
CString strText;
m_ctlSpecials.GetLBText(nItem, strText) ;
int iHyphen = strText.Find ("-");
if (iHyphen == -1)
return;
strText = strText.Mid (iHyphen + 1);
strText.TrimLeft ();
strText.TrimRight ();
m_ctlText.ReplaceSel (strText);
} // end of CDebugWorldInputDlg::OnSpecial
LRESULT CDebugWorldInputDlg::OnKickIdle(WPARAM, LPARAM)
{
UpdateDialogControls (AfxGetApp()->m_pMainWnd, false);
return 0;
} // end of CChooseNotepadDlg::OnKickIdle
void CDebugWorldInputDlg::OnUpdateNeedSelection(CCmdUI* pCmdUI)
{
int nItem = m_ctlSpecials.GetCurSel ();
pCmdUI->Enable(nItem != LB_ERR);
}
extern "C" int _pcre_ord2utf(int cvalue, unsigned char *buffer);
void CDebugWorldInputDlg::OnInsertUnicode()
{
CInsertUnicodeDlg dlg;
dlg.m_bHex = true;
if (dlg.DoModal () != IDOK)
return; // cancelled
unsigned char utf8 [10];
int iLen = _pcre_ord2utf (dlg.m_iCode, utf8);
CString strText;
for (int i = 0; i < iLen; i++)
strText += CFormat ("\\%02X", utf8 [i]);
m_ctlText.ReplaceSel (strText);
}