Skip to main content

Module app

Module app 

Source
Expand description

Application state and event loop.

Everything that reads or changes scx.service goes through the backend, which is scxcli. The app holds the last listing it got back, the kernel’s own view read every tick, and the selections of the three views.

Re-exportsΒ§

use std::time::Duration; πŸ”’
use std::time::Instant; πŸ”’
use anyhow::Result; πŸ”’
use ratatui::DefaultTerminal; πŸ”’
use ratatui::crossterm::event; πŸ”’
use ratatui::crossterm::event::Event; πŸ”’
use ratatui::crossterm::event::KeyCode; πŸ”’
use ratatui::crossterm::event::KeyEvent; πŸ”’
use ratatui::crossterm::event::KeyEventKind; πŸ”’
use ratatui::crossterm::event::KeyModifiers; πŸ”’
use crate::backend::Backend; πŸ”’
use crate::kernel; πŸ”’
use crate::kernel::KernelState; πŸ”’
use crate::logs; πŸ”’
use crate::logs::LogLine; πŸ”’
use crate::model::DEFAULT_ID; πŸ”’
use crate::model::Installed; πŸ”’
use crate::model::Listing; πŸ”’
use crate::model::Pick; πŸ”’
use crate::model::validate_arg; πŸ”’
use crate::system::system_command; πŸ”’
use crate::ui; πŸ”’
use crate::watch::Watcher; πŸ”’

StructsΒ§

App
Input
A single-line text field. The cursor is counted in characters, so editing multi-byte input stays sound; the UI derives its cursor block from the same count.
Message

EnumsΒ§

PendingAction πŸ”’
Deferred user actions: queued by key handlers, executed by the event loop right after the frame announcing them has been drawn. scxcli blocks (a restart waits for the unit to come up, pkexec may prompt), so the UI must show feedback before the call starts.
View
Which screen is shown.

ConstantsΒ§

ACTION_DEBOUNCE πŸ”’
Minimum spacing between two scheduler-affecting actions. Linux terminals deliver key autorepeat as plain Press events, so without this, holding Enter would fire one start per repeat.
MESSAGE_TTL πŸ”’
How long informational messages stay in the message bar. Errors are exempt: they are actionable and stay until replaced.
REFRESH_EVERY πŸ”’
Slow poll for what inotify cannot see: the unit’s state and the process behind it. The catalog and environment files are refreshed on inotify events instead.
TICK πŸ”’
How often the input poll wakes up to redraw / refresh.

FunctionsΒ§

is_running
Whether id is the entry that runs, for the lists’ marker: the running scheduler’s name, or default while the kernel’s own runs.
is_selected
Whether id is what the next start would run, for the lists’ second marker: a selection that is stopped or failed.
step πŸ”’