Skip to content

Commit 65a4ff8

Browse files
committed
Added option TabInsertsTabInMultiLineDialogs
1 parent cc31b32 commit 65a4ff8

File tree

4 files changed

+47
-16
lines changed

4 files changed

+47
-16
lines changed

MUSHclient.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ class CMUSHclientApp : public CWinApp
166166
unsigned int m_nTimerInterval;
167167
unsigned int m_bEnablePackageLibrary;
168168
unsigned int m_iFixedPitchFontSize;
169+
unsigned int m_bTabInsertsTab;
169170

170171

171172
COLORREF m_cNotepadBackColour;

dialogs/EditMultiLine.cpp

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ void CEditMultiLine::DoDataExchange(CDataExchange* pDX)
5050
if(!pDX->m_bSaveAndValidate && App.m_bFixedFontForEditing)
5151
FixFont (m_font, m_ctlText, App.m_strFixedPitchFont, App.m_iFixedPitchFontSize, FW_NORMAL, DEFAULT_CHARSET);
5252

53+
if(!pDX->m_bSaveAndValidate)
54+
m_ctlText.SetTabStops(10);
5355
}
5456

5557

@@ -76,12 +78,12 @@ END_MESSAGE_MAP()
7678
iTopOfRow, iWidth, iHeight)
7779

7880

79-
void CEditMultiLine::OnSize(UINT nType, int cx, int cy)
81+
void CEditMultiLine::OnSize(UINT nType, int cx, int cy)
8082
{
8183
CDialog::OnSize(nType, cx, cy);
82-
83-
if (m_ctlText.m_hWnd &&
84-
m_ctlCancel.m_hWnd &&
84+
85+
if (m_ctlText.m_hWnd &&
86+
m_ctlCancel.m_hWnd &&
8587
m_ctlFunctionListButton.m_hWnd &&
8688
m_ctlCompleteFunctionButton.m_hWnd &&
8789
m_ctlGoToLineButton.m_hWnd &&
@@ -140,21 +142,21 @@ void CEditMultiLine::OnSize(UINT nType, int cx, int cy)
140142

141143
}
142144

143-
BOOL CEditMultiLine::OnInitDialog()
145+
BOOL CEditMultiLine::OnInitDialog()
144146
{
145147
CDialog::OnInitDialog();
146-
148+
147149
CWindowPlacement wp;
148150
wp.Restore ("Edit MultiLine Dialog", this, false);
149151

150152
if (!m_strTitle.IsEmpty ())
151-
SetWindowText (m_strTitle);
152-
153+
SetWindowText (m_strTitle);
154+
153155
PostMessage (WM_COMMAND, CLEAR_SELECTION);
154156

155157
if (!m_bScript)
156158
{
157-
m_ctlFunctionListButton.ShowWindow (SW_HIDE);
159+
m_ctlFunctionListButton.ShowWindow (SW_HIDE);
158160
m_ctlCompleteFunctionButton.ShowWindow (SW_HIDE);
159161
m_ctlGoToLineButton.ShowWindow (SW_HIDE);
160162
}
@@ -170,7 +172,7 @@ void CEditMultiLine::OnRemoveSelection()
170172

171173
}
172174

173-
void CEditMultiLine::OnFunctionList()
175+
void CEditMultiLine::OnFunctionList()
174176
{
175177
int nStartChar,
176178
nEndChar;
@@ -184,21 +186,21 @@ CString strSelection;
184186
ShowFunctionslist (strSelection, nStartChar, nEndChar, m_bLua);
185187
}
186188

187-
void CEditMultiLine::OnCompleteWord()
189+
void CEditMultiLine::OnCompleteWord()
188190
{
189191
FunctionMenu (m_ctlText, m_bScript && m_bLua);
190192
}
191193

192-
void CEditMultiLine::OnDestroy()
194+
void CEditMultiLine::OnDestroy()
193195
{
194196
CDialog::OnDestroy();
195-
197+
196198
CWindowPlacement wp;
197199
wp.Save ("Edit MultiLine Dialog", this);
198-
200+
199201
}
200202

201-
void CEditMultiLine::OnGotoLine()
203+
void CEditMultiLine::OnGotoLine()
202204
{
203205
CGoToLineDlg dlg;
204206

@@ -218,8 +220,34 @@ CGoToLineDlg dlg;
218220

219221
// go to the start of that line
220222
m_ctlText.SetSel(iIndex, iIndex);
221-
223+
222224
// ensure text box has the focus if you click on the button
223225
m_ctlText.SetFocus ();
224226

225227
}
228+
229+
BOOL CEditMultiLine::PreTranslateMessage(MSG* pMsg)
230+
{
231+
232+
if ( pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_TAB &&
233+
App.m_bTabInsertsTab)
234+
{
235+
int nStartChar,
236+
nEndChar;
237+
238+
// find the selection range
239+
m_ctlText.GetSel(nStartChar, nEndChar);
240+
241+
// select zero chars
242+
m_ctlText.SetSel(nStartChar, nStartChar);
243+
244+
// then replace that selection with a TAB
245+
m_ctlText.ReplaceSel("\t", TRUE);
246+
247+
// no need to do a msg translation, so quit.
248+
// that way no further processing gets done
249+
return TRUE;
250+
}
251+
252+
return CDialog::PreTranslateMessage(pMsg);
253+
} // end of CEditMultiLine::PreTranslateMessage

dialogs/EditMultiLine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class CEditMultiLine : public CDialog
4040
//{{AFX_VIRTUAL(CEditMultiLine)
4141
protected:
4242
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
43+
virtual BOOL PreTranslateMessage(MSG* pMsg);
4344
//}}AFX_VIRTUAL
4445

4546
// Implementation

globalregistryoptions.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ static tGlobalConfigurationNumericOption GlobalOptionsTable [] = {
6161
{ GLB_OPT (m_nPrinterTopMargin ), "PrinterTopMargin", 15 },
6262
{ GLB_OPT (m_nTimerInterval ), "TimerInterval", 0 },
6363
{ GLB_OPT (m_iFixedPitchFontSize ), "FixedPitchFontSize", 9 },
64+
{ GLB_OPT (m_bTabInsertsTab ), "TabInsertsTabInMultiLineDialogs", 0 },
6465

6566
{NULL} // end of table marker
6667

0 commit comments

Comments
 (0)