Skip to content

Commit 5bb6c97

Browse files
committed
Added script function SetScroll
1 parent fdf2772 commit 5bb6c97

File tree

9 files changed

+94
-14
lines changed

9 files changed

+94
-14
lines changed

doc.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@ BEGIN_DISPATCH_MAP(CMUSHclientDoc, CDocument)
605605
DISP_FUNCTION(CMUSHclientDoc, "WindowResize", WindowResize, VT_I4, VTS_BSTR VTS_I4 VTS_I4 VTS_I4)
606606
DISP_FUNCTION(CMUSHclientDoc, "WindowMoveHotspot", WindowMoveHotspot, VT_I4, VTS_BSTR VTS_BSTR VTS_I4 VTS_I4 VTS_I4 VTS_I4)
607607
DISP_FUNCTION(CMUSHclientDoc, "WindowTransformImage", WindowTransformImage, VT_I4, VTS_BSTR VTS_BSTR VTS_R4 VTS_R4 VTS_I2 VTS_R4 VTS_R4 VTS_R4 VTS_R4)
608+
DISP_FUNCTION(CMUSHclientDoc, "SetScroll", SetScroll, VT_I4, VTS_I4 VTS_BOOL)
608609
DISP_PROPERTY_PARAM(CMUSHclientDoc, "NormalColour", GetNormalColour, SetNormalColour, VT_I4, VTS_I2)
609610
DISP_PROPERTY_PARAM(CMUSHclientDoc, "BoldColour", GetBoldColour, SetBoldColour, VT_I4, VTS_I2)
610611
DISP_PROPERTY_PARAM(CMUSHclientDoc, "CustomColourText", GetCustomColourText, SetCustomColourText, VT_I4, VTS_I2)

doc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,7 @@ class CMUSHclientDoc : public CDocument
12881288
map<COLORREF, COLORREF> m_ColourTranslationMap;
12891289

12901290
list<CPaneStyle> m_OutstandingLines;
1291+
BOOL m_bScrollBarWanted; // true if we want to see scroll bars
12911292

12921293
long m_nCount_IAC_DO; // count of IAC DO we got
12931294
long m_nCount_IAC_DONT; // count of IAC DONT we got
@@ -2672,6 +2673,7 @@ class CMUSHclientDoc : public CDocument
26722673
afx_msg long WindowResize(LPCTSTR Name, long Width, long Height, long BackgroundColour);
26732674
afx_msg long WindowMoveHotspot(LPCTSTR Name, LPCTSTR HotspotId, long Left, long Top, long Right, long Bottom);
26742675
afx_msg long WindowTransformImage(LPCTSTR Name, LPCTSTR ImageId, float Left, float Top, short Mode, float Mxx, float Mxy, float Myx, float Myy);
2676+
afx_msg long SetScroll(long Position, BOOL Visible);
26752677
afx_msg long GetNormalColour(short WhichColour);
26762678
afx_msg void SetNormalColour(short WhichColour, long nNewValue);
26772679
afx_msg long GetBoldColour(short WhichColour);

doc_construct.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ int i;
122122
m_strSpamMessage = "look";
123123
m_iSpamLineCount = 20;
124124
m_iLastOutgoingChatPort = DEFAULT_CHAT_PORT;
125+
m_bScrollBarWanted = TRUE;
125126

126127
m_iSocksProcessing = 0; // no socks processing wanted
127128
m_iProxyServerPort = 1080; // default socks port

mushclient.cnt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@
488488
3 SetOption=FNC_SetOption
489489
3 SetOutputFont=FNC_SetOutputFont
490490
3 SetStatus=FNC_SetStatus
491+
3 SetScroll=FNC_SetScroll
491492
3 SetTimerOption=FNC_SetTimerOption
492493
3 SetToolBarPosition=FNC_SetToolBarPosition
493494
3 SetTriggerOption=FNC_SetTriggerOption

mushclient.odl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ library MUSHclient
7070
[id(44)] long SetCommand(BSTR Message);
7171
[id(45)] BSTR GetNotes();
7272
[id(46)] void SetNotes(BSTR Message);
73-
[id(403), propget] long NormalColour(short WhichColour);
74-
[id(403), propput] void NormalColour(short WhichColour, long nNewValue);
75-
[id(404), propget] long BoldColour(short WhichColour);
76-
[id(404), propput] void BoldColour(short WhichColour, long nNewValue);
77-
[id(405), propget] long CustomColourText(short WhichColour);
78-
[id(405), propput] void CustomColourText(short WhichColour, long nNewValue);
79-
[id(406), propget] long CustomColourBackground(short WhichColour);
80-
[id(406), propput] void CustomColourBackground(short WhichColour, long nNewValue);
73+
[id(404), propget] long NormalColour(short WhichColour);
74+
[id(404), propput] void NormalColour(short WhichColour, long nNewValue);
75+
[id(405), propget] long BoldColour(short WhichColour);
76+
[id(405), propput] void BoldColour(short WhichColour, long nNewValue);
77+
[id(406), propget] long CustomColourText(short WhichColour);
78+
[id(406), propput] void CustomColourText(short WhichColour, long nNewValue);
79+
[id(407), propget] long CustomColourBackground(short WhichColour);
80+
[id(407), propput] void CustomColourBackground(short WhichColour, long nNewValue);
8181
[id(47)] void Redraw();
8282
[id(48)] long ResetTimer(BSTR TimerName);
8383
[id(49)] void SetOutputFont(BSTR FontName, short PointSize);
@@ -434,6 +434,7 @@ library MUSHclient
434434
[id(400)] long WindowResize(BSTR Name, long Width, long Height, long BackgroundColour);
435435
[id(401)] long WindowMoveHotspot(BSTR Name, BSTR HotspotId, long Left, long Top, long Right, long Bottom);
436436
[id(402)] long WindowTransformImage(BSTR Name, BSTR ImageId, float Left, float Top, short Mode, float Mxx, float Mxy, float Myx, float Myy);
437+
[id(403)] long SetScroll(long Position, BOOL Visible);
437438
//}}AFX_ODL_METHOD
438439

439440
};

mushview.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3053,6 +3053,8 @@ if (wp.showCmd != SW_MINIMIZE &&
30533053

30543054
} // end of auto-wrap wanted
30553055
pDoc->SendWindowSizes (pDoc->m_nWrapColumn);
3056+
EnableScrollBarCtrl (SB_VERT, pDoc->m_bScrollBarWanted);
3057+
30563058
}
30573059

30583060
void CMUSHView::OnDisplayFreezeoutput()
@@ -4401,7 +4403,7 @@ int iDeltaY = m_scroll_position.y - pt.y;
44014403
// update scroll bar
44024404
GetScrollInfo (SB_VERT, &ScrollInfo, SIF_POS);
44034405
ScrollInfo.nPos = m_scroll_position.y;
4404-
SetScrollInfo (SB_VERT, &ScrollInfo, SIF_POS);
4406+
SetScrollInfo (SB_VERT, &ScrollInfo, pDoc->m_bScrollBarWanted);
44054407
ScrollWindow (0, iSmoothDelta);
44064408
UpdateWindow ();
44074409
}
@@ -4436,11 +4438,11 @@ int iDeltaY = m_scroll_position.y - pt.y;
44364438
// update scroll bar
44374439
GetScrollInfo (SB_VERT, &ScrollInfo, SIF_POS);
44384440
ScrollInfo.nPos = pt.y;
4439-
SetScrollInfo (SB_VERT, &ScrollInfo, SIF_POS);
4441+
SetScrollInfo (SB_VERT, &ScrollInfo, pDoc->m_bScrollBarWanted);
44404442

44414443
// GetScrollInfo (SB_HORZ, &ScrollInfo, SIF_POS);
44424444
// ScrollInfo.nPos = pt.x;
4443-
// SetScrollInfo (SB_HORZ, &ScrollInfo, SIF_POS);
4445+
// SetScrollInfo (SB_HORZ, &ScrollInfo, pDoc->m_bScrollBarWanted);
44444446

44454447
if (pDoc->m_bAutoFreeze)
44464448
m_freeze = GetScrollPos (SB_VERT) < GetScrollLimit(SB_VERT);
@@ -4451,22 +4453,24 @@ void CMUSHView::SetScrollSizes (SIZE sizeTotal,
44514453
const SIZE& sizePage,
44524454
const SIZE& sizeLine)
44534455
{
4454-
SCROLLINFO ScrollInfo;
4456+
CMUSHclientDoc* pDoc = GetDocument();
4457+
ASSERT_VALID(pDoc);
4458+
SCROLLINFO ScrollInfo;
44554459

44564460
m_scroll_limit = sizeTotal;
44574461

44584462
GetScrollInfo (SB_VERT, &ScrollInfo, SIF_ALL);
44594463
ScrollInfo.nMin = 0;
44604464
ScrollInfo.nMax = sizeTotal.cy - 1;
44614465
ScrollInfo.nPage = sizePage.cy;
4462-
SetScrollInfo (SB_VERT, &ScrollInfo, SIF_ALL);
4466+
SetScrollInfo (SB_VERT, &ScrollInfo, pDoc->m_bScrollBarWanted);
44634467

44644468
/*
44654469
GetScrollInfo (SB_HORZ, &ScrollInfo, SIF_ALL);
44664470
ScrollInfo.nMin = 0;
44674471
ScrollInfo.nMax = sizeTotal.cx - 1;
44684472
ScrollInfo.nPage = sizePage.cx;
4469-
SetScrollInfo (SB_HORZ, &ScrollInfo, SIF_ALL);
4473+
SetScrollInfo (SB_HORZ, &ScrollInfo, pDoc->m_bScrollBarWanted);
44704474
*/
44714475

44724476
} // end of CMUSHView::SetScrollSizes

scripting/functionlist.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ tInternalFunctionsTable InternalFunctionsTable [] = {
346346
{ "SetNotes" , "( Message )" } ,
347347
{ "SetOption" , "( OptionName , Value )" } ,
348348
{ "SetOutputFont" , "( FontName , PointSize )" } ,
349+
{ "SetScroll", "( Position , Visible )" },
349350
{ "SetStatus" , "( Message )" } ,
350351
{ "SetTimerOption" , "( TimerName , OptionName , Value )" } ,
351352
{ "SetToolBarPosition" , "( Which , Float , Side , Top , Left )" } ,

scripting/lua_methods.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5195,6 +5195,18 @@ static int L_SetOutputFont (lua_State *L)
51955195
return 0; // number of result fields
51965196
} // end of L_SetOutputFont
51975197

5198+
//----------------------------------------
5199+
// world.SetScroll
5200+
//----------------------------------------
5201+
static int L_SetScroll (lua_State *L)
5202+
{
5203+
CMUSHclientDoc *pDoc = doc (L);
5204+
lua_pushnumber (L, pDoc->SetScroll (
5205+
my_checknumber (L, 1), // position
5206+
optboolean (L, 2, 1) // enabled flag, defaults to true
5207+
));
5208+
return 1; // number of result fields
5209+
} // end of L_SetScroll
51985210

51995211
//----------------------------------------
52005212
// world.SetStatus
@@ -6738,6 +6750,7 @@ static const struct luaL_reg worldlib [] =
67386750
{"SetNotes", L_SetNotes},
67396751
{"SetOption", L_SetOption},
67406752
{"SetOutputFont", L_SetOutputFont},
6753+
{"SetScroll", L_SetScroll},
67416754
{"SetStatus", L_SetStatus},
67426755
{"SetTimerOption", L_SetTimerOption},
67436756
{"SetToolBarPosition", L_SetToolBarPosition},

scripting/methods.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4203,6 +4203,7 @@ tInfoTypeMapping InfoTypes [] =
42034203
{ 115, "Localization active" },
42044204
{ 118, "Variables have changed" },
42054205
{ 119, "Script engine active" },
4206+
{ 120, "Scroll bar visible" },
42064207

42074208

42084209
// (numbers (longs) - calculated at runtime)
@@ -4302,6 +4303,7 @@ tInfoTypeMapping InfoTypes [] =
43024303
{ 293, "Actual text rectangle - bottom" },
43034304
{ 294, "State of keyboard modifiers" },
43044305
{ 295, "Times output window redrawn" },
4306+
{ 296, "Output window scroll bar position" },
43054307

43064308

43074309
// (dates - calculated at runtime)
@@ -4553,6 +4555,7 @@ VARIANT CMUSHclientDoc::GetInfo(long InfoType)
45534555
case 115: SetUpVariantBool (vaResult, App.m_Translator_Lua != NULL); break;
45544556
case 118: SetUpVariantBool (vaResult, m_bVariablesChanged); break;
45554557
case 119: SetUpVariantBool (vaResult, m_ScriptEngine != NULL); break;
4558+
case 120: SetUpVariantBool (vaResult, m_bScrollBarWanted); break;
45564559

45574560

45584561
case 201: SetUpVariantLong (vaResult, m_total_lines); break;
@@ -5023,6 +5026,18 @@ VARIANT CMUSHclientDoc::GetInfo(long InfoType)
50235026
SetUpVariantLong (vaResult, m_iOutputWindowRedrawCount);
50245027
break; // state of virtual keys
50255028

5029+
case 296:
5030+
{
5031+
CMUSHView* pmyView = GetFirstOutputWindow ();
5032+
if (pmyView)
5033+
{
5034+
CPoint pt = pmyView->GetScrollPosition ();
5035+
SetUpVariantLong (vaResult, pt.y);
5036+
break;
5037+
}
5038+
}
5039+
break;
5040+
50265041
case 301:
50275042
if (m_tConnectTime.GetTime ()) // only if non-zero, otherwise return empty
50285043
SetUpVariantDate (vaResult, COleDateTime (m_tConnectTime.GetTime ()));
@@ -14903,6 +14918,47 @@ long CMUSHclientDoc::WindowTransformImage(LPCTSTR Name, LPCTSTR ImageId, float L
1490314918

1490414919

1490514920

14921+
long CMUSHclientDoc::SetScroll(long Position, BOOL Visible)
14922+
{
14923+
14924+
CPoint pt (0, 0);
14925+
int lastline = GetLastLine ();
14926+
m_bScrollBarWanted = Visible;
14927+
14928+
for(POSITION pos = GetFirstViewPosition(); pos != NULL; )
14929+
{
14930+
CView* pView = GetNextView(pos);
14931+
14932+
if (pView->IsKindOf(RUNTIME_CLASS(CMUSHView)))
14933+
{
14934+
CMUSHView* pmyView = (CMUSHView*)pView;
14935+
14936+
int highest = (lastline * m_FontHeight) - pmyView->GetOutputWindowHeight ();
14937+
14938+
// -1 goes to the end
14939+
if (Position == -1)
14940+
pt.y = highest;
14941+
else
14942+
pt.y = Position;
14943+
14944+
if (pt.y < 0)
14945+
pt.y = 0;
14946+
if (pt.y > highest)
14947+
pt.y = highest;
14948+
14949+
pmyView->EnableScrollBarCtrl (SB_VERT, Visible);
14950+
if (Position != -2) // if -2, do not change position
14951+
pmyView->ScrollToPosition (pt, false);
14952+
pmyView->Invalidate ();
14953+
14954+
} // end of being a CMUSHView
14955+
} // end of loop through views
14956+
14957+
14958+
return eOK;
14959+
}
14960+
14961+
1490614962
/*
1490714963
1490814964
======================================================================

0 commit comments

Comments
 (0)