Lines
90.48 %
Functions
50 %
Branches
100 %
//! Intents of the rows-like widgets: selects, rows lists and the split tag list.
use super::{Intent, apply_editor_intent};
use crate::widgets::{RowsWidget, SelectWidget, SplitsWidget};
pub(super) fn apply_select_intent(sw: &mut SelectWidget, intent: Intent) {
match intent {
Intent::SelectNext => sw.next(),
Intent::SelectPrev => sw.prev(),
Intent::SelectConfirm => sw.confirm(),
Intent::SelectOpen => sw.open_list(),
Intent::SelectCancel => sw.cancel(),
Intent::SelectPick(index) => sw.pick(index),
Intent::SelectPageUp => sw.page(false),
Intent::SelectPageDown => sw.page(true),
Intent::InsertChar(c) => sw.filter_push(c),
Intent::DeleteBackward => sw.filter_pop(),
_ => {}
}
pub(super) fn apply_rows_intent(rw: &mut RowsWidget, intent: Intent) {
Intent::CellNext => rw.advance_cell(),
Intent::CellPrev => rw.retreat_cell(),
Intent::RowNext => rw.next_row(),
Intent::RowPrev => rw.prev_row(),
Intent::SplitAddRow => rw.add_row(),
Intent::SplitRemoveRow => rw.remove_row(),
Intent::InsertChar(c) if rw.is_empty() && !c.is_whitespace() => {
rw.add_row();
apply_rows_intent(rw, intent);
intent => {
if let Some(select) = rw.focused_select_mut() {
apply_select_intent(select, intent);
} else if let Some(editor) = rw.focused_editor_mut() {
apply_editor_intent(editor, intent);
pub(super) fn apply_tags_intent(sw: &mut SplitsWidget, intent: Intent) {
Intent::ToggleSplitTags => {
sw.close_tags();
Intent::SplitAddRow => sw.add_tag(),
Intent::InsertChar(c)
if !c.is_whitespace() && sw.tags().is_some_and(RowsWidget::is_empty) =>
{
sw.add_tag();
apply_tags_intent(sw, intent);
if let Some(rw) = sw.tags_mut() {