From 5c84feb9dbd962d2c2a1301a3772d31986c944e7 Mon Sep 17 00:00:00 2001 From: Bob Farrell Date: Mon, 28 Apr 2008 15:33:27 +0100 Subject: [PATCH] Auto-indent added It was pretty trivial (it just autoindents if a line ends with a colon or if the previous line was indented). --- CHANGELOG | 4 ++++ bpython.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 29f9736..3666513 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +v0.3.0 +====== +Now with auto-indent. Let me know if it's annoying. + v0.2.4 ====== Thanks a lot to Angus Gibson for submitting a patch to fix a problem diff --git a/bpython.py b/bpython.py index 5988c9a..8fd8698 100644 --- a/bpython.py +++ b/bpython.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# bpython 0.2.4::fancy curses interface to the Python repl::Bob Farrell 2008 +# bpython 0.3.0::fancy curses interface to the Python repl::Bob Farrell 2008 # # The MIT License # @@ -197,6 +197,7 @@ class Repl: self.f_string = '' self.matches = [] self.argspec = None + self.s = '' if not OPTS.argspec: return @@ -1001,10 +1002,15 @@ class Repl: which returns None if Enter is pressed (that means "Return", idiot).""" - self.ts = '' + indent = self.s.endswith(':') or self.s.startswith('\t') self.s = '' self.iy, self.ix = self.scr.getyx() + + if indent:#self.s_hist and self.s_hist[-1].rstrip().endswith(':'): + self.c = '\t' + self.p_key() + self.c = None self.cpos = 0 while True: