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: ")]
def _execute(self, w, **vargs):
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:
n = len(w.buffer.lines) - n
# now let's protect the user from their own mistakes
if n < 0:
n = 0
elif n >= len(w.buffer.lines):
n = len(w.buffer.lines) - 1
else:
n -= 1
# ok so go to the line now
n = len(w.buffer.lines) + n + 1
if n > len(w.buffer.lines):
n = len(w.buffer.lines)
elif n < 1:
n = 1
w.goto_line(n)
class ForwardLines(Method):
'''Move forward the specified number of characters'''