예제 #1
0
class CommandLineHandler(object):

    def __init__(self):
        self.command = ''
        self.history = HistoryList()
        self.execute = EventHook()

    def line_changed(self, line):
        if callable(line):
            line = line()
        self.command = line
        self.history.reset()

    def previous(self):
        try:
            self.history.previous()
        finally:
            self.command = self.history.current

    def next(self):
        try:
            self.history.next()
        finally:
            self.command = self.history.current

    def finish(self):
        if self.command == '':
            return
        self.history.append(self.command)
        self.execute.fire(self.command)
예제 #2
0
 def __init__(self):
     self.command = ''
     self.history = HistoryList()
     self.execute = EventHook()