Exemple #1
0
 def run(self, edit, dateval=None):
     if (type(dateval) == str):
         dateval = orgdate.OrgDateFreeFloating.from_str(dateval)
     # TODO: Find scheduled and replace it as well.
     node = db.Get().AtInView(self.view)
     if (node and not node.is_root()):
         self.oldsel = self.view.sel()[0]
         pt = self.view.text_point(node.start_row, 0)
         l = self.view.line(pt)
         # Last row handling If we are the last row we can't jump over the newline
         # we have to add one.
         nl = ""
         addnl = 1
         if (self.view.isBeyondLastRow(node.start_row + 1)):
             nl = "\n"
             addnl = 0
         insertpt = l.end() + addnl
         endpt = insertpt + len(nl) + len(node.indent()) + len(self.prefix)
         self.reg = sublime.Region(insertpt, endpt)
         self.view.insert(edit, insertpt, nl + node.indent() + self.prefix)
         pt = self.view.text_point(node.start_row + 1, 0)
         l = self.view.line(pt)
         self.view.sel().clear()
         self.view.sel().add(l.end())
         if (dateval == None):
             datep.Pick(evt.Make(self.insert))
         else:
             self.insert(dateval)
Exemple #2
0
def InsertClosed(view, node, onDone=None):
    stamp = OrgDate.format_clock(datetime.datetime.now(), active=False)
    closedPt = LocateClosed(view, node)
    if (closedPt):
        text = node.indent() + "CLOSED: " + stamp
        view.ReplaceRegion(closedPt, text, onDone)
    else:
        row = node.start_row + 1
        pt = view.text_point(row, 0)
        newline = "\n" if view.isBeyondLastRow(row) else ""
        text = newline + node.indent() + "CLOSED: " + stamp + "\n"
        view.Insert(pt, text, onDone)
Exemple #3
0
 def run(self, edit):
     node = db.Get().AtInView(self.view)
     if (not node.is_root()):
         self.oldsel = self.view.sel()[0]
         pt = self.view.text_point(node.start_row, 0)
         l = self.view.line(pt)
         # Last row handling If we are the last row we can't jump over the newline
         # we have to add one.
         nl = ""
         addnl = 1
         if (self.view.isBeyondLastRow(node.start_row + 1)):
             nl = "\n"
             addnl = 0
         now = datetime.datetime.now()
         toInsert = orgdate.OrgDate.format_clock(now, False)
         self.view.insert(edit,
                          l.end() + addnl,
                          nl + node.indent() + "CLOSED: " + toInsert + "\n")