/usr/share/gps/library/filepos.py is in gnat-gps-common 5.0-13.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 31 32 33 34 35 36 37 | """This script saves the cursor location when an editor is closed, and
restore it when the editor is reopened later on"""
############################################################################
## No user customization below this line
############################################################################
from GPS import *
def on_file_closed (hook, file):
buffer = EditorBuffer.get (file)
line = buffer.current_view().cursor().line()
column = buffer.current_view().cursor().column()
file.set_property ("lastloc_line", `line`, persistent=True)
file.set_property ("lastloc_column", `column`, persistent=True)
Logger ("FileLoc").log \
("Last location for " + file.name() + " is " + `line` + " " + `column`)
def on_file_edited (hook, file):
try:
buffer = EditorBuffer.get (file)
cursor = buffer.current_view().cursor()
# Do not change the line if the editor was already scrolled for
# any reason
if cursor.line() == 1 and cursor.column() == 1:
line = file.get_property ("lastloc_line")
column = file.get_property ("lastloc_column")
Logger ("FileLoc").log ("Restoring last location " + line + " " + column)
buffer.current_view().goto \
(EditorLocation (buffer, int (line), int (column)))
except:
pass
Hook ("file_closed").add (on_file_closed)
Hook ("file_edited").add (on_file_edited)
|