Make StatusBarView work with hotkeys

- StatusItem can now define a hotkey which is then
  bound to its action.
- In catalog app replace use of raw key event to
  item's hotkey for status bar visibility.
- Various doc updates.
- Relates #826
This commit is contained in:
Janne Valkealahti
2023-10-30 09:31:03 +00:00
parent db3f67784a
commit bba7a82ab4
9 changed files with 227 additions and 22 deletions

View File

@@ -56,6 +56,7 @@
** xref:tui/intro/index.adoc[]
*** xref:tui/intro/terminalui.adoc[]
** xref:tui/views/index.adoc[]
*** xref:tui/views/app.adoc[]
*** xref:tui/views/box.adoc[]
*** xref:tui/views/button.adoc[]
*** xref:tui/views/dialog.adoc[]
@@ -63,6 +64,7 @@
*** xref:tui/views/list.adoc[]
*** xref:tui/views/menu.adoc[]
*** xref:tui/views/menubar.adoc[]
*** xref:tui/views/statusbar.adoc[]
** xref:tui/events/index.adoc[]
*** xref:tui/events/eventloop.adoc[]
*** xref:tui/events/key.adoc[]

View File

@@ -0,0 +1,41 @@
= AppView
:page-section-summary-toc: 1
ifndef::snippets[:snippets: ../../../../../src/test/java/org/springframework/shell/docs]
_AppView_ is a base implementation providing functionality to draw opinionated _application view_.
Inherits xref:tui/views/box.adoc[].
Generic idea is to have menu and status views which typically are xref:tui/views/menubar.adoc[] and
xref:tui/views/statusbar.adoc[] respectively. Main content view is then whatever user want to show
in it.
[source, text]
----
┌──────────────────────────┐
│ Menu │
├──────────────────────────┤
│ │
│ Main │
│ │
├──────────────────────────┤
│ Status │
└──────────────────────────┘
----
== Key Handling
If menu has a focus key handling is processed there, then main is consulted for handling.
Lastly cursor left/right are processed to dispatch _AppViewEvent_.
== HotKey Handling
Hotkeys are processed in order of _main_, _menu_ and _status_.
== Events
.AppView Events
|===
|Event |Description
|AppViewEvent
|Direction for a next selection.
|===

View File

@@ -7,6 +7,13 @@ ifndef::snippets[:snippets: ../../../../../src/test/java/org/springframework/she
_MenuBarView_ is a base implementation providing functionality to draw a menu bar.
Inherits xref:tui/views/box.adoc[].
[source, text]
----
┌─────────────────────────────┐
│ File Help │
└─────────────────────────────┘
----
== Default Bindings
Default _key bindigs_ are:

View File

@@ -0,0 +1,48 @@
= StatusBarView
:page-section-summary-toc: 1
ifndef::snippets[:snippets: ../../../../../src/test/java/org/springframework/shell/docs]
_StatusBarView_ is a base implementation providing functionality to draw a status bar.
Inherits xref:tui/views/box.adoc[].
[source, text]
----
┌─────────────────────────────┐
│ Item1 | Item2 | Item3 │
└─────────────────────────────┘
----
You can create a simple status bar with an item:
[source, java, indent=0]
----
include::{snippets}/StatusBarViewSnippets.java[tag=simple]
----
Constructor can take array form which allows to lay out simple
item definitions in a _dsl_ style.
[source, java, indent=0]
----
include::{snippets}/StatusBarViewSnippets.java[tag=viaarray]
----
Items support runnable actions which generally as executed when
item is selected. It can also get attached to a hot key.
[source, java, indent=0]
----
include::{snippets}/StatusBarViewSnippets.java[tag=items]
----
== Events
.StatusBarView Events
|===
|Event |Description
|StatusBarViewOpenSelectedItemEvent
|StatusItem is selected.
|===