Skip to content

Commit

Permalink
Fix AllCode line numbering bug
Browse files Browse the repository at this point in the history
Add keyboard shortcuts for more help menu items
Add Tools section to Manual
  • Loading branch information
benjie-git committed Mar 12, 2021
1 parent a9bcefe commit 9dea3d7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 11 deletions.
13 changes: 8 additions & 5 deletions allCodeWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ def AppendOnSetupCode(self, obj):
displayName = UiView.handlerDisplayNames[handlerName]
handlerCode = obj.GetHandler(handlerName)
if handlerCode:
self.methodStartLines.append((self.numLines, card, obj, handlerName))
self.text += f"# {name}\n"
self.numLines += 1

self.methodStartLines.append((self.numLines, card, obj, handlerName))
code = f"def {displayName}\n"
lines = handlerCode.splitlines(False)
code += "\n".join(["\t"+line for line in lines])
self.text += code + "\n\n"
self.numLines += 2 + len(lines) + 1
self.numLines += 1 + len(lines) + 1
for child in obj.childModels:
self.AppendOnSetupCode(child)

Expand All @@ -78,11 +80,12 @@ def AppendNonSetupCode(self, obj):
displayName = UiView.handlerDisplayNames[handlerName]
handlerCode = obj.GetHandler(handlerName)
if handlerCode:
self.methodStartLines.append((self.numLines, card, obj, handlerName))
if not didAddComment:
self.text += f"# {name}\n"
didAddComment = True
self.numLines += 1

self.methodStartLines.append((self.numLines, card, obj, handlerName))
code = f"def {displayName}\n"
lines = handlerCode.splitlines(False)
code += "\n".join(["\t"+line for line in lines])
Expand All @@ -99,8 +102,8 @@ def OnUpdateUi(self, event):
if line != self.lastLineNum:
self.lastLineNum = line
for l in reversed(self.methodStartLines):
if line >= l[0]:
self.JumpToCode(l[1], l[2], l[3], line-l[0]-1)
if line >= l[0]-1:
self.JumpToCode(l[1], l[2], l[3], line-l[0])
break

def JumpToCode(self, card, obj, handlerName, lineNum):
Expand Down
8 changes: 4 additions & 4 deletions designer.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,10 @@ def MakeMenu(self):
# and the help menu
helpMenu = wx.Menu()
helpMenu.Append(wx.ID_ABOUT, "&About", "About")
helpMenu.Append(wx.ID_HELP, "&Manual", "Manual")
helpMenu.Append(wx.ID_REFRESH, "&Reference Guide", "Reference Guide")
helpMenu.Append(wx.ID_CONTEXT_HELP, "&Show/Hide Context Help", "Toggle Context Help")
helpMenu.Append(ID_SHOW_ERROR_LIST, "&Show/Hide Error Window\tCtrl-Alt-E", "Toggle Errors")
helpMenu.Append(wx.ID_HELP, "&Manual\tCtrl-Alt-M", "Manual")
helpMenu.Append(wx.ID_REFRESH, "&Reference Guide\tCtrl-Alt-R", "Reference Guide")
helpMenu.Append(wx.ID_CONTEXT_HELP, "&Show/Hide Context Help\tCtrl-Alt-H", "Toggle Context Help")
helpMenu.Append(ID_SHOW_ERROR_LIST, "&Show/Hide Error List Window\tCtrl-Alt-E", "Toggle Errors")
helpMenu.Append(ID_SHOW_ALL_CODE, "&Show/Hide All Code Window\tCtrl-Alt-C", "Toggle AllCode")

# and add them to a menubar
Expand Down
2 changes: 1 addition & 1 deletion errorListWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __repr__(self):

class ErrorListWindow(wx.Frame):
def __init__(self, designer):
super().__init__(designer, title="Errors", style=wx.DEFAULT_FRAME_STYLE|wx.FRAME_TOOL_WINDOW|wx.FRAME_FLOAT_ON_PARENT)
super().__init__(designer, title="Error List", style=wx.DEFAULT_FRAME_STYLE|wx.FRAME_TOOL_WINDOW|wx.FRAME_FLOAT_ON_PARENT)
self.SetMinClientSize(wx.Size(300,20))
self.SetClientSize(wx.Size(500,50))
self.designer = designer
Expand Down
2 changes: 1 addition & 1 deletion examples/astroids.cds
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@
}
],
"CardStock_stack_format": 1,
"CardStock_stack_version": "0.8.1"
"CardStock_stack_version": "0.8.2"
}
17 changes: 17 additions & 0 deletions helpDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,23 @@ def GetHTML(self):
<p>When you want to try running your stack from within the Designer app, and see how it works, you can use the Run Stack menu item
in the File menu. Then just close your running stack window to return to the Designer to continue editing.</p>
<br/><br/>
<h2>Tools</h2>
<p>If any errors come up while running your stack, you will see them in the status bar at the bottom the running stack's
window. Any errors will also appear after your return to the Designer, in the red-colored Error List window that will
appear. You can also open it from the Help menu. Clicking on an error will take you to the offending line in the code
editor.</p>
<p>If you want to look at all of your code at once, instead of only at one object's code for one event at a time,
you can open the All Code window from the Help menu. Clicking a line in the All Code editor will also take you to that
line of the right object's event code in the code editor.</p>
<p>Note that CardStock has a full Find and Replace system, that lets you find, and optionally replace, strings in your
code and properties throughout your whole stack. It allows finding using python style regular expression syntax, if you
want to use that to search for more complex expressions.</p>
<p>There are lots of example stacks that come with CardStock. Try playing with some of them, and then dig in deeper
to figure out how they work, and make some changes to see if you can make things work the way you want them to.</p>
Expand Down

0 comments on commit 9dea3d7

Please sign in to comment.