branch : pmacs2
This commit is contained in:
moculus 2007-06-15 15:02:22 +00:00
parent e6db05be3b
commit 2f4b124477
1 changed files with 5 additions and 13 deletions

View File

@ -123,20 +123,12 @@ class GotoLine(Method):
return [Argument("lineno", type=type(0), prompt="Goto line: ")] return [Argument("lineno", type=type(0), prompt="Goto line: ")]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
n = vargs["lineno"] n = vargs["lineno"]
# 0 is not a supported input line number
if n == 0:
return
# negative line numbers are offsets from the end
if n < 0: if n < 0:
n = len(w.buffer.lines) - n n = len(w.buffer.lines) + n + 1
# now let's protect the user from their own mistakes if n > len(w.buffer.lines):
if n < 0: n = len(w.buffer.lines)
n = 0 elif n < 1:
elif n >= len(w.buffer.lines): n = 1
n = len(w.buffer.lines) - 1
else:
n -= 1
# ok so go to the line now
w.goto_line(n) w.goto_line(n)
class ForwardLines(Method): class ForwardLines(Method):
'''Move forward the specified number of characters''' '''Move forward the specified number of characters'''