TerminalUI

TerminalUI 是用于驱动 UI 执行逻辑的主要实现。

Create TerminalUI

你可以手动构建 TerminalUI,但推荐的方法是使用 TerminalUIBuilder,它会为你自动配置构建并且将设置所需的 Services。

Unresolved include directive in modules/ROOT/pages/tui/intro/terminalui.adoc - include::../../../../../src/test/java/org/springframework/shell/docs/TerminalUiSnippets.java[]

Configuring Views

TerminalUI 有一个助手方法 configure(View),它可用于将所需的集成设置到 eventloop 及其他 Services。

Unresolved include directive in modules/ROOT/pages/tui/intro/terminalui.adoc - include::../../../../../src/test/java/org/springframework/shell/docs/TerminalUiSnippets.java[]

Running UI Loop

运行 TerminalUI 执行循环是一个阻塞操作。你需要一种方法来退出循环,例如 Exiting App

Unresolved include directive in modules/ROOT/pages/tui/intro/terminalui.adoc - include::../../../../../src/test/java/org/springframework/shell/docs/TerminalUiSnippets.java[]

Exiting App

如果你想使用正常的 CTRL-Q 键组合来退出应用程序,请监听事件并请求 interrupt

Unresolved include directive in modules/ROOT/pages/tui/intro/terminalui.adoc - include::../../../../../src/test/java/org/springframework/shell/docs/TerminalUiSnippets.java[]

Modal View

TerminalUI 支持有一个活动模式视图。模式视图放在所有其他视图之上,并获取所有输入事件。

Unresolved include directive in modules/ROOT/pages/tui/intro/terminalui.adoc - include::../../../../../src/test/java/org/springframework/shell/docs/TerminalUiSnippets.java[]

因为视图不应该直接了解任何有关`TerminalUi`和接口`ViewService`公开模式相关功能的信息。