From 3c16004844c1c33b534c65b75bfca466dd42e7a1 Mon Sep 17 00:00:00 2001 From: Stephen Dranger Date: Tue, 8 Feb 2011 16:59:25 -0600 Subject: [PATCH] history obj --- dataobjs.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/dataobjs.py b/dataobjs.py index 9b3456b..bbff459 100644 --- a/dataobjs.py +++ b/dataobjs.py @@ -173,3 +173,24 @@ class PesterProfile(object): return False return True +class PesterHistory(object): + def __init__(self): + self.history = [] + self.current = -1 + def next(self): + if self.current == -1: + return "" + text = self.history[self.current] + if self.current > 0: + self.current -= 1 + return text + def prev(self): + if self.current == -1 or self.current == len(self.history) - 1: + return "" + self.current += 1 + return self.history[self.current] + def reset(self): + self.current = len(self.history) - 1 + def add(self, text): + self.history.append(text) + self.current = len(self.history) - 1