File: eclipse.py

package info (click to toggle)
gnat-gps 18-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 45,716 kB
  • sloc: ada: 362,679; python: 31,031; xml: 9,597; makefile: 1,030; ansic: 917; sh: 264; java: 17
file content (30 lines) | stat: -rw-r--r-- 698 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
""" Enables a selection of Eclipse-like shortcuts in GPS.

The "delete selected lines" (Ctrl-D or Cmd-D) action was contributed
by Robert ter Vehn.
"""


import GPS
import gps_utils


name = 'delete line from selection'


@gps_utils.interactive(name=name, key='primary-d')
def delete_line():
    """
    Remove the lines that include the current selection. If there is
    no selection, remove the line at the cursor position.
    """

    buffer = GPS.EditorBuffer.get()

    append = GPS.last_command() == name
    if append:
        GPS.set_last_command(name)

    start = buffer.selection_start().beginning_of_line()
    end = buffer.selection_end().end_of_line()
    buffer.delete(start, end)