From c91b5fbbb84ed44d193a4ad7dcb7a6c268aae004 Mon Sep 17 00:00:00 2001 From: Andrew Ferguson Date: Thu, 16 Aug 2018 12:57:37 +0100 Subject: [PATCH 1/9] [[Bugfix-14721]] Added go visible form of go command The go command has been updated to include the go visible form which automatically sets the visible property of the stack to true when it is opened. This is particularly useful for script-only stacks that display any kind of interface (ie: that have visible controls), as they currently need to manually include a line in the openStack or preOpenStack handler to set the visible property to true. --- engine/src/cmds.h | 1 + engine/src/cmdss.cpp | 12 +++++++++--- engine/src/exec-interface.cpp | 16 ++++++++-------- engine/src/exec.h | 4 ++-- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/engine/src/cmds.h b/engine/src/cmds.h index 52b304b6c1b..fb9837a15b2 100644 --- a/engine/src/cmds.h +++ b/engine/src/cmds.h @@ -1738,6 +1738,7 @@ class MCGo : public MCStatement Window_mode mode; Boolean marked; Boolean visible; + Boolean explicit_visibility = False; Boolean thisstack; MCChunk *widget; diff --git a/engine/src/cmdss.cpp b/engine/src/cmdss.cpp index 88396ccb7eb..491016289e7 100644 --- a/engine/src/cmdss.cpp +++ b/engine/src/cmdss.cpp @@ -111,8 +111,14 @@ Parse_stat MCGo::parse(MCScriptPoint &sp) Chunk_term lterm = CT_UNDEFINED; initpoint(sp); - if (sp.skip_token(SP_FACTOR, TT_PROPERTY, P_INVISIBLE) == PS_NORMAL) + if (sp.skip_token(SP_FACTOR, TT_PROPERTY, P_INVISIBLE) == PS_NORMAL) { visible = False; + explicit_visibility = True; + } + if (sp.skip_token(SP_FACTOR, TT_PROPERTY, P_VISIBLE) == PS_NORMAL) { + visible = True; + explicit_visibility = True; + } while (True) { if (sp.next(type) != PS_NORMAL) @@ -744,9 +750,9 @@ void MCGo::exec_ctxt(MCExecContext &ctxt) } } else if (window != nil) - MCInterfaceExecGoCardInWindow(ctxt, cptr, *t_window, visible == True, thisstack == True); + MCInterfaceExecGoCardInWindow(ctxt, cptr, *t_window, visible == True, explicit_visibility == True, thisstack == True); else - MCInterfaceExecGoCardAsMode(ctxt, cptr, mode, visible == True, thisstack == True); + MCInterfaceExecGoCardAsMode(ctxt, cptr, mode, visible == True, explicit_visibility == True, thisstack == True); } MCHide::~MCHide() diff --git a/engine/src/exec-interface.cpp b/engine/src/exec-interface.cpp index f0f165d973b..a5d792b276b 100644 --- a/engine/src/exec-interface.cpp +++ b/engine/src/exec-interface.cpp @@ -4329,7 +4329,7 @@ void MCInterfaceExecChooseTool(MCExecContext& ctxt, MCStringRef p_input, int p_t //////////////////////////////////////////////////////////////////////////////// -void MCInterfaceExecGo(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window, int p_mode, bool p_this_stack, bool p_visible) +void MCInterfaceExecGo(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window, int p_mode, bool p_this_stack, bool p_visible, bool p_explicit_visibility) { if (p_card == nil) { @@ -4452,11 +4452,11 @@ void MCInterfaceExecGo(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window MCtrace = False; // MW-2007-02-11: [[ Bug 4029 ]] - 'go invisible' fails to close stack window if window already open - if (!p_visible && t_stack -> getflag(F_VISIBLE)) + if (p_explicit_visibility) { if (t_stack -> getwindow() != NULL) MCscreen -> closewindow(t_stack -> getwindow()); - t_stack->setflag(False, F_VISIBLE); + t_stack->setflag(p_visible, F_VISIBLE); } // MW-2011-02-27: [[ Bug ]] Make sure that if we open as a sheet, we have a parent pointer! @@ -4539,14 +4539,14 @@ void MCInterfaceExecGo(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window ctxt . Throw(); } -void MCInterfaceExecGoCardAsMode(MCExecContext& ctxt, MCCard *p_card, int p_mode, bool p_visible, bool p_this_stack) +void MCInterfaceExecGoCardAsMode(MCExecContext& ctxt, MCCard *p_card, int p_mode, bool p_visible, bool p_explicit_visibility, bool p_this_stack) { - MCInterfaceExecGo(ctxt, p_card, nil, p_mode, p_this_stack, p_visible); + MCInterfaceExecGo(ctxt, p_card, nil, p_mode, p_this_stack, p_visible, p_explicit_visibility); } -void MCInterfaceExecGoCardInWindow(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window, bool p_visible, bool p_this_stack) +void MCInterfaceExecGoCardInWindow(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window, bool p_visible, bool p_explicit_visibility, bool p_this_stack) { - MCInterfaceExecGo(ctxt, p_card, p_window, WM_MODELESS, p_this_stack, p_visible); + MCInterfaceExecGo(ctxt, p_card, p_window, WM_MODELESS, p_this_stack, p_visible, p_explicit_visibility); } void MCInterfaceExecGoRecentCard(MCExecContext& ctxt) @@ -4572,7 +4572,7 @@ void MCInterfaceExecGoHome(MCExecContext& ctxt, MCCard *p_card) MCdefaultstackptr->close(); MCdefaultstackptr->checkdestroy(); } - MCInterfaceExecGo(ctxt, p_card, nil, 0, false, true); + MCInterfaceExecGo(ctxt, p_card, nil, 0, false, true, false); } //////////////////////////////////////////////////////////////////////////////// diff --git a/engine/src/exec.h b/engine/src/exec.h index 81f22a8fe02..041fd9104a4 100644 --- a/engine/src/exec.h +++ b/engine/src/exec.h @@ -2449,8 +2449,8 @@ void MCInterfaceExecReplaceInField(MCExecContext& ctxt, MCStringRef p_pattern, M void MCInterfaceExecChooseTool(MCExecContext& ctxt, MCStringRef p_input, int p_tool); -void MCInterfaceExecGoCardAsMode(MCExecContext& ctxt, MCCard *p_card, int p_mode, bool p_visible, bool p_this_stack); -void MCInterfaceExecGoCardInWindow(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window, bool p_visible, bool p_this_stack); +void MCInterfaceExecGoCardAsMode(MCExecContext& ctxt, MCCard *p_card, int p_mode, bool p_visible, bool p_explicit_visibility, bool p_this_stack); +void MCInterfaceExecGoCardInWindow(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window, bool p_visible, bool p_explicit_visibility, bool p_this_stack); void MCInterfaceExecGoRecentCard(MCExecContext& ctxt); void MCInterfaceExecGoCardRelative(MCExecContext& ctxt, bool p_forward, real8 p_amount); void MCInterfaceExecGoCardEnd(MCExecContext& ctxt, bool p_is_start); From e04b8b956dd6afd9a8ffecf43980f4d72e334a49 Mon Sep 17 00:00:00 2001 From: Andrew Ferguson Date: Thu, 16 Aug 2018 13:03:19 +0100 Subject: [PATCH 2/9] [[Bugfix-14721]] Add parser and script tests for go visible A new parser test file has been created for the go command, as it did not have one before. Three new tests have been added, to test the basic syntax of go stack "stack", go visible stack "stack" and go invisible stack "stack". This test file is far from complete - there are many other forms of the go command that have not been tested, however I have added in only the three most relevent to the go visible command. Any others can be added separately in a different branch. Several new tests for the go command have been added to the core interface test file. These tests check that the stack actually opens when using the visible and invisible forms and that the visibility of the stack is correctly set. --- tests/lcs/core/interface/go.livecodescript | 81 +++++++++++++++++++++- tests/lcs/parser/go.parsertest | 39 +++++++++++ 2 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 tests/lcs/parser/go.parsertest diff --git a/tests/lcs/core/interface/go.livecodescript b/tests/lcs/core/interface/go.livecodescript index 009593777db..d886fdbd5bc 100644 --- a/tests/lcs/core/interface/go.livecodescript +++ b/tests/lcs/core/interface/go.livecodescript @@ -55,14 +55,19 @@ on TestGoCardUnquotedName end TestGoCardUnquotedName local sStackFileName -command _TestCreateStack pBinary +command _TestCreateStack pBinary pVisible local tStack put "stackToGo" into tStack if pBinary then create stack tStack + set the visible of stack tStack to pVisible else create script only stack tStack + if pVisible then + put "on preOpenStack" & return & "set the visible of me to" && pVisible & return & "end preOpenStack" into tScript + set the script of stack tStack to tScript + end if end if put the tempname into sStackFileName @@ -78,7 +83,7 @@ end _TestCleanupStack command _TestGoStackUrl pWhich TestSkipIfNot "write" local tStack - _TestCreateStack pWhich is "binary" + _TestCreateStack pWhich is "binary", true put it into tStack go url ("file:" & sStackFileName) TestDiagnostic the result @@ -117,3 +122,75 @@ on TestGoToCard TestAssert "openCard sent to opened card", the cOpened of card 1 TestAssert "closeCard sent to closed card", the cClosed of card 2 end TestGoToCard + +on _TestGoInvisibleVisibleStack pMode pWhich pVisible + TestSkipIfNot "write" + local tStack + _TestCreateStack pWhich is "binary", pVisible is "visible" + put it into tStack + do "go" && pMode && "stack sStackFilename" + TestDiagnostic the result + if pMode is empty then + put pVisible into pExpectedVisibility + else if pMode is "invisible" and pWhich is "script only" and pVisible is "visible" then + --a special case: + --a visible script only stack will be visible even if go invisible + --is used because the stack becomes visible by a "set the visible..." + --line in preOpenStack or openStack. So the setting of the visibility + --by the engine will be overridden when the stack is opened + put "visible" into pExpectedVisibility + else + put pMode into pExpectedVisibility + end if + TestAssert "go" && pMode && "on a" && pVisible && pWhich && "stack opened", there is a stack tStack + TestAssert "go" && pMode && "on a" && pVisible && pWhich && "stack is" && pExpectedVisibility, the visible of stack tStack is (pExpectedVisibility is "visible") + _TestCleanupStack +end _TestGoInvisibleVisibleStack + +on TestGoVisibleOnVisibleBinary + _TestGoInvisibleVisibleStack "visible", "binary", "visible" +end TestGoVisibleOnVisibleBinary + +on TestGoVisibleOnInvisibleBinary + _TestGoInvisibleVisibleStack "visible", "binary", "invisible" +end TestGoVisibleOnInvisibleBinary + +on TestGoVisibleOnVisibleScriptOnly + _TestGoInvisibleVisibleStack "visible", "script only", "visible" +end TestGoVisibleOnVisibleScriptOnly + +on TestGoVisibleOnInvisibleScriptOnly + _TestGoInvisibleVisibleStack "visible", "script only", "invisible" +end TestGoVisibleOnInvisibleScriptOnly + +on TestGoInvisibleOnVisibleBinary + _TestGoInvisibleVisibleStack "invisible", "binary", "visible" +end TestGoInvisibleOnVisibleBinary + +on TestGoInvisibleOnInvisibleBinary + _TestGoInvisibleVisibleStack "invisible", "binary", "invisible" +end TestGoInvisibleOnInvisibleBinary + +on TestGoInvisibleOnVisibleScriptOnly + _TestGoInvisibleVisibleStack "invisible", "script only", "visible" +end TestGoInvisibleOnVisibleScriptOnly + +on TestGoInvisibleOnInvisibleScriptOnly + _TestGoInvisibleVisibleStack "invisible", "script only", "invisible" +end TestGoInvisibleOnInvisibleScriptOnly + +on TestGoRegularOnVisibleBinary + _TestGoInvisibleVisibleStack "", "binary", "visible" +end TestGoRegularOnVisibleBinary + +on TestGoRegularOnInvisibleBinary + _TestGoInvisibleVisibleStack "", "binary", "invisible" +end TestGoRegularOnInvisibleBinary + +on TestGoRegularOnVisibleScriptOnly + _TestGoInvisibleVisibleStack "", "script only", "visible" +end TestGoRegularOnVisibleScriptOnly + +on TestGoRegularOnInvisibleScriptOnly + _TestGoInvisibleVisibleStack "", "script only", "invisible" +end TestGoRegularOnInvisibleScriptOnly diff --git a/tests/lcs/parser/go.parsertest b/tests/lcs/parser/go.parsertest new file mode 100644 index 00000000000..bc03de7ddc7 --- /dev/null +++ b/tests/lcs/parser/go.parsertest @@ -0,0 +1,39 @@ +%% Copyright (C) 2018 LiveCode Ltd. +%% +%% This file is part of LiveCode. +%% +%% LiveCode is free software; you can redistribute it and/or modify it under +%% the terms of the GNU General Public License v3 as published by the Free +%% Software Foundation. +%% +%% LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY +%% WARRANTY; without even the implied warranty of MERCHANTABILITY or +%% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +%% for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with LiveCode. If not see . + +%TEST GoRegularStack +on parse_test + go stack "sample" +end parse_test +%EXPECT PASS +%SUCCESS +%ENDTEST + +%TEST GoVisibleStack +on parse_test + go visible stack "sample" +end parse_test +%EXPECT PASS +%SUCCESS +%ENDTEST + +%TEST GoVisibleStack +on parse_test + go invisible stack "sample" +end parse_test +%EXPECT PASS +%SUCCESS +%ENDTEST From 2565ef3bf3ef73a0e25b5bc79357579ef34580b3 Mon Sep 17 00:00:00 2001 From: Andrew Ferguson Date: Thu, 16 Aug 2018 13:09:09 +0100 Subject: [PATCH 3/9] [[Bugfix-14721]] Updated dictionary for go visible The dictionary file for the go command has been updated to include the new go visible command. A note has also been added to point out the occasion where the go visible and go invisible commands will not work as expected (when the stack overrides the command by setting its visible property in its script as it opens). --- docs/dictionary/command/go.lcdoc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/dictionary/command/go.lcdoc b/docs/dictionary/command/go.lcdoc index d593c1aa2cc..ddb4bbf95dd 100644 --- a/docs/dictionary/command/go.lcdoc +++ b/docs/dictionary/command/go.lcdoc @@ -4,11 +4,11 @@ Synonyms: open Type: command -Syntax: go [invisible] [to] [of ] [{as |in [a] new window|in }] +Syntax: go [{visible | invisible}] [to] [of ] [{as |in [a] new window|in }] -Syntax: go [invisible] [to] {first | prev[ious]| next | last | any} [marked] [] +Syntax: go [{visible | invisible}] [to] {first | prev[ious]| next | last | any} [marked] [] -Syntax: go [invisible] [to] {recent | start | finish | home} +Syntax: go [{visible | invisible}] [to] {recent | start | finish | home} Syntax: go {forward | forth | back[ward]} [] @@ -36,6 +36,9 @@ go back 7 Example: go invisible stack "Preferences" +Example: +go visible stack "Script-only stack" + Example: local tStackFile, tStackFolder put the effective filename of me into tStackFile @@ -153,6 +156,11 @@ among the previously-visited cards: form moves forward in the recent cards list. "forward" and "forth" are synonyms. +If you use the visible form, the stack is made visible after being +opened. (When going to a stack, this form sets the stack's + to true.) Use this form of the command to display a +script-only stack without explicitly setting the +in the or handlers. If you use the invisible form, the window or card change does not show on the screen. (When going to a stack, this form sets the stack's @@ -160,6 +168,10 @@ show on the screen. (When going to a stack, this form sets the stack's a stack without displaying it on screen. To display the stack later, use the or set its to true. +Note that if a stack’s property is set in either the +or handlers, then this will override the expected behaviour +of the visible and invisible forms. + Any visual effects that have been queued with the visual effect command are displayed when the command is executed (unless the screen is locked). From f4cc1a08baa6c4294c8238c0e9e4e820de9e7144 Mon Sep 17 00:00:00 2001 From: Andrew Ferguson Date: Thu, 16 Aug 2018 16:43:51 +0100 Subject: [PATCH 4/9] [[Bugfix-14721]] Represent visibility type by enum The two boolean variables that represented the visibility of the stack, p_visible and p_explicitly_visible, have been replaced by a single enum p_visibility_type, of type MCGoStackVisibilityType, which has three options: kImplicit (if the regular go form is used, so the visible property of the stack remains unchanged), kExplicitVisible (if the go visible form is used, so the visibility of the stack should be set to true) and kExplicitInvisible (if the go invisible form is used, so the visibility of the stack should be set to false). The visible variable of the MCGo class (declared on line 1740 of cmds.h) has not been removed as it appears to be used by several other parts of the engine. --- engine/src/cmds.h | 2 +- engine/src/cmdss.cpp | 16 ++++++---------- engine/src/exec-interface.cpp | 21 +++++++++++++-------- engine/src/exec.h | 5 +++-- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/engine/src/cmds.h b/engine/src/cmds.h index fb9837a15b2..39b656fe065 100644 --- a/engine/src/cmds.h +++ b/engine/src/cmds.h @@ -1738,7 +1738,7 @@ class MCGo : public MCStatement Window_mode mode; Boolean marked; Boolean visible; - Boolean explicit_visibility = False; + MCGoStackVisibility visibilityType = kImplicit; Boolean thisstack; MCChunk *widget; diff --git a/engine/src/cmdss.cpp b/engine/src/cmdss.cpp index 491016289e7..616f98514d2 100644 --- a/engine/src/cmdss.cpp +++ b/engine/src/cmdss.cpp @@ -111,14 +111,10 @@ Parse_stat MCGo::parse(MCScriptPoint &sp) Chunk_term lterm = CT_UNDEFINED; initpoint(sp); - if (sp.skip_token(SP_FACTOR, TT_PROPERTY, P_INVISIBLE) == PS_NORMAL) { - visible = False; - explicit_visibility = True; - } - if (sp.skip_token(SP_FACTOR, TT_PROPERTY, P_VISIBLE) == PS_NORMAL) { - visible = True; - explicit_visibility = True; - } + if (sp.skip_token(SP_FACTOR, TT_PROPERTY, P_INVISIBLE) == PS_NORMAL) + visibilityType = kExplicitInvisible; + if (sp.skip_token(SP_FACTOR, TT_PROPERTY, P_VISIBLE) == PS_NORMAL) + visibilityType = kExplicitVisible; while (True) { if (sp.next(type) != PS_NORMAL) @@ -750,9 +746,9 @@ void MCGo::exec_ctxt(MCExecContext &ctxt) } } else if (window != nil) - MCInterfaceExecGoCardInWindow(ctxt, cptr, *t_window, visible == True, explicit_visibility == True, thisstack == True); + MCInterfaceExecGoCardInWindow(ctxt, cptr, *t_window, visibilityType, thisstack == True); else - MCInterfaceExecGoCardAsMode(ctxt, cptr, mode, visible == True, explicit_visibility == True, thisstack == True); + MCInterfaceExecGoCardAsMode(ctxt, cptr, mode, visibilityType, thisstack == True); } MCHide::~MCHide() diff --git a/engine/src/exec-interface.cpp b/engine/src/exec-interface.cpp index a5d792b276b..3bdad3be7b9 100644 --- a/engine/src/exec-interface.cpp +++ b/engine/src/exec-interface.cpp @@ -4329,8 +4329,9 @@ void MCInterfaceExecChooseTool(MCExecContext& ctxt, MCStringRef p_input, int p_t //////////////////////////////////////////////////////////////////////////////// -void MCInterfaceExecGo(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window, int p_mode, bool p_this_stack, bool p_visible, bool p_explicit_visibility) +void MCInterfaceExecGo(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window, int p_mode, bool p_this_stack, MCGoStackVisibility p_visibility_type) { + if (p_card == nil) { if (MCresult -> isclear()) @@ -4452,11 +4453,14 @@ void MCInterfaceExecGo(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window MCtrace = False; // MW-2007-02-11: [[ Bug 4029 ]] - 'go invisible' fails to close stack window if window already open - if (p_explicit_visibility) + if (p_visibility_type != kImplicit) { if (t_stack -> getwindow() != NULL) MCscreen -> closewindow(t_stack -> getwindow()); - t_stack->setflag(p_visible, F_VISIBLE); + if (p_visibility_type == kExplicitVisible) + t_stack->setflag(true, F_VISIBLE); + if (p_visibility_type == kExplicitInvisible) + t_stack->setflag(false, F_VISIBLE); } // MW-2011-02-27: [[ Bug ]] Make sure that if we open as a sheet, we have a parent pointer! @@ -4539,14 +4543,14 @@ void MCInterfaceExecGo(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window ctxt . Throw(); } -void MCInterfaceExecGoCardAsMode(MCExecContext& ctxt, MCCard *p_card, int p_mode, bool p_visible, bool p_explicit_visibility, bool p_this_stack) +void MCInterfaceExecGoCardAsMode(MCExecContext& ctxt, MCCard *p_card, int p_mode, MCGoStackVisibility p_visibility_type, bool p_this_stack) { - MCInterfaceExecGo(ctxt, p_card, nil, p_mode, p_this_stack, p_visible, p_explicit_visibility); + MCInterfaceExecGo(ctxt, p_card, nil, p_mode, p_this_stack, p_visibility_type); } -void MCInterfaceExecGoCardInWindow(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window, bool p_visible, bool p_explicit_visibility, bool p_this_stack) +void MCInterfaceExecGoCardInWindow(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window, MCGoStackVisibility p_visibility_type, bool p_this_stack) { - MCInterfaceExecGo(ctxt, p_card, p_window, WM_MODELESS, p_this_stack, p_visible, p_explicit_visibility); + MCInterfaceExecGo(ctxt, p_card, p_window, WM_MODELESS, p_this_stack, p_visibility_type); } void MCInterfaceExecGoRecentCard(MCExecContext& ctxt) @@ -4572,7 +4576,8 @@ void MCInterfaceExecGoHome(MCExecContext& ctxt, MCCard *p_card) MCdefaultstackptr->close(); MCdefaultstackptr->checkdestroy(); } - MCInterfaceExecGo(ctxt, p_card, nil, 0, false, true, false); + MCGoStackVisibility visibilityType = kImplicit; + MCInterfaceExecGo(ctxt, p_card, nil, 0, false, visibilityType); } //////////////////////////////////////////////////////////////////////////////// diff --git a/engine/src/exec.h b/engine/src/exec.h index 041fd9104a4..c5fbd1f21df 100644 --- a/engine/src/exec.h +++ b/engine/src/exec.h @@ -2449,8 +2449,9 @@ void MCInterfaceExecReplaceInField(MCExecContext& ctxt, MCStringRef p_pattern, M void MCInterfaceExecChooseTool(MCExecContext& ctxt, MCStringRef p_input, int p_tool); -void MCInterfaceExecGoCardAsMode(MCExecContext& ctxt, MCCard *p_card, int p_mode, bool p_visible, bool p_explicit_visibility, bool p_this_stack); -void MCInterfaceExecGoCardInWindow(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window, bool p_visible, bool p_explicit_visibility, bool p_this_stack); +enum MCGoStackVisibility { kImplicit, kExplicitVisible, kExplicitInvisible }; +void MCInterfaceExecGoCardAsMode(MCExecContext& ctxt, MCCard *p_card, int p_mode, MCGoStackVisibility p_visibility_type, bool p_this_stack); +void MCInterfaceExecGoCardInWindow(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window, MCGoStackVisibility p_visibility_type, bool p_this_stack); void MCInterfaceExecGoRecentCard(MCExecContext& ctxt); void MCInterfaceExecGoCardRelative(MCExecContext& ctxt, bool p_forward, real8 p_amount); void MCInterfaceExecGoCardEnd(MCExecContext& ctxt, bool p_is_start); From b46a43fdf36524d29ee03cb8865b51e6166777a1 Mon Sep 17 00:00:00 2001 From: Andrew Ferguson Date: Thu, 16 Aug 2018 16:58:16 +0100 Subject: [PATCH 5/9] [[Bugfix-14721]] Seperate parameters by comma The parameters on the _TestGoInvisibleVisibleStack and _TestCreateStack commands have been seperated by a comma. --- tests/lcs/core/interface/go.livecodescript | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/lcs/core/interface/go.livecodescript b/tests/lcs/core/interface/go.livecodescript index d886fdbd5bc..a8db125dfbe 100644 --- a/tests/lcs/core/interface/go.livecodescript +++ b/tests/lcs/core/interface/go.livecodescript @@ -55,7 +55,7 @@ on TestGoCardUnquotedName end TestGoCardUnquotedName local sStackFileName -command _TestCreateStack pBinary pVisible +command _TestCreateStack pBinary, pVisible local tStack put "stackToGo" into tStack @@ -123,7 +123,7 @@ on TestGoToCard TestAssert "closeCard sent to closed card", the cClosed of card 2 end TestGoToCard -on _TestGoInvisibleVisibleStack pMode pWhich pVisible +on _TestGoInvisibleVisibleStack pMode, pWhich, pVisible TestSkipIfNot "write" local tStack _TestCreateStack pWhich is "binary", pVisible is "visible" From 64bf79523074923c8fb856ea3cfc6031a1d1ad13 Mon Sep 17 00:00:00 2001 From: Andrew Ferguson Date: Fri, 17 Aug 2018 10:14:17 +0100 Subject: [PATCH 6/9] [[Bugfix-14721]] Increase readability of enum The readibility of the MCGoStackVisibility enum has been increased by renaming it to MCInterfaceExecGoVisibility, and prepending the new enum name to all the enumeration values. Also the use of braces in the enum definition has been updated to conform to the existing style (note to self: read C++style.md *first* next time). --- engine/src/cmds.h | 2 +- engine/src/cmdss.cpp | 4 ++-- engine/src/exec-interface.cpp | 14 +++++++------- engine/src/exec.h | 11 ++++++++--- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/engine/src/cmds.h b/engine/src/cmds.h index 39b656fe065..85557943f39 100644 --- a/engine/src/cmds.h +++ b/engine/src/cmds.h @@ -1738,7 +1738,7 @@ class MCGo : public MCStatement Window_mode mode; Boolean marked; Boolean visible; - MCGoStackVisibility visibilityType = kImplicit; + MCInterfaceExecGoVisibility visibilityType = kMCInterfaceExecGoVisibilityImplicit; Boolean thisstack; MCChunk *widget; diff --git a/engine/src/cmdss.cpp b/engine/src/cmdss.cpp index 616f98514d2..e35323d0752 100644 --- a/engine/src/cmdss.cpp +++ b/engine/src/cmdss.cpp @@ -112,9 +112,9 @@ Parse_stat MCGo::parse(MCScriptPoint &sp) initpoint(sp); if (sp.skip_token(SP_FACTOR, TT_PROPERTY, P_INVISIBLE) == PS_NORMAL) - visibilityType = kExplicitInvisible; + visibilityType = kMCInterfaceExecGoVisibilityExplicitInvisible; if (sp.skip_token(SP_FACTOR, TT_PROPERTY, P_VISIBLE) == PS_NORMAL) - visibilityType = kExplicitVisible; + visibilityType = kMCInterfaceExecGoVisibilityExplicitVisible; while (True) { if (sp.next(type) != PS_NORMAL) diff --git a/engine/src/exec-interface.cpp b/engine/src/exec-interface.cpp index 3bdad3be7b9..c5f08bc6cbb 100644 --- a/engine/src/exec-interface.cpp +++ b/engine/src/exec-interface.cpp @@ -4329,7 +4329,7 @@ void MCInterfaceExecChooseTool(MCExecContext& ctxt, MCStringRef p_input, int p_t //////////////////////////////////////////////////////////////////////////////// -void MCInterfaceExecGo(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window, int p_mode, bool p_this_stack, MCGoStackVisibility p_visibility_type) +void MCInterfaceExecGo(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window, int p_mode, bool p_this_stack, MCInterfaceExecGoVisibility p_visibility_type) { if (p_card == nil) @@ -4453,13 +4453,13 @@ void MCInterfaceExecGo(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window MCtrace = False; // MW-2007-02-11: [[ Bug 4029 ]] - 'go invisible' fails to close stack window if window already open - if (p_visibility_type != kImplicit) + if (p_visibility_type != kMCInterfaceExecGoVisibilityImplicit) { if (t_stack -> getwindow() != NULL) MCscreen -> closewindow(t_stack -> getwindow()); - if (p_visibility_type == kExplicitVisible) + if (p_visibility_type == kMCInterfaceExecGoVisibilityExplicitVisible) t_stack->setflag(true, F_VISIBLE); - if (p_visibility_type == kExplicitInvisible) + if (p_visibility_type == kMCInterfaceExecGoVisibilityExplicitInvisible) t_stack->setflag(false, F_VISIBLE); } @@ -4543,12 +4543,12 @@ void MCInterfaceExecGo(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window ctxt . Throw(); } -void MCInterfaceExecGoCardAsMode(MCExecContext& ctxt, MCCard *p_card, int p_mode, MCGoStackVisibility p_visibility_type, bool p_this_stack) +void MCInterfaceExecGoCardAsMode(MCExecContext& ctxt, MCCard *p_card, int p_mode, MCInterfaceExecGoVisibility p_visibility_type, bool p_this_stack) { MCInterfaceExecGo(ctxt, p_card, nil, p_mode, p_this_stack, p_visibility_type); } -void MCInterfaceExecGoCardInWindow(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window, MCGoStackVisibility p_visibility_type, bool p_this_stack) +void MCInterfaceExecGoCardInWindow(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window, MCInterfaceExecGoVisibility p_visibility_type, bool p_this_stack) { MCInterfaceExecGo(ctxt, p_card, p_window, WM_MODELESS, p_this_stack, p_visibility_type); } @@ -4576,7 +4576,7 @@ void MCInterfaceExecGoHome(MCExecContext& ctxt, MCCard *p_card) MCdefaultstackptr->close(); MCdefaultstackptr->checkdestroy(); } - MCGoStackVisibility visibilityType = kImplicit; + MCInterfaceExecGoVisibility visibilityType = kMCInterfaceExecGoVisibilityImplicit; MCInterfaceExecGo(ctxt, p_card, nil, 0, false, visibilityType); } diff --git a/engine/src/exec.h b/engine/src/exec.h index c5fbd1f21df..0e38c5e76a4 100644 --- a/engine/src/exec.h +++ b/engine/src/exec.h @@ -2449,9 +2449,14 @@ void MCInterfaceExecReplaceInField(MCExecContext& ctxt, MCStringRef p_pattern, M void MCInterfaceExecChooseTool(MCExecContext& ctxt, MCStringRef p_input, int p_tool); -enum MCGoStackVisibility { kImplicit, kExplicitVisible, kExplicitInvisible }; -void MCInterfaceExecGoCardAsMode(MCExecContext& ctxt, MCCard *p_card, int p_mode, MCGoStackVisibility p_visibility_type, bool p_this_stack); -void MCInterfaceExecGoCardInWindow(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window, MCGoStackVisibility p_visibility_type, bool p_this_stack); +enum MCInterfaceExecGoVisibility +{ + kMCInterfaceExecGoVisibilityImplicit, + kMCInterfaceExecGoVisibilityExplicitVisible, + kMCInterfaceExecGoVisibilityExplicitInvisible +}; +void MCInterfaceExecGoCardAsMode(MCExecContext& ctxt, MCCard *p_card, int p_mode, MCInterfaceExecGoVisibility p_visibility_type, bool p_this_stack); +void MCInterfaceExecGoCardInWindow(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window, MCInterfaceExecGoVisibility p_visibility_type, bool p_this_stack); void MCInterfaceExecGoRecentCard(MCExecContext& ctxt); void MCInterfaceExecGoCardRelative(MCExecContext& ctxt, bool p_forward, real8 p_amount); void MCInterfaceExecGoCardEnd(MCExecContext& ctxt, bool p_is_start); From e1a84aeee809ee3e92af54b07bebae0e8aa1399f Mon Sep 17 00:00:00 2001 From: Andrew Ferguson Date: Fri, 17 Aug 2018 10:31:55 +0100 Subject: [PATCH 7/9] [[Bugfix-14721]] Add release note A release note has been added for the new visible form of the go command. --- docs/notes/Bugfix-14721.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/notes/Bugfix-14721.md diff --git a/docs/notes/Bugfix-14721.md b/docs/notes/Bugfix-14721.md new file mode 100644 index 00000000000..61d83a5ced8 --- /dev/null +++ b/docs/notes/Bugfix-14721.md @@ -0,0 +1 @@ +# Implement 'go visible ' as an antonym to 'go invisible' From 3340244731768f819e4dafdbdddfecbcc35453e2 Mon Sep 17 00:00:00 2001 From: Andrew Ferguson Date: Fri, 17 Aug 2018 11:52:16 +0100 Subject: [PATCH 8/9] [[Bugfix-14721]] Cleanup variables The visibiltyType variable has been renamed to visibility_type to conform to the coding standards. An unnecessary instance of the MCInterfaceExecGoVisibilityType enum was removed and replaced with a direct reference to the enum. The visibile boolean variable is now redundant and has been removed. --- engine/src/cmds.h | 5 ++--- engine/src/cmdss.cpp | 8 ++++---- engine/src/exec-interface.cpp | 3 +-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/engine/src/cmds.h b/engine/src/cmds.h index 85557943f39..3724775b515 100644 --- a/engine/src/cmds.h +++ b/engine/src/cmds.h @@ -1737,8 +1737,7 @@ class MCGo : public MCStatement MCExpression *window; Window_mode mode; Boolean marked; - Boolean visible; - MCInterfaceExecGoVisibility visibilityType = kMCInterfaceExecGoVisibilityImplicit; + MCInterfaceExecGoVisibility visibility_type; Boolean thisstack; MCChunk *widget; @@ -1751,7 +1750,7 @@ class MCGo : public MCStatement window(nil), mode(WM_LAST), marked(False), - visible(True), + visibility_type(kMCInterfaceExecGoVisibilityImplicit), thisstack(False), widget(nil), direction(CT_BACKWARD) diff --git a/engine/src/cmdss.cpp b/engine/src/cmdss.cpp index e35323d0752..7a0d26ff775 100644 --- a/engine/src/cmdss.cpp +++ b/engine/src/cmdss.cpp @@ -112,9 +112,9 @@ Parse_stat MCGo::parse(MCScriptPoint &sp) initpoint(sp); if (sp.skip_token(SP_FACTOR, TT_PROPERTY, P_INVISIBLE) == PS_NORMAL) - visibilityType = kMCInterfaceExecGoVisibilityExplicitInvisible; + visibility_type = kMCInterfaceExecGoVisibilityExplicitInvisible; if (sp.skip_token(SP_FACTOR, TT_PROPERTY, P_VISIBLE) == PS_NORMAL) - visibilityType = kMCInterfaceExecGoVisibilityExplicitVisible; + visibility_type = kMCInterfaceExecGoVisibilityExplicitVisible; while (True) { if (sp.next(type) != PS_NORMAL) @@ -746,9 +746,9 @@ void MCGo::exec_ctxt(MCExecContext &ctxt) } } else if (window != nil) - MCInterfaceExecGoCardInWindow(ctxt, cptr, *t_window, visibilityType, thisstack == True); + MCInterfaceExecGoCardInWindow(ctxt, cptr, *t_window, visibility_type, thisstack == True); else - MCInterfaceExecGoCardAsMode(ctxt, cptr, mode, visibilityType, thisstack == True); + MCInterfaceExecGoCardAsMode(ctxt, cptr, mode, visibility_type, thisstack == True); } MCHide::~MCHide() diff --git a/engine/src/exec-interface.cpp b/engine/src/exec-interface.cpp index c5f08bc6cbb..c8c42065b5c 100644 --- a/engine/src/exec-interface.cpp +++ b/engine/src/exec-interface.cpp @@ -4576,8 +4576,7 @@ void MCInterfaceExecGoHome(MCExecContext& ctxt, MCCard *p_card) MCdefaultstackptr->close(); MCdefaultstackptr->checkdestroy(); } - MCInterfaceExecGoVisibility visibilityType = kMCInterfaceExecGoVisibilityImplicit; - MCInterfaceExecGo(ctxt, p_card, nil, 0, false, visibilityType); + MCInterfaceExecGo(ctxt, p_card, nil, 0, false, MCInterfaceExecGoVisibility(kMCInterfaceExecGoVisibilityImplicit)); } //////////////////////////////////////////////////////////////////////////////// From b875fbd63de19e03def6ef9c624dd99c1cbd5717 Mon Sep 17 00:00:00 2001 From: Andrew Ferguson Date: Mon, 20 Aug 2018 11:09:51 +0100 Subject: [PATCH 9/9] [[Bugfix-14721]] Removed unnecessary cast to enum A cast to the MCInterfaceExecGoVisibility enum has been replaced with a direct pass of the relevent item in the enum. --- engine/src/exec-interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/src/exec-interface.cpp b/engine/src/exec-interface.cpp index c8c42065b5c..f80b264678b 100644 --- a/engine/src/exec-interface.cpp +++ b/engine/src/exec-interface.cpp @@ -4576,7 +4576,7 @@ void MCInterfaceExecGoHome(MCExecContext& ctxt, MCCard *p_card) MCdefaultstackptr->close(); MCdefaultstackptr->checkdestroy(); } - MCInterfaceExecGo(ctxt, p_card, nil, 0, false, MCInterfaceExecGoVisibility(kMCInterfaceExecGoVisibilityImplicit)); + MCInterfaceExecGo(ctxt, p_card, nil, 0, false, kMCInterfaceExecGoVisibilityImplicit); } ////////////////////////////////////////////////////////////////////////////////