TerminalUI

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

TerminalUI is a main implementation to drive ui execution logic.

Create TerminalUI

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

You can build TerminalUI manually but recommended way is to use TerminalUIBuilder build is autoconfigured for you and will set needed 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。

TerminalUI has a helper method configure(View) which can be used to set needed integrations into eventloop and other 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

Running TerminalUI execution loop is a blocking operation. You’re going to need a way to exit from a loop, for example 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

If you want to exit from an app using normal CTRL-Q key combination listen events and request 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 支持有一个活动模式视图。模式视图放在所有其他视图之上,并获取所有输入事件。

TerminalUI supports having one active modal view. Modal view is placed on top of all other views and takes all input events.

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

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

As views should not directly know anything about TerminalUi and interface ViewService exposes modal related functions.