This class represents a bullet or checkbox list in a TextBuffer
. It is used to perform recursive actions on the list.
While the TextBuffer
just treats list items as lines that start with a bullet, the TextBufferList maps to a number of lines that together form a list. It uses "row ids" to refer to specific items within this range.
TextBufferList objects will become invalid after any modification to the buffer that changes the line count within the list. Using them after such modification will result in errors.
Class Method | new_from_line |
Constructor for a new TextBufferList mapping the list at a specific line in the buffer |
Method | __init__ |
Constructor |
Method | can_indent |
Check whether a specific item in the list can be indented |
Method | can_unindent |
Check if a specific item in the list has indenting which can be reduced |
Method | get_row_at_line |
Get the row in the list for a specific line |
Method | indent |
Indent a list item and all it's children |
Method | set_bullet |
Set the bullet type for a specific item and update parents and children accordingly |
Method | unindent |
Un-indent a list item and it's children |
Constant | BULLET_COL |
Undocumented |
Constant | INDENT_COL |
Undocumented |
Constant | LINE_COL |
Undocumented |
Instance Variable | buffer |
Undocumented |
Instance Variable | firstline |
Undocumented |
Instance Variable | lastline |
Undocumented |
Method | _change_bullet_type |
Undocumented |
Method | _checkbox_checked |
Undocumented |
Method | _checkbox_unchecked |
Undocumented |
Method | _indent |
Undocumented |
Method | _indent_row |
Undocumented |
Method | _parents |
Undocumented |
Parameters | |
textbuffer | a TextBuffer object |
line | a line number This line should be part of a list, the TextBufferList object that is returned maps the full list, so it possibly extends above and below line. |
Returns | |
a 2-tuple of a row id and a the new TextBufferList object, or (None, None) if line is not part of a list. The row id points to line in the list. |
Parameters | |
textbuffer | a TextBuffer object |
firstline | the line number for the first line of the list |
lastline | the line number for the last line of the list |
Check whether a specific item in the list can be indented
List items can only be indented if they are on top of the list or when there is some node above them to serve as new parent node. This avoids indenting two levels below the parent.
So e.g. in the case of:
* item a * item b
then "item b" can indent and become a child of "item a". However after indenting once:
* item a * item b
now "item b" can not be indented further because it is already one level below "item a".
Parameters | |
row | the row id |
Returns | |
True when indenting is possible |
Parameters | |
row | the row id |
Returns | |
True when the item has indenting |
Parameters | |
line | the line number for a line in the TextBuffer |
Returns | |
the row id for a row in the list or None when the line was outside of the list |
Indent a list item and all it's children
For example, when indenting "item b" in this list:
* item a * item b * item C
it will result in:
* item a * item b * item C
Parameters | |
row | the row id |
Returns | |
True if successfulll |
Set the bullet type for a specific item and update parents and children accordingly
Used to (un-)check the checkboxes and synchronize child nodes and parent nodes. When a box is checked, any open child nodes are checked. Also when this is the last checkbox on the given level to be checked, the parent box can be checked as well. When a box is un-checked, also the parent checkbox is un-checked. Both updating of children and parents is recursive.
Parameters | |
row | the row id |
bullet | the bullet type, which can be one of: BULLET CHECKED_BOX UNCHECKED_BOX XCHECKED_BOX MIGRATED_BOX TRANSMIGRATED_BOX |