From b431523edea925bc234888b3f86d3a52bfe15c41 Mon Sep 17 00:00:00 2001 From: moculus Date: Sun, 17 Jun 2007 14:55:36 +0000 Subject: [PATCH] --HG-- branch : pmacs2 --- application.py | 13 ++++++------- method.py | 38 ++++++++++++++++++-------------------- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/application.py b/application.py index c0fd2a0..3f95473 100755 --- a/application.py +++ b/application.py @@ -494,7 +494,7 @@ class Application(object): else: self.highlight_chars(slot.offset + count, px, px + slot.width) px += slot.width - if x + slot.width >= len(line): + if x + slot.width >= len(w.buffer.lines[y]): x = 0 y += 1 else: @@ -584,7 +584,7 @@ class Application(object): s_offset = max(x - token.x, 0) x_offset = max(token.x - x, 0) - assert x_offset < slot.width + assert x_offset < slot.width, '%d < %d' % (x_offset, slot.width) c = self._get_token_color(w, token) s = token.string[s_offset:] @@ -644,11 +644,10 @@ class Application(object): perc = "%2d%%" % (first.y*100 / len(b.lines)) # XYZ: we should actually use more of the 'state' variables - - #format = "----:%s-Fl %-18s (%s)--L%d--C%d--%s" - #status = format % (modflag, name, w.mode.name(), cursor.y+1, cursor.x+1, perc) - format = "----:%s-Fl %-18s (%s)--L%d--C%d--%s--%s--%s" - status = format % (modflag, name, w.mode.name(), cursor.y+1, cursor.x+1, w.first, w.last, perc) + format = "----:%s-Fl %-18s (%s)--L%d--C%d--%s" + status = format % (modflag, name, w.mode.name(), cursor.y+1, cursor.x+1, perc) + #format = "----:%s-Fl %-18s (%s)--L%d--C%d--%s--%s--%s" + #status = format % (modflag, name, w.mode.name(), cursor.y+1, cursor.x+1, w.first, w.last, perc) status = status[:slot.width + 1] status += "-" * (slot.width - len(status) + 1) self.win.addnstr(slot.height + slot.offset, 0, status, slot.width + 1, diff --git a/method.py b/method.py index 02a4898..6e4046c 100644 --- a/method.py +++ b/method.py @@ -14,10 +14,10 @@ DATATYPES = { } class Argument: - def __init__(self, name, type=type(""), datatype=None, prompt=None, help="", + def __init__(self, name, typ=type(""), datatype=None, prompt=None, help="", default=default.none, load_default=False): self.name = name - self.type = type + self.type = typ self.datatype = datatype if prompt is None: self.prompt = "%s: " % (name) @@ -38,8 +38,8 @@ class Argument: return value def ask_for_value(self, method, w, **vargs): - assert w.application.mini_buffer_is_open() is False, \ - "Recursive minibuffer antics" + app = w.application + assert app.mini_buffer_is_open() is False, "Recursive minibuffer antics" vargs2 = vargs.copy() assert callable(self.default), "default value func must be callable" if self.load_default: @@ -52,16 +52,16 @@ class Argument: if d is not None and v == "": v = d vargs2[self.name] = self.coerce_to_type(v) - w.application.close_mini_buffer() + app.close_mini_buffer() method.execute(w, **vargs2) tabber = DATATYPES.get(self.datatype, None) if d is not None: p = self.prompt + "(%s) " % (d) else: p = self.prompt - w.application.open_mini_buffer(p, return_value, method, tabber) + app.open_mini_buffer(p, return_value, method, tabber) if starting_value: - w.application.mini_buffer.set_data(starting_value) + app.mini_buffer.set_data(starting_value) class Method: _is_method = True @@ -149,7 +149,7 @@ class Search(Method): class ReverseSearch(Method): '''Interactive search; finds previous occurance of text in buffer''' def execute(self, w, **vargs): - self.old_cursor = w.logical_cursor().offset(0, 0) + self.old_cursor = w.logical_cursor() self.old_window = w self.direction = 'previous' w.application.open_mini_buffer('I-Search: ', @@ -508,7 +508,6 @@ class InsertSpace(Method): w.insert_string_at_cursor(' ') class InsertTab(Method): '''Insert tab into buffer, or tabbify line, depending on mode''' - #XYZ def _execute(self, w, **vargs): cursor = w.logical_cursor() #i = w.mode.get_indentation_level(cursor.y) @@ -528,8 +527,7 @@ class KillWhitespace(Method): cursor = w.logical_cursor() i = w.buffer.count_leading_whitespace(cursor.y) if i > 0: - w.kill(Point(0, cursor.y), - Point(i, cursor.y)) + w.kill(Point(0, cursor.y), Point(i, cursor.y)) # tabification class TabBuffer(Method): @@ -557,7 +555,7 @@ class CommentRegion(Method): w.input_line = "Empty kill region" return for y in range(p1.y, p2.y): - w.buffer.insert_string_at_cursor(Point(0, y), "#") + w.buffer.insert_string(Point(0, y), "#") class UncommentRegion(Method): '''Remove a comment from every line in the current buffer''' def _execute(self, w, **vargs): @@ -573,7 +571,7 @@ class UncommentRegion(Method): return for y in range(p1.y, p2.y): if w.buffer.lines[y].startswith("#"): - w.buffer.delete_string(Point(0, y), Point(1, y)) + w.buffer.delete(Point(0, y), Point(1, y)) # wrapping/justifying/etc class WrapLine(Method): @@ -674,7 +672,7 @@ class JustifyLeft(Method): return if this_line[i] != ' ': return - w.buffer.delete_string(Point(i, cursor.y), cursor) + w.buffer.delete(Point(i, cursor.y), cursor) # undo/redo class Undo(Method): @@ -782,8 +780,8 @@ class UnindentBlock(Method): for i in range(0, len(lines)): if lines[i].startswith(' '): lines[i] = lines[i][4:] - w.buffer.delete_string(Point(0, p1.y), Point(0, p2.y)) - w.buffer.insert_string_at_cursor(Point(0, p1.y), '\n'.join(lines) + '\n') + w.buffer.delete(Point(0, p1.y), Point(0, p2.y)) + w.buffer.insert_string(Point(0, p1.y), '\n'.join(lines) + '\n') class IndentBlock(Method): '''Add 4 spaces to each line in region''' def _execute(self, w, **vargs): @@ -800,8 +798,8 @@ class IndentBlock(Method): lines = w.buffer.lines[p1.y:p2.y] for i in range(0, len(lines)): lines[i] = ' ' + lines[i] - w.buffer.delete_string(Point(0, p1.y), Point(0, p2.y)) - w.buffer.insert_string_at_cursor(Point(0, p1.y), '\n'.join(lines) + '\n') + w.buffer.delete(Point(0, p1.y), Point(0, p2.y)) + w.buffer.insert_string(Point(0, p1.y), '\n'.join(lines) + '\n') class CodeComplete(Method): '''Complete based on tokenized strings''' @@ -846,7 +844,7 @@ class CodeComplete(Method): seen_keys = seen.keys() num_seen = len(seen_keys) if word == sofar: - #w.application.set_error('No completion possible: %r' % word) + w.application.set_error('No completion possible: %r' % word) pass elif sofar: w.buffer.delete(p1, p2) @@ -856,7 +854,7 @@ class CodeComplete(Method): else: w.application.set_error('Ambiguous: %r' % seen_keys) else: - #w.application.set_error('No completion found: %r' % word) + w.application.set_error('No completion found: %r' % word) pass class OpenConsole(Method):