Spanish translation of AppInfo (Nicol��s de la Torre).
[rox-edit.git] / goto.py
blob7246fc461d727f70e9bbfd7ada4d1bd3512165cc
1 from rox import g
2 import rox
3 from EditWindow import Minibuffer
5 class Goto(Minibuffer):
6 "A minibuffer used to find a line by number."
8 def setup(self, window):
9 self.window = window
10 self.window.set_mini_label('Goto line:')
12 info = 'Enter the line number to go to. Line numbers start from 1. ' \
13 'Press Escape to cancel, or Return to jump to the line.'
15 def activate(self):
16 line = self.window.mini_entry.get_text()
17 if line:
18 try:
19 line = int(line)
20 assert line >= 1
21 except:
22 rox.alert('Invalid line number: %s' % line)
23 else:
24 buffer = self.window.buffer
25 iter = buffer.get_iter_at_line(line - 1)
26 buffer.place_cursor(iter)
27 self.window.text.scroll_to_iter(iter,
28 0.05, g.FALSE)
29 self.window.set_minibuffer(None)