diff --git a/application.py b/application.py index 1574596..607b5ae 100755 --- a/application.py +++ b/application.py @@ -369,7 +369,7 @@ class Application(object): def push_kill(self, s): if s is not None: if self.last_action in self.kill_commands and \ - len(self.kill_ring): + len(self.kill_ring): self.kill_ring[-1] = self.kill_ring[-1] + s else: self.kill_ring.append(s) @@ -446,14 +446,47 @@ class Application(object): # full screen drawer def draw(self): - self.hide_cursor() self.draw_slots() self.draw_input_bar() + self.draw_cursor() self.hide_cursor() self.win.noutrefresh() - self.hide_cursor() curses.doupdate() + def draw_cursor(self): + if self.mini_active: + b = self.mini_buffer + w = b.windows[0] + (cx, cy) = w.logical_cursor().xy() + if cy >= len(b.lines): + return + elif cx == len(b.lines[cy]): + c = ' ' + else: + c = b.lines[cy][cx] + self.win.addch(self.y-1, cx + len(self.mini_prompt), c, curses.A_REVERSE) + self.win.move(self.y-1, cx + len(self.mini_prompt)) + else: + slot = self.bufferlist.slots[self.active_slot] + w = slot.window + if w.active_point is not None and w.point_is_visible(w.active_point): + p = w.active_point + else: + p = w.logical_cursor() + count = 0 + (x, y) = w.first.xy() + while count < slot.height: + if p.y == y and p.x >= x and p.x <= x + slot.width: + self.highlight_char(slot.offset + count, p.x - x) + break + if x + slot.width >= len(w.buffer.lines[y]): + x = 0 + y += 1 + else: + x += slot.width + count += 1 + self.win.move(slot.offset + count, p.x - x) + # sub-drawing methods def draw_slots(self): self.win.erase() @@ -521,24 +554,6 @@ class Application(object): attr = color.build('default', shade, 'bold') self.win.addch(j + slot.offset, limit, char, attr) - if self.mini_active is False and self.active_slot == i: - if w.active_point is not None and w.point_is_visible(w.active_point): - p = w.active_point - else: - p = w.logical_cursor() - count = 0 - (x, y) = w.first.xy() - while count < slot.height: - if p.y == y and p.x >= x and p.x <= x + slot.width: - self.highlight_char(slot.offset + count, p.x - x) - break - if x + slot.width >= len(w.buffer.lines[y]): - x = 0 - y += 1 - else: - x += slot.width - count += 1 - def _draw_slot_raw(self, i): slot = self.bufferlist.slots[i] w = slot.window @@ -692,17 +707,6 @@ class Application(object): s2 = util.padtrunc(s1, l) self.win.addnstr(self.y-1, 0, s2, l) - if self.mini_active: - w = b.windows[0] - cursor = w.logical_cursor() - (cx, cy) = cursor.xy() - if cy >= len(b.lines): - return - elif cx == len(b.lines[cy]): - c = ' ' - else: - c = b.lines[cy][cx] - self.win.addch(self.y-1, cx + len(self.mini_prompt), c, curses.A_REVERSE) def draw_nothing(self): l = self.x - 1 self.win.addnstr(self.y-1, 0, util.pad('', l), l) diff --git a/mode_python.py b/mode_python.py index 70ad183..9dd5286 100644 --- a/mode_python.py +++ b/mode_python.py @@ -146,7 +146,6 @@ class PythonTabber(tab2.StackTabber): elif token.string in ('elif', 'else') and self.is_leftmost_token(y, i): # we know we'll unindent at least to the first if/elif if not self.popped and not self.last_popped: - raise Exception, "junka" self._pop_until('if', 'elif') currlvl = self.get_curr_level() self._append(token.string, currlvl + 4)