当前位置: 首页>>代码示例>>Python>>正文


Python Lib.get_cur_point方法代码示例

本文整理汇总了Python中Lib.get_cur_point方法的典型用法代码示例。如果您正苦于以下问题:Python Lib.get_cur_point方法的具体用法?Python Lib.get_cur_point怎么用?Python Lib.get_cur_point使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lib的用法示例。


在下文中一共展示了Lib.get_cur_point方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: merge_css

# 需要导入模块: import Lib [as 别名]
# 或者: from Lib import get_cur_point [as 别名]
def merge_css(self, edit, setlists):
    '''压缩样式内容'''
    view = self.view
    sel = view.sel()

    syntax = view.settings().get('syntax')
    _fsyntax_ = re.search(r'\/([\w ]+)\.',syntax)
    # 取得文件类型
    fsyntax = _fsyntax_.group(1)
    # 未选中时默认处理方式
    notSel = setlists['notSel']

    if fsyntax == 'CSS' or fsyntax == 'HTML':
        for region in sel:
            if region.empty():# 如果没有选中
                if fsyntax == 'CSS' and notSel == 'all':
                    # 全选
                    region = sublime.Region(0, view.size())
                    # 整理文本
                    text = merge_line(view.substr(region), setlists)
                    view.replace(edit, region, text)
                # 处理HTML文件中的STYLE标签
                elif fsyntax == 'HTML' and notSel == 'all':
                    if ST2:
                        rules = Lib.expand_to_style(view, region)
                    else:
                        rules = modeCSS.Lib.expand_to_style(view, region)
                    # 倒序替换
                    for i in range(len(rules)-1, -1,-1):
                        # 整理文本
                        text = merge_line(view.substr(rules[i]), setlists)
                        view.replace(edit, rules[i], text)
                else:
                    if ST2:
                        region = Lib.expand_to_css_rule(view, region)
                    else:
                        region = modeCSS.Lib.expand_to_css_rule(view, region)
                    # 整理文本
                    text = merge_line(view.substr(region), setlists)
                    view.replace(edit, region, text)
            else:
                if notSel == 'all':
                    # 全选
                    region = sublime.Region(0, view.size())
                if ST2:
                    region = Lib.get_cur_point(view,region)
                else:
                    region = modeCSS.Lib.get_cur_point(view,region)
                # 整理文本
                text = merge_line(view.substr(region), setlists)
                view.replace(edit, region, text)
开发者ID:chenermeng,项目名称:modeCSS,代码行数:53,代码来源:MergeCss.py

示例2: run

# 需要导入模块: import Lib [as 别名]
# 或者: from Lib import get_cur_point [as 别名]
    def run(self, edit):
        view = self.view
        sel = view.sel()

        syntax = view.settings().get("syntax")
        _fsyntax_ = re.search(r"\/([\w ]+)\.", syntax)
        # 取得文件类型
        fsyntax = _fsyntax_.group(1)

        if ST2:
            setlists = Lib.get_default_set()
            project_dir = setlists["default_porject_path"] or Lib.get_dis(view)
        else:
            setlists = modeCSS.Lib.get_default_set()
            project_dir = setlists["default_porject_path"] or modeCSS.Lib.get_dis(view)

        for region in sel:
            _pic_path_ = []
            if ST2:
                _region = Lib.get_cur_point(view, region)
            else:
                _region = modeCSS.Lib.get_cur_point(view, region)

            if _region:
                # 取得图片路径列表
                rules_ = expand_pic_in_html(_region, view.substr(_region))

                if len(rules_) > 0:
                    for rules in rules_:
                        for pic_path_ in rules:
                            if project_dir:
                                # 相对路径转绝对路径
                                if ST2:
                                    _pic_path = Lib.get_abs_path(pic_path_[1], project_dir)
                                else:
                                    _pic_path = modeCSS.Lib.get_abs_path(pic_path_[1], project_dir)

                                _temp_ = []
                                if os.path.isfile(_pic_path):
                                    _temp_.append(pic_path_[0])
                                    _temp_.append(encode_pic(_pic_path))
                                else:
                                    _temp_.append("")
                                    _temp_.append(_pic_path)

                                _pic_path_.append(_temp_)

                reg_rule = re.compile(r"(<img[^>]+src\s*=\s*[\'\"])[^\'\"]+([\'\"][^>]*>)", re.I)
                reg_background = re.compile(
                    r"(background(?:\s*\:|-image\s*\:).*?url\([\'|\"]?)[\w+:\/\/^]?[^? \}]*\.\w+\?*.*?([\'|\"]?\))",
                    re.I,
                )
                reg_filter = re.compile(
                    r"(Microsoft\.AlphaImageLoader\(.*?src=[\'|\"]?)[\w:\/\/\.]*\.\w+\?*.*?([\'|\"]?.*?\))", re.I
                )

                if len(_pic_path_) > 0:
                    for i in range(len(_pic_path_) - 1, -1, -1):  # 倒序替换
                        if _pic_path_[i][0]:
                            if ST2:
                                _region = Lib.point_to_region(_pic_path_[i][0])
                            else:
                                _region = modeCSS.Lib.point_to_region(_pic_path_[i][0])

                            text = reg_rule.sub("\\1" + _pic_path_[i][1] + "\\2", view.substr(_region))
                            self.view.replace(edit, _region, text)
                            text = reg_background.sub("\\1" + _pic_path_[i][1] + "\\2", view.substr(_region))
                            self.view.replace(edit, _region, text)
                            text = reg_filter.sub("\\1" + _pic_path_[i][1] + "\\2", view.substr(_region))
                            self.view.replace(edit, _region, text)

                            if setlists["base64_fold"]:
                                fold_base64(view)
开发者ID:ghostzhang,项目名称:modeCSS,代码行数:75,代码来源:EncodePic.py


注:本文中的Lib.get_cur_point方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。