Skip to content

Commit b57100e

Browse files
committed
Added option 'wrap_input' to wrap command window at output wrap column
1 parent e093abc commit b57100e

File tree

8 files changed

+91
-2
lines changed

8 files changed

+91
-2
lines changed

dialogs/world_prefs/configuration.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,6 +1616,8 @@ void CMUSHclientDoc:: SavePrefsP14 (CPrefsP14 &page14)
16161616

16171617
m_nWrapColumn = page14.m_nWrapColumn;
16181618

1619+
FixInputWrap();
1620+
16191621
} // end of CMUSHclientDoc::SavePrefsP14
16201622

16211623
void CMUSHclientDoc:: SavePrefsP15 (CPrefsP15 &page15)

doc.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7823,3 +7823,19 @@ void CMUSHclientDoc::SortWindows (void)
78237823

78247824
} // end of CMUSHclientDoc::SortWindows
78257825

7826+
7827+
void CMUSHclientDoc::FixInputWrap()
7828+
{
7829+
for(POSITION pos=GetFirstViewPosition();pos!=NULL;)
7830+
{
7831+
CView* pView = GetNextView(pos);
7832+
7833+
if (pView->IsKindOf(RUNTIME_CLASS(CSendView)))
7834+
{
7835+
CSendView* pmyView = (CSendView*)pView;
7836+
pmyView->UpdateWrap();
7837+
} // end of if CSendView
7838+
} // end of for each view
7839+
} // end of CMUSHclientDoc::FixInputWrap()
7840+
7841+

doc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ enum {
377377
#define OPT_PLUGIN_CANNOT_RW 0x300000 // plugin may not read or write its value
378378
#define OPT_CANNOT_WRITE 0x400000 // cannot be changed by any script
379379
#define OPT_SERVER_CAN_WRITE 0x800000 // CAN be changed by <recommend_option> tag
380+
#define OPT_FIX_INPUT_WRAP 0x1000000 // Added for input wrapping.
380381

381382
// for debug.options and MXP <option> tag
382383
typedef struct
@@ -880,6 +881,9 @@ class CMUSHclientDoc : public CDocument
880881
unsigned short m_bTreeviewAliases; // show aliases in tree view?
881882
unsigned short m_bTreeviewTimers; // show timers in tree view?
882883

884+
// version 4.81
885+
unsigned short m_bAutoWrapInput; // Match input wrap to output?
886+
883887
// end of stuff saved to disk **************************************************************
884888

885889
// stuff from pre version 11, read from disk but not saved
@@ -1423,6 +1427,7 @@ class CMUSHclientDoc : public CDocument
14231427
CArgumentList & ArgumentList);
14241428

14251429
void AddToCommandHistory (LPCTSTR Message);
1430+
void FixInputWrap();
14261431

14271432
// simple test to see if we are in secure mode right now
14281433
inline bool MXP_Secure (void)

mushview.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ CMUSHView::CMUSHView()
282282
m_nLastToolTipColumn = 0;
283283
m_scroll_position = 0;
284284
m_mousedover = false;
285+
m_bottomview = NULL;
285286

286287
m_iPauseStatus = ePauseUninitialised;
287288

@@ -3213,6 +3214,10 @@ if (wp.showCmd != SW_MINIMIZE &&
32133214
pDoc->SendWindowSizes (pDoc->m_nWrapColumn);
32143215
EnableScrollBarCtrl (SB_VERT, pDoc->m_bScrollBarWanted);
32153216

3217+
// update wrap size
3218+
if (m_bottomview)
3219+
m_bottomview->UpdateWrap();
3220+
32163221
}
32173222

32183223
void CMUSHView::OnDisplayFreezeoutput()

plugins/Config_Option_Changer.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ boolean_options = {
6868
do_not_translate_iac_to_iac_iac = { desc = 'Translate IAC to IAC IAC?' , invert = true },
6969
play_sounds_in_background = { desc = 'Play sounds in background?' },
7070
send_keep_alives = { desc = 'Send keep-alives?' },
71+
wrap_input = { desc = 'Wrap command window at output wrap column' },
7172
} -- end boolean_options
7273
7374
-- numeric options they can change

scriptingoptions.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ tConfigurationNumericOption OptionsTable [] = {
152152
{"paste_delay_per_lines", 1, O(m_nPasteDelayPerLines), 1, 100000},
153153
{"paste_echo", false, O(m_bPasteEcho)},
154154
{"play_sounds_in_background", false, O(m_bPlaySoundsInBackground)},
155-
{"pixel_offset", 1, O(m_iPixelOffset), 0, 20, OPT_UPDATE_VIEWS},
155+
{"pixel_offset", 1, O(m_iPixelOffset), 0, 20, OPT_UPDATE_VIEWS | OPT_FIX_INPUT_WRAP},
156156
{"port", 4000, O(m_port), 1, USHRT_MAX, OPT_PLUGIN_CANNOT_WRITE},
157157
{"proxy_port", 1080, O(m_iProxyServerPort), 0, USHRT_MAX, OPT_PLUGIN_CANNOT_WRITE},
158158
{"proxy_type", eProxyServerNone, O(m_iSocksProcessing), eProxyServerNone, eProxyServerLast - 1, OPT_PLUGIN_CANNOT_WRITE},
@@ -206,7 +206,9 @@ tConfigurationNumericOption OptionsTable [] = {
206206
{"validate_incoming_chat_calls", false, O(m_bValidateIncomingCalls)},
207207
{"warn_if_scripting_inactive", true, O(m_bWarnIfScriptingInactive)},
208208
{"wrap", true, O(m_wrap)},
209-
{"wrap_column", 80, O(m_nWrapColumn), 20, MAX_LINE_WIDTH, OPT_FIX_WRAP_COLUMN},
209+
{"wrap_input", false, O(m_bAutoWrapInput), 0, 0, OPT_FIX_INPUT_WRAP}, // Added this, also fix wrap on column change.
210+
{"wrap_column", 80, O(m_nWrapColumn), 20, MAX_LINE_WIDTH, OPT_FIX_WRAP_COLUMN | OPT_FIX_INPUT_WRAP},
211+
210212
{"write_world_name_to_log", true, O(m_bWriteWorldNameToLog)},
211213

212214
{NULL} // end of table marker
@@ -517,6 +519,9 @@ long iResult = SetBaseOptionItem (iItem,
517519
if (m_pCurrentLine) // a new world might not have a line yet
518520
FixUpOutputBuffer (Value);
519521

522+
if (OptionsTable [iItem].iFlags & OPT_FIX_INPUT_WRAP)
523+
FixInputWrap();
524+
520525
if (OptionsTable [iItem].iFlags & OPT_FIX_WRAP_COLUMN)
521526
{
522527
if (m_pCurrentLine) // a new world might not have a line yet

sendvw.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,7 @@ void CSendView::OnChange()
11741174

11751175
NotifyPluginCommandChanged ();
11761176

1177+
UpdateWrap();
11771178
} // end of CSendView::OnChange
11781179

11791180

@@ -1221,6 +1222,9 @@ void CSendView::OnInitialUpdate()
12211222

12221223
// if they want auto-command size, put back to 1
12231224
AdjustCommandWindowSize ();
1225+
1226+
UpdateWrap();
1227+
12241228
} // end of CSendView::OnInitialUpdate
12251229

12261230
void CSendView::OnContextMenu(CWnd*, CPoint point)
@@ -2961,3 +2965,53 @@ void CSendView::OnEditCopyashtml()
29612965
m_topview->OnEditCopyashtml ();
29622966
} // end of CSendView::OnEditCopyashtml()
29632967

2968+
2969+
void CSendView::UpdateWrap()
2970+
{
2971+
2972+
CMUSHclientDoc* pDoc = GetDocument();
2973+
CEdit& theEdit = GetEditCtrl();
2974+
2975+
int iOffset = pDoc->m_iPixelOffset; // Need this either way.
2976+
2977+
if (pDoc->m_bAutoWrapInput)
2978+
{
2979+
2980+
CRect r;
2981+
GetClientRect(r); // How big is the input window?
2982+
2983+
int iWidth = pDoc->m_nWrapColumn + 1; // Letter-width of the line.
2984+
2985+
if (iWidth < 20)
2986+
iWidth = 20;
2987+
if (iWidth > MAX_LINE_WIDTH)
2988+
iWidth = MAX_LINE_WIDTH; // Uses the minimums and maximums from elsewhere.
2989+
2990+
// Subtracts the pixel width of text and the left-side offset to determine what the right side should be.
2991+
int rMargin = r.Width() - (iWidth * pDoc->m_InputFontWidth) - iOffset;
2992+
2993+
// If the right side isn't at least as big as the offset, use the offset.
2994+
if (rMargin < iOffset)
2995+
rMargin = iOffset;
2996+
2997+
// If the margin needs to change, change it.
2998+
if (rMargin != HIWORD(theEdit.GetMargins()))
2999+
{
3000+
theEdit.SetMargins (iOffset, rMargin);
3001+
theEdit.Invalidate (FALSE);
3002+
} // end if changed
3003+
3004+
} // end if m_bAutoWrapInput
3005+
else
3006+
{
3007+
iOffset = 0; // prefer this, Neva
3008+
// not wrapping
3009+
if ( HIWORD(theEdit.GetMargins ()) != iOffset) // If the option is off, just using the offset.
3010+
{
3011+
theEdit.SetMargins (iOffset, iOffset);
3012+
theEdit.Invalidate (FALSE);
3013+
} // end if changed
3014+
} // end if
3015+
3016+
} // end of CSendView::UpdateWrap()
3017+

sendvw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class CSendView : public CEditView
8080
void AdjustCommandWindowSize (void);
8181
void CheckForSelectionChange (void);
8282
void CancelSelection (void);
83+
void UpdateWrap();
8384

8485
// Overrides
8586
// ClassWizard generated virtual function overrides

0 commit comments

Comments
 (0)