Beispiel #1
0
 def __init_term_emulator(self):
     self.termEmulator = TermEmulator.V102Terminal(self.termRows,
                                                   self.termCols)
     # self.termEmulator.SetCallback(self.termEmulator.CALLBACK_SCROLL_UP_SCREEN,
     # 							  self.OnTermEmulatorScrollUpScreen)
     self.termEmulator.SetCallback(self.termEmulator.CALLBACK_UPDATE_LINES,
                                   self.OnTermEmulatorUpdateLines)
     # self.termEmulator.SetCallback(self.termEmulator.CALLBACK_UPDATE_CURSOR_POS,
     # 							  self.OnTermEmulatorUpdateCursorPos)
     # self.termEmulator.SetCallback(self.termEmulator.CALLBACK_UPDATE_WINDOW_TITLE,
     # 							  self.OnTermEmulatorUpdateWindowTitle)
     # self.termEmulator.SetCallback(self.termEmulator.CALLBACK_UNHANDLED_ESC_SEQ,
     # 							  self.OnTermEmulatorUnhandledEscSeq)
     # self.termEmulator.SetCallback(self.termEmulator.CALLBACK_NEWLINE,
     # 							  self.BreakLine)
     self.termEmulator.SetCallback(self.termEmulator.CALLBACK_PUSHCHAR,
                                   self.InsertChar)
Beispiel #2
0
	def __init__(self, parent, name, session = None, style = wx.TE_MULTILINE| wx.TE_DONTWRAP):
		self.session = session

		wx.TextCtrl.__init__(self, parent, ID_TERMINAL, name, style = style, size = wx.Size(300,200))
		# self.SetBackgroundColour((0,0,0))
		font = wx.Font(10, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTSTYLE_NORMAL, False)
		self.SetFont(font)
		# self.SetDefaultStyle(wx.TextAttr(wx.WHITE, wx.NullColor, font))

		self.Bind(wx.EVT_CHAR, self.OnTerminalChar, id = ID_TERMINAL)
		self.Bind(wx.EVT_KEY_DOWN, self.OnTerminalKeyDown, id = ID_TERMINAL)
		self.Bind(wx.EVT_KEY_UP, self.OnTerminalKeyUp, id = ID_TERMINAL)
		self.Bind(wx.EVT_CLOSE, self.OnClose, id = ID_TERMINAL)

		self.Bind(wx.EVT_RIGHT_DOWN, self.OnMouseRightDown, id = ID_TERMINAL)

		self.is_closed = False

		self.termRows = 24
		self.termCols = 80
		self.linesScrolledUp = 0
		self.scrolledUpLinesLen = 0
		self.FillScreen()

		self.termEmulator = TermEmulator.V102Terminal(self.termRows, self.termCols)
		self.termEmulator.SetCallback(self.termEmulator.CALLBACK_SCROLL_UP_SCREEN,
									  self.OnTermEmulatorScrollUpScreen)
		self.termEmulator.SetCallback(self.termEmulator.CALLBACK_UPDATE_LINES,
									  self.OnTermEmulatorUpdateLines)
		self.termEmulator.SetCallback(self.termEmulator.CALLBACK_UPDATE_CURSOR_POS,
									  self.OnTermEmulatorUpdateCursorPos)
		# self.termEmulator.SetCallback(self.termEmulator.CALLBACK_UPDATE_WINDOW_TITLE,
		# 							  self.OnTermEmulatorUpdateWindowTitle)
		self.termEmulator.SetCallback(self.termEmulator.CALLBACK_UNHANDLED_ESC_SEQ,
									  self.OnTermEmulatorUnhandledEscSeq)
	
		self.OnBeginRun()
Beispiel #3
0
    def __init__(self):
        wx.Frame.__init__(self, None, wx.ID_ANY, "TermEmulator Demo", \
                          size = (700, 500))

        self.Bind(wx.EVT_CLOSE, self.OnClose)

        vbox = wx.BoxSizer(wx.VERTICAL)
        hbox1 = wx.BoxSizer(wx.HORIZONTAL)

        self.st1 = wx.StaticText(self, wx.ID_ANY, "Program path:")
        hbox1.Add(self.st1, 0, wx.ALIGN_CENTER | wx.LEFT, 10)

        self.tc1 = wx.TextCtrl(self, wx.ID_ANY)
        self.tc1.SetValue("/bin/bash")
        hbox1.Add(self.tc1, 1, wx.ALIGN_CENTER)

        self.st2 = wx.StaticText(self, wx.ID_ANY, "Arguments:")
        hbox1.Add(self.st2, 0, wx.ALIGN_CENTER | wx.LEFT, 10)

        self.tc2 = wx.TextCtrl(self, wx.ID_ANY)
        hbox1.Add(self.tc2, 1, wx.ALIGN_CENTER)

        self.b1 = wx.Button(self, wx.ID_ANY, "Run")
        hbox1.Add(self.b1, 0, wx.LEFT | wx.RIGHT, 10)
        self.b1.Bind(wx.EVT_BUTTON, self.OnRun, id=self.b1.GetId())

        vbox.Add(hbox1, 0, wx.EXPAND | wx.HORIZONTAL | wx.TOP | wx.BOTTOM, 5)

        hbox2 = wx.BoxSizer(wx.HORIZONTAL)

        self.st3 = wx.StaticText(self, wx.ID_ANY, "Terminal Size, Rows:")
        hbox2.Add(self.st3, 0, wx.ALIGN_CENTER | wx.LEFT, 10)

        self.tc3 = wx.TextCtrl(self, wx.ID_ANY)
        self.tc3.SetValue("24")
        hbox2.Add(self.tc3, 1, wx.ALIGN_CENTER)

        self.st4 = wx.StaticText(self, wx.ID_ANY, "Columns:")
        hbox2.Add(self.st4, 0, wx.ALIGN_CENTER | wx.LEFT, 10)

        self.tc4 = wx.TextCtrl(self, wx.ID_ANY)
        self.tc4.SetValue("80")
        hbox2.Add(self.tc4, 1, wx.ALIGN_CENTER)

        self.b2 = wx.Button(self, wx.ID_ANY, "Resize")
        hbox2.Add(self.b2, 0, wx.LEFT | wx.RIGHT, 10)
        self.b2.Bind(wx.EVT_BUTTON, self.OnResize, id=self.b2.GetId())

        self.cb1 = wx.CheckBox(self, wx.ID_ANY, "Disable text coloring")
        hbox2.Add(self.cb1, 0, wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT, 10)

        vbox.Add(hbox2, 0, wx.EXPAND | wx.HORIZONTAL | wx.TOP | wx.BOTTOM, 5)

        self.txtCtrlTerminal = wx.TextCtrl(self,
                                           ID_TERMINAL,
                                           style=wx.TE_MULTILINE
                                           | wx.TE_DONTWRAP)
        font = wx.Font(10, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL,
                       wx.FONTSTYLE_NORMAL, False)
        self.txtCtrlTerminal.SetFont(font)

        self.txtCtrlTerminal.Bind(wx.EVT_CHAR,
                                  self.OnTerminalChar,
                                  id=ID_TERMINAL)

        self.txtCtrlTerminal.Bind(wx.EVT_KEY_DOWN,
                                  self.OnTerminalKeyDown,
                                  id=ID_TERMINAL)

        self.txtCtrlTerminal.Bind(wx.EVT_KEY_UP,
                                  self.OnTerminalKeyUp,
                                  id=ID_TERMINAL)

        vbox.Add(self.txtCtrlTerminal, 1, wx.EXPAND | wx.ALL)
        self.SetSizer(vbox)

        self.termRows = 24
        self.termCols = 80

        self.linesScrolledUp = 0
        self.scrolledUpLinesLen = 0

        self.termEmulator = TermEmulator.V102Terminal(self.termRows,
                                                      self.termCols)
        self.termEmulator.SetCallback(
            self.termEmulator.CALLBACK_SCROLL_UP_SCREEN,
            self.OnTermEmulatorScrollUpScreen)
        self.termEmulator.SetCallback(self.termEmulator.CALLBACK_UPDATE_LINES,
                                      self.OnTermEmulatorUpdateLines)
        self.termEmulator.SetCallback(
            self.termEmulator.CALLBACK_UPDATE_CURSOR_POS,
            self.OnTermEmulatorUpdateCursorPos)
        self.termEmulator.SetCallback(
            self.termEmulator.CALLBACK_UPDATE_WINDOW_TITLE,
            self.OnTermEmulatorUpdateWindowTitle)
        self.termEmulator.SetCallback(
            self.termEmulator.CALLBACK_UNHANDLED_ESC_SEQ,
            self.OnTermEmulatorUnhandledEscSeq)

        self.isRunning = False
        self.UpdateUI()

        self.Show(True)