Okay started writing my first speech programming command for Leo. It's very 
simple. Given a line of text in a node, converted to a section heading and 
create a new section of that name. My intent is to look at the text on the 
line where the cursor is. Take the line, everything from the first nonwhite 
space character in the line to the last nonwhite space character in the 
line is used as the section heading. Any trailing whitespace is removed. By 
adding "<< " and " >>" as appropriate, I can use the text as a section 
heading both in the child node and in the original node. Focus is returned 
to the original node and the cursor moves down one line to prepare for the 
next running of the same command.

I'm not even close to having this even outlined but here is what I've 
pieced together from reading the docs.

last = c.lastTopLevel()

head, lines, tail, oldSel, oldYview = c.getBodyLines()

g.es(">>>"+type(head)+"<<<")

g.es(">>>"+type(tail)+"<<<")

g.es(">>>"+type(lines)+"<<<")

g.es(">>>"+type(oldSel)+"<<<")

g.es(">>>"+type(oldYview)+"<<<")

new_node.h = 'my net node'

new_node = p.insertAsLastChild().copy()

new_node.b = "'''\n'''"

c.redraw(new_node) # Selects the new node.



There's a bunch of things here that I'd don't understand but I'm making a 
guess. The new_node header and body code work. I can create a child node 
with the given name and a given body. But why did the example put a copy 
after insertAtLastChild? I'm also not sure how to invoke getBodyLines(). 
 it gives me a:

TypeError: must be str, not type
--------------------
  line 3: last = c.lastTopLevel()
* line 4: head, lines, tail, oldSel, oldYview = c.getBodyLines()
  line 5: g.es(">>>"+type(head)+"<<<")
  line 6: g.es(">>>"+type(tail)+"<<<")

I've been staring at this too much for it to make sense anymore.

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to