Skip to content

Cannot call send_message with python string #32

Description

@scriptum

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions