docs: explain Tessera modules and execution flows in Chinese

This commit is contained in:
2026-11-11 23:36:03 +08:00
parent 4c3fc8b5dd
commit 1fedd21d3c
77 changed files with 1418 additions and 0 deletions
+18
View File
@@ -1,16 +1,23 @@
//! 开发工具画面的绘制辅助:文字行、按钮、分隔线和滚动条。
//! 绘制命令与可交互区域同步登记,保证屏幕上的管理控件能用同一几何命中。
//!
use super::*;
/// 开发工具的绘制助手,把布局结果写入同帧显示列表。
pub(super) struct Painter {
pub(super) ui: Ui<Action>,
pub(super) layout: DeveloperToolsLayout,
}
impl Painter {
/// 绘制对应管理界面原语,并按控件需要同步登记命中和滚动区域。
pub(super) fn fill(&mut self, r: Rect, c: Color) {
self.ui.fill(r, c);
}
/// 绘制对应管理界面原语,并按控件需要同步登记命中和滚动区域。
pub(super) fn label(&mut self, x: f32, y: f32, value: &str, c: Color, code: bool) {
self.ui.label(x, y, value, c, code);
}
/// 绘制对应管理界面原语,并按控件需要同步登记命中和滚动区域。
pub(super) fn button(&mut self, r: Rect, label: &str, action: Action, active: bool) {
let role = match action {
Action::Follow | Action::Snapshot | Action::Cloud => Role::Toggle,
@@ -19,14 +26,17 @@ impl Painter {
self.ui
.button(r, action, Button::new(label).selected(active).role(role));
}
/// 绘制对应管理界面原语,并按控件需要同步登记命中和滚动区域。
pub(super) fn enabled_button(&mut self, r: Rect, label: &str, action: Action, enabled: bool) {
self.ui
.button(r, action, Button::new(label).enabled(enabled));
}
/// 绘制对应管理界面原语,并按控件需要同步登记命中和滚动区域。
pub(super) fn split(&mut self, r: Rect, kind: Split) {
// Paint and register splitters after all pane content, in one overlay pass.
self.layout.splits.push((r, kind));
}
/// 绘制对应管理界面原语,并按控件需要同步登记命中和滚动区域。
pub(super) fn lines(
&mut self,
area: Rect,
@@ -132,6 +142,7 @@ impl Painter {
self.scrollbar(area, region, false, s.y, content_h);
self.scrollbar(area, region, true, s.x, content_w);
}
/// 绘制对应管理界面原语,并按控件需要同步登记命中和滚动区域。
pub(super) fn scrollbar(
&mut self,
r: Rect,
@@ -170,6 +181,7 @@ impl Painter {
}
}
#[derive(Clone)]
/// 一行可绘制、可关联源码位置的工具文本。
pub(super) struct Line {
pub(super) value: String,
pub(super) color: Color,
@@ -178,11 +190,13 @@ pub(super) struct Line {
pub(super) action: Option<Action>,
}
#[derive(Clone, Copy)]
/// 管理画面内分隔条方向/位置描述。
pub(super) enum Divider {
Accent,
Neutral,
}
impl Line {
/// 构造本类型并初始化其状态;资源建立和默认字段以函数体为准。
pub(super) fn new(value: impl Into<String>, color: Color) -> Self {
Self {
value: value.into(),
@@ -193,6 +207,7 @@ impl Line {
}
}
}
/// 按行绘制工具文本,返回后续布局需要的占用范围。
pub(super) fn multiline(out: &mut Vec<Line>, value: &str, color: Color) {
out.extend(
value
@@ -201,6 +216,7 @@ pub(super) fn multiline(out: &mut Vec<Line>, value: &str, color: Color) {
.map(|s| Line::new(s, color)),
);
}
/// 把一条 Console 结果投影为可滚动、可选择的文字画面。
pub(super) fn console_result(out: &mut Vec<Line>, body: &str, color: Color) {
if let Ok(value) = serde_json::from_str::<serde_json::Value>(body) {
if value["execution"] == "repl" {
@@ -263,6 +279,7 @@ pub(super) fn console_result(out: &mut Vec<Line>, body: &str, color: Color) {
}
multiline(out, body, color);
}
/// 将代码层次展开为工具可绘制的行数据,保留节点与源范围关联。
pub(super) fn flatten<'a>(node: &'a CodeNode, depth: usize, out: &mut Vec<(usize, &'a CodeNode)>) {
out.push((depth, node));
for child in &node.children {
@@ -270,6 +287,7 @@ pub(super) fn flatten<'a>(node: &'a CodeNode, depth: usize, out: &mut Vec<(usize
}
}
/// 绘制选中请求的头部、正文预览与响应信息,不重新执行该请求。
pub(super) fn request_details(out: &mut Vec<Line>, r: &Exchange) {
multiline(
out,