-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
I'm trying to write simple autocomplete plugin:
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import geany, os, gettext, re, glob
from ctypes import *
gsc = geany.scintilla
gsc.WORDSTARTPOSITION = 2266
gsc.AUTOCSHOW = 2100
gsc.AUTOCACTIVE = 2102
class AutocompleteFilePlugin(geany.Plugin):
__plugin_name__ = "Autocomplete file names"
__plugin_description__ = ("Autocompletion based on existing files")
__plugin_version__ = "0.1"
__plugin_author__ = "Pavel Roschin <rpg89(at)post(dot)ru>"
def editor_cb(self, obj, editor, nt):
if nt.nmhdr.code != gsc.MODIFIED: return False
if not nt.modification_type & (gsc.MOD_INSERT_TEXT | gsc.MOD_DELETE_TEXT): return False
sci = editor.scintilla
if sci.has_selection(): return False
ssm = sci.send_message
if ssm(gsc.AUTOCACTIVE): return False
line = sci.get_current_line()
start = sci.get_position_from_line(line)
end = sci.get_current_position()
if nt.modification_type & gsc.MOD_INSERT_TEXT: end += 1
if start == end: return False
col = sci.get_col_from_position(end)
if col > 100: return False
text = sci.get_contents_range(start, end)
match = re.search('[^\s\'"<>()]+$', text)
if not match: return False
path = match.group(0)
paths = glob.glob(path+'*')
if len(paths) == 0: return False
print "\n".join(paths)
# ssm(gsc.AUTOCSHOW, len(path), "\n".join(paths))
def __init__(self):
geany.Plugin.__init__(self)
geany.signals.connect("editor-notify", self.editor_cb)Problematic line: ssm(gsc.AUTOCSHOW, len(path), "\n".join(paths)). Geany crashes if string passed to send_message function.
Metadata
Metadata
Assignees
Labels
No labels