示例#1
0
 def on_tree_tree_sel_changed(self, evt):
     item = evt.Item
     txt = self.FindWindowByName("text")
     if self.prev_node and txt.IsModified():
         orgutils.set_org_text(self.prev_node, txt.Value)
         self.file.modified = True
     node = self.FindWindowByName("tree").GetItemPyData(item)
     lines = [i.decode("UTF-8") for i in node.content if isinstance(i, str)]
     text = "".join(lines).strip()  # The newlines are in the input already
     txt.Value = text
     self.prev_node = node
     rid = xrc.XRCID("remove")
     # Removing the only node of the 1st level would break everything else
     if node.level == 1 and len(node.parent.content) == 1:
         self.MenuBar.Enable(rid, False)
     else:
         self.MenuBar.Enable(rid, True)
     # And some movement operations would not be possible as well in some cases
     self.MenuBar.Enable(xrc.XRCID("left"), node.level != 1)
     self.MenuBar.Enable(xrc.XRCID("right"), len(node.parent.content) != 1)
     self.MenuBar.Enable(xrc.XRCID("up"),
                         node.parent.content.index(node) != 0)
     self.MenuBar.Enable(xrc.XRCID("down"), node.parent.content[-1] != node)
     # Time recording if requested
     if self.file.track_times:
         orgutils.set_node_property(node, "accessed",
                                    orgutils.current_time())
示例#2
0
 def on_tree_tree_sel_changed(self, evt):
     item = evt.Item
     txt = self.FindWindowByName("text")
     if not txt:
         print("Failed to get the text control?")
         return
     if self.prev_node and txt.IsModified():
         orgutils.set_org_text(self.prev_node, txt.Value)
         self.file.modified = True
     node = self.FindWindowByName("tree").GetItemData(item)
     lines = [i for i in node.content if isinstance(i, str)] # It ends with a new line anyway, see the modification in PyOrgMode.py.
     text = "".join(lines)
     txt.Value = text
     self.prev_node = node
     rid = xrc.XRCID("remove")
     # Removing the only node of the 1st level would break everything else
     if node.level == 1 and len(node.parent.content) == 1:
         self.MenuBar.Enable(rid, False)
     else:
         self.MenuBar.Enable(rid, True)
     # And some movement operations would not be possible as well in some cases
     self.MenuBar.Enable(xrc.XRCID("left"), node.level != 1)
     self.MenuBar.Enable(xrc.XRCID("right"), len(node.parent.content) != 1)
     self.MenuBar.Enable(xrc.XRCID("up"), node.parent.content.index(node) != 0)
     self.MenuBar.Enable(xrc.XRCID("down"), node.parent.content[-1] != node)
     # Time recording if requested
     if self.file.track_times:
         orgutils.set_node_property(node, "accessed", orgutils.current_time())
示例#3
0
 def create_node(self):		
     name = wx.GetTextFromUser(_("Enter a name for the new node"), _("Node title"), parent=self)
     if name:
         node = PyOrgMode.OrgNode.Element()
         node.heading = name
         if self.file.track_times:
             orgutils.set_node_property(node, "created", orgutils.current_time())
         return node, name
     return None, None # User cancelled or no name given
示例#4
0
 def update_current_node_text(self):
     tree = self.tree
     txt = self.FindWindowByName("text")
     if txt.IsModified():  # Persist current changes
         orgutils.set_org_text(tree.GetItemPyData(tree.Selection),
                               txt.Value)
         self.file.modified = True
         if self.file.track_times:
             orgutils.set_node_property(tree.GetItemPyData(tree.Selection),
                                        "modified", orgutils.current_time())
示例#5
0
 def create_node(self):
     name = wx.GetTextFromUser(_("Enter a name for the new node"),
                               _("Node title"),
                               parent=self)
     if name:
         node = PyOrgMode.OrgNode.Element()
         node.heading = name.encode(
             "UTF-8"
         )  # Needed, the library expects strs/does not care but does a + on the strings
         if self.file.track_times:
             orgutils.set_node_property(node, "created",
                                        orgutils.current_time())
         return node, name
     return None, None  # User cancelled or no name given
示例#6
0
 def update_current_node_text(self):
     tree = self.tree
     txt = self.FindWindowByName("text")
     if txt.IsModified(): # Persist current changes
         orgutils.set_org_text(tree.GetItemData(tree.Selection), txt.Value)
         self.file.modified = True    
         txt.SetModified(False)
         if self.file.track_times:
             orgutils.set_node_property(tree.GetItemData(tree.Selection), "modified", orgutils.current_time())