Files
MujicaUI/docs/components/317-diff-stat.md
T

46 lines
865 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 317 DiffStat 差异统计
## 用途
显示 +新增 −删除 行数,以及按比例填充的方块条。
## 最小示例
```go
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.DiffStat(c, 120, 8, mujica.DiffStatOptions{})
}
ui.Render(view, 400, 300, 1)
```
签名:`func DiffStat(c *ui.Context, added, deleted int, opts DiffStatOptions) *ui.Element`
## 参数
`DiffStatOptions`
| 字段 | 类型 | 默认值 | 含义 |
| --- | --- | --- | --- |
| Blocks | int | 0(即 5) | 比例条方块数;为负 panic。 |
added、deleted 为负时 panic。
## 状态
- 数字带 + 与 − 符号,不只靠颜色;非零一侧至少占一格。
- 无变化时方块为 Border 色。
- 朗读为“新增 n 行,删除 m 行”。
## 事件
- 无。
## 键盘操作
- 无:纯展示,不获取焦点。
## 限制
- 无。