diff --git a/Cura/gui/alterationPanel.py b/Cura/gui/alterationPanel.py index 144f3d94..c47772d7 100644 --- a/Cura/gui/alterationPanel.py +++ b/Cura/gui/alterationPanel.py @@ -1,4 +1,4 @@ -import wx +import wx,wx.stc import sys,math,threading,os from gui import gcodeTextArea @@ -20,6 +20,7 @@ class alterationPanel(wx.Panel): self.list.SetSelection(0) self.Bind(wx.EVT_LISTBOX, self.OnSelect, self.list) self.textArea.Bind(wx.EVT_KILL_FOCUS, self.OnFocusLost, self.textArea) + self.textArea.Bind(wx.stc.EVT_STC_CHANGE, self.OnFocusLost, self.textArea) sizer = wx.GridBagSizer() sizer.Add(self.list, (0,0), span=(1,1), flag=wx.EXPAND) diff --git a/Cura/gui/gcodeTextArea.py b/Cura/gui/gcodeTextArea.py index 5487241f..aa2701d5 100644 --- a/Cura/gui/gcodeTextArea.py +++ b/Cura/gui/gcodeTextArea.py @@ -3,7 +3,7 @@ import sys,math,os from util import profile -if sys.platform == 'darwin': +if False and sys.platform == 'darwin': class GcodeTextArea(wx.TextCtrl): def __init__(self, parent): super(GcodeTextArea, self).__init__(parent, style=wx.TE_MULTILINE|wx.TE_DONTWRAP|wx.TE_PROCESS_TAB) @@ -29,12 +29,45 @@ else: self.IndicatorSetForeground(1, "#FF0000") self.SetWrapMode(wx.stc.STC_WRAP_NONE) self.SetScrollWidth(1000) + if sys.platform == 'darwin': + self.Bind(wx.EVT_KEY_DOWN, self.OnMacKeyDown) #GCodes and MCodes as supported by Marlin #GCode 21 is not really supported by Marlin, but we still do not report it as error as it's often used. self.supportedGCodes = [0,1,2,3,4,21,28,90,91,92] self.supportedMCodes = [17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,42,80,81,82,83,84,85,92,104,105,106,107,109,114,115,117,119,140,190,201,202,203,204,205,206,220,221,240,301,302,303,400,500,501,502,503,999] + def OnMacKeyDown(self, e): + code = e.GetKeyCode(); + stopPropagation = True + #Command + if e.CmdDown(): + if code == wx._core.WXK_LEFT: + self.GotoLine(self.GetCurrentLine()) + elif code == wx._core.WXK_RIGHT: + self.GotoPos(self.GetLineEndPosition(self.GetCurrentLine())) + elif code == wx._core.WXK_UP: + self.GotoPos(0) + elif code == wx._core.WXK_DOWN: + self.GotoPos(self.GetLength()) + else: + stopPropagation = False + # Control + elif e.GetModifiers() & 0xF0: + if code == 65: # A + self.GotoLine(self.GetCurrentLine()) + elif code == 69: # E + self.GotoPos(self.GetLineEndPosition(self.GetCurrentLine())) + else: + stopPropagation = False + else: + stopPropagation = False + # Event propagation + if stopPropagation: + e.StopPropagation() + else: + e.Skip() + def OnStyle(self, e): lineNr = self.LineFromPosition(self.GetEndStyled()) while self.PositionFromLine(lineNr) > -1: diff --git a/Cura/gui/projectPlanner.py b/Cura/gui/projectPlanner.py index 310f67a2..9aaba3d7 100644 --- a/Cura/gui/projectPlanner.py +++ b/Cura/gui/projectPlanner.py @@ -164,7 +164,8 @@ class projectPlanner(wx.Frame): util3d.Vector3(profile.getPreferenceFloat('extruder_offset_x2'), profile.getPreferenceFloat('extruder_offset_y2'), 0), util3d.Vector3(profile.getPreferenceFloat('extruder_offset_x3'), profile.getPreferenceFloat('extruder_offset_y3'), 0)] - self.toolbar = toolbarUtil.Toolbar(self) + self.toolbarPanel = wx.Panel(self, -1) + self.toolbar = toolbarUtil.Toolbar(self.toolbarPanel) toolbarUtil.NormalButton(self.toolbar, self.OnLoadProject, 'open.png', 'Open project') toolbarUtil.NormalButton(self.toolbar, self.OnSaveProject, 'save.png', 'Save project') @@ -179,7 +180,8 @@ class projectPlanner(wx.Frame): self.toolbar.Realize() - self.toolbar2 = toolbarUtil.Toolbar(self) + self.toolbar2Panel = wx.Panel(self, -1) + self.toolbar2 = toolbarUtil.Toolbar(self.toolbar2Panel) toolbarUtil.NormalButton(self.toolbar2, self.OnAddModel, 'object-add.png', 'Add model') toolbarUtil.NormalButton(self.toolbar2, self.OnRemModel, 'object-remove.png', 'Remove model') self.toolbar2.AddSeparator() @@ -201,8 +203,8 @@ class projectPlanner(wx.Frame): self.sliceButton = wx.Button(self, -1, "Slice") self.autoPlaceButton = wx.Button(self, -1, "Auto Place") - sizer.Add(self.toolbar, (0,0), span=(1,1), flag=wx.EXPAND) - sizer.Add(self.toolbar2, (0,1), span=(1,2), flag=wx.EXPAND) + sizer.Add(self.toolbarPanel, (0,0), span=(1,1), flag=wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT) + sizer.Add(self.toolbar2Panel, (0,1), span=(1,2), flag=wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT) sizer.Add(self.preview, (1,0), span=(4,1), flag=wx.EXPAND) sizer.Add(self.listbox, (1,1), span=(1,2), flag=wx.EXPAND) sizer.Add(self.addButton, (2,1), span=(1,1))