0
0
Fork 0

tui: add domain types (Project, POU, Hunk, Selection)

This commit is contained in:
Karstein Phobic Nyvold Kvistad 2026-04-28 21:08:50 +02:00
parent 2ea39cb9a6
commit 961d15a389

52
src/tui/shared/types.ts Normal file
View file

@ -0,0 +1,52 @@
export type POUKind =
| 'PRG'
| 'FB'
| 'GVL'
| 'STRUCT'
| 'ENUM'
| 'METHOD'
| 'PROPERTY_GETTER'
| 'PROPERTY_SETTER'
| 'META'
| 'OTHER';
export interface POU {
/** Display name without .st extension */
name: string;
kind: POUKind;
/** Path relative to the device root, with forward slashes. */
relPath: string;
absPath: string;
/** Non-blank line count */
loc: number;
mtimeMs: number;
}
export interface Device {
/** Top-level subdir under mcp-mirror/, e.g. "CodesysRpi" */
name: string;
pous: POU[];
}
export interface Project {
/** The project's parent directory (the dir that contains mcp-mirror/) */
rootDir: string;
/** Mirror dir mtime — used for the "stale" indicator */
mirrorMtimeMs: number;
devices: Device[];
}
export interface Selection {
device: string;
pou: POU;
viewerLine: number;
}
export type HunkKind = 'add' | 'del' | 'ctx';
export interface Hunk {
kind: HunkKind;
/** 1-based line number in the side this hunk belongs to (new-side for add/ctx, old-side for del). */
lineNo: number;
text: string;
}