Commit c1a9f8d6 authored by Kliment Yanev's avatar Kliment Yanev

Save commands entered into command box and retrieve them when up/down key is pressed.

parent 193347b6
...@@ -613,6 +613,9 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -613,6 +613,9 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.commandbox=wx.TextCtrl(self.panel,style = wx.TE_PROCESS_ENTER) self.commandbox=wx.TextCtrl(self.panel,style = wx.TE_PROCESS_ENTER)
self.commandbox.SetToolTip(wx.ToolTip("Send commands to printer\n(Type 'help' for simple\nhelp function)")) self.commandbox.SetToolTip(wx.ToolTip("Send commands to printer\n(Type 'help' for simple\nhelp function)"))
self.commandbox.Bind(wx.EVT_TEXT_ENTER,self.sendline) self.commandbox.Bind(wx.EVT_TEXT_ENTER,self.sendline)
self.commandbox.Bind(wx.EVT_CHAR, self.cbkey)
self.commandbox.history=[]
self.commandbox.histindex=1
#self.printerControls.append(self.commandbox) #self.printerControls.append(self.commandbox)
lbrs.Add(self.commandbox,1) lbrs.Add(self.commandbox,1)
self.sendbtn=wx.Button(self.panel,-1,_("Send"),style=wx.BU_EXACTFIT) self.sendbtn=wx.Button(self.panel,-1,_("Send"),style=wx.BU_EXACTFIT)
...@@ -824,6 +827,26 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -824,6 +827,26 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
#uts.Layout() #uts.Layout()
self.cbuttons_reload() self.cbuttons_reload()
def cbkey(self,e):
if e.GetKeyCode()==wx.WXK_UP:
print self.commandbox.history, self.commandbox.histindex
#if len(self.commandbox.history)==0 or self.commandbox.histindex<len(self.commandbox.history)-1:
# self.commandbox.history+=[self.commandbox.GetValue()] #save current command
if len(self.commandbox.history):
self.commandbox.histindex=(self.commandbox.histindex-1)%len(self.commandbox.history)
self.commandbox.SetValue(self.commandbox.history[self.commandbox.histindex])
self.commandbox.SetSelection(0,len(self.commandbox.history[self.commandbox.histindex]))
elif e.GetKeyCode()==wx.WXK_DOWN:
#if len(self.commandbox.history)==0 or self.commandbox.histindex<len(self.commandbox.history)-1:
# self.commandbox.history+=[self.commandbox.GetValue()] #save current command
if len(self.commandbox.history):
self.commandbox.histindex=(self.commandbox.histindex+1)%len(self.commandbox.history)
self.commandbox.SetValue(self.commandbox.history[self.commandbox.histindex])
self.commandbox.SetSelection(0,len(self.commandbox.history[self.commandbox.histindex]))
else:
e.Skip()
def plate(self,e): def plate(self,e):
import plater import plater
print "plate function activated" print "plate function activated"
...@@ -1293,6 +1316,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -1293,6 +1316,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.webInterface.AppendLog(">>>"+command+"\n") self.webInterface.AppendLog(">>>"+command+"\n")
self.onecmd(str(command)) self.onecmd(str(command))
self.commandbox.SetSelection(0,len(command)) self.commandbox.SetSelection(0,len(command))
self.commandbox.history+=[command]
self.commandbox.histindex=len(self.commandbox.history)-1
def clearOutput(self,e): def clearOutput(self,e):
self.logbox.Clear() self.logbox.Clear()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment