def on_view_key_press_event(self, view, event):
        """Display the completion window or complete the current word."""
        active_doc = self.window.get_active_document()
        # If the current tab is not a Haxe sourcefile, do not attempt to complete
        # TODO It would be best to never get called in the first place.

        try:
            if not active_doc.get_uri ().endswith ('hx'):
                return self.cancel ()
        except:
            return self.cancel ()

        #  The "Alt"-key might be mapped to something else
        # TODO Find out which keybinding are already in use.
        keybinding = configuration.getKeybindingCompleteTuple()
        ctrl_pressed = (event.state & gtk.gdk.CONTROL_MASK) == gtk.gdk.CONTROL_MASK
        #alt_pressed = (event.state & gtk.gdk.MOD1_MASK) == gtk.gdk.MOD1_MASK
        #shift_pressed = (event.state & gtk.gdk.SHIFT_MASK) == gtk.gdk.SHIFT_MASK
        keyval = gtk.gdk.keyval_from_name(keybinding[configuration.KEY])
        key_pressed = (event.keyval == keyval)

        # It's ok if a key is pressed and it's needed or
        # if a key is not pressed if it isn't needed.
        ctrl_ok = not (keybinding[configuration.MODIFIER_CTRL] ^ ctrl_pressed )
        #alt_ok =  not (keybinding[configuration.MODIFIER_ALT] ^ alt_pressed )
        #shift_ok = not (keybinding[configuration.MODIFIER_SHIFT] ^ shift_pressed )

        if ctrl_ok and key_pressed or event.keyval == gtk.keysyms.period or event.keyval == gtk.keysyms.parenleft:
            return self.display_completions(view, event)
        
        return self.cancel()
    def on_view_key_press_event(self, view, event):
        """Display the completion window or complete the current word."""
        active_doc = self.window.get_active_document()
        if active_doc is None or active_doc.get_mime_type() != 'text/x-python':
            return self.cancel()

        # FIXME This might result in a clash with other plugins eg. snippets
        # FIXME This code is not portable! 
        #  The "Alt"-key might be mapped to something else
        # TODO Find out which keybinding are already in use.
        keybinding = configuration.getKeybindingCompleteTuple()
        ctrl_pressed = (event.state & gtk.gdk.CONTROL_MASK) == gtk.gdk.CONTROL_MASK
        alt_pressed = (event.state & gtk.gdk.MOD1_MASK) == gtk.gdk.MOD1_MASK
        shift_pressed = (event.state & gtk.gdk.SHIFT_MASK) == gtk.gdk.SHIFT_MASK
        keyval = gtk.gdk.keyval_from_name(keybinding[configuration.KEY])
        key_pressed = (event.keyval == keyval)

        # It's ok if a key is pressed and it's needed or
        # if a key is not pressed if it isn't needed.
        ctrl_ok = not (keybinding[configuration.MODIFIER_CTRL] ^ ctrl_pressed )
        alt_ok =  not (keybinding[configuration.MODIFIER_ALT] ^ alt_pressed )
        shift_ok = not (keybinding[configuration.MODIFIER_SHIFT] ^ shift_pressed )

        if ctrl_ok and alt_ok and shift_ok and key_pressed or event.keyval == gtk.keysyms.period:
            return self.display_completions(view, event)
        
        return self.cancel()
Esempio n. 3
0
    def on_view_key_press_event(self, view, event):
        """Display the completion window or complete the current word."""
        active_doc = self.window.get_active_document()
        # If the current tab is not a Haxe sourcefile, do not attempt to complete
        # TODO It would be best to never get called in the first place.

        try:
            if not active_doc.get_uri().endswith('hx'):
                return self.cancel()
        except:
            return self.cancel()

        #  The "Alt"-key might be mapped to something else
        # TODO Find out which keybinding are already in use.
        keybinding = configuration.getKeybindingCompleteTuple()
        ctrl_pressed = (event.state
                        & gtk.gdk.CONTROL_MASK) == gtk.gdk.CONTROL_MASK
        #alt_pressed = (event.state & gtk.gdk.MOD1_MASK) == gtk.gdk.MOD1_MASK
        #shift_pressed = (event.state & gtk.gdk.SHIFT_MASK) == gtk.gdk.SHIFT_MASK
        keyval = gtk.gdk.keyval_from_name(keybinding[configuration.KEY])
        key_pressed = (event.keyval == keyval)

        # It's ok if a key is pressed and it's needed or
        # if a key is not pressed if it isn't needed.
        ctrl_ok = not (keybinding[configuration.MODIFIER_CTRL] ^ ctrl_pressed)
        #alt_ok =  not (keybinding[configuration.MODIFIER_ALT] ^ alt_pressed )
        #shift_ok = not (keybinding[configuration.MODIFIER_SHIFT] ^ shift_pressed )

        if ctrl_ok and key_pressed or event.keyval == gtk.keysyms.period or event.keyval == gtk.keysyms.parenleft:
            return self.display_completions(view, event)

        return self.cancel()
Esempio n. 4
0
    def on_view_key_press_event(self, view, event):
        """Display the completion window or complete the current word."""
        active_doc = self.window.get_active_document()
        if active_doc is None or active_doc.get_mime_type() != 'text/x-python':
            return self.cancel()

        # FIXME This might result in a clash with other plugins eg. snippets
        # FIXME This code is not portable!
        #  The "Alt"-key might be mapped to something else
        # TODO Find out which keybinding are already in use.
        keybinding = configuration.getKeybindingCompleteTuple()
        ctrl_pressed = (event.state
                        & gtk.gdk.CONTROL_MASK) == gtk.gdk.CONTROL_MASK
        alt_pressed = (event.state & gtk.gdk.MOD1_MASK) == gtk.gdk.MOD1_MASK
        shift_pressed = (event.state
                         & gtk.gdk.SHIFT_MASK) == gtk.gdk.SHIFT_MASK
        keyval = gtk.gdk.keyval_from_name(keybinding[configuration.KEY])
        key_pressed = (event.keyval == keyval)

        # It's ok if a key is pressed and it's needed or
        # if a key is not pressed if it isn't needed.
        ctrl_ok = not (keybinding[configuration.MODIFIER_CTRL] ^ ctrl_pressed)
        alt_ok = not (keybinding[configuration.MODIFIER_ALT] ^ alt_pressed)
        shift_ok = not (keybinding[configuration.MODIFIER_SHIFT]
                        ^ shift_pressed)

        if ctrl_ok and alt_ok and shift_ok and key_pressed or event.keyval == gtk.keysyms.period:
            return self.display_completions(view, event)

        return self.cancel()
    def on_view_key_press_event(self, view, event):
        #self.t = time.time()
        #print self.t
        #print "on_view_key_press_event started"

        #print "view event.keyval %s" % event.keyval
        if self.islaunching:
            self.tempstring += event.string
        """Display the completion window or complete the current word."""
        active_doc = self.window.get_active_document()
        #print "active_doc.get_uri_for_display() %s ." % active_doc.get_uri_for_display()
        #print "active_doc.get_short_name_for_display() %s ." % active_doc.get_short_name_for_display()
        # If the current tab is not a Haxe sourcefile, do not attempt to complete
        # TODO It would be best to never get called in the first place.

        try:
            if not active_doc.get_uri_for_display().endswith('hx'):
                return self.cancel()
        except:
            return self.cancel()

        #  The "Alt"-key might be mapped to something else
        # TODO Find out which keybinding are already in use.
        keybinding = configuration.getKeybindingCompleteTuple()

        ctrl_pressed = (
            event.state
            & Gdk.ModifierType.CONTROL_MASK) == Gdk.ModifierType.CONTROL_MASK
        alt_pressed = (
            event.state
            & Gdk.ModifierType.MOD1_MASK) == Gdk.ModifierType.MOD1_MASK
        shift_pressed = (
            event.state
            & Gdk.ModifierType.SHIFT_MASK) == Gdk.ModifierType.SHIFT_MASK
        # It's ok if a key is pressed and it's needed or
        # if a key is not pressed if it isn't needed.
        ctrl_ok = not (keybinding[configuration.MODIFIER_CTRL] ^ ctrl_pressed)
        alt_ok = not (keybinding[configuration.MODIFIER_ALT] ^ alt_pressed)
        shift_ok = not (keybinding[configuration.MODIFIER_SHIFT]
                        ^ shift_pressed)

        keyval = Gdk.keyval_from_name(keybinding[configuration.KEY])
        key_ok = (event.keyval == keyval)

        #print time.time() - self.t
        #print "on_view_key_press_event done"
        #self.t = time.time()

        if event.keyval == Gdk.KEY_period and configuration.getDotComplete():
            return self.display_completions(view, event)
        elif ctrl_ok and alt_ok and shift_ok and key_ok:
            return self.display_completions(view, event)

        return self.cancel()