Complete Task Manager terminal layout and mounted refresh

This commit is contained in:
waozi committed 2026-11-29 01:39:21 -03:00
1 parent 767e40681e
commit e8ded3000c
7 files changed
+250 -56

No files matched your search

+2 -2
View File
@@ -32,8 +32,8 @@ make performance-test # build the performance harness
## Pins
- Ziran toolchain: `bbaac5e493973e616e90f1f7ac84dfeb32134194`
- Kryon: `71a62c5a0d94960863338b25e8927eb1a78baae0`
- data_views: `239b593496354122ada2b163ad4b3c845045d02b`
- Kryon: `1044aea9592a8ea0c0906161131712540a7bc931`
- data_views: `97db6e2acdc62567cf0243b42f4dfd7d79bb7bc0`
Commit as Waozi <waozi@proton.me>; ordinary changes stay in CHANGELOG's
`Unreleased` section. Window tests scrub inherited display/session variables
+8 -1
View File
@@ -18,7 +18,12 @@
### Changed
- Pin Ziran bbaac5e4, Kryon 71a62c5a and DataViews 239b5934 so the process
- Keep the terminal profile in native character-cell units, with visible tabs,
process tables, performance readings, menus and dialogs.
- Tie terminal refresh deadlines to the mounted screen, honor paused updates
without idle repainting, and cancel timers when the screen closes.
- Pin Ziran bbaac5e4, Kryon 1044aea9 and DataViews 97db6e2a so the process
monitor and DataViews share exactly one Kryon in the application graph.
- Use the ordinary `ziran` package launcher for builds and packaging; remove
the duplicate local toolchain selection script.
@@ -41,6 +46,8 @@
### Fixed
- Keep text typed outside the command dialog from being inserted when that
dialog opens later.
- Sample real Linux host processes and DRM counters in the portable ZX profile
instead of clearing its snapshot. Use the host's clock, CPU tick rate and
page size, and keep ordinary ZX runners distinct from TaijiOS task guests.
+6
View File
@@ -87,6 +87,12 @@ The desktop profile opens an SDL2 window through Kryon's `desktop` backend.
The `tui`, `web`, and `portable` profiles use the same
application `Frame` declared in `ziran.toml`.
Run `ziran run tui` for the 80 × 24 character-cell interface. Press 1, 2 or 3
to change tabs, or Ctrl+F to enter the menu bar; arrow keys, Home/End and Enter
navigate its menus. Escape closes a menu or dialog, and Ctrl+C exits while
restoring the terminal. View → Update Speed controls the same model refresh
interval as the desktop interface; Paused leaves an idle screen unchanged.
On a Linux ZX runner, the portable profile samples the host's real `/proc`
and DRM files through Ziran's file capabilities, uses its monotonic clock for
refreshes, and requests process control and CPU/RSS units through typed process
+48 -33
View File
@@ -4,6 +4,7 @@
// in app_state.zi and its sibling native modules; no widget draw operation is
// reachable from application code.
import * as App from "kryon/app";
import { Compose, Current } from "kryon/component";
import { ButtonEmphasis, ButtonTone } from "kryon/control_props";
import { ColorFromPacked } from "kryon/drawing_props";
import { Rectangle } from "kryon/geometry";
@@ -11,7 +12,7 @@ import * as NativeModal from "kryon/modal";
import * as NativeMenu from "kryon/menu";
import { Session } from "kryon/session";
import { TextAlign } from "kryon/text_align";
import { KeyboardModifiers, KeyboardTake } from "kryon/tree_input";
import { KeyboardModifiers, KeyboardTake, TypedCodepointTake } from "kryon/tree_input";
import * as Theme from "kryon/Theme";
import { ActionModal } from "kryon/tsx/action_modal";
import { Box } from "kryon/tsx/box";
@@ -30,23 +31,23 @@ import * as S from "app_state";
// tabs fill with the theme's accent tone.
function TaskButton(session: Session, id: s32, label: string, bounds: Rectangle,
accent: boolean, disabled: boolean): boolean {
return Button({session: session, props: {key: u64(id), id: id, bounds: bounds,
return Button({session: session, props: {class_name: S.CellStyle(), key: u64(id), id: id, bounds: bounds,
label: label, disabled: disabled,
emphasis: accent ? ButtonEmphasis.ButtonEmphasisFilled : ButtonEmphasis.ButtonEmphasisOutline,
tone: accent ? ButtonTone.ButtonToneAccent : ButtonTone.ButtonToneNeutral}});
}
function Label(session: Session, key: s32, text: string, bounds: Rectangle, font: s32): void {
<Text session={session} props={{key: u64(key), bounds: bounds, text: text, size: font}}/>;
<Text session={session} props={{class_name: S.CellStyle(), key: u64(key), bounds: bounds, text: text, size: font}}/>;
}
function ValueLabel(session: Session, key: s32, text: string, bounds: Rectangle, font: s32): void {
<Text session={session} props={{key: u64(key), bounds: bounds, text: text, size: font,
<Text session={session} props={{class_name: S.CellStyle(), key: u64(key), bounds: bounds, text: text, size: font,
align: TextAlign.TextAlignEnd}}/>;
}
function CenteredLabel(session: Session, key: s32, text: string, bounds: Rectangle, font: s32): void {
<Text session={session} props={{key: u64(key), bounds: bounds, text: text, size: font,
<Text session={session} props={{class_name: S.CellStyle(), key: u64(key), bounds: bounds, text: text, size: font,
align: TextAlign.TextAlignCenter}}/>;
}
@@ -65,18 +66,18 @@ function TaskTabs(session: Session, bounds: Rectangle): void {
function StatusBar(session: Session, bounds: Rectangle, font: s32): void {
const theme = Theme.CurrentTheme();
const texts = S.PrepareStatusBar();
<Box session={session} props={{key: u64(500), bounds: bounds,
<Box session={session} props={{class_name: S.CellStyle(), key: u64(500), bounds: bounds,
fill: ColorFromPacked(S.PaletteLayer(u32(5))),
border: ColorFromPacked(S.PaletteBorder())}}/>;
for (let index = s32(0); index < s32(3); index += s32(1)) {
const pane = S.StatusPaneBounds(bounds, index);
<Box session={session} props={{key: u64(501) + u64(index) * u64(2), bounds: pane,
<Box session={session} props={{class_name: S.CellStyle(), key: u64(501) + u64(index) * u64(2), bounds: pane,
fill: ColorFromPacked(S.PaletteBackground()),
border: ColorFromPacked(S.PaletteBorder()),
radius: theme.metrics.radius_mark}}/>;
Label(session, s32(502) + index * s32(2),
index === s32(0) ? texts.processes : index === s32(1) ? texts.cpu : texts.memory,
{x: pane.x + 6, y: pane.y + 2, width: pane.width - 12, height: pane.height - 4}, font);
S.CellLayout() ? pane : {x: pane.x + 6, y: pane.y + 2, width: pane.width - 12, height: pane.height - 4}, font);
}
}
@@ -90,7 +91,7 @@ function InfoRow(session: Session, key: s32, area: Rectangle, row: s32, label: s
// The graph box with its series drawn through the public paint queue.
function GraphBox(session: Session, key: s32, bounds: Rectangle, kind: s32,
inner: Rectangle, font: s32, withKernel: boolean): void {
<Box session={session} props={{key: u64(key), bounds: bounds,
<Box session={session} props={{class_name: S.CellStyle(), key: u64(key), bounds: bounds,
fill: ColorFromPacked(u32(0x000000ff)),
border: ColorFromPacked(S.GraphBorderColor(kind)), radius: 0}}/>;
S.DrawGraphSeries(session, inner, kind, font, withKernel);
@@ -98,7 +99,7 @@ function GraphBox(session: Session, key: s32, bounds: Rectangle, kind: s32,
function PerformanceGraph(session: Session, key: s32, bounds: Rectangle, title: string,
kind: s32, reading: string, font: s32, withKernel: boolean): void {
<Fieldset session={session} props={{key: u64(key), bounds: bounds, title: title}}/>;
<Fieldset session={session} props={{class_name: S.CellStyle(), key: u64(key), bounds: bounds, title: title}}/>;
const content = S.GroupContent(bounds);
const graph = S.GraphBounds(content);
GraphBox(session, key + s32(1), graph, kind, S.GraphInner(graph), font, withKernel);
@@ -125,28 +126,28 @@ function PerformanceScreen(session: Session, area: Rectangle, font: s32): void {
Model.HISTORY_VRAM, perf.vram, font, false);
const totals = S.PerfGroupBounds(area, s32(0));
<Fieldset session={session} props={{key: u64(440), bounds: totals, title: "Totals"}}/>;
<Fieldset session={session} props={{class_name: S.CellStyle(), key: u64(440), bounds: totals, title: "Totals"}}/>;
const totalsArea = S.GroupContent(totals);
InfoRow(session, s32(441), totalsArea, s32(0), "Handles", perf.handles, font);
InfoRow(session, s32(443), totalsArea, s32(1), "Threads", perf.threads, font);
InfoRow(session, s32(445), totalsArea, s32(2), "Processes", perf.processes, font);
const physical = S.PerfGroupBounds(area, s32(1));
<Fieldset session={session} props={{key: u64(450), bounds: physical, title: "Physical Memory"}}/>;
<Fieldset session={session} props={{class_name: S.CellStyle(), key: u64(450), bounds: physical, title: "Physical Memory"}}/>;
const physicalArea = S.GroupContent(physical);
InfoRow(session, s32(451), physicalArea, s32(0), "Total", perf.phys_total, font);
InfoRow(session, s32(453), physicalArea, s32(1), "Available", perf.phys_available, font);
InfoRow(session, s32(455), physicalArea, s32(2), "System Cache", perf.phys_cache, font);
const commit = S.PerfGroupBounds(area, s32(2));
<Fieldset session={session} props={{key: u64(460), bounds: commit, title: "Commit Charge"}}/>;
<Fieldset session={session} props={{class_name: S.CellStyle(), key: u64(460), bounds: commit, title: "Commit Charge"}}/>;
const commitArea = S.GroupContent(commit);
InfoRow(session, s32(461), commitArea, s32(0), "Total", perf.commit_total, font);
InfoRow(session, s32(463), commitArea, s32(1), "Limit", perf.commit_limit, font);
InfoRow(session, s32(465), commitArea, s32(2), "Peak", perf.commit_peak, font);
const kernel = S.PerfGroupBounds(area, s32(3));
<Fieldset session={session} props={{key: u64(470), bounds: kernel, title: "Kernel Memory"}}/>;
<Fieldset session={session} props={{class_name: S.CellStyle(), key: u64(470), bounds: kernel, title: "Kernel Memory"}}/>;
const kernelArea = S.GroupContent(kernel);
InfoRow(session, s32(471), kernelArea, s32(0), "Total", perf.kernel_total, font);
InfoRow(session, s32(473), kernelArea, s32(1), "Paged", perf.kernel_paged, font);
@@ -166,11 +167,11 @@ function ProcessesScreen(session: Session, area: Rectangle, font: s32): void {
const frame = S.PrepareProcessTable();
let outcome: S.TableOutcome = nativeInit<S.TableOutcome>({});
{
const table = TableView({session: session, props: {key: u64(100), bounds: tableBounds,
const table = TableView({session: session, props: {class_name: S.CellStyle(), key: u64(100), bounds: tableBounds,
columns: S.ProcessColumns(), rows: nativeSlice(frame.rows, s32(0), frame.count),
column_widths: S.ProcessWidths(), selected_row: S.ProcessSelectedRow(),
selected_column: s32(-1), sort_column: S.SortColumn(), sort_direction: S.SortDirection(),
scroll_offset: S.ProcessScroll(), row_height: s32(26), header_height: s32(30),
scroll_offset: S.ProcessScroll(), row_height: S.RowHeight(s32(26)), header_height: S.RowHeight(s32(30)),
resizable: true}});
outcome = {selected_row: table.selected_row, clicked_row: table.clicked_row,
scroll_offset: table.scroll_offset, sort_column: table.sort_column,
@@ -192,11 +193,11 @@ function ApplicationsScreen(session: Session, area: Rectangle, font: s32): void
const frame = S.PrepareApplicationsTable();
let outcome: S.TableOutcome = nativeInit<S.TableOutcome>({});
{
const table = TableView({session: session, props: {key: u64(200), bounds: tableBounds,
const table = TableView({session: session, props: {class_name: S.CellStyle(), key: u64(200), bounds: tableBounds,
columns: S.AppColumns(), rows: nativeSlice(frame.rows, s32(0), frame.count),
column_widths: S.AppWidths(), selected_row: S.AppSelectedRow(),
selected_column: s32(-1), sort_column: s32(-1),
scroll_offset: S.AppScroll(), row_height: s32(26), header_height: s32(30),
scroll_offset: S.AppScroll(), row_height: S.RowHeight(s32(26)), header_height: S.RowHeight(s32(30)),
resizable: true}});
outcome = {selected_row: table.selected_row, clicked_row: table.clicked_row,
scroll_offset: table.scroll_offset, sort_column: table.sort_column,
@@ -205,7 +206,8 @@ function ApplicationsScreen(session: Session, area: Rectangle, font: s32): void
S.ApplicationsTableResult(outcome);
if (!S.AppsListAvailable()) {
CenteredLabel(session, s32(205), S.AppsListMessage(),
{x: tableBounds.x, y: tableBounds.y + 60, width: tableBounds.width, height: 24}, font);
{x: tableBounds.x, y: tableBounds.y + (S.CellLayout() ? 2 : 60),
width: tableBounds.width, height: S.CellLayout() ? 1 : 24}, font);
}
const none = S.AppSelectionEmpty();
if (TaskButton(session, s32(210), "End Task", S.AppButtonBounds(area, s32(0)), false, none)) {
@@ -220,18 +222,19 @@ function ApplicationsScreen(session: Session, area: Rectangle, font: s32): void
}
function RunDialog(session: Session, font: s32): void {
const modal = ResolvedModal({session: session, props: {key: u64(300),
title: "Create New Task", width: s32(460), height: s32(210),
const modal = ResolvedModal({session: session, props: {class_name: S.CellStyle(), key: u64(300),
title: "Create New Task", width: S.DialogWidth(s32(460)), height: S.DialogHeight(s32(210)),
left_label: "Cancel", right_label: "OK",
has_left_action: true, has_right_action: true},
children: (frame: NativeModal.ModalFrameResult): void => {
S.BeginRunDialogFrame(frame.right_clicked);
const area = frame.layout.content;
Label(session, s32(301), "Type the command to run. It starts in the background.",
{x: area.x, y: area.y, width: area.width, height: 22}, font);
{x: area.x, y: area.y, width: area.width, height: S.CellLayout() ? 1 : 22}, font);
const result = ControlledTextField({session: session, props: {
key: u64(302), id: s32(302),
bounds: {x: area.x, y: area.y + 30, width: area.width, height: 36},
class_name: S.CellStyle(), key: u64(302), id: s32(302),
bounds: {x: area.x, y: area.y + (S.CellLayout() ? 2 : 30),
width: area.width, height: S.CellLayout() ? 1 : 36},
value: S.CommandValue(), label: "Open", placeholder: "for example: xterm",
max_bytes: Model.COMMAND_CAPACITY, cursor: S.CommandCursor(),
anchor: S.CommandAnchor(), scroll_x: S.CommandScroll(),
@@ -242,17 +245,17 @@ function RunDialog(session: Session, font: s32): void {
}
function AboutDialog(session: Session): void {
const answer = ActionModal({session: session, props: {key: u64(310),
const answer = ActionModal({session: session, props: {class_name: S.CellStyle(), key: u64(310),
title: "About Task Manager",
message: "taskmgr shows the applications, processes and performance of this Linux computer. It reads /proc directly and lists windows from the X11 window manager.",
max_width: s32(440)}, actions: S.AboutActions()});
max_width: S.DialogWidth(s32(440))}, actions: S.AboutActions()});
S.AboutResult(answer);
}
function EndProcessDialog(session: Session): void {
const answer = ActionModal({session: session, props: {key: u64(320),
const answer = ActionModal({session: session, props: {class_name: S.CellStyle(), key: u64(320),
title: "Task Manager Warning", message: S.EndWarningMessage(),
max_width: s32(460)}, actions: S.EndWarningActions()});
max_width: S.DialogWidth(s32(460))}, actions: S.EndWarningActions()});
S.EndWarningResult(answer);
}
@@ -261,18 +264,25 @@ function EndProcessDialog(session: Session): void {
// then modal dialogs, then the tab shortcut keys.
export function TaskmgrFrame(session: Session, viewport: Rectangle): s32 {
S.EnsureStarted();
S.BeginFrameLayout();
// Only the command dialog accepts text. Other frames consume their text
// now, so tab and menu keys cannot type into a dialog opened later.
if (S.Dialog() !== S.DIALOG_RUN) {
while (TypedCodepointTake(session) !== s32(0)) {}
}
S.RefreshTick();
const font = S.FrameFont(viewport);
const small = S.FrameSmallFont(viewport);
const theme = Theme.CurrentTheme();
const menuProps = S.MenuProps(session, viewport);
<Box session={session} props={{key: u64(1), bounds: viewport,
<Box session={session} props={{class_name: S.CellStyle(), key: u64(1), bounds: viewport,
fill: ColorFromPacked(S.PaletteBackground())}}/>;
TaskTabs(session, S.TabsBounds(viewport));
const panel = S.PanelBounds(viewport);
<Box session={session} props={{key: u64(41), bounds: panel,
<Box session={session} props={{class_name: S.CellStyle(), key: u64(41), bounds: panel,
fill: ColorFromPacked(S.PaletteLayer(u32(3))),
border: ColorFromPacked(S.PaletteBorder()),
radius: theme.metrics.radius_small}}/>;
@@ -318,7 +328,7 @@ export function TaskmgrFrame(session: Session, viewport: Rectangle): s32 {
{label: "Help", items: nativeSlice(helpItems)}];
const menuState = nativeRef(S.menu_state);
if (!menuState.initialized) { NativeMenu.MenuStateInit(menuState); }
const menu = Menu({session: session, props: {key: u64(20), bounds: S.MenuBarBounds(viewport)},
const menu = Menu({session: session, props: menuProps,
groups: nativeSlice(groups), state: menuState});
if (menu.activated_id > s32(0)) { S.RunMenu(menu.activated_id); }
@@ -328,7 +338,8 @@ export function TaskmgrFrame(session: Session, viewport: Rectangle): s32 {
// Menus and dialogs get first chance to consume the key. With no modal
// active, Ctrl+1/2/3 follows the visible tab order.
if (S.Dialog() === S.DIALOG_NONE) {
const shortcut = Shortcuts.TabForShortcut(KeyboardTake(session), KeyboardModifiers(session));
const shortcut = Shortcuts.TabForShortcut(KeyboardTake(session),
KeyboardModifiers(session) | (S.CellLayout() ? s32(2) : s32(0)));
if (shortcut >= s32(0)) { S.SelectTab(shortcut); }
}
return s32(0);
@@ -336,7 +347,11 @@ export function TaskmgrFrame(session: Session, viewport: Rectangle): s32 {
export function Frame(frame: App.Frame): void {
const session: Session = {slot: frame.slot, epoch: frame.epoch};
TaskmgrFrame(session, frame.viewport);
Compose({session: session, component: "TaskManager", key: {specified: false, value: u64(0)},
children: (): void => {
TaskmgrFrame(session, frame.viewport);
S.ScheduleRefresh(Current(session));
}});
}
export function main(): s32 {
+174 -8
View File
@@ -14,7 +14,9 @@ TextField :: #import "kryon/text_field";
#import "kryon/key_input"
#import "kryon/tree_input"
#import "kryon/paint_queue"
using PageLayout :: #import "kryon/PageLayout";
#import "kryon/font_metrics"
#import "kryon/style_sheet"
using StyleField;
#import "std/byte_text_linux"
using Model :: #import "model";
Apps :: #import "windows";
@@ -27,6 +29,9 @@ Theme :: #import "kryon/Theme";
SystemTheme :: #import "kryon/SystemTheme";
Number :: #import "std/number_text";
Platform :: #import "task_platform";
Shortcuts :: #import "app_shortcuts";
Components :: #import "kryon/component_lifecycle";
ComponentTypes :: #import "kryon/component_types";
#if !#defined(TASKMGR_TAIJI) && OS == .LINUX {
SystemThemeHostLinux :: #import "kryon/SystemThemeHostLinux";
Timer :: #import "std/timer_linux";
@@ -93,6 +98,70 @@ BUTTON_HEIGHT :: 32.0;
BUTTON_WIDTH :: 120.0;
PAD :: 10.0;
cell_layout: bool;
cell_styles_installed: bool;
CELL_STYLE :: 43121;
CellStyle :: () -> s32 { return ifx cell_layout then CELL_STYLE else 0 }
CellLayout :: () -> bool { return cell_layout }
RowHeight :: (pixels: s32) -> s32 { return ifx cell_layout then 1 else pixels }
DialogWidth :: (pixels: s32) -> s32 { return ifx cell_layout then 60 else pixels }
DialogHeight :: (pixels: s32) -> s32 { return ifx cell_layout then 9 else pixels }
// Native glyph metrics identify cell hosts even when a window is narrow.
// The screen and domain model stay shared; only their layout units change.
BeginFrameLayout :: () {
cell_layout = GlyphLineHeight(14, "") == 1
if !cell_layout || cell_styles_installed { return }
rules := ActiveStyleRules()
if rules.count > StyleRuleCapacity - 7 { return }
rule: StyleRule
rule.selector = StyleDefaultSelector()
rule.selector.class_name = CELL_STYLE
rule.style.fields = cast(u32)StyleFontSize | cast(u32)StyleLineHeight | cast(u32)StylePaddingX |
cast(u32)StylePaddingY | cast(u32)StyleGap | cast(u32)StyleRadius |
cast(u32)StyleBorderWidth | cast(u32)StyleContentOffset | cast(u32)StyleIconSize
rule.style.font_size = 1.0
rule.style.line_height = 1.0
rule.style.line_height_unit = .LineHeightLength
rule.style.padding_x = 1.0
rule.style.gap = 1.0
rule.style.icon_size = 1.0
rule.style.offset_x = 1.0
rule.style.offset_y = 1.0
rules.items[rules.count] = rule; rules.count += 1
rule.selector.kind = StyleKindButton()
rule.style.offset_x = 0.0
rule.style.offset_y = 0.0
rules.items[rules.count] = rule; rules.count += 1
rule.selector.kind = StyleKindFieldset()
rule.style.offset_x = 1.0
rule.style.offset_y = 1.0
rule.style.gap = 0.0
rules.items[rules.count] = rule; rules.count += 1
rule.selector.kind = StyleKindModal()
rule.style.gap = 1.0
rule.style.padding_x = 2.0
rule.style.padding_y = 1.0
rule.style.offset_x = 20.0
rule.style.offset_y = 3.0
rules.items[rules.count] = rule; rules.count += 1
rule.selector.role = Modal.ModalTitleRole()
rule.style.offset_y = 1.0
rules.items[rules.count] = rule; rules.count += 1
rule.selector.role = Modal.ModalPanelRole()
rule.style.offset_y = 3.0
rule.style.offset_x = 60.0
rule.style.icon_size = 20.0
rules.items[rules.count] = rule; rules.count += 1
rule.selector.role = Modal.ModalActionRole()
rule.style.offset_x = 6.0
rule.style.offset_y = 20.0
rule.style.icon_size = 1.0
rules.items[rules.count] = rule; rules.count += 1
cell_styles_installed = InstallStyleRules(rules)
}
COLUMNS :: Model.COLUMNS;
APP_COLUMNS :: 5;
APP_COLUMN_CPU :: 2;
@@ -238,6 +307,8 @@ frames_since_refresh: s32;
last_refresh_ms: s64 = -1;
pending_sort: bool;
refresh_requested: bool;
refresh_timer: ComponentTypes.Token;
refresh_due_ms: s64 = -1;
show_kernel_times: bool;
confirm_end: bool = true;
group_processes: bool = true;
@@ -345,7 +416,7 @@ PaletteLayer :: (opacity: u32) -> u32 {
PaletteBackground :: () -> u32 { return palette_background }
PaletteBase :: () -> u32 { return palette_base }
PaletteText :: () -> u32 { return palette_text }
PaletteBorder :: () -> u32 { return palette_border }
PaletteBorder :: () -> u32 { return ifx cell_layout then cast(u32)0 else palette_border }
AppendText :: (output: []u8, start: s32, text: string) -> s32 {
length := start
@@ -381,26 +452,31 @@ Inset :: (bounds: Rectangle, amount: float32) -> Rectangle {
// Classic layout regions the TSX screens place their widgets in.
TabsBounds :: (viewport: Rectangle) -> Rectangle {
if cell_layout { return .{viewport.x + 1.0, viewport.y + 1.0, viewport.width - 2.0, 1.0} }
tabs_y := viewport.y + MENU_HEIGHT + 6.0
return .{viewport.x + 8.0, tabs_y, viewport.width - 16.0, TAB_HEIGHT}
}
TabBounds :: (bounds: Rectangle, index: s32) -> Rectangle {
gap: float32 = 4.0
if cell_layout { gap = 1.0 }
width := (bounds.width - gap * 2.0) / 3.0
return .{bounds.x + cast(float32)index * (width + gap), bounds.y, width, bounds.height}
}
MenuBarBounds :: (viewport: Rectangle) -> Rectangle {
if cell_layout { return .{viewport.x, viewport.y, viewport.width, 1.0} }
return .{viewport.x, viewport.y, viewport.width, MENU_HEIGHT}
}
StatusBounds :: (viewport: Rectangle) -> Rectangle {
if cell_layout { return .{viewport.x, viewport.y + viewport.height - 1.0, viewport.width, 1.0} }
return .{viewport.x, viewport.y + viewport.height - STATUS_HEIGHT,
viewport.width, STATUS_HEIGHT}
}
PanelBounds :: (viewport: Rectangle) -> Rectangle {
if cell_layout { return .{viewport.x + 1.0, viewport.y + 3.0, viewport.width - 2.0, viewport.height - 5.0} }
tabs_y := viewport.y + MENU_HEIGHT + 6.0
status_y := viewport.y + viewport.height - STATUS_HEIGHT
panel_y := tabs_y + TAB_HEIGHT
@@ -411,28 +487,33 @@ PanelBounds :: (viewport: Rectangle) -> Rectangle {
}
ContentBounds :: (panel: Rectangle) -> Rectangle {
if cell_layout { return panel }
return Inset(panel, PAD)
}
// Messages from the last action sit at the panel's bottom left.
StatusLabelBounds :: (content: Rectangle) -> Rectangle {
if cell_layout { return .{content.x, content.y + content.height - 1.0, content.width - 16.0, 1.0} }
return .{content.x, content.y + content.height - BUTTON_HEIGHT + 8.0,
content.width - BUTTON_WIDTH * 3.0 - 32.0, 18.0}
}
TableAreaBounds :: (area: Rectangle) -> Rectangle {
if cell_layout { return .{area.x, area.y, area.width, area.height - 2.0} }
bounds := Rectangle.{area.x, area.y, area.width, area.height - BUTTON_HEIGHT - PAD}
if bounds.height < 60.0 { bounds.height = 60.0 }
return bounds
}
ProcessEndButtonBounds :: (area: Rectangle) -> Rectangle {
if cell_layout { return .{area.x + area.width - 14.0, area.y + area.height - 1.0, 14.0, 1.0} }
return .{area.x + area.width - BUTTON_WIDTH, area.y + area.height - BUTTON_HEIGHT,
BUTTON_WIDTH, BUTTON_HEIGHT}
}
// Applications-tab buttons: 0 End Task, 1 Switch To, 2 New Task.
AppButtonBounds :: (area: Rectangle, slot: s32) -> Rectangle {
if cell_layout { return .{area.x + area.width - 44.0 + cast(float32)slot * 15.0, area.y + area.height - 1.0, 14.0, 1.0} }
right := area.x + area.width
button_y := area.y + area.height - BUTTON_HEIGHT
if slot == 0 { return .{right - BUTTON_WIDTH * 3.0 - 16.0, button_y, BUTTON_WIDTH, BUTTON_HEIGHT} }
@@ -441,11 +522,13 @@ AppButtonBounds :: (area: Rectangle, slot: s32) -> Rectangle {
}
GroupContent :: (bounds: Rectangle) -> Rectangle {
if cell_layout { return .{bounds.x + 1.0, bounds.y + 1.0, bounds.width - 2.0, bounds.height - 1.0} }
return .{bounds.x + 12.0, bounds.y + 22.0, bounds.width - 24.0, bounds.height - 30.0}
}
// Performance graph inside a group box.
GraphBounds :: (content: Rectangle) -> Rectangle {
if cell_layout { return .{content.x, content.y, content.width, content.height - 1.0} }
graph := Rectangle.{content.x, content.y, content.width,
content.height - 18.0 - 3.0}
if graph.height < 20.0 { graph.height = 20.0 }
@@ -453,25 +536,34 @@ GraphBounds :: (content: Rectangle) -> Rectangle {
}
GraphReadingBounds :: (content: Rectangle, graph: Rectangle) -> Rectangle {
if cell_layout { return .{content.x, graph.y + graph.height, content.width, 1.0} }
return .{content.x, graph.y + graph.height + 3.0, content.width, 18.0}
}
GraphInner :: (bounds: Rectangle) -> Rectangle {
if cell_layout { return bounds }
return .{bounds.x + 2.0, bounds.y + 2.0, bounds.width - 4.0, bounds.height - 4.0}
}
// One label/value row inside a group box.
InfoLabelBounds :: (area: Rectangle, row: s32) -> Rectangle {
if cell_layout { return .{area.x, area.y + cast(float32)row, area.width * 0.55, 1.0} }
return .{area.x, area.y + cast(float32)row * 20.0, area.width * 0.55, 18.0}
}
InfoValueBounds :: (area: Rectangle, row: s32) -> Rectangle {
if cell_layout { return .{area.x + area.width * 0.55, area.y + cast(float32)row, area.width * 0.45, 1.0} }
return .{area.x + area.width * 0.45, area.y + cast(float32)row * 20.0,
area.width * 0.55, 18.0}
}
// The four performance graphs: 0 CPU, 1 memory, 2 GPU, 3 VRAM.
PerfGraphBounds :: (area: Rectangle, slot: s32) -> Rectangle {
if cell_layout {
half := (area.width - 2.0) / 2.0
return .{area.x + cast(float32)(slot % 2) * (half + 2.0),
area.y + cast(float32)(slot / 2) * 5.0, half, 4.0}
}
half := (area.width - PAD) / 2.0
info_height: float32 = 92.0
info_block := info_height * 2.0 + PAD
@@ -488,6 +580,11 @@ PerfGraphBounds :: (area: Rectangle, slot: s32) -> Rectangle {
// The four performance group boxes: 0 totals, 1 physical, 2 commit, 3 kernel.
PerfGroupBounds :: (area: Rectangle, slot: s32) -> Rectangle {
if cell_layout {
half := (area.width - 2.0) / 2.0
return .{area.x + cast(float32)(slot % 2) * (half + 2.0),
area.y + 10.0 + cast(float32)(slot / 2) * 4.0, half, 4.0}
}
half := (area.width - PAD) / 2.0
info_height: float32 = 92.0
graph_height := (area.height - info_height * 2.0 - PAD * 2.0) / 2.0
@@ -512,13 +609,11 @@ GuestPerfBounds :: (area: Rectangle, slot: s32) -> Rectangle {
}
FrameFont :: (viewport: Rectangle) -> s32 {
page := PageLayout.PageFor(viewport, 640.0)
return PageLayout.FontSize(*page, 14)
return ifx cell_layout then 1 else 14
}
FrameSmallFont :: (viewport: Rectangle) -> s32 {
page := PageLayout.PageFor(viewport, 640.0)
return PageLayout.FontSize(*page, 13)
return ifx cell_layout then 1 else 13
}
CurrentTab :: () -> s32 { return current_tab }
@@ -649,6 +744,27 @@ RefreshTick :: () -> bool {
return refreshed
}
RefreshWake :: (instance: ComponentTypes.Instance) {
unused instance
refresh_requested = true
}
// Cell hosts sleep until input or this mounted component's next refresh.
// The registry owns cancellation when the component or its session closes.
ScheduleRefresh :: (instance: ComponentTypes.Instance) {
if !cell_layout { return }
if refresh_interval_ms <= 0 {
unused Components.Cancel(refresh_timer)
refresh_due_ms = -1
return
}
due := last_refresh_ms + refresh_interval_ms
if due == refresh_due_ms && Components.ResourceIndex(refresh_timer) >= 0 { return }
unused Components.Cancel(refresh_timer)
refresh_due_ms = due
refresh_timer = Components.Timer(instance, cast(float64)due / 1000.0, 0.0, RefreshWake)
}
// Group names are retained as bytes, never as string views into refreshed
// snapshots. The model's matcher keeps Codex-family aliases in one group.
GroupNameMatches :: (name: []u8, entry: *Model.Process) -> bool {
@@ -1164,9 +1280,11 @@ ColumnWidths :: (width: float32) {
widths_for = width
widths_gpu = app_gpu_shown
usable := width - 18.0
if cell_layout { usable = width - 1.0 }
for column: 0..COLUMNS - 1 {
value := cast(s32)(usable * process_fractions[column])
if value < 40 { value = 40 }
minimum: s32 = ifx cell_layout then 4 else 40
if value < minimum { value = minimum }
process_widths[column] = value
}
for column: 0..APP_COLUMNS - 1 {
@@ -1174,12 +1292,48 @@ ColumnWidths :: (width: float32) {
// Without a GPU column its share goes to the Task names.
if column == 0 && !app_gpu_shown { fraction += app_fractions[APP_COLUMN_GPU] }
value := cast(s32)(usable * fraction)
if value < 40 { value = 40 }
minimum: s32 = ifx cell_layout then 4 else 40
if value < minimum { value = minimum }
app_widths[column] = value
}
}
// Menu bar state consumed by the TSX menu composition in app.tsx.
// Ctrl+F enters the shared menu. Only an active menu consumes navigation;
// other keys remain available to the normal tab shortcuts and widgets.
MenuProps :: (session: Session, viewport: Rectangle) -> Menu.Props {
props: Menu.Props
props.key = 20
props.class_name = CellStyle()
props.bounds = MenuBarBounds(viewport)
if !cell_layout { return props }
key := KeyboardTake(session)
if key == 70 && (KeyboardModifiers(session) & 2) != 0 {
menu_state.focused = !menu_state.focused
if !menu_state.focused { menu_state.open_index = -1 }
return props
}
if !menu_state.focused && dialog == DIALOG_NONE {
tab := Shortcuts.TabForShortcut(key, 2)
if tab >= 0 { SelectTab(tab); return props }
}
if menu_state.focused {
props.input.up = key == 265
props.input.down = key == 264
props.input.left = key == 263
props.input.right = key == 262
props.input.home = key == 268
props.input.end = key == 269
props.input.enter = key == 257
props.input.space = key == 32
props.input.escape = key == 256
if props.input.up || props.input.down || props.input.left || props.input.right || props.input.home ||
props.input.end || props.input.enter || props.input.space || props.input.escape { return props }
}
if key != 0 { unused KeyboardSend(session, key) }
return props
}
MenuNewTaskDisabled :: () -> bool { return !Platform.CanRunShell() }
ConfirmEndChecked :: () -> bool { return confirm_end }
GroupProcessesChecked :: () -> bool { return group_processes }
@@ -1628,6 +1782,12 @@ DrawGraphSeries :: (session: Session, inner: Rectangle, kind: s32, font: s32, wi
row := Rectangle.{inner.x + 3.0,
inner.y + 2.0 + cast(float32)device_index * 16.0,
inner.width - 6.0, 15.0}
if cell_layout {
row = .{inner.x, inner.y + cast(float32)device_index, inner.width, 1.0}
PaintClippedLabel(session, -1, GpuLegend(device, kind, graph_legend[:]),
cast(s32)row.x, cast(s32)row.y, font, ColorFromPacked(color), inner)
continue
}
PaintLine(session, -1, .{row.x + 3.0, row.y + 7.0, 8.0, 0.0},
ColorFromPacked(color))
PaintClippedLabel(session, -1, GpuLegend(device, kind, graph_legend[:]),
@@ -1678,6 +1838,12 @@ PrepareStatusBar :: () -> StatusTexts {
// One status pane's sunken rectangle; x accumulates the earlier panes.
StatusPaneBounds :: (bounds: Rectangle, index: s32) -> Rectangle {
if cell_layout {
widths: [3]float32 = .{0.24, 0.24, 0.52}
x := bounds.x
for pane: 0..index - 1 { x += bounds.width * widths[pane] }
return .{x, bounds.y, bounds.width * widths[index], 1.0}
}
#if #defined(TASKMGR_TAIJI) {
widths: [3]float32 = .{0.24, 0.32, 0.44}
} else {
+10 -10
View File
@@ -65,21 +65,21 @@
"url": "https://github.com/xiph/opus.git"
},
{
"commit": "239b593496354122ada2b163ad4b3c845045d02b",
"dependencies": {"kryon": "waozi_xyz_kryonlabs_kryon_71a62c5a0d94"},
"dependency_refs": {"kryon": "71a62c5a0d94960863338b25e8927eb1a78baae0"},
"id": "waozi_xyz_kryonlabs_data_views_239b59349635",
"commit": "97db6e2acdc62567cf0243b42f4dfd7d79bb7bc0",
"dependencies": {"kryon": "waozi_xyz_kryonlabs_kryon_1044aea9592a"},
"dependency_refs": {"kryon": "1044aea9592a8ea0c0906161131712540a7bc931"},
"id": "waozi_xyz_kryonlabs_data_views_97db6e2acdc6",
"name": "DataViews",
"ref": "239b593496354122ada2b163ad4b3c845045d02b",
"ref": "97db6e2acdc62567cf0243b42f4dfd7d79bb7bc0",
"url": "https://git.waozi.xyz/kryonlabs/data-views.git"
},
{
"commit": "71a62c5a0d94960863338b25e8927eb1a78baae0",
"commit": "1044aea9592a8ea0c0906161131712540a7bc931",
"dependencies": {"audio": "waozi_xyz_ziranlang_audio_b5c6b56b7117", "avif": "waozi_xyz_ziranlang_avif_6ff696d436b6", "image_codec": "waozi_xyz_ziranlang_image_codec_3017f0d1cc56", "libaom": "src_aomedia_googlesource_com_aom_b141d9c45db2", "libavif": "src_github_com_AOMediaCodec_libavif_1aadfad932c9", "libwebp": "src_github_com_webmproject_libwebp_1844042d1ca7", "sdl3": "src_github_com_libsdl_org_SDL_829a65d769d9", "webp": "waozi_xyz_ziranlang_webp_4b9a61d32460"},
"dependency_refs": {"audio": "b5c6b56b71172c4361ae01e3afdd2118bdac0975", "avif": "6ff696d436b6b4f142eb1e3ecf210de7adfa048f", "image_codec": "3017f0d1cc56975aa29c600a1f55a62e1193cf7b", "libaom": "b141d9c45db236335351c8a4b2a14b3ade27c937", "libavif": "1aadfad932c98c069a1204261b1856f81f3bc199", "libwebp": "1844042d1ca751e62e61df7617dba19c98588339", "sdl3": "829a65d769d935c4852f8159e964312c0957260a", "webp": "4b9a61d32460d481624fe0f83996a7de50327dfe"},
"id": "waozi_xyz_kryonlabs_kryon_71a62c5a0d94",
"id": "waozi_xyz_kryonlabs_kryon_1044aea9592a",
"name": "kryon",
"ref": "71a62c5a0d94960863338b25e8927eb1a78baae0",
"ref": "1044aea9592a8ea0c0906161131712540a7bc931",
"url": "https://git.waozi.xyz/kryonlabs/kryon.git"
},
{
@@ -128,8 +128,8 @@
}
],
"root": {
"dependencies": {"data_views": "waozi_xyz_kryonlabs_data_views_239b59349635", "kryon": "waozi_xyz_kryonlabs_kryon_71a62c5a0d94"},
"dependency_refs": {"data_views": "239b593496354122ada2b163ad4b3c845045d02b", "kryon": "71a62c5a0d94960863338b25e8927eb1a78baae0"},
"dependencies": {"data_views": "waozi_xyz_kryonlabs_data_views_97db6e2acdc6", "kryon": "waozi_xyz_kryonlabs_kryon_1044aea9592a"},
"dependency_refs": {"data_views": "97db6e2acdc62567cf0243b42f4dfd7d79bb7bc0", "kryon": "1044aea9592a8ea0c0906161131712540a7bc931"},
"name": "taskmgr"
},
"toolchain": {
+2 -2
View File
@@ -11,11 +11,11 @@ ref = "bbaac5e493973e616e90f1f7ac84dfeb32134194"
[dependencies.kryon]
git = "https://git.waozi.xyz/kryonlabs/kryon.git"
ref = "71a62c5a0d94960863338b25e8927eb1a78baae0"
ref = "1044aea9592a8ea0c0906161131712540a7bc931"
[dependencies.data_views]
git = "https://git.waozi.xyz/kryonlabs/data-views.git"
ref = "239b593496354122ada2b163ad4b3c845045d02b"
ref = "97db6e2acdc62567cf0243b42f4dfd7d79bb7bc0"
[exports]
model = "src/model.zi"