Lines
94.57 %
Functions
100 %
Branches
mod account_balances;
mod account_balances_future;
mod account_edit;
mod accounts_order;
mod arrange;
mod bulk_delete;
mod clipped;
mod close;
mod commodity_edit;
mod commodity_fill;
mod config_list;
mod console_eval;
mod console_streams;
mod convert;
mod corner_drag;
mod create;
mod cross_talk;
mod delete;
mod deliver;
mod desktop;
mod detail_refresh;
mod dialog_move;
mod dialog_origin;
mod dialog_title_drag;
mod discard;
mod edit;
mod edit_uuid;
mod empty_start;
mod filter_builder;
mod filter_builder_cells;
mod filter_builder_rows;
mod help_keys;
mod help_window;
mod hold;
mod instances;
mod kitty_clipped;
mod late_openers;
mod lossless;
mod merge;
mod merge_preview;
mod mutation_refresh;
mod new_row;
mod notice;
mod open;
mod options;
mod options_db;
mod options_overrides;
mod options_save;
mod origin;
pub(crate) mod overlap;
mod page_edge;
mod paging;
mod palette_args;
mod palette_leaves;
mod pending_place;
mod report;
mod report_args;
mod report_chart;
mod report_chart_override;
mod report_chart_refetch;
mod report_csv;
mod report_enter;
mod report_enter_server;
mod report_rerun;
mod request_ids;
mod resize;
mod script_bytecode;
mod script_forms;
mod scripts;
mod size_move;
mod ssh_keys;
mod ssh_keys_palette;
mod status;
mod tag_hints;
mod tags;
mod template_forms;
mod template_pick;
mod template_test;
mod templates;
mod text_area;
mod title_drag;
mod transaction;
mod transaction_detail;
mod transaction_filter;
mod transaction_list;
mod ui_config;
mod ui_keymap;
mod viewer;
mod window_clicks;
mod window_keys;
mod window_list;
mod window_seqs;
mod windows;
use super::*;
use crate::route::{Route, RouteCtx};
use crate::tabs::fetch::Fetch;
use crate::tabs::nms::ConsoleState;
use crate::tabs::nms_eval::ConsoleEval;
use crate::tabs::nms_eval::double::Sent;
use crate::view::{Tab, ViewId};
use crate::window::{View, WindowId};
use cli_core::render::ListRow;
impl App {
/// Opens a window of every view, so that each number is its view's digit, and raises
/// Accounts; Next from there reaches Transactions first.
pub(crate) fn open_every_view(&mut self) {
for kind in ViewId::ALL {
self.open_new_window(super::windows::new_view(kind));
}
if let Some(accounts) = self.window_id(ViewId::Accounts) {
self.raise_window(accounts);
/// The id of the most recent window of `kind`; the test fails when there is none.
pub(crate) fn window_of(&self, kind: ViewId) -> WindowId {
match self.window_id(kind) {
Some(id) => id,
None => panic!("no {kind:?} window"),
/// The window with TV number `number`; the test fails when there is none.
pub(crate) fn window_of_number(&self, number: u8) -> WindowId {
match self.windows.iter().find(|win| win.number == Some(number)) {
Some(win) => win.id,
None => panic!("no window {number}"),
/// How many windows of `kind` are open.
pub(crate) fn windows_of(&self, kind: ViewId) -> usize {
self.window_ids(kind).len()
/// Opens another window of `kind` in front and returns it.
pub(crate) fn open_extra(&mut self, kind: ViewId) -> WindowId {
self.open_new_window(super::windows::new_view(kind))
/// Toggles the zoom of the most recent window of `kind`.
pub(crate) fn toggle_zoom_of(&mut self, kind: ViewId) {
let id = self.window_of(kind);
self.desktop.toggle_zoom(id);
/// Brings the console to the front and gives its prompt the keyboard.
pub(crate) fn focus_console(&mut self) {
self.switch_tab(ViewId::Console);
self.set_console_focused(true);
/// The script routes awaiting a reply.
pub(crate) fn script_routes(&self) -> Vec<&crate::route::ScriptRoute> {
self.pending_routes
.values()
.filter_map(|route| match &route.ctx {
RouteCtx::Script(script) => Some(script),
_ => None,
})
.collect()
/// Attaches a recording console, without the config read `attach_console` starts.
pub(crate) fn attach_echo(&mut self) -> Sent {
let (eval, sent) = ConsoleEval::recording();
self.console_eval = Some(eval);
sent
/// Swaps in a console whose request ids ran out and whose replies are closed.
pub(crate) fn break_console(&mut self) {
self.console_eval = Some(ConsoleEval::broken());
/// Drains a real console until its UI config read is answered; false when it never is.
pub(crate) async fn await_ui_config_read(&mut self) -> bool {
for _ in 0..500 {
self.drain_eval();
let pending = self
.pending_routes
.any(|route| matches!(route.ctx, RouteCtx::UiConfig { .. }));
if !pending {
return true;
tokio::time::sleep(std::time::Duration::from_millis(20)).await;
false
#[test]
fn all_has_ten_tabs_console_ninth_scripts_last() {
assert_eq!(Tab::ALL.len(), 10);
assert_eq!(Tab::ALL[8], Tab::Console);
assert_eq!(Tab::ALL[9], Tab::Scripts);
fn console_label_is_console() {
assert_eq!(Tab::Console.label(), "Console");
#[tokio::test]
async fn attaching_the_console_opens_no_window() {
let mut app = crate::test_support::empty_app();
app.attach_console(ConsoleEval::recording().0);
assert_eq!(app.front_kind(), None);
fn switch_tab_sets_target() {
let mut app = crate::test_support::app();
app.switch_tab(Tab::Reports);
assert_eq!(app.front_kind(), Some(Tab::Reports));
fn open_and_close_command_line() {
assert!(!app.cmdline.active);
app.open_command_line();
assert!(app.cmdline.active);
app.close_command_line();
fn request_quit_sets_flag() {
assert!(!app.should_quit);
app.request_quit();
assert!(app.should_quit);