コード例 #1
0
ファイル: orglist.py プロジェクト: waynezhang/orgextended
def LookupNamedListInFile(name):
    l = None
    view = sublime.active_window().active_view()
    if (view):
        node = db.Get().AtInView(view)
        if (node):
            # Look for named objects in the file.
            names = node.names
            if (names and name in names):
                row = names[name]['row']
                last_row = view.lastRow()
                for r in range(row, last_row):
                    pt = view.text_point(r, 0)
                    line = view.substr(view.line(pt))
                    m = RE_ISCOMMENT.search(line)
                    if (m):
                        continue
                    elif (line.strip() == ""):
                        continue
                    else:
                        row = r
                        break
                pt = view.text_point(row, 0)
                reg = view.line(pt)
                line = view.substr(reg)
                if (numberedlist.isNumberedLine(view, reg)
                        or checkbox.isUnorderedList(line)):
                    l = ListData(view, pt)
    return l
コード例 #2
0
ファイル: orglist.py プロジェクト: waynezhang/orgextended
def IfListExtract(view, pt):
    l = None
    reg = view.line(pt)
    line = view.substr(reg)
    if (numberedlist.isNumberedLine(view, reg)
            or checkbox.isUnorderedList(line)):
        l = ListData(view, pt)
    return l
コード例 #3
0
ファイル: orglist.py プロジェクト: waynezhang/orgextended
 def __init__(self, view=None, pt=None):
     if (view != None):
         reg = view.line(pt)
         line = view.substr(reg)
         if (numberedlist.isNumberedLine(view, reg)):
             wasNumbered = True
             self.data = numberedlist.getListAtPoint(view, pt)
         elif (checkbox.isUnorderedList(line)):
             self.data = checkbox.getListAtPoint(view, pt)
         else:
             self.data = None
     else:
         self.data = []
コード例 #4
0
 def run(self, edit):
     line = self.view.curLine()
     cb = checkbox.get_checkbox(self.view, line)
     if (cb):
         self.view.run_command('org_insert_checkbox')
         return
     if (checkbox.isUnorderedList(self.view.substr(line))):
         self.view.run_command('org_insert_unordered_list')
         return
     if (numberedlist.isNumberedLine(self.view)):
         numberedlist.AppendLine(self.view, edit)
         return
     n = db.Get().AtInView(self.view)
     if (not n.is_root()):
         self.view.run_command('org_insert_heading_sibling')
コード例 #5
0
 def run(self, edit):
     line = self.view.curLine()
     cb = checkbox.get_checkbox(self.view, line)
     if (cb):
         editing.deindent_list(self.view, self.view.curRow(), edit)
         return
     if (checkbox.isUnorderedList(self.view.substr(line))):
         editing.deindent_list(self.view, self.view.curRow(), edit)
         return
     if (numberedlist.isNumberedLine(self.view)):
         editing.deindent_list(self.view, self.view.curRow(), edit)
         return
     n = db.Get().AtInView(self.view)
     if (n and type(n) != node.OrgRootNode):
         editing.deindent_node(self.view, n, edit)
         file = db.Get().FindInfo(self.view)
         file.LoadS(self.view)
コード例 #6
0
ファイル: orgediting.py プロジェクト: waynezhang/orgextended
    def run(self, edit):
        # Get a list of things
        things = None
        wasNumbered = False
        if (numberedlist.isNumberedLine(self.view)):
            wasNumbered = True
            things = numberedlist.getListAtPointForSorting(self.view)
        elif (checkbox.isUnorderedList(self.view.getLine(self.view.curRow()))):
            things = checkbox.getListAtPointForSorting(self.view)
        if (not things):
            log.error(" Could not sort at point")
            return
        # Build macro region
        start = things[0][0][0]
        end = things[len(things) - 1][0][1]
        sp = self.view.text_point(start, 0)
        ep = self.view.text_point(end, 0)
        ep = self.view.line(ep).end()
        reg = sublime.Region(sp, ep)

        # Sort the things
        sort_things_alphabetically(things)

        # Copy from macro region to sorted version
        buffer = ""
        for thing in things:
            bs = self.view.text_point(thing[0][0], 0)
            be = self.view.text_point(thing[0][1] - 1, 0)
            be = self.view.line(be).end()
            breg = sublime.Region(bs, be)
            ss = self.view.substr(breg).rstrip() + "\n"
            buffer += ss
        # Replace the macro region with new str
        self.view.replace(edit, reg, buffer)
        if (wasNumbered):
            self.view.run_command('org_update_numbered_list')
        pass