Added Edit.xml file, which can be used as a feed for 0launch (Thomas Leonard).
[rox-edit.git] / goto.py
blob855e91bfa8d7f96fee635cfc7b076de58c48479a
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, 0.05, False)
28 self.window.set_minibuffer(None)