Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions docs/dictionary/command/go.lcdoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ Synonyms: open

Type: command

Syntax: go [invisible] [to] <card> [of <stack>] [{as <mode> |in [a] new window|in <window>}]
Syntax: go [{visible | invisible}] [to] <card> [of <stack>] [{as <mode> |in [a] new window|in <window>}]

Syntax: go [invisible] [to] {first | prev[ious]| next | last | any} [marked] [<card>]
Syntax: go [{visible | invisible}] [to] {first | prev[ious]| next | last | any} [marked] [<card>]

Syntax: go [invisible] [to] {recent | start | finish | home} <card>
Syntax: go [{visible | invisible}] [to] {recent | start | finish | home} <card>

Syntax: go {forward | forth | back[ward]} [<number>]

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -153,13 +156,22 @@ among the previously-visited cards:
form moves forward in the recent cards list. "forward" and "forth" are
synonyms.

If you use the <go> visible form, the stack is made visible after being
opened. (When going to a stack, this form sets the stack's <visible>
<property> to true.) Use this form of the <go> command to display a
script-only stack without explicitly setting the <visible (property)>
in the <openStack> or <preOpenStack> handlers.

If you use the <go> invisible form, the window or card change does not
show on the screen. (When going to a stack, this form sets the stack's
<visible> <property> to false.) Use this form of the <go> command to open
a stack without displaying it on screen. To display the stack later, use
the <show> <command> or set its <visible (property)>to true.

Note that if a stack’s <visible> property is set in either the <openStack>
or <preOpenStack> handlers, then this will override the expected behaviour
of the <go> visible and <go> invisible forms.

Any visual effects that have been queued with the visual effect command
are displayed when the <go> command is executed (unless the screen is
locked).
Expand Down
1 change: 1 addition & 0 deletions docs/notes/Bugfix-14721.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Implement 'go visible <stack>' as an antonym to 'go invisible'
4 changes: 2 additions & 2 deletions engine/src/cmds.h
Original file line number Diff line number Diff line change
Expand Up @@ -1737,7 +1737,7 @@ class MCGo : public MCStatement
MCExpression *window;
Window_mode mode;
Boolean marked;
Boolean visible;
MCInterfaceExecGoVisibility visibility_type;
Boolean thisstack;

MCChunk *widget;
Expand All @@ -1750,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)
Expand Down
8 changes: 5 additions & 3 deletions engine/src/cmdss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ Parse_stat MCGo::parse(MCScriptPoint &sp)

initpoint(sp);
if (sp.skip_token(SP_FACTOR, TT_PROPERTY, P_INVISIBLE) == PS_NORMAL)
visible = False;
visibility_type = kMCInterfaceExecGoVisibilityExplicitInvisible;
if (sp.skip_token(SP_FACTOR, TT_PROPERTY, P_VISIBLE) == PS_NORMAL)
visibility_type = kMCInterfaceExecGoVisibilityExplicitVisible;
while (True)
{
if (sp.next(type) != PS_NORMAL)
Expand Down Expand Up @@ -744,9 +746,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, visibility_type, thisstack == True);
else
MCInterfaceExecGoCardAsMode(ctxt, cptr, mode, visible == True, thisstack == True);
MCInterfaceExecGoCardAsMode(ctxt, cptr, mode, visibility_type, thisstack == True);
}

MCHide::~MCHide()
Expand Down
20 changes: 12 additions & 8 deletions engine/src/exec-interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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)
{
if (MCresult -> isclear())
Expand Down Expand Up @@ -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_visible && t_stack -> getflag(F_VISIBLE))
if (p_visibility_type != kMCInterfaceExecGoVisibilityImplicit)
{
if (t_stack -> getwindow() != NULL)
MCscreen -> closewindow(t_stack -> getwindow());
t_stack->setflag(False, F_VISIBLE);
if (p_visibility_type == kMCInterfaceExecGoVisibilityExplicitVisible)
t_stack->setflag(true, F_VISIBLE);
if (p_visibility_type == kMCInterfaceExecGoVisibilityExplicitInvisible)
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!
Expand Down Expand Up @@ -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_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_visible);
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_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_visible);
MCInterfaceExecGo(ctxt, p_card, p_window, WM_MODELESS, p_this_stack, p_visibility_type);
}

void MCInterfaceExecGoRecentCard(MCExecContext& ctxt)
Expand All @@ -4572,7 +4576,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, kMCInterfaceExecGoVisibilityImplicit);
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
10 changes: 8 additions & 2 deletions engine/src/exec.h
Original file line number Diff line number Diff line change
Expand Up @@ -2449,8 +2449,14 @@ 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);
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);
Expand Down
81 changes: 79 additions & 2 deletions tests/lcs/core/interface/go.livecodescript
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
39 changes: 39 additions & 0 deletions tests/lcs/parser/go.parsertest
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.

%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