← Todos los ejemplos
Ejemplo 12
Workspace inspect
what is open in the terminal right now — charts, the active
- Categoría
- Espacio de trabajo: lee o cambia gráficos y paneles
- Permisos
- workspace.read
- Antes de ejecutarlo
- a terminal window (the T0 Lang window running in TTT)
- Qué hace
- none
- Cómo ejecutarlo
- in TTT, open "T0 Lang", open this file, grant workspace.read, Run.
- Lenguaje
>=0.1.1, <0.2.0- Host
>=0.1.3, <0.2.0- Necesita
- workspace >=0.1.2, <0.2.0
Código
// Purpose: what is open in the terminal right now — charts, the active // one and what it draws, the symbols on offer, the panels and the panel // kinds the terminal can open. Changes nothing. // Category: workspace // Permissions: workspace.read // Preconditions: a terminal window (the T0 Lang window running in TTT) // Side effects: none // Run: in TTT, open "T0 Lang", open this file, grant workspace.read, Run. lang ">=0.1.1, <0.2.0"; host "ttt" ">=0.1.3, <0.2.0"; requires "workspace" ">=0.1.2, <0.2.0"; fn main() -> Result<Unit, Error> { let charts = workspace.charts(); print(to_string(charts.len()) + " chart(s) open:"); for c in charts { let marker = if c.active { "*" } else { " " }; print(marker + " " + c.symbol + " " + c.timeframe + " " + to_string(workspace.indicators(c.chart)?)); } print(to_string(workspace.symbols().len()) + " symbols on offer"); let panels = workspace.panels(); print(to_string(panels.len()) + " panel(s):"); for p in panels { let marker = if p.focused { "*" } else { " " }; print(marker + " " + p.kind + ": " + p.title); } print("the terminal opens: " + to_string(workspace.panel_kinds())); return Ok(()); }