Files
Mahmoud Ben Hassine e3cb93791d Update documentation
2025-04-25 10:13:56 +02:00

57 lines
1.6 KiB
Plaintext

= TerminalUI
:page-section-summary-toc: 1
ifndef::snippets[:snippets: ../../../../../src/test/java/org/springframework/shell/docs]
`TerminalUI` is a main implementation to drive ui execution logic.
== Create TerminalUI
You can build `TerminalUI` manually but the recommended way is to use `TerminalUIBuilder`
which is autoconfigured for you and will set needed services.
[source, java, indent=0]
----
include::{snippets}/TerminalUiSnippets.java[tag=uibuilderautowire]
----
== Configuring Views
`TerminalUI` has a helper method _configure(View)_ which can be used to set
needed integrations into _eventloop_ and other services.
[source, java, indent=0]
----
include::{snippets}/TerminalUiSnippets.java[tag=configureview]
----
== Running UI Loop
Running `TerminalUI` execution loop is a blocking operation. You're going to need
a way to exit from a loop, for example <<Exiting App>>.
[source, java, indent=0]
----
include::{snippets}/TerminalUiSnippets.java[tag=uirun]
----
== Exiting App
If you want to exit from an app using normal _CTRL-Q_ key combination, then
you need to register a listener for events and request to _interrupt_ the execution.
[source, java, indent=0]
----
include::{snippets}/TerminalUiSnippets.java[tag=exitingfromloop]
----
== Modal View
`TerminalUI` supports having one active modal view. Modal view is placed
on top of all other views and takes all input events.
[source, java, indent=0]
----
include::{snippets}/TerminalUiSnippets.java[tag=uimodal]
----
NOTE: As views should not directly know anything about `TerminalUi` and
interface `ViewService` exposes modal related functions.