def run(self, edit, onDone=None): self.onDone = onDone idValue = "TODAY" node = db.Get().AtInView(self.view) if (not node or node.is_root()): log.debug("Cannot update root node or non existent node as today") return file, at = db.Get().FindByCustomId(idValue) if (file != None and at != None): node = file.At(at) if (node): props.RemoveProperty(self.view, node, "CUSTOM_ID") node = db.Get().AtInView(self.view) if (node and not node.is_root()): props.UpdateProperty(self.view, node, "CUSTOM_ID", idValue, self.onDone)
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)
def on_done(self, text): if (text): # No spaces allowed in a custom id text = text.replace(" ", "-") node = db.Get().AtInView(self.view) if (node and not node.is_root()): props.UpdateProperty(self.view, node, "CUSTOM_ID", text, self.onDone)
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")