~ubuntu-branches/ubuntu/maverick/gedit-plugins/maverick

« back to all changes in this revision

Viewing changes to plugins/commander/modules/goto.py

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-03-30 11:24:05 UTC
  • mfrom: (1.1.25 upstream)
  • Revision ID: james.westby@ubuntu.com-20100330112405-fttwf75vj5obn7ug
Tags: 2.30.0-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
"""Goto specific places in the document"""
2
2
import os
 
3
 
3
4
import commander.commands as commands
 
5
import commander.commands.completion
 
6
import commander.commands.result
 
7
import commander.commands.exceptions
4
8
 
5
9
__commander_module__ = True
6
10
 
7
 
def __default__(view, line, column=0):
 
11
def __default__(view, line, column=1):
8
12
        """Goto line number"""
9
 
        
 
13
 
10
14
        buf = view.get_buffer()
11
15
        ins = buf.get_insert()
12
16
        citer = buf.get_iter_at_mark(ins)
21
25
                
22
26
                column = int(column) - 1
23
27
        except ValueError:
24
 
                raise commands.exceptions.Execute('Please specify a valid line number')
25
 
 
26
 
        linnum = max(0, linnum)
27
 
        column = max(0, column)
 
28
                raise commander.commands.exceptions.Execute('Please specify a valid line number')
 
29
 
 
30
        linnum = min(max(0, linnum), buf.get_line_count() - 1)
 
31
        citer = buf.get_iter_at_line(linnum)
 
32
 
 
33
        column = min(max(0, column), citer.get_chars_in_line() - 1)
28
34
 
29
35
        citer = buf.get_iter_at_line(linnum)
30
36
        citer.forward_chars(column)
31
 
        
32
 
        buf.move_mark(ins, citer)
33
 
        buf.move_mark(buf.get_selection_bound(), buf.get_iter_at_mark(ins))
34
 
        return False
 
37
 
 
38
        buf.place_cursor(citer)
 
39
        view.scroll_to_iter(citer, 0.0, True)
 
40
 
 
41
        return commander.commands.result.HIDE