Пример #1
0
    def test_history(self):
        hist = History(3)
        for i in range(6):
            hist.add(i)
        self.assertEqual([3, 4, 5], list(hist))

        hist.back()

        self.assertEqual(4, hist.current())
        self.assertEqual([3, 4], list(hist._left()))

        self.assertEqual(5, hist.top())

        hist.back()
        self.assertEqual(3, hist.current())
        self.assertEqual([3], list(hist._left()))

        # no change if current == bottom
        self.assertEqual(hist.current(), hist.bottom())
        last = hist.current()
        hist.back()
        self.assertEqual(hist.current(), last)

        self.assertEqual(5, hist.top())

        hist.forward()
        hist.forward()
        self.assertEqual(5, hist.current())
        self.assertEqual([3, 4, 5], list(hist._left()))

        self.assertEqual(3, hist.bottom())
        hist.add(6)
        self.assertEqual(4, hist.bottom())
        self.assertEqual([4, 5, 6], list(hist._left()))

        hist.back()
        hist.fast_forward()
        self.assertEqual([4, 5, 6], list(hist._left()))
        hist.back()
        hist.back()
        hist.fast_forward()
        self.assertEqual([4, 5, 6], list(hist._left()))
        hist.back()
        hist.back()
        hist.back()
        hist.fast_forward()
        self.assertEqual([4, 5, 6], list(hist._left()))
        hist.back()
        hist.back()
        hist.back()
        hist.back()
        hist.fast_forward()
        self.assertEqual([4, 5, 6], list(hist._left()))
Пример #2
0
 def __init__(self, win):
     Widget.__init__(self, win)
     self.clear()
     self.history = History(self.settings.max_console_history_size)
     # load history from files
     if not ranger.arg.clean:
         self.historypath = self.fm.confpath('history')
         try:
             f = open(self.historypath, 'r')
         except:
             pass
         else:
             for line in f:
                 self.history.add(line[:-1])
             f.close()
Пример #3
0
    def __init__(self, path):
        SignalDispatcher.__init__(self)
        self.path = abspath(expanduser(path))
        self._cf = None
        self.pathway = ()
        self.directories = {}
        self.keybuffer = KeyBuffer(None, None)
        self.keymanager = KeyManager(self.keybuffer, ALLOWED_CONTEXTS)
        self.copy = set()
        self.history = History(self.settings.max_history_size, unique=False)

        try:
            self.username = pwd.getpwuid(os.geteuid()).pw_name
        except:
            self.username = '******' + str(os.geteuid())
        self.hostname = socket.gethostname()
        self.home_path = os.path.expanduser('~')

        self.signal_bind('move',
                         self._set_cf_from_signal,
                         priority=0.1,
                         weak=True)