|
@@ -199,12 +199,23 @@ class CmdThread(threading.Thread):
|
|
self.requestCmd.abort()
|
|
self.requestCmd.abort()
|
|
if self.requestQ.empty():
|
|
if self.requestQ.empty():
|
|
self._want_abort_all = False
|
|
self._want_abort_all = False
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+# Occurs event when some new text appears.
|
|
|
|
+# Text priority is specified by priority attribute.
|
|
|
|
+# Priority is 1 (lowest), 2, 3 (highest);
|
|
|
|
+# value 0 is currently not used and probably will not be used.
|
|
|
|
+# In theory, it can be used when text is completely uninteresting.
|
|
|
|
+# It is similar to wx.EVT_TEXT.
|
|
|
|
+# However, the new text or the whole text are not event attributes.
|
|
|
|
+gOutputText, EVT_OUTPUT_TEXT = NewEvent()
|
|
|
|
+
|
|
|
|
+
|
|
class GConsole(wx.SplitterWindow):
|
|
class GConsole(wx.SplitterWindow):
|
|
"""!Create and manage output console for commands run by GUI.
|
|
"""!Create and manage output console for commands run by GUI.
|
|
"""
|
|
"""
|
|
def __init__(self, parent, id = wx.ID_ANY, margin = False,
|
|
def __init__(self, parent, id = wx.ID_ANY, margin = False,
|
|
- frame = None, notebook = None,
|
|
|
|
|
|
+ frame = None,
|
|
style = wx.TAB_TRAVERSAL | wx.FULL_REPAINT_ON_RESIZE,
|
|
style = wx.TAB_TRAVERSAL | wx.FULL_REPAINT_ON_RESIZE,
|
|
gcstyle = GC_EMPTY,
|
|
gcstyle = GC_EMPTY,
|
|
**kwargs):
|
|
**kwargs):
|
|
@@ -220,11 +231,6 @@ class GConsole(wx.SplitterWindow):
|
|
self.frame = frame
|
|
self.frame = frame
|
|
else:
|
|
else:
|
|
self.frame = parent
|
|
self.frame = parent
|
|
-
|
|
|
|
- if notebook:
|
|
|
|
- self._notebook = notebook
|
|
|
|
- else:
|
|
|
|
- self._notebook = self.parent.notebook
|
|
|
|
|
|
|
|
self._gcstyle = gcstyle
|
|
self._gcstyle = gcstyle
|
|
self.lineWidth = 80
|
|
self.lineWidth = 80
|
|
@@ -453,8 +459,14 @@ class GConsole(wx.SplitterWindow):
|
|
|
|
|
|
self.cmdOutput.SetStyle()
|
|
self.cmdOutput.SetStyle()
|
|
|
|
|
|
|
|
+ # documenting old behavior/implementation:
|
|
|
|
+ # switch notebook if required
|
|
if switchPage:
|
|
if switchPage:
|
|
- self._notebook.SetSelectionByName('output')
|
|
|
|
|
|
+ priority = 2
|
|
|
|
+ else:
|
|
|
|
+ priority = 1
|
|
|
|
+ event = gOutputText(priority = priority)
|
|
|
|
+ wx.PostEvent(self, event)
|
|
|
|
|
|
if not style:
|
|
if not style:
|
|
style = self.cmdOutput.StyleDefault
|
|
style = self.cmdOutput.StyleDefault
|
|
@@ -622,14 +634,15 @@ class GConsole(wx.SplitterWindow):
|
|
except GException, e:
|
|
except GException, e:
|
|
print >> sys.stderr, e
|
|
print >> sys.stderr, e
|
|
return
|
|
return
|
|
-
|
|
|
|
- # switch to 'Command output' if required
|
|
|
|
|
|
+
|
|
|
|
+ # documenting old behavior/implementation:
|
|
|
|
+ # switch and focus if required
|
|
|
|
+ # TODO: this probably should be run command event
|
|
if switchPage:
|
|
if switchPage:
|
|
- self._notebook.SetSelectionByName('output')
|
|
|
|
-
|
|
|
|
- self.frame.SetFocus()
|
|
|
|
- self.frame.Raise()
|
|
|
|
-
|
|
|
|
|
|
+ priority = 3
|
|
|
|
+ event = gOutputText(priority = priority)
|
|
|
|
+ wx.PostEvent(self, event)
|
|
|
|
+
|
|
# activate computational region (set with g.region)
|
|
# activate computational region (set with g.region)
|
|
# for all non-display commands.
|
|
# for all non-display commands.
|
|
if compReg:
|
|
if compReg:
|
|
@@ -739,16 +752,14 @@ class GConsole(wx.SplitterWindow):
|
|
"""!Print command output"""
|
|
"""!Print command output"""
|
|
message = event.text
|
|
message = event.text
|
|
type = event.type
|
|
type = event.type
|
|
|
|
+
|
|
self.cmdOutput.AddStyledMessage(message, type)
|
|
self.cmdOutput.AddStyledMessage(message, type)
|
|
|
|
|
|
- if self._notebook.GetSelection() != self._notebook.GetPageIndexByName('output'):
|
|
|
|
- page = self._notebook.GetPageIndexByName('output')
|
|
|
|
- textP = self._notebook.GetPageText(page)
|
|
|
|
- if textP[-1] != ')':
|
|
|
|
- textP += ' (...)'
|
|
|
|
- self._notebook.SetPageText(page, textP)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ # documenting old behavior/implementation:
|
|
|
|
+ # add elipses if not active
|
|
|
|
+ event = gOutputText(priority = 1)
|
|
|
|
+ wx.PostEvent(self, event)
|
|
|
|
+
|
|
def OnCmdProgress(self, event):
|
|
def OnCmdProgress(self, event):
|
|
"""!Update progress message info"""
|
|
"""!Update progress message info"""
|
|
self.progressbar.SetValue(event.value)
|
|
self.progressbar.SetValue(event.value)
|
|
@@ -1091,6 +1102,7 @@ class GStc(stc.StyledTextCtrl):
|
|
|
|
|
|
# remember position of line begining (used for '\r')
|
|
# remember position of line begining (used for '\r')
|
|
self.linePos = -1
|
|
self.linePos = -1
|
|
|
|
+
|
|
#
|
|
#
|
|
# styles
|
|
# styles
|
|
#
|
|
#
|
|
@@ -1220,7 +1232,7 @@ class GStc(stc.StyledTextCtrl):
|
|
|
|
|
|
# reset output window to read only
|
|
# reset output window to read only
|
|
self.SetReadOnly(True)
|
|
self.SetReadOnly(True)
|
|
-
|
|
|
|
|
|
+
|
|
def AddStyledMessage(self, message, style = None):
|
|
def AddStyledMessage(self, message, style = None):
|
|
"""!Add message to text area.
|
|
"""!Add message to text area.
|
|
|
|
|