diff --git a/application.py b/application.py index 19d1d3a..35275f2 100755 --- a/application.py +++ b/application.py @@ -146,6 +146,8 @@ class Application(object): # initialize our buffers # note that only the first buffer will be initially visible buffers.append(buffer.about.AboutBuffer()) + self.log = buffer.LogBuffer() + buffers.append(self.log) if self.rcerror: buffers.insert(0, buffer.data.DataBuffer('*RcError*', self.rcerror)) @@ -513,9 +515,12 @@ class Application(object): window.Window(b, self, height=slot.height, width=slot.width) # error string handling - def set_error(self, s): + def set_msg(self, s): self.error_string = s self.error_timestamp = time.time() + def set_error(self, s): + self.set_msg(s) + self.log.append_lines([s, ""], act=buffer.ACT_NONE, force=True) def clear_error(self): self.error_string = "" self.error_timestamp = None @@ -1051,7 +1056,6 @@ if __name__ == "__main__": i += 1 import optparse - parser = optparse.OptionParser() parser.set_defaults(debug=False) parser.set_defaults(goto=None) diff --git a/buffer/__init__.py b/buffer/__init__.py index 36c9c6d..b7bc53a 100644 --- a/buffer/__init__.py +++ b/buffer/__init__.py @@ -782,3 +782,20 @@ class Binary32Buffer(FileBuffer): return '\n'.join(lines) def write_filter(self, data): return ''.join(self.rawdata) + +# log is another singleton +log = None +class LogBuffer(Buffer): + btype = 'log' + def __new__(cls, *args, **kwargs): + global log + if log is None: + log = object.__new__(LogBuffer, *args, **kwargs) + return log + + def __init__(self): Buffer.__init__(self) + def clear(self): log.set_data('', force=True) + def name(self): return '*Log*' + def changed(self): return False + def close(self): global log; log = None + def readonly(self): return True diff --git a/buffer/console.py b/buffer/console.py index 79b8c41..792e836 100644 --- a/buffer/console.py +++ b/buffer/console.py @@ -28,6 +28,3 @@ class ConsoleBuffer(Buffer): def changed(self): return False def close(self): global console; console = None def readonly(self): return True - def input_insert_lines(self, p, lines, act=ACT_NORM, force=False): pass - def output_insert_lines(self, p, lines, act=ACT_NORM, force=False): pass - def result_insert_lines(self, p, lines, act=ACT_NORM, force=False): pass diff --git a/method/__init__.py b/method/__init__.py index 6858f7d..dfef0d0 100644 --- a/method/__init__.py +++ b/method/__init__.py @@ -908,7 +908,7 @@ class Cancel(Method): w.application.close_mini_buffer() if w.application.completion_window_is_open(): w.application.close_completion_buffer() - w.set_error('Cancel') + w.set_msg('Cancel') class SplitWindow(Method): '''Split the main window horizontally into upper and lower windows''' @@ -916,8 +916,6 @@ class SplitWindow(Method): a = w.application a.add_slot() if not w.cursor_is_visible(): - #p = w.first - #w.goto(p) w.center_view(force=True) n = len(a.bufferlist.slots) a.set_error('Window has been split into %d windows!' % n) diff --git a/mode/__init__.py b/mode/__init__.py index 577d56b..e2033c4 100644 --- a/mode/__init__.py +++ b/mode/__init__.py @@ -445,7 +445,7 @@ class Fundamental(Handler): try: act = Handler.handle_token(self, t) if act is None: - self.window.set_error(' '.join(self.curr_tokens)) + self.window.set_msg(' '.join(self.curr_tokens)) return else: act.execute(self.window) @@ -454,7 +454,7 @@ class Fundamental(Handler): except ActionError, e: #XYZ: HACK--should fix if t in ('C-]', 'C-g'): - self.window.set_error('Cancelled') + self.window.set_msg('Cancelled') else: self.window.set_error(str(e)) except Exception, e: diff --git a/window.py b/window.py index 19e4294..538b843 100644 --- a/window.py +++ b/window.py @@ -75,10 +75,9 @@ class Window(object): return os.path.splitext(path)[1].lower() # some useful pass-through to application - def set_error(self, s): - self.application.set_error(s) - def clear_error(self): - self.application.clear_error() + def set_msg(self, s): self.application.set_msg(s) + def set_error(self, s): self.application.set_error(s) + def clear_error(self): self.application.clear_error() # mode stuff def set_mode(self, m):