feat: add full screen renderer
- implement renderer that clears and redraws all lines - switch example to the library renderer
This commit is contained in:
+3
-29
@@ -9,7 +9,7 @@ using TinyTUI.Stdout;
|
||||
using var terminalInput = new ConsoleTerminalInput();
|
||||
var terminalOutput = new ConsoleTerminalOutput();
|
||||
var parser = new DefaultInputParser();
|
||||
var renderer = new DemoRenderer(terminalOutput);
|
||||
var renderer = new FullScreenRenderer(terminalOutput);
|
||||
using var runtime = new TuiRuntime(terminalInput, parser, renderer);
|
||||
|
||||
var component = new EchoComponent(runtime);
|
||||
@@ -46,6 +46,8 @@ file sealed class EchoComponent(ITuiRuntime runtime) : IInputComponent
|
||||
{
|
||||
"TinyTUI Runtime 示例",
|
||||
"====================",
|
||||
$"当前渲染宽度: {width}",
|
||||
string.Empty,
|
||||
"测试方式:",
|
||||
"- 输入普通字符 验证 Text 事件会进入焦点组件",
|
||||
"- 按方向键 Enter Backspace Tab Delete 验证 Key 事件会进入焦点组件",
|
||||
@@ -94,31 +96,3 @@ file sealed class EchoComponent(ITuiRuntime runtime) : IInputComponent
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用于手动验证 Runtime 的临时全量渲染器
|
||||
/// </summary>
|
||||
file sealed class DemoRenderer(ConsoleTerminalOutput output) : IRenderer
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void Render(IReadOnlyList<string> lines, TerminalSize size)
|
||||
{
|
||||
output.ClearScreen();
|
||||
output.Write($"尺寸: {size.Columns} x {size.Rows}\r\n");
|
||||
output.Write("\r\n");
|
||||
|
||||
foreach (var line in lines)
|
||||
{
|
||||
output.Write(line);
|
||||
output.Write("\r\n");
|
||||
}
|
||||
|
||||
output.Flush();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Reset()
|
||||
{
|
||||
output.ClearScreen();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user