RemoteShellViewModel

class RemoteShellViewModel(val destNum: Int, dispatchers: CoroutineDispatchers, nodeRepository: NodeRepository, commandSender: CommandSender, remoteShellHandler: RemoteShellHandler, applicationScope: ApplicationCoroutineScope) : ViewModel(source)

Terminal session against the firmware DMShell module.

The protocol lives in RemoteShellLink, the screen model in TerminalOutput and predictive echo in LocalEcho; all three are mutated only under linkMutex, so a frame, a tick and a keystroke never interleave. This class owns the clock, the radio and the UI state.

Two input modes. Character mode streams keystrokes (debounced into one frame per burst) so tab completion, line editing and prompts behave as on any terminal, and draws what was sent with LocalEcho until the node echoes it. Line mode composes the whole command locally and sends it in one frame, the cheapest way to spend airtime; it keeps a local history so recalling a command costs no round trip.

Constructors

Link copied to clipboard
constructor(destNum: Int, dispatchers: CoroutineDispatchers, nodeRepository: NodeRepository, commandSender: CommandSender, remoteShellHandler: RemoteShellHandler, applicationScope: ApplicationCoroutineScope)

Types

Link copied to clipboard
Link copied to clipboard

Properties

Link copied to clipboard
val bell: SharedFlow<Unit>
Link copied to clipboard
val composer: StateFlow<String>
Link copied to clipboard
Link copied to clipboard
val fontSizeSp: StateFlow<Int>
Link copied to clipboard
val health: StateFlow<LinkHealth>
Link copied to clipboard
val history: StateFlow<List<String>>
Link copied to clipboard
Link copied to clipboard
val modifiers: StateFlow<Modifiers>
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
expect open fun addCloseable(closeable: AutoCloseable)
expect fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard
fun adjustFontSize(deltaSp: Int)
Link copied to clipboard
Link copied to clipboard
expect fun <T : AutoCloseable> getCloseable(key: String): T?
Link copied to clipboard
fun insertCommand(command: String)
Link copied to clipboard
Link copied to clipboard
fun paste(text: String)

Clipboard text: typed in character mode, appended to the composer in line mode.

Link copied to clipboard

Steps the composer through local history: older true walks back, false walks forward to an empty line.

Link copied to clipboard
fun resize(cols: Int, rows: Int)
Link copied to clipboard
fun sendKey(key: RemoteKey)

An extra-keys or hardware key. Pending typing goes first so the bytes reach the PTY in the order pressed.

Link copied to clipboard
fun setComposer(text: String)
Link copied to clipboard
Link copied to clipboard

Sends the composed line in one frame; an empty line still sends Enter, which a prompt may be waiting for.

Link copied to clipboard
fun toggleAlt()
Link copied to clipboard
Link copied to clipboard

Edits the unsent buffer while there is one; past it, the remote line, by sending DEL.

Link copied to clipboard
fun typeChord(char: Char, ctrl: Boolean, alt: Boolean)

A hardware Ctrl/Alt chord. Any armed sticky modifier applies on top, as it would to a typed key.

Link copied to clipboard
fun typeEnter()
Link copied to clipboard
fun typeKey(char: Char)

A typed character. With a sticky modifier armed it is sent at once as the modified byte(s).