use editor_core::{
Command, CommandExecutor, CursorCommand, EditCommand, StyleCommand, StyleLayerId, ViewCommand,
};
fn main() {
let mut executor = CommandExecutor::empty(80);
executor
.execute(Command::View(ViewCommand::SetAutoPairsEnabled {
enabled: true,
}))
.unwrap();
executor
.execute(Command::Edit(EditCommand::TypeChar { ch: '(' }))
.unwrap();
executor
.execute(Command::Edit(EditCommand::TypeChar { ch: 'a' }))
.unwrap();
executor
.execute(Command::Edit(EditCommand::TypeChar { ch: ')' }))
.unwrap();
println!(
"after typing: text={:?} cursor={:?}",
executor.editor().get_text(),
executor.editor().cursor_position()
);
executor
.execute(Command::Cursor(CursorCommand::MoveTo {
line: 0,
column: 1,
}))
.unwrap();
executor
.execute(Command::Style(StyleCommand::UpdateBracketMatchHighlights))
.unwrap();
let highlight_count = executor
.editor()
.style_layer(StyleLayerId::BRACKET_MATCHES)
.map(|t| t.len())
.unwrap_or(0);
println!("bracket highlight intervals={highlight_count}");
executor
.execute(Command::Cursor(CursorCommand::MoveToMatchingBracket))
.unwrap();
println!(
"after jump cursor={:?}",
executor.editor().cursor_position()
);
}