Skip to content

Commit a451ad8

Browse files
committed
Added option to have Ctrl+Backspace delete the entered word
1 parent 9d4f265 commit a451ad8

File tree

4 files changed

+52
-3
lines changed

4 files changed

+52
-3
lines changed

doc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,7 @@ class CMUSHclientDoc : public CDocument
930930
unsigned short m_iFadeOutputBufferAfterSeconds; // fade output buffer after these many seconds (0 = disable)
931931
unsigned short m_FadeOutputOpacityPercent; // what opacity to fade to (0 to 100 percent)
932932
unsigned short m_FadeOutputSeconds; // how many seconds to fade over
933+
unsigned short m_bCtrlBackspaceDeletesLastWord; // Ctrl+Backspace deletes last word in command window
933934

934935
// end of stuff saved to disk **************************************************************
935936

doc_construct.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,10 @@ int i;
433433

434434
m_timeFadeCancelled = CTime ((time_t) 0);
435435
m_timeLastWindowDraw = CTime ((time_t) 0);
436+
m_iFadeOutputBufferAfterSeconds = 0;
437+
m_FadeOutputOpacityPercent = 20;
438+
m_FadeOutputSeconds = 8;
439+
m_bCtrlBackspaceDeletesLastWord = false;
436440

437441
// set up some default triggers for MUSHes
438442

scriptingoptions.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ tConfigurationNumericOption OptionsTable [] = {
7272
{"ctrl_n_goes_to_next_command", false, O(m_bCtrlNGoesToNextCommand)},
7373
{"ctrl_p_goes_to_previous_command", false, O(m_bCtrlPGoesToPreviousCommand)},
7474
{"ctrl_z_goes_to_end_of_buffer", false, O(m_bCtrlZGoesToEndOfBuffer)},
75+
{"ctrl_backspace_deletes_last_word", false, O(m_bCtrlBackspaceDeletesLastWord)},
7576
{"custom_16_is_default_colour", false, O(m_bCustom16isDefaultColour), 0, 0, OPT_UPDATE_VIEWS},
7677

7778
{"default_trigger_send_to", eSendToWorld, O(m_iDefaultTriggerSendTo), eSendToWorld, eSendToLast - 1},
@@ -112,9 +113,9 @@ tConfigurationNumericOption OptionsTable [] = {
112113
{"enable_triggers", true, O(m_enable_triggers)},
113114
{"enable_trigger_sounds", true, O(m_enable_trigger_sounds)},
114115
{"escape_deletes_input", false, O(m_bEscapeDeletesInput)},
115-
{"fade_output_buffer_after_seconds", 0, O(m_iFadeOutputBufferAfterSeconds), 5, 3600 }, // seconds to wait before fading
116-
{"fade_output_opacity_percent", 20, O(m_FadeOutputOpacityPercent), 0, 100 }, // percent to fade to
117-
{"fade_output_seconds", 8, O(m_FadeOutputSeconds), 1, 60 }, // how many seconds to take to fade
116+
{"fade_output_buffer_after_seconds", 0, O(m_iFadeOutputBufferAfterSeconds), 5, 3600, OPT_UPDATE_VIEWS }, // seconds to wait before fading
117+
{"fade_output_opacity_percent", 20, O(m_FadeOutputOpacityPercent), 0, 100, OPT_UPDATE_VIEWS }, // percent to fade to
118+
{"fade_output_seconds", 8, O(m_FadeOutputSeconds), 1, 60, OPT_UPDATE_VIEWS }, // how many seconds to take to fade
118119
{"flash_taskbar_icon", false, O(m_bFlashIcon)},
119120
{"history_lines", 1000, O(m_nHistoryLines), 20, 5000},
120121
{"hyperlink_adds_to_command_history", true, O(m_bHyperlinkAddsToCommandHistory)},

sendvw.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,6 +2442,49 @@ ASSERT_VALID(pDoc);
24422442

24432443
void CSendView::OnRepeatLastWord()
24442444
{
2445+
CMUSHclientDoc* pDoc = GetDocument();
2446+
ASSERT_VALID(pDoc);
2447+
2448+
// if wanted, delete the last word in the command window
2449+
if (pDoc->m_bCtrlBackspaceDeletesLastWord)
2450+
{
2451+
int nStartChar;
2452+
int nEndChar;
2453+
2454+
GetEditCtrl().GetSel(nStartChar, nEndChar);
2455+
2456+
// if something selected, just delete it
2457+
2458+
if (nStartChar != nEndChar)
2459+
{
2460+
GetEditCtrl().ReplaceSel ("", TRUE);
2461+
return;
2462+
}
2463+
2464+
// get current text
2465+
2466+
CString strCurrent;
2467+
GetEditCtrl().GetWindowText (strCurrent);
2468+
2469+
// don't bother if nothing typed
2470+
2471+
if (strCurrent.IsEmpty ())
2472+
return;
2473+
2474+
CString strLast = strCurrent.Mid (nStartChar); // after the selection
2475+
CString strFirst = strCurrent.Left (nStartChar); // up to the selection
2476+
strFirst.TrimRight (); // skip trailing spaces
2477+
int iPos = strFirst.ReverseFind (' ');
2478+
strFirst = strFirst.Left (iPos + 1); // up to and including the space
2479+
strFirst += strLast; // put last bit back
2480+
GetEditCtrl().SetSel (0, -1); // select all
2481+
GetEditCtrl().ReplaceSel (strFirst, TRUE);
2482+
2483+
return;
2484+
}
2485+
2486+
// otherwise, recall the last word from the previously-sent line
2487+
24452488
// can't, if no previous command
24462489
if (m_msgList.IsEmpty ())
24472490
return;

0 commit comments

Comments
 (0)