pub struct Tree { /* private fields */ }Expand description
A foldable, editable JSON/YAML value tree with a cursor and undo history.
Implementations§
Source§impl Tree
impl Tree
Sourcepub fn from_text(text: &str, format: Format) -> Result<Self, String>
pub fn from_text(text: &str, format: Format) -> Result<Self, String>
Parse text as JSON or YAML into a value tree. YAML’s parser also
accepts JSON.
§Errors
Returns the parser’s own message (line/column included) when text
does not parse, instead of discarding it (Run H, T543: this used to
return a bare Option, so the caller could only show a static “not
valid JSON or YAML” with no indication of what was actually wrong or
where).
Sourcepub fn is_editing(&self) -> bool
pub fn is_editing(&self) -> bool
Whether a scalar is currently being edited.
Sourcepub fn edit_buffer(&self) -> &str
pub fn edit_buffer(&self) -> &str
The in-progress edit text (valid while Tree::is_editing).
Sourcepub fn is_container(&self, i: usize) -> bool
pub fn is_container(&self, i: usize) -> bool
Whether visible row i is a container (object/array).
Sourcepub fn is_collapsed(&self, i: usize) -> bool
pub fn is_collapsed(&self, i: usize) -> bool
Whether visible row i is a collapsed container.
Sourcepub fn mark_saved(&mut self)
pub fn mark_saved(&mut self)
Mark the tree as saved (called by the host after a successful write).
Sourcepub fn ensure_visible(&mut self, height: usize)
pub fn ensure_visible(&mut self, height: usize)
Adjust the scroll so the selected row stays within a height-row window.
Sourcepub fn handle_key(&mut self, key: KeyEvent, page: usize) -> Outcome
pub fn handle_key(&mut self, key: KeyEvent, page: usize) -> Outcome
Interpret a key event and report what the host should do next.