示例#1
0
    def _handle_completions_response(self, msg) -> None:
        text = editor_helpers.get_active_text_widget()
        if not text:
            return

        source, row, column = editor_helpers.get_relevant_source_and_cursor_position(
            text)

        if msg.get("error"):
            self._close_box()
            messagebox.showerror("Autocomplete error",
                                 msg.error,
                                 master=get_workbench())
        elif msg.source != source or msg.row != row or msg.column != column:
            # situation has changed, information is obsolete
            # ignore this event
            return
        elif not msg.completions:
            # the user typed something which is not completable
            self._close_box()
            return
        else:
            if not self._completions_box:
                self._completions_box = CompletionsBox(self)
            self._completions_box.present_completions(text, msg.completions)
示例#2
0
    def _on_autocomplete_insertion(self, event=None):
        text = get_active_text_widget()
        if not text:
            return

        if (self._box_is_visible() or self._should_show_automatically()
                and text.get("insert -1 chars") == "("):
            self.request_calltip_for_text(text)
示例#3
0
    def request_completions(self, event=None) -> None:
        if self._box_is_visible():
            self._completions_box.request_details()
            return

        text = editor_helpers.get_active_text_widget()
        if text:
            self.request_completions_for_text(text)
        else:
            get_workbench().bell()
示例#4
0
    def handle_response(self, msg) -> None:
        text = get_active_text_widget()
        if not text:
            return

        source, row, column = editor_helpers.get_relevant_source_and_cursor_position(text)

        if msg.get("error"):
            self._hide_box()
            messagebox.showerror("Calltip error", msg.error, master=get_workbench())
        elif msg.source != source or msg.row != row or msg.column != column:
            # situation has changed, information is obsolete
            return
        elif not msg.signatures:
            logger.debug("Back-end gave 0 signatures")
            self._hide_box()
        else:
            if not self._calltip_box:
                self._calltip_box = CalltipBox(self)
            self._calltip_box.present_signatures(text, msg.signatures)
示例#5
0
 def request_calltip(self) -> None:
     text = get_active_text_widget()
     if not text:
         return
     self.request_calltip_for_text(text)