ToolTipHelper.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:ToolTip-Helper 作者: doobleweb 项目源码 文件源码
def run(self, edit):
        if CURRENT_VERSION:
            # get the cursor point
            sel = self.selEvent if self.selEvent != None else self.view.sel()[0].begin()
            # get the current scope of cursor position
            current_scope = self.view.scope_name(sel)
            # update scope in status bar
            sublime.status_message("scope: %s" % current_scope)
            # get user selection in string
            sel = self.get_user_selection(sel)
            tooltip_files_arr = self.get_tooltip_files(current_scope)
            # do match with user selection and return the result
            results = self.match_selection(sel, tooltip_files_arr, current_scope)
            for result in results:
                # get the correct link if there is 
                link = self.has_link(result)
                location = ""
                file_name = ""
                if 'location' in result:
                    location = result['location']
                    file_name = result['file_name']
                    html_tooltip = Utilities.result_format(result['json_result'], 
                                                            self.keyorder, 
                                                            link,
                                                            self.style, 
                                                            location, 
                                                            file_name)
                else:
                    html_tooltip = Utilities.result_format(result['json_result'], 
                                                            self.keyorder, 
                                                            link,
                                                            self.style)
                # edit the result in html for tooltip window
                self.results_arr.append(html_tooltip)
            # this names will be in the output panel
            names = self.get_file_names(results)
            # write logging to logger file
            if self.has_debug:
                print(self.logger_msg)
            num_of_results = len(self.results_arr)
            if num_of_results == 1:
                self.show_tooltip_popup(self.results_arr[0])
            elif num_of_results > 1:
                if self.last_choosen_fun != sel:
                    self.last_index = 0
                    self.last_choosen_fun = sel
                sublime.active_window().show_quick_panel(names, self.on_done, 
                                                        sublime.MONOSPACE_FONT, 
                                                        self.last_index)
            else:
                print("documentation not exist")
                # self.show_tooltip_popup("documentation not exist")
    # <doc>
    # des: pp
    # </doc>
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号