diff --git a/404.html b/404.html index 2bd5e3625..19b2b7ac4 100755 --- a/404.html +++ b/404.html @@ -304,7 +304,7 @@
Stop the animation and remove it from the screen.
Start the animation and refresh it until all its tasks are finished.
Stop the animation, but leave it on the screen.
Stop the animation and remove it from the screen.
Start the animation and refresh it until all its tasks are finished.
Stop the animation, but leave it on the screen.
A CoroutineAnimator for a ProgressBarAnimation.
A CoroutineAnimator for a single task.
Create a progress bar animation that runs in a coroutine.
val animation = progressBarContextLayout<String> { ... }.animateInCoroutine(terminal, "context")
launch { animation.execute() }
animation.update { ... }
The terminal to draw the progress bar to
The context to pass to the task
The total number of steps needed to complete the progress task, or null
if it is indeterminate.
The number of steps currently completed in the progress task.
If true
, start the task immediately.
If false
, the task will not be drawn to the screen.
If true
, the animation will be cleared when all tasks are finished. Otherwise, the animation will stop when all tasks are finished, but remain on the screen.
The duration over which to estimate the speed of the progress tasks. This estimate will be a rolling average over this duration.
The time source to use for the animation.
The widget maker to use to lay out the progress bars.
Create a progress bar animation for a single task that runs synchronously.
val animation = progressBarLayout { ... }.animateInCoroutine(terminal)
launch { animation.execute() }
animation.update { ... }
The terminal to draw the progress bar to
The total number of steps needed to complete the progress task, or null
if it is indeterminate.
The number of steps currently completed in the progress task.
If true
, start the task immediately.
If false
, the task will not be drawn to the screen.
If true
, the animation will be cleared when all tasks are finished. Otherwise, the animation will stop when all tasks are finished, but remain on the screen.
The duration over which to estimate the speed of the progress tasks. This estimate will be a rolling average over this duration.
The time source to use for the animation.
The widget maker to use to lay out the progress bars.
Create an animator that runs this animation in a coroutine.
val animation = terminal.animation<Unit> { ... }.animateInCoroutine(terminal)
launch { animation.execute() }
Create an animator that runs this animation in a coroutine.
val animator = animation.animateInCoroutine(terminal)
launch { animator.execute() }
Create an animator that runs this animation in a coroutine.
val animator = animation.animateInCoroutine()
launch { animator.execute() }
A CoroutineAnimator for a ProgressBarAnimation.
A CoroutineAnimator for a single task.
Create an animator that runs this animation in a coroutine.
Create a progress bar animation for a single task that runs synchronously.
Create a progress bar animation that runs in a coroutine.
Enter raw mode, emit input events until the flow in cancelled, then exit raw mode.
Enter raw mode, emit KeyboardEvents until the flow in cancelled, then exit raw mode.
Enter raw mode, emit MouseEvents until the flow in cancelled, then exit raw mode.
Enter raw mode, emit input events until the flow in cancelled, then exit raw mode.
The type of mouse tracking to enable.
Enter raw mode, emit KeyboardEvents until the flow in cancelled, then exit raw mode.
Enter raw mode, emit MouseEvents until the flow in cancelled, then exit raw mode.
The type of mouse tracking to enable.
Create an animator that runs this animation synchronously.
Run the animation in a background thread on an executor.
Start the animation and refresh it until all its tasks are finished.
Start the animation and refresh it until all its tasks are finished.
This calls Thread.sleep between each frame, so it should usually be run in a separate thread so that you can update the state concurrently.
Create an animator that runs this animation synchronously.
Run the animation in a background thread on an executor.
Start the animation and refresh it until all its tasks are finished.
Start the animation and refresh it until all its tasks are finished.
This calls Thread.sleep between each frame, so it should usually be run in a separate thread so that you can update the state concurrently.
Add a new task to the progress bar with the given definition and context.
Add a new task to the progress bar with the given definition.
Create an animator that runs this animation synchronously.
Run the animation in a background thread on an executor.
Remove a task with the given taskId from the progress bar.
Remove a task from the progress bar.
Start the animation and refresh it until all its tasks are finished.
Add a new task to the progress bar with the given definition and context.
The definition of the progress bar to add
The context to pass to the task
The total number of steps needed to complete the progress task, or null
if it is indeterminate.
The number of steps currently completed in the progress task.
If true
, start the task immediately.
If false
, the task will not be drawn to the screen.
Add a new task to the progress bar with the given definition and context.
Add a new task to the progress bar with the given definition.
Create an animator that runs this animation synchronously.
Remove a task with the given taskId from the progress bar.
Remove a task from the progress bar.
Remove a task with the given taskId from the progress bar.
true
if the task was removed, false
if it was not found.
Add a new task to the progress bar with the given definition and context.
The definition of the progress bar to add
The context to pass to the task
The total number of steps needed to complete the progress task, or null
if it is indeterminate.
The number of steps currently completed in the progress task.
If true
, start the task immediately.
If false
, the task will not be drawn to the screen.
An animation that can draw one or more progress tasks to the screen.
Add a new task to the progress bar with the given definition and context.
Add a new task to the progress bar with the given definition.
Remove a task with the given taskId from the progress bar.
Remove a task from the progress bar.
Remove a task with the given taskId from the progress bar.
true
if the task was removed, false
if it was not found.
Advance the completed progress of this task by amount.
Create a ProgressState for this task's current state
Update the task's state.
Set the completed progress of this task to completed.
Create a ProgressState for this task's current state
Update the task's state.
If the completed count is equal to the total, the task will be marked as finished.
If the task is already finished, this method will still update the task's state, but it will remain marked as finished. Use reset if you want to start the task again.
Note that if you are calling this method concurrently, the block may be called more than once, so it should not have any side effects.
A BlockingAnimator for a ProgressBarAnimation.
Add a new task to the progress bar with the given definition and context.
Add a new task to the progress bar with the given definition.
Create an animator that runs this animation synchronously.
Run the animation in a background thread on an executor.
Remove a task with the given taskId from the progress bar.
Remove a task from the progress bar.
Start the animation and refresh it until all its tasks are finished.
A BlockingAnimator for a single task.
Advance the completed progress of this task by amount.
Create an animator that runs this animation synchronously.
Run the animation in a background thread on an executor.
Create a ProgressState for this task's current state
Start the animation and refresh it until all its tasks are finished.
Update the task's state.
Set the completed progress of this task to completed.
Add a new task to the progress bar with the given definition.
Advance the completed progress of this task by amount.
This is a shortcut for update { completed += amount }
.
Create a progress bar animation with a single task that runs synchronously.
Use execute to run the animation on a background thread.
val animation = progressBarContextLayout<String> { ... }.animateOnThread(terminal, "context")
animation.execute()
animation.update { ... }
The terminal to draw the progress bar to
The context to pass to the task
The total number of steps needed to complete the progress task, or null
if it is indeterminate.
The number of steps currently completed in the progress task.
If true
, start the task immediately.
If false
, the task will not be drawn to the screen.
If true
, the animation will be cleared when all tasks are finished. Otherwise, the animation will stop when all tasks are finished, but remain on the screen.
The duration over which to estimate the speed of the progress tasks. This estimate will be a rolling average over this duration.
The time source to use for the animation.
The widget maker to use to lay out the progress bars.
Create a progress bar animation for a single task that runs synchronously.
Use execute to run the animation on a background thread.
val animation = progressBarLayout { ... }.animateOnThread(terminal)
animation.execute()
animation.update { ... }
The terminal to draw the progress bar to
The total number of steps needed to complete the progress task, or null
if it is indeterminate.
The number of steps currently completed in the progress task.
If true
, start the task immediately.
If false
, the task will not be drawn to the screen.
If true
, the animation will be cleared when all tasks are finished. Otherwise, the animation will stop when all tasks are finished, but remain on the screen.
The duration over which to estimate the speed of the progress tasks. This estimate will be a rolling average over this duration.
The time source to use for the animation.
The widget maker to use to lay out the progress bars.
Create an animator that runs this animation synchronously.
Use execute to run the animation on a background thread.
val animation = terminal.animation<Unit>{ ... }.animateOnThread(terminal)
animation.execute()
Create an animator that runs this animation synchronously.
Use execute to run the animation on a background thread.
val animator = animation.animateOnThread(terminal)
animator.execute()
Create an animator that runs this animation synchronously.
Use execute to run the animation on a background thread.
val animator = animation.animateOnThread()
animator.execute()
Run the animation in a background thread on an executor.
a Future that can be used to cancel the animation.
An animation that can draw one or more progress tasks to the screen.
A BlockingAnimator for a ProgressBarAnimation.
A BlockingAnimator for a single task.
Add a new task to the progress bar with the given definition.
Advance the completed progress of this task by amount.
Create an animator that runs this animation synchronously.
Create a progress bar animation for a single task that runs synchronously.
Create a progress bar animation with a single task that runs synchronously.
Run the animation in a background thread on an executor.
Remove a task from the progress bar.
Set the completed progress of this task to completed.
Remove a task from the progress bar.
true
if the task was removed, false
if it was not found.
Set the completed progress of this task to completed.
This is a shortcut for update { this.completed += completed }
.
An Animation renders a widget to the screen each time update is called, clearing the render from the previous call.
If you print anything in between calls to update, the rendered widget will be cleared, before the print, then rendered again below it.
Note that Animation doesn't render the widget automatically: you need to call update yourself when your data changes. If your terminal is not interactive, the animation will not render anything.
You can create instances of Animations with animation, textAnimation, animate a progressBarLayout, or by creating a subclass.
Note that although this class's state is thread safe, calling update concurrently will likely cause garbled output, so usage of this class should be serialized.
Create an animator that runs this animation synchronously.
Convert this Animation to a RefreshableAnimation.
Stop this animation and remove it from the screen.
Stop this animation without removing it from the screen.
Anything printed to the terminal after this call will be printed below this last frame of this animation.
Convert this Animation to a RefreshableAnimation.
terminal.animation<Unit> {/*...*/}.asRefreshable().animateOnThread()
The rate at which the animation should be refreshed.
A function that returns true
if the animation has finished.
Convert this Animation to a RefreshableAnimation.
The time between refreshes. This is 1 / refreshRate
Create an Animation that wraps the result of the draw function into a Text widget and renders it.
An InputReceiver that is also an StoppableAnimation.
Receive an input event.
Enter raw mode, read input from the terminal for this InputReceiver until it returns a result, then exit raw mode.
Receive an input event.
Enter raw mode, read input from the terminal for this InputReceiver until it returns a result, then exit raw mode.
Receive an input event.
Status.Continue to continue receiving events, or Status.Finished to stop.
The input event to process
Add an item to the list of items to select from
If true, clear the list when the user submits the selections. If false, leave it on screen
Run the select list in multi select mode.
The result will be the selected item titles, or null
if the user canceled the selection.
Run the select list in single select mode.
The result will be the selected item title, or null
if the user canceled the selection.
Set the marker to display where the cursor is located. Defaults to the theme string select.cursor
Set the description of the key to apply the filter when filtering in multi select mode
Set the description of the key to submit the selection in multi select mode
Set the description of the key to stop filtering the list
Set the description of the key to filter the list
Set the description of the key to move the cursor down
Set the description of the key to move the cursor up
Set the description of the key to submit the selection in single select mode
Set the description of the key to toggle the selection of an item in multi select mode
Set the list of items to select from
Set whether the list should be filterable
Configure an interactive selection list.
Run the selection with runSingleSelect
or runMultiSelect
. On JS and Wasm, where those methods aren't available, you can use createSingleSelectInputAnimation and createMultiSelectInputAnimation and feed them keyboard events manually.
Add an item to the list of items to select from
If true, clear the list when the user submits the selections. If false, leave it on screen
Run the select list in multi select mode.
Run the select list in single select mode.
Set the marker to display where the cursor is located. Defaults to the theme string select.cursor
Set the description of the key to apply the filter when filtering in multi select mode
Set the description of the key to submit the selection in multi select mode
Set the description of the key to stop filtering the list
Set the description of the key to filter the list
Set the description of the key to move the cursor down
Set the description of the key to move the cursor up
Set the description of the key to submit the selection in single select mode
Set the description of the key to toggle the selection of an item in multi select mode
Set the list of items to select from
Set whether the list should be filterable
Set the key to stop filtering the list
Set the key to filter the list
Set the key to move the cursor down
Set the key to move the cursor up
Set the key to submit the selection
Set the key to toggle the selection of an item in multi select mode
Set the maximum number of items that can be selected
If true, only show the description of the highlighted item
Set the marker to display for selected items. Defaults to the theme string select.selected
Set the style to use to highlight the currently selected item. Defaults to the theme style select.selected
Whether to show instructions at the bottom of the list
Set the index of the item to start the cursor on
Set the title to display above the list
Set the marker to display for unselected items. Defaults to the theme string select.unselected
Set the style to use for the marker of unselected items. Defaults to the theme style select.unselected-marker
Set the style to use for the title of unselected items. Defaults to the theme style select.unselected-title
Set the key to stop filtering the list
Set the key to filter the list
Set the key to move the cursor down
Set the key to move the cursor up
Set the key to submit the selection
Set the key to toggle the selection of an item in multi select mode
Set the maximum number of items that can be selected
If true, only show the description of the highlighted item
Set the marker to display for selected items. Defaults to the theme string select.selected
Set the style to use to highlight the currently selected item. Defaults to the theme style select.selected
Whether to show instructions at the bottom of the list
Set the index of the item to start the cursor on
Set the title to display above the list
Set the style to use for the marker of unselected items. Defaults to the theme style select.unselected-marker
Set the marker to display for unselected items. Defaults to the theme string select.unselected
Set the style to use for the title of unselected items. Defaults to the theme style select.unselected-title
An event representing a single key press, including modifiers keys.
This class uses the same format as the web KeyboardEvent.
Keep in mind that the not all modifier combinations or special keys are reported by all terminals.
A string describing the key pressed.
If the key is a printable character, this will be the character itself.
If the key is a special key, this will be a string describing the key, like "ArrowLeft"
. The full list of possible values is available at MDN, but not all terminals will report all keys.
If the key cannot be identified, the value is "Unidentified"
.
An event representing a single mouse event.
This includes button press, release, and movement events.
true
if the horizontal mouse wheel moved right. This is not reported on all platforms.
Any-event mode is the same as button-event mode, except that all motion events are reported, even if no mouse button is down.
Button-event tracking is essentially the same as normal tracking, but xterm also reports button-motion events. Motion events are reported only if the mouse pointer has moved to a different character cell.
Normal tracking mode sends an escape sequence on both button press and release. Modifier key (shift, ctrl, meta) information is also sent.
Returns a representation of an immutable list of all enum entries, in the order they're declared.
This method may be used to iterate over the enum entries.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
Returns an array containing the constants of this enum type, in the order they're declared.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
if this enum type has no constant with the specified name
Returns an array containing the constants of this enum type, in the order they're declared.
This method may be used to iterate over the constants.
Read a single input event from the terminal.
Read a single input event from the terminal.
Read a single keyboard event from the terminal, ignoring any mouse events that arrive first.
Read a single keyboard event from the terminal, ignoring any mouse events that arrive first.
Read a single mouse event from the terminal, ignoring any keyboard events that arrive first.
Read a single mouse event from the terminal, ignoring any keyboard events that arrive first.
Read a single input event from the terminal.
The event, or null
if no event was received before the timeout.
The maximum amount of time to wait for an event.
Read a single input event from the terminal.
The maximum amount of time to wait for an event.
if no event is received before the timeout, or input cannot be read.
Read a single keyboard event from the terminal, ignoring any mouse events that arrive first.
The event, or null
if no event was received before the timeout.
The maximum amount of time to wait for an event.
Read a single keyboard event from the terminal, ignoring any mouse events that arrive first.
The maximum amount of time to wait for an event.
if no event is received before the timeout, or input cannot be read.
Read a single mouse event from the terminal, ignoring any keyboard events that arrive first.
The event, or null
if no event was received before the timeout.
The maximum amount of time to wait for an event.
Read a single mouse event from the terminal, ignoring any keyboard events that arrive first.
The maximum amount of time to wait for an event.
if no event is received before the timeout, or input cannot be read.
Enter raw mode on the terminal, disabling line buffering and echoing to enable reading individual input events.
A scope that will restore the terminal to its previous state when closed, or null
if the terminal is not interactive.
What type of mouse events to listen for.
Enter raw mode on the terminal, disabling line buffering and echoing to enable reading individual input events.
A scope that will restore the terminal to its previous state when closed
What type of mouse events to listen for.
if the terminal is not interactive or raw mode cannot be entered.
An object that can receive input events.
An InputReceiver that is also an StoppableAnimation.
Configure an interactive selection list.
An event representing a single key press, including modifiers keys.
An event representing a single mouse event.
Enter raw mode on the terminal, disabling line buffering and echoing to enable reading individual input events.
Enter raw mode on the terminal, disabling line buffering and echoing to enable reading individual input events.
Display a list of items and allow the user to select zero or more with the arrow keys and enter.
Display a list of items and allow the user to select one with the arrow keys and enter.
Enter raw mode, read input from the terminal for this InputReceiver until it returns a result, then exit raw mode.
Enter raw mode, read input and pass any InputEvents to block until it returns a result, then exit raw mode.
Enter raw mode, read input and pass any KeyboardEvents to block until it returns a result, then exit raw mode.
Enter raw mode, read input and pass any MouseEvents to block until it returns a result, then exit raw mode.
Display a list of items and allow the user to select zero or more with the arrow keys and enter.
the selected item titles, or null if the user canceled the selection
Display a list of items and allow the user to select zero or more with the arrow keys and enter.
the selected item titles, or null if the user canceled the selection
The list of items to select from
The title to display above the list
Display a list of items and allow the user to select one with the arrow keys and enter.
the selected item title, or null if the user canceled the selection
Display a list of items and allow the user to select one with the arrow keys and enter.
the selected item title, or null if the user canceled the selection
The list of items to select from
The title to display above the list
Whether this event represents a Ctrl+C
key press.
Enter raw mode, read input from the terminal for this InputReceiver until it returns a result, then exit raw mode.
the result of the completed receiver.
The type of mouse tracking to enable.
if the terminal is not interactive or the input could not be read.
Enter raw mode, read input and pass any InputEvents to block until it returns a result, then exit raw mode.
the result of the completed receiver.
The type of mouse tracking to enable.
if the terminal is not interactive or the input could not be read.
Enter raw mode, read input and pass any KeyboardEvents to block until it returns a result, then exit raw mode.
the result of the completed receiver.
if the terminal is not interactive or the input could not be read.
Enter raw mode, read input and pass any MouseEvents to block until it returns a result, then exit raw mode.
the result of the completed receiver.
The type of mouse tracking to enable.
if the terminal is not interactive or the input could not be read.
Immediately exit the process with the given status code.
On browsers, where it's not possible to exit the process, this function is a no-op.
Utility functions useful for multiplatform command line apps interacting with the system.
Immediately exit the process with the given status code.
Get the value of an environment variable.
Read the contents of a file as a UTF-8 string.
Get the value of an environment variable.
If the variable is not set, this function returns null
.
Read the contents of a file as a UTF-8 string.
The file contents decoded as a UTF-8 string, or null
if the file could not be read.
Utility functions useful for multiplatform command line apps interacting with the system.
Returns a representation of an immutable list of all enum entries, in the order they're declared.
This method may be used to iterate over the enum entries.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
if this enum type has no constant with the specified name
Characters to use for one section of a BorderType
+--+--+
| | |
+--+--+
| | |
+--+--+
| | |
+--+--+
| | |
+--+--+
+--+--+
| | |
+==+==+
| | |
+--+--+
| | |
+==+==+
| | |
+--+--+
Whitespace as borders
╔══╦══╗
║ ║ ║
╠══╬══╣
║ ║ ║
╠══╬══╣
║ ║ ║
╠══╬══╣
║ ║ ║
╚══╩══╝
┏━━┳━━┓
┃ ┃ ┃
┣━━╋━━┫
┃ ┃ ┃
┣━━╋━━┫
┃ ┃ ┃
┣━━╋━━┫
┃ ┃ ┃
┗━━┻━━┛
┏━━┳━━┓
┃ ┃ ┃
┡━━╇━━┩
│ │ │
├──┼──┤
│ │ │
┢━━╈━━┪
┃ ┃ ┃
┗━━┻━━┛
╭──┬──╮
│ │ │
├──┼──┤
│ │ │
├──┼──┤
│ │ │
├──┼──┤
│ │ │
╰──┴──╯
┌──┬──┐
│ │ │
├──┼──┤
│ │ │
├──┼──┤
│ │ │
├──┼──┤
│ │ │
└──┴──┘
┌──┬──┐
│ │ │
╞══╪══╡
│ │ │
├──┼──┤
│ │ │
╞══╪══╡
│ │ │
└──┴──┘
Whitespace as borders
Characters to use to draw borders on a table or other box widget.
Create a copy of these lines with any existing styles replaced with style
Create a copy of these lines with any existing styles replaced with style
Truncate words that exceed the maximum line length, and replace the last visible character with …
Returns a representation of an immutable list of all enum entries, in the order they're declared.
This method may be used to iterate over the enum entries.
Setting for handling of long words that exceed the line length by themselves.
These values correspond to the values of the CSS overflow-wrap property.
Note that OverflowWrap
has no effect unless Whitespace.wrap is true
.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
Returns an array containing the constants of this enum type, in the order they're declared.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
if this enum type has no constant with the specified name
Returns an array containing the constants of this enum type, in the order they're declared.
This method may be used to iterate over the constants.
Align text to the left side of the widget, and include trailing whitespace so that all lines are the lame length.
Returns a representation of an immutable list of all enum entries, in the order they're declared.
This method may be used to iterate over the enum entries.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
if this enum type has no constant with the specified name
An rgb hex string in the form "#ffffff" or "ffffff"
Create a color code from an RGB color.
The red amount, in the range [0, 1]
The green amount, in the range [0, 1]
The blue amount, in the range [0, 1]
Create a with this color as the background.
Create a with this color as the background.
Create a with this color as the background.
Create a with this color as the background.
Create a with this color as the background.
Create a with this color as the background.
Create a with this color as the background.
Create a with this color as the background.
Create a with this color as the background.
Create a with this color as the background.
Returns a representation of an immutable list of all enum entries, in the order they're declared.
This method may be used to iterate over the enum entries.
Create a with this color as the background.
Create a with this color as the background.
Default text colors that can be used to style text.
These styles are not automatically downsampled. You should print the styled strings with Terminal.println to do so.
import com.github.ajalt.mordant.rendering.TextColors.*
val t = Terminal()
t.println("This text is ${green("colorful")}!")
Create a with this color as the background.
Returns a representation of an immutable list of all enum entries, in the order they're declared.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
Returns an array containing the constants of this enum type, in the order they're declared.
Create a with this color as the background.
Create a with this color as the background.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
if this enum type has no constant with the specified name
Returns an array containing the constants of this enum type, in the order they're declared.
This method may be used to iterate over the constants.
Create a with this color as the background.
Create a with this color as the background.
Create a with this color as the background.
red.bg == TextStyle(bgColor=red)
Create a with this color as the background.
Create a style with the foreground color of bg as the background color of the new style.
All other attributes will be copied from this style.
(red on blue) == TextStyle(color=red, bgColor=blue)
val style1 = TextStyle(red, bold=true)
val style2 = TextStyle(blue, italic=true)
(style1 on style2) == TextStyle(red, blue, bold=true)
Return a new style that combines this style with other.
And attributes that are set on both this and other will take the value from other. Any null
values on other will keep the value from this style.
val style1 = TextStyle(red, blue, bold=true, italic=true)
val style2 = TextStyle(green, italic=false, dim=true)
(style1 + style2) == TextStyle(green, blue, bold=true, italic=false, dim=true)
Create a text style with a hyperlink.
The destination should include an explicit protocol like https://
, since most terminals won't open links without one.
Returns a representation of an immutable list of all enum entries, in the order they're declared.
This method may be used to iterate over the enum entries.
Default text style that can be applied to text.
These styles are not automatically downsampled. You should print the styled strings with Terminal.println to do so.
import com.github.ajalt.mordant.rendering.TextStyles.*
val t = Terminal()
t.println("This text is ${bold("bold")}!")
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
Returns an array containing the constants of this enum type, in the order they're declared.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
if this enum type has no constant with the specified name
Returns an array containing the constants of this enum type, in the order they're declared.
This method may be used to iterate over the constants.
A theme that uses no text colors or styles, and uses only ASCII characters
Return a dimension if defined, or null
otherwise
Return a flag if defined, or null
otherwise
Return a dimension if defined, or null
otherwise
Return a flag if defined, or null
otherwise
Return a string if defined, or null
otherwise
Return a style if defined, or null
otherwise
Return a string if defined, or null
otherwise
Return a style if defined, or null
otherwise
Returns a representation of an immutable list of all enum entries, in the order they're declared.
This method may be used to iterate over the enum entries.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
Returns an array containing the constants of this enum type, in the order they're declared.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
if this enum type has no constant with the specified name
Returns an array containing the constants of this enum type, in the order they're declared.
This method may be used to iterate over the constants.
Wrap text and collapse all whitespaces and line breaks
Collapse spaces and line breaks, but don't wrap lines. This will effectively put all text on a single line.
Make no changes to the input text
Returns a representation of an immutable list of all enum entries, in the order they're declared.
This method may be used to iterate over the enum entries.
Settings for handling of whitespace and line wrapping.
These values correspond to the values of the CSS white-space property.
If true, line breaks in the text will be replaced with spaces.
If true, consecutive spaces will be replaced with a single space.
Returns a representation of an immutable list of all enum entries, in the order they're declared.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
Returns an array containing the constants of this enum type, in the order they're declared.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
if this enum type has no constant with the specified name
Returns an array containing the constants of this enum type, in the order they're declared.
This method may be used to iterate over the constants.
Characters to use to draw borders on a table or other box widget.
Characters to use for one section of a BorderType
Setting for handling of long words that exceed the line length by themselves.
Default text colors that can be used to style text.
Default text style that can be applied to text.
Settings for handling of whitespace and line wrapping.
Returns a representation of an immutable list of all enum entries, in the order they're declared.
This method may be used to iterate over the enum entries.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
if this enum type has no constant with the specified name
Set the number of columns that this cell should span. The value will be truncated to the width of the table.
Borders around each individual cell.
Set the number of columns that this cell should span. The value will be truncated to the width of the table.
Vertical alignment of cell contents
Borders around each individual cell.
For cells on the edges of the table, the outside borders can be overridden by tableBorders
Borders around each individual cell.
Vertical alignment of cell contents
Set the padding around each cell
If you want to set the padding around the entire layout, use withPadding.
The padding around each cell
If you want to set the padding around the entire layout, use withPadding.
Vertical alignment of cell contents
Borders around each individual cell.
Vertical alignment of cell contents
Set the width for this column
Set the width for this column
If false, (the default) padding in fixed width columns will reduce the content width so that the total width is always exactly the specified width.
If true, padding will be added to the specified width so padding never reduces the content width.
Configure a single column, which the first column at index 0.
If false, (the default) padding in fixed width columns will reduce the content width so that the total width is always exactly the specified width.
The column will fit to the size of its content
The column will expand to fill the available terminal width.
If there are multiple expanding columns, the available width will be divided among them proportional to their weights.
The column will have a fixed width.
The width includes padding, so increasing horizontal padding of a fixed column will decrease content width rather than expand the column.
The column will expand to fill the available terminal width.
The column will have a fixed width.
The weight of the column when expanding, or null
if the column should not expand.
If there are multiple expanding columns with the same priority, the available width will be divided among them proportional to their weights.
Configuration for how a column should be sized in a table.
Only fields containing the delimiter
, the quotechar
, or any characters in the lineterminator
will be quoted
Fields will never be quoted. If a special character (a delimeter, quote, or line terminator) is present in a field, it will be preceded by an escapechar
if one is specified, or an IllegalArgumentException will be thrown in escapechar
is null.
Returns a representation of an immutable list of all enum entries, in the order they're declared.
This method may be used to iterate over the enum entries.
All fields containing non-numeric characters will be quoted
Fields will never be quoted. If a special character (a delimeter, quote, or line terminator) is present in a field, it will be preceded by an escapechar
if one is specified, or an IllegalArgumentException will be thrown in escapechar
is null.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
Returns an array containing the constants of this enum type, in the order they're declared.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
if this enum type has no constant with the specified name
Returns an array containing the constants of this enum type, in the order they're declared.
This method may be used to iterate over the constants.
If false, (the default) padding in fixed width columns will reduce the content width so that the total width is always exactly the specified width.
Borders around each individual cell.
Vertical alignment of cell contents
If false, (the default) padding in fixed width columns will reduce the content width so that the total width is always exactly the specified width.
Vertical alignment of cell contents
Vertical alignment of cell contents
Borders around each individual cell.
Vertical alignment of cell contents
Add a row with one or more cells.
Add a row.
Configure a single column, which the first column at index 0.
Borders around each individual cell.
Vertical alignment of cell contents
Configure the body section.
A text style to apply to the cell border characters
The characters to use to draw cell edges
Configure the footer section.
Configure the header section.
If false, (the default) padding in fixed width columns will reduce the content width so that the total width is always exactly the specified width.
A text style to apply to the cell border characters
The characters to use to draw cell edges
Borders around each individual cell.
Which borders to draw on the outer edge of the table.
Vertical alignment of cell contents
Configure the body section.
Configure a single column, which the first column at index 0.
Configure the footer section.
Configure the header section.
Which borders to draw on the outer edge of the table.
This overrides cellBorders for borders on the outer edges of the table. The default values of null
will not override cellBorders.
Add padding around this widget.
Set the width for this layout. By default, the width is Auto
and lines are not padded to equal width.
The character used to separate fields
The character used to surround fields that contain any of the special characters: delimiter, quoteChar, or lineTerminator
The character placed before special characters when quoting is NONE or doubleQuote is false
If true
, occurrences of quoteChar inside a quoted field will be doubled. If false
, they will be prefixed by escapeChar, or an IllegalArgumentException will be thrown if escapeChar is null
.
The character used to terminate lines
The quoting method to use
Build a grid widget that can be used to lay out text and other widgets.
This builder functions like a table builder, but has no sections and no borders.
By default, there is one space between cells in a row. You can increase this by adding padding, or remove it by setting cellBorders to NONE.
Lay out widget in a horizontal row.
You can set the spacing between each widget in the layout.
Configuration for how a column should be sized in a table.
Build a grid widget that can be used to lay out text and other widgets.
Lay out widget in a horizontal row.
Build a table widget.
Lay out widgets in a vertical column.
Build a table widget.
Tables have three optional sections: the header, the body, and the footer.
Within each section, you can add entire rows of cells at once, or one at a time with the cell builder.
You can customize the table's styles at a number of levels, with more specific styles overriding less specific styles. The places you can customize are, from least-specific to most-specific:
Table: applies to every cell
Section: applies to all cells in the header, body, or footer
Table Column: applies to all cells in a column
Section Column: applies to all cells in a column for a single section
Row: applies to all cells in a row
Cell: applies to a single cell
A base class for terminal interfaces for JVM POSIX systems that uses System.in
for input.
Display a PrintRequest on this terminal.
Enter raw mode on the terminal, disabling line buffering and echoing to enable reading individual character.
Return the current size, in cells, of the terminal, or null if the size is unknown.
Read a single input event from the terminal, or null if no event is available but this call should be retried immediately.
Read a single line of input from stdin, returning null if no input is available
Return true if the getTerminalSize method should be called frequently to update the size.
Whether the input stream is detected as interactive.
Whether the output stream is detected as interactive.
Constants for termios flags and control characters.
The values for these are platform-specific. https://www.man7.org/linux/man-pages/man3/termios.3.html
Enter raw mode on the terminal, disabling line buffering and echoing to enable reading individual character.
A scope that will restore the terminal to its previous state when closed.
A terminal interface for POSIX systems.
This class provides a base interface for POSIX systems like Linux and macOS that use termios for terminal configuration.
Constants for termios flags and control characters.
Display a PrintRequest on this terminal.
Enter raw mode on the terminal, disabling line buffering and echoing to enable reading individual character.
Return the current size, in cells, of the terminal, or null if the size is unknown.
Read a single input event from the terminal, or null if no event is available but this call should be retried immediately.
Read a single line of input from stdin, returning null if no input is available
Return true if the getTerminalSize method should be called frequently to update the size.
Whether the input stream is detected as interactive.
Whether the output stream is detected as interactive.
Read a single input event from the terminal, or null if no event is available but this call should be retried immediately.
You would return null
if you receive an event that should be ignored, like a mouse event when mouse tracking is off.
The event, or null
if no event is available but this call should be retried
The point in time that this call should block to while waiting for an event. If the timeout is in the past, this method should not block.
The current mouse tracking mode.
Whether the input stream is detected as interactive.
Whether the output stream is detected as interactive.
Enter raw mode on the terminal, disabling line buffering and echoing to enable reading individual character.
A scope that will restore the terminal to its previous state when closed.
A base TerminalInterface implementation for Windows systems.
Display a PrintRequest on this terminal.
Enter raw mode on the terminal, disabling line buffering and echoing to enable reading individual character.
Return the current size, in cells, of the terminal, or null if the size is unknown.
Read a single input event from the terminal, or null if no event is available but this call should be retried immediately.
Read a single line of input from stdin, returning null if no input is available
Return true if the getTerminalSize method should be called frequently to update the size.
Whether the input stream is detected as interactive.
Whether the output stream is detected as interactive.
Read a single input event from the terminal, or null if no event is available but this call should be retried immediately.
You would return null
if you receive an event that should be ignored, like a mouse event when mouse tracking is off.
The event, or null
if no event is available but this call should be retried
The point in time that this call should block to while waiting for an event. If the timeout is in the past, this method should not block.
The current mouse tracking mode.
A base class for terminal interfaces for JVM POSIX systems that uses System.in
for input.
A terminal interface for POSIX systems.
A base TerminalInterface implementation for Windows systems.
Create a ConfirmationPrompt that uses StringPrompts to ask for input.
All parameters are passed to the StringPrompt constructor.
Create a ConfirmationPrompt from two strings which are passed to a builder to construct the prompt instances.
ConfirmationPrompt.create(
"Delete files?", "Are you sure?"
) { YesNoPrompt(it, terminal) }
Create a ConfirmationPrompt that uses StringPrompts to ask for input.
A prompt that requires the user to enter the same value twice.
You can create an instance of this class by passing in two Prompts to the constructor, or by using the create or createString methods.
Clear the line after the cursor, leaving anything after the cursor unchanged.
Clear the line before the cursor, leaving anything after the cursor unchanged.
Clear the current line.
Clear the screen after the cursor, leaving anything before the cursor unchanged.
Clear the screen before the cursor, leaving anything after the cursor unchanged.
Clear the entire terminal screen.
Clear the line after the cursor, leaving anything after the cursor unchanged.
Clear the line before the cursor, leaving anything after the cursor unchanged.
Clear the entire terminal screen.
Clear the screen after the cursor, leaving anything before the cursor unchanged.
Clear the screen before the cursor, leaving anything after the cursor unchanged.
Move the cursor to the position saved with a prior savePosition call.
Save the current cursor position. Restore it with restorePosition
Set the cursor to an absolute position.
Move the cursor to the start of the current line
Move the cursor to the position saved with a prior savePosition call.
Save the current cursor position. Restore it with restorePosition
Move the cursor to the start of the current line
If True, a trailing linebreak should be written after the text.
The base class for prompts.
ask will print the prompt and ask for a line of user input and return the result of passing that line to convert. If convert instead returns ConversionResult.Invalid, its message will be printed and the user will be asked for input again.
prompt.prompt
: applied to the prompt string
prompt.choices
: applied to the rendered choices values when shown in the prompt
prompt.default
: applied to the rendered default value when shown in the prompt
prompt.choices.invalid
: applied to the invalidChoiceMessage when shown
danger
: applied to the error message returned by convert
Display a PrintRequest on this terminal.
A base class for terminal interfaces that prints using standard kotlin.io
functions.
Display a PrintRequest on this terminal.
Enter raw mode on the terminal, disabling line buffering and echoing to enable reading individual character.
Return the current size, in cells, of the terminal, or null if the size is unknown.
Read a single input event from the terminal, or null if no event is available but this call should be retried immediately.
Read a single line of input from stdin, returning null if no input is available
Return true if the getTerminalSize method should be called frequently to update the size.
Whether the input stream is detected as interactive.
Whether the output stream is detected as interactive.
Get information about the current terminal.
The level of ANSI codes to use, or null
to autodetect.
Whether to enable hyperlink support, or null
to autodetect.
Whether the output stream is interactive. If null
, it will be autodetected.
Whether the input stream is interactive. If null
, it will be autodetected.
Read a single line of input from stdin, returning null if no input is available
If true, treat the input like a password that should not be echoed to the screen as it's typed.
if the current interface doesn't support reading input. Currently, all targets are supported by default except Browser JS.
Whether the input stream is detected as interactive.
Whether the output stream is detected as interactive.
A Prompt that returns the user input unchanged.
Return a string contianing the ANSI codes for the movements commands called in movements.
If the terminal is not interactive, this will always return an empty string.
Print the movement commands called in movements.
Print the movement commands called in movements.
If the terminal is not interactive, this call does nothing.
Show the cursor
Detect information about the current terminal.
The desired level of ANSI support. If null
, the level will be detected.
Whether to enable hyperlink support. If null
, hyperlinks support will be detected.
Force stdin to be treated as interactive. If null
, stdin will be detected.
Force stdout to be treated as interactive. If null
, stdout will be detected.
Whether stdin was detected as interactive.
Whether stdout was detected as interactive.
Detect information about the current terminal.
Detect information about the current terminal.
If true, ANSI hyperlink codes can be used
If true, ANSI hyperlink codes can be used
If false the intput stream is not an interactive terminal, such as when it's redirected from a file
Return true if both input and output are interactive
If false the output stream is not an interactive terminal, such as when it's redirected to a file.
If false using ANSI cursor movement codes may not work.
If false the intput stream is not an interactive terminal, such as when it's redirected from a file
Return true if both input and output are interactive
If false the output stream is not an interactive terminal, such as when it's redirected to a file.
If false using ANSI cursor movement codes may not work.
A provider for a TerminalInterface.
Implementations of this interface are loaded via the ServiceLoader
mechanism, and should be declared in the META-INF/services/com.github.ajalt.mordant.terminal.TerminalInterfaceProvider
file.
Load the terminal interface.
The terminal interface, or null if it could not be loaded.
Display a PrintRequest on this terminal.
Enter raw mode on the terminal, disabling line buffering and echoing to enable reading individual character.
A scope that will restore the terminal to its previous state when closed.
Return the current size, in cells, of the terminal, or null if the size is unknown.
Display a PrintRequest on this terminal.
Enter raw mode on the terminal, disabling line buffering and echoing to enable reading individual character.
Return the current size, in cells, of the terminal, or null if the size is unknown.
Read a single input event from the terminal, or null if no event is available but this call should be retried immediately.
Read a single line of input from stdin, returning null if no input is available
Return true if the getTerminalSize method should be called frequently to update the size.
Get information about the current terminal.
The level of ANSI codes to use, or null
to autodetect.
Whether to enable hyperlink support, or null
to autodetect.
Whether the output stream is interactive. If null
, it will be autodetected.
Whether the input stream is interactive. If null
, it will be autodetected.
Read a single input event from the terminal, or null if no event is available but this call should be retried immediately.
You would return null
if you receive an event that should be ignored, like a mouse event when mouse tracking is off.
The event, or null
if no event is available but this call should be retried
The point in time that this call should block to while waiting for an event. If the timeout is in the past, this method should not block.
The current mouse tracking mode.
Read a single line of input from stdin, returning null if no input is available
If true, treat the input like a password that should not be echoed to the screen as it's typed.
if the current interface doesn't support reading input. Currently, all targets are supported by default except Browser JS.
Return true if the getTerminalSize method should be called frequently to update the size.
Display a PrintRequest on this terminal.
Enter raw mode on the terminal, disabling line buffering and echoing to enable reading individual character.
A scope that will restore the terminal to its previous state when closed.
Return the current size, in cells, of the terminal, or null if the size is unknown.
A TerminalInterface that records all output and allows you to provide input.
val recorder = TerminalRecorder()
val t = Terminal(terminalInterface = recorder)
t.println("Hello, world!")
assertEquals(recorder.output(), "Hello, world!\n")
Input events to return when reading in raw mode
Lines of input to return from readLineOrNull.
Display a PrintRequest on this terminal.
Enter raw mode on the terminal, disabling line buffering and echoing to enable reading individual character.
Return the current size, in cells, of the terminal, or null if the size is unknown.
Render the contents of this TerminalRecorder as an HTML document.
Read a single input event from the terminal, or null if no event is available but this call should be retried immediately.
Read a single line of input from stdin, returning null if no input is available
Return true if the getTerminalSize method should be called frequently to update the size.
Get information about the current terminal.
The level of ANSI codes to use, or null
to autodetect.
Whether to enable hyperlink support, or null
to autodetect.
Whether the output stream is interactive. If null
, it will be autodetected.
Whether the input stream is interactive. If null
, it will be autodetected.
Input events to return when reading in raw mode
Lines of input to return from readLineOrNull.
Read a single input event from the terminal, or null if no event is available but this call should be retried immediately.
You would return null
if you receive an event that should be ignored, like a mouse event when mouse tracking is off.
The event, or null
if no event is available but this call should be retried
The point in time that this call should block to while waiting for an event. If the timeout is in the past, this method should not block.
The current mouse tracking mode.
Read a single line of input from stdin, returning null if no input is available
If true, treat the input like a password that should not be echoed to the screen as it's typed.
if the current interface doesn't support reading input. Currently, all targets are supported by default except Browser JS.
The level of color support to use, or null
to detect the level of the current terminal
The theme to use for widgets and styles like success
The width to render widget and wrap text, or null
to detect the current width.
The height of the terminal to use when rendering widgets, or null
to detect the current width.
The width to use when the terminal is not interactive, or null
to use the default of 79 columns.
The height to use when the terminal is not interactive, or null
to use the default of 24 rows.
whether to render hyperlinks using ANSI codes, or null
to detect the capability
The number of spaces to use for \t
characters
Set to true to always use color codes, even if stdout is redirected to a file, or null
to detect the capability. This can be useful if you expect to call your program from some other source like gradle that forwards the output to the terminal.
The terminal interface to use to interact with the terminal.
Functions for controlling the terminal's cursor.
If the terminal is not interactive, all the cursor functions are no-ops.
Functions for printing styled text to the terminal.
Use functions like print and println instead of kotlin.io.println to automatically downsample any TextColors and TextStyles you use in strings, and to render widgets like table and HorizontalRule.
The default constructor for this class will detect the current terminal capabilities, but you can override this detection by passing your desired value for ansiLevel
, hyperlinks
, and interactive
.
Functions for controlling the terminal's cursor.
The terminal capabilities that were detected or set in the constructor.
The interface to use to interact with the system terminal.
Print a line styled with the theme's Theme.danger style.
Enter raw mode on the terminal, disabling line buffering and echoing to enable reading individual input events.
Enter raw mode on the terminal, disabling line buffering and echoing to enable reading individual input events.
Print a line styled with the theme's Theme.info style.
Display a list of items and allow the user to select zero or more with the arrow keys and enter.
Display a list of items and allow the user to select one with the arrow keys and enter.
Print a line styled with the theme's Theme.muted style.
Print a widget to the terminal.
Print a message to the terminal.
Print a line break to the terminal.
Print a widget to the terminal, followed by a line break.
Print a message to the terminal, followed by a line break.
Print a prompt to the user and return the value they enter.
Read a line of input from stdin.
Enter raw mode, read input and pass any InputEvents to block until it returns a result, then exit raw mode.
Enter raw mode, read input and pass any KeyboardEvents to block until it returns a result, then exit raw mode.
Enter raw mode, read input and pass any MouseEvents to block until it returns a result, then exit raw mode.
Print a line styled with the theme's Theme.success style.
Detect the current terminal's size and update size.
Print a line styled with the theme's Theme.warning style.
Print a message to the terminal.
Any contained TextColors and TextStyles will be automatically downsampled based on the current terminal's terminalInfo.
The message to print as a string.
How to handle whitespace and line wrapping. By default, whitespace is printed unchanged and lines are not wrapped.
How to align text in the terminal. By default, no alignment is performed.
How to wrap words longer than a single line. By default, long words are not wrapped.
The width to wrap to if whitespace or overflowWrap are set. By default, this will use TerminalInfo.width
Whether to print to stderr instead of stdout.
Print a widget to the terminal.
Print a message to the terminal, followed by a line break.
Any contained TextColors and TextStyles will be automatically downsampled based on the current terminal's terminalInfo.
The message to print as a string.
How to handle whitespace and line wrapping. By default, whitespace is printed unchanged and lines are not wrapped.
How to align text in the terminal. By default, no alignment is performed.
How to wrap words longer than a single line. By default, long words are not wrapped.
The width to wrap to if whitespace or overflowWrap are set. By default, this will use TerminalInfo.width
Whether to print to stderr instead of stdout.
Print a widget to the terminal, followed by a line break.
Print a line break to the terminal.
Read a line of input from stdin.
This is similar to readlnOrNull, but is supported on NodeJS, and uses this terminal's interface, so it can be customized or mocked for testing.
Render a message to a string.
Any contained TextColors and TextStyles will be automatically downsampled based on the current terminal's terminalInfo.
The message to render as a string.
How to handle whitespace and line wrapping. By default, whitespace is printed unchanged and lines are not wrapped.
How to align text in the terminal. By default, no alignment is performed.
How to wrap words longer than a single line. By default, long words are not wrapped.
The width to wrap to if whitespace or overflowWrap are set. By default, this will use TerminalInfo.width
Render a widget as a string
The terminal capabilities that were detected or set in the constructor.
The interface to use to interact with the system terminal.
Detect the current terminal's size and update size.
This is called automatically whenever you print to the terminal.
The message asking for input to show the user
The terminal to use
The value to return if the user enters an empty line, or null
to require a value
If true and default is not null
, the default choice will be shown in uppercase.
If true, the choices will be added to the prompt
The strings to accept for true
and false
inputs
A string to append after prompt when showing the user the prompt
The message to show the user if they enter a value that isn't one of the choiceStrings.
A boolean prompt that asks for a yes or no response.
The message asking for input to show the user
The terminal to use
The value to return if the user enters an empty line, or null
to require a value
If true and default is not null
, the default choice will be shown in uppercase.
If true, the choices will be added to the prompt
The strings to accept for true
and false
inputs
A string to append after prompt when showing the user the prompt
The message to show the user if they enter a value that isn't one of the choiceStrings.
Print a line styled with the theme's Theme.danger style.
The base class for prompts.
A base class for terminal interfaces that prints using standard kotlin.io
functions.
A Prompt that returns the user input unchanged.
Detect information about the current terminal.
A provider for a TerminalInterface.
A TerminalInterface that records all output and allows you to provide input.
A boolean prompt that asks for a yes or no response.
Print a line styled with the theme's Theme.danger style.
Print a line styled with the theme's Theme.info style.
Print a line styled with the theme's Theme.muted style.
Render the contents of this TerminalRecorder as an HTML document.
Print a prompt to the user and return the value they enter.
Print a line styled with the theme's Theme.success style.
Print a line styled with the theme's Theme.warning style.
Print a line styled with the theme's Theme.info style.
Print a line styled with the theme's Theme.muted style.
Render the contents of this TerminalRecorder as an HTML document.
If true, the output will be wrapped in <html><body>
tags.
If true, the output will be wrapped in <pre><code>
tags. If false, only <pre>
will be used.
If given, the output will be wrapped in a terminal frame with this background color.
Print a prompt to the user and return the value they enter.
To customize the prompt behavior, see the Prompt class.
The message asking for input to show the user
The value to return if the user enters an empty line, or null
to require a value
If true and a default is specified, add the default value to the prompt
If true, the user's input will be treated like a password and hidden from the screen. This value will be ignored on platforms where it is not supported.
The set of values that the user must choose from.
A string to append after prompt when showing the user the prompt
The message to show the user if choices is specified, and they enter a value that isn't one of the choices.
Print a line styled with the theme's Theme.success style.
Print a line styled with the theme's Theme.warning style.
How to align the columns of the progress bar when multiple tasks are present.
The cells in this layout.
A ProgressBarDefinition that caches the widgets for each cell so that they only update as fast as their fps.
Create a progress bar animation for a single task that runs synchronously.
Create a progress bar animation with a single task that runs synchronously.
Create a widget for this ProgressBarDefinition with the given state.
Create a widget for this ProgressBarDefinition with the given state.
Cache this progress bar definition so that each cell only updates as often as its fps.
Invalidate the cache for this definition.
Invalidate the cache for this definition.
Build the widgets for each cell in the progress bar.
This can be used if you want to manually include the individual cells in a layout like a table.
A list of rows, where each row is a list of widgets for the cells in that row.
Build a progress widget with the given rows.
The default implementation of ProgressBarWidgetMaker.
It uses a grid or verticalLayout to render the progress bars.
Build a progress widget with the given rows.
Build the widgets for each cell in the progress bar.
Create a new progress bar layout definition.
How to align the columns of the progress bar when multiple tasks are present.
The cells in this layout.
The cells and configuration for a progress bar layout.
Create a progress bar animation for a single task that runs synchronously.
Create a progress bar animation with a single task that runs synchronously.
Create a widget for this ProgressBarDefinition with the given state.
Create a widget for this ProgressBarDefinition with the given state.
Cache this progress bar definition so that each cell only updates as often as its fps.
Build a progress widget with the given rows.
Instances of this interface creates widgets for progress bars.
The default implementation is MultiProgressBarWidgetMaker.
Build a progress widget with the given rows.
The default framerate for animation cells
Build the progress bar layout.
Add a cell to this layout.
The content will be called every time the cell is rendered. In the case of animations, that will usually be at its fps.
The width of the cell.
The number of times per second to refresh the cell when animated. If 0, the cell should not be refreshed.
The text alignment for the cell when multiple tasks are present and cells are aligned, or null
to use the default.
The vertical alignment for the cell if there are other taller cells in the layout, or null
to use the default.
A lambda returning the widget to display in this cell.
A builder for creating a progress bar layout.
If you don't want to use the progressBarLayout DSL, you can use this builder instead, and call build when you're done adding cells.
Add a cell to this layout.
Add a cell that displays the current completed count to this layout.
Add a fixed width text cell that scrolls its contents horizontally so that long text can be displayed in a fixed width.
Add a cell that displays the current percentage to this layout.
Add a progress bar cell to this layout.
Add a cell that displays the current speed to this layout.
Add a Spinner to this layout.
Add a fixed text cell to this layout.
Add a dynamic text cell to this layout.
Add a cell that displays the elapsed time to this layout.
Add a cell that displays the time remaining to this layout.
The default vertical alignment for cells
The default framerate for animation cells
Add a cell to this layout.
The content will be called every time the cell is rendered. In the case of animations, that will usually be at its fps.
The width of the cell.
The number of times per second to refresh the cell when animated. If 0, the cell should not be refreshed.
The text alignment for the cell when multiple tasks are present and cells are aligned, or null
to use the default.
The vertical alignment for the cell if there are other taller cells in the layout, or null
to use the default.
A lambda returning the widget to display in this cell.
Add a cell to this layout.
Add a cell that displays the current completed count to this layout.
Add a fixed width text cell that scrolls its contents horizontally so that long text can be displayed in a fixed width.
Add a cell that displays the current percentage to this layout.
Add a progress bar cell to this layout.
Add a cell that displays the current speed to this layout.
Add a Spinner to this layout.
Add a fixed text cell to this layout.
Add a dynamic text cell to this layout.
Add a cell that displays the elapsed time to this layout.
Add a cell that displays the time remaining to this layout.
The default vertical alignment for cells
Create a ProgressState with no context.
The time that this task finished, or null
if it isn't finished.
The time that this task was paused, or null
if it isn't paused.
The time that this task started, or null
if it hasn't started.
The time that this task finished, or null
if it isn't finished.
The time that this task was paused, or null
if it isn't paused.
The time that this task started, or null
if it hasn't started.
The time that this task finished, or null
if it isn't finished.
The time that this task was paused, or null
if it isn't paused.
The time that this task started, or null
if it hasn't started.
The time that this task finished, or null
if it isn't finished.
The time that this task was paused, or null
if it isn't paused.
The time that this task started, or null
if it hasn't started.
The time that this task finished, or null
if it isn't finished.
The time that this task was paused, or null
if it isn't paused.
The time that this task started, or null
if it hasn't started.
The time that the progress layout was first constructed.
Use this for continuous animations, since it's the same for all tasks.
The time that the progress layout was first constructed.
true
if the task's status is NotStarted.
true
if the task does not have a total specified.
The running status of the task.
Calculate the time elapsed for this task, or null
if the task hasn't started.
Calculate the estimated time remaining for this task, or null
if the time cannot be estimated.
Return the number of frames that have elapsed at the given fps since the start of the animationTime.
The running status of the task.
Build a progress widget with the given rows.
Create a widget for this ProgressBarDefinition with the given state.
Create a widget for this ProgressBarDefinition with the given state.
Cache this progress bar definition so that each cell only updates as often as its fps.
Calculate the time elapsed for this task, or null
if the task hasn't started.
If the task is finished or paused, the elapsed time is the time between the start and finish/pause times. If the task is running, the elapsed time is the time between the start and now.
Calculate the estimated time remaining for this task, or null
if the time cannot be estimated.
If true
, return the total elapsed time when the task is finished.
Add a cell that displays the current completed count to this layout.
A string to append to the end of the displayed count, such as "B" if you are tracking bytes. Empty by default.
If true, the total count will be displayed after the completed count, separated by a slash. True by default.
The number of decimal places to display. 1 by default.
The style to use for the displayed count.
The number of times per second to update the displayed count. Uses the text fps by default.
The time that this task finished, or null
if it isn't finished.
Return the number of frames that have elapsed at the given fps since the start of the animationTime.
A ProgressBarDefinition that caches the widgets for each cell so that they only update as fast as their fps.
The default implementation of ProgressBarWidgetMaker.
The cells and configuration for a progress bar layout.
Instances of this interface creates widgets for progress bars.
A builder for creating a progress bar layout.
The time that this task finished, or null
if it isn't finished.
true
if the task's status is NotStarted.
true
if the task does not have a total specified.
The time that this task was paused, or null
if it isn't paused.
The time that this task started, or null
if it hasn't started.
Build a progress widget with the given rows.
Create a widget for this ProgressBarDefinition with the given state.
Create a widget for this ProgressBarDefinition with the given state.
Cache this progress bar definition so that each cell only updates as often as its fps.
Calculate the time elapsed for this task, or null
if the task hasn't started.
Calculate the estimated time remaining for this task, or null
if the time cannot be estimated.
Add a cell that displays the current completed count to this layout.
Return the number of frames that have elapsed at the given fps since the start of the animationTime.
Add a fixed width text cell that scrolls its contents horizontally so that long text can be displayed in a fixed width.
Add a cell that displays the current percentage to this layout.
Add a progress bar cell to this layout.
Create a progress bar layout with that has a context of type T.
Create a new progress bar layout definition.
Create a progress bar layout that doesn't use a context.
Create a ProgressState with no context.
Add a cell that displays the current speed to this layout.
Add a Spinner to this layout.
Add a fixed text cell to this layout.
Add a dynamic text cell to this layout.
Add a cell that displays the elapsed time to this layout.
Add a cell that displays the time remaining to this layout.
true
if the task's status is NotStarted.
true
if the task does not have a total specified.
Add a fixed width text cell that scrolls its contents horizontally so that long text can be displayed in a fixed width.
The width of the cell in characters.
The number of times per second to update the displayed text.
The text alignment for this cell when scrollWhenContentFits is false
and the content fits in the width.
If true
, the text will always scroll, even if it fits in the width.
The text to display in this cell.
Add a fixed width text cell that scrolls its contents horizontally so that long text can be displayed in a fixed width.
The text to display in this cell.
The width of the cell in characters.
The number of times per second to update the displayed text.
The text alignment for this cell when scrollWhenContentFits is false
and the content fits in the width.
If true
, the text will always scroll, even if it fits in the width.
The time that this task was paused, or null
if it isn't paused.
Add a cell that displays the current percentage to this layout.
The number of times per second to update the displayed percentage. Uses the text fps by default.
Create a progress bar layout with that has a context of type T.
If you don't need a context, you can use progressBarLayout instead. If you need a builder rather than a DSL, you can use ProgressLayoutBuilder.
The number of spaces between cells in this layout.
How to align the columns of the progress bar when multiple tasks are present. If true
, the cells in each column will have the same width. Widths are only aligned for contiguous cells, so if you have a row with alignColumns=false
between rows with alignColumns=true
, none of the three will be aligned.
The default framerate for text based cells like timeRemaining
The default framerate for animation cells like progressBar
The default horizontal alignment for cells
The default vertical alignment for cells
A lambda that adds cells to the layout
Create a progress bar layout that doesn't use a context.
If you need a context, you can use progressBarContextLayout instead.
The number of spaces between cells in this layout.
How to align the columns of the progress bar when multiple tasks are present. If true
, the cells in each column will have the same width. Width are only aligned for contiguous cells, so if you have a row with alignColumns=false
between rows with alignColumns=true
, none of the three will be aligned.
The default framerate for text based cells like timeRemaining
The default framerate for animation cells like progressBar
The default horizontal alignment for cells
The default vertical alignment for cells
A lambda that adds cells to the layout
Add a progress bar cell to this layout.
The width in characters for this widget, or null
to expand to fill the remaining space.
(theme string: "progressbar.pending") The character to use to draw the pending portion of the bar in the active state.
(theme string: "progressbar.separator") The character to draw in between the competed and pending bar in the active state.
(theme string: "progressbar.complete") The character to use to draw the completed portion of the bar in the active state.
(theme style: "progressbar.pending") The style to use for the pendingChars
(theme style: "progressbar.separator") The style to use for the separatorChar
(theme style: "progressbar.complete") The style to use for the completeChar when completed < total
(theme style: "progressbar.complete") The style to use for the completeChar when total <= completed
e (theme style: "progressbar.separator") The style to use when the state us indeterminate
(theme flag: "progressbar.pulse") The time that it takes for one cycle of the pulse animation. 2 seconds by default. Set this to 0 or the theme flag to false
to disable the pulse.
The number of times per second to update the displayed bar. Uses the animation fps by default.
Add a cell that displays the current speed to this layout.
A string to append to the end of the displayed speed, such as "B/s" if you are tracking bytes. "/s" by default.
The style to use for the displayed speed.
The number of times per second to update the displayed speed. Uses the text fps by default.
Add a Spinner to this layout.
spinner(Spinner.Dots())
The spinner to display
The number of times per second to advance the spinner's displayed frame. 8 by default.
The time that this task started, or null
if it hasn't started.
Add a fixed text cell to this layout.
The cell is always the same size as the content. For a fixed-width text cell, use marquee.
The text to display in this cell.
The text alignment for this cell. Cells are right-aligned by default.
Add a dynamic text cell to this layout.
The content lambda will be called with the current progress state as its receiver.
The cell is always the same size as the content. For a fixed-width text cell, use marquee.
text { context.toString() }
The text alignment for this cell. Cells are right-aligned by default.
A lambda returning the text to display in this cell.
Add a cell that displays the elapsed time to this layout.
If true
, the displayed time will be formatted as "MM:SS" if time remaining is less than an hour. false
by default.
The style to use for the displayed time.
The number of times per second to update the displayed time. Uses the text fps by default.
Add a cell that displays the time remaining to this layout.
A string to prepend to the displayed time, such as "eta "
or "time left: "
. "eta "
by default.
If true
, the displayed time will be formatted as "MM:SS"
if time remaining is less than an hour. false
by default.
If true
, the elapsed time will be displayed when the task is finished. false
by default.
A string to prepend to the displayed time when elapsedWhenFinished is true
. " in "
by default.
The style to use for the displayed time.
The number of times per second to update the displayed time. Uses the text fps by default.
The number of blank lines between entries
Set the description for this entry
Set the description for this entry to a Text widget.
All function parameters are forwarded to the Text constructor.
Set the description for this entry
Set the description for this entry to a Text widget.
Set the term for this entry
Set the term for this entry to a Text widget.
Set the term for this entry
Set the term for this entry to a Text widget.
All function parameters are forwarded to the Text constructor.
A line drawn across the terminal, with an optional title.
The content to draw in the center of the panel.
The content to draw in the top border
The content to draw in the bottom border
If true, the panel will expand horizontally to fill the screen. If false, it will be just wide enough to fit the content.
Extra padding to add between the content and the panel border. (default: no extra padding)
The type of border to draw around the content, or null
for no border
The horizontal alignment for the top title (default: center)
The horizontal alignment for the bottom title (default: copy titleAlign)
The TextStyle for the border (default: Theme style panel.border
)
Amount of horizontal padding to add between the titles and the border characters (default: Theme value panel.title.padding
)
The content to draw in the center of the panel.
The content to draw in the top border
The content to draw in the bottom border
If true, the panel will expand horizontally to fill the screen. If false, it will be just wide enough to fit the content.
Extra padding to add between the content and the panel border. (default: no extra padding)
The type of border to draw around the content, or null
for no border
The horizontal alignment for the top title (default: center)
The horizontal alignment for the bottom title (default: copy titleAlign)
The TextStyle for the border (default: Theme style panel.border
)
Amount of horizontal padding to add between the titles and the border characters (default: Theme value panel.title.padding
)
A box drawn around another widget, with optional top and bottom titles.
terminal.print(Panel(
"my panel content",
title = "title",
bottomTitle = "subtitle",
titleAlign = TextAlign.LEFT,
bottomTitleAlign = TextAlign.RIGHT
))
╭─ title ────────╮
│my panel content│
╰───── subtitle ─╯
The bar draws the fraction complete as completed
The bar draws the fraction complete as completed
The width in characters for this widget
When indeterminate is true, the pulse animation is drawn at a fraction along the bar calculated by pulsePosition % 1.0
(theme flag: "progressbar.pulse") If false, never draw the pulse animation in the indeterminate state.
(theme string: "progressbar.pending") The character to use to draw the pending portion of the bar in the active state.
(theme string: "progressbar.separator") The character to draw in between the competed and pending bar in the active state.
(theme string: "progressbar.complete") The character to use to draw the completed portion of the bar in the active state.
(theme style: "progressbar.pending") The style to use for the pendingChars
(theme style: "progressbar.separator") The style to use for the separatorChar
(theme style: "progressbar.complete") The style to use for the completeChar when completed<total
(theme style: "progressbar.complete") The style to use for the completeChar when total<= completed
e (theme style: "progressbar.separator") The style to use when indeterminate is true
A number between 0 and 1, with 0 drawing all pendingChars, and 1 drawing all completeChars
If true, fractionComplete is ignored and the bar draws in an indeterminate state
The width in characters for this widget
When indeterminate is true, the pulse animation is drawn at a fraction along the bar calculated by pulsePosition % 1.0
(theme flag: "progressbar.pulse") If false, never draw the pulse animation in the indeterminate state.
(theme string: "progressbar.pending") The character to use to draw the pending portion of the bar in the active state.
(theme string: "progressbar.separator") The character to draw in between the competed and pending bar in the active state.
(theme string: "progressbar.complete") The character to use to draw the completed portion of the bar in the active state.
(theme style: "progressbar.pending") The style to use for the pendingChars
(theme style: "progressbar.separator") The style to use for the separatorChar
(theme style: "progressbar.complete") The style to use for the completeChar when fractionComplete< 1
(theme style: "progressbar.complete") The style to use for the completeChar when fractionComplete == 1
e (theme style: "progressbar.separator") The style to use when indeterminate is true
A horizontal bar that tracks progress.
The bar has three states:
indeterminate: the bar will draw its full width and show a pulsing animation based on pulsePosition
in progress: the bar will draw a width proportional to fractionComplete
, or completed / total
finished: the bar will draw its full width with no pulse.
An optional description of the entry.
A list widget with selectable items.
Use interactiveSelectList
to create a list that can be interacted with.
Increment the tick value by one and return the new value.
The current frame
A widget that will loop through a fixed list of frames.
The widget will render the same frame until tick is set or advanceTick is called, at which point the next frame will render. The animation will loop when tick is larger than the number frames.
To reduce the speed of the animation, increase the duration.
the starting tick value.
Increment the tick value by one and return the new value.
Add padding around this widget.
Crop or pad another content widget to a fixed size, and optionally scroll visible portion of the widget within that size.
If width or height are larger than the size of the content widget, the extra space will be filled with spaces.
You can specify scrollRight and scrollDown to scroll the viewport across the content. Negative values will scroll the widget to the right or up, respectively.
val text = Text(
"""
123
456
7890
""".trimIndent()
)
val viewport1 = Viewport(text, width = 2, height = 2, scrollRight = 1, scrollDown = 1)
terminal.println(Panel(viewport1))
val viewport2 = Viewport(text, width = 2, height = 2, scrollRight = -1, scrollDown = -1)
terminal.println(Panel(viewport2))
Will print the following:
╭──╮
│56│
│89│
╰──╯
╭──╮
│ │
│ 1│
╰──╯
Build a definition list widget.
Call entry to add entries
A widget with 0 width, 0 height, and no content.
A line drawn across the terminal, with an optional title.
A numbered list of widgets.
A horizontal bar that tracks progress.
A list widget with selectable items.
Build a definition list widget.
Add padding around this widget.
Add padding around this widget.
By default, horizontal padding will be added to every line of the output, even if the line is empty. If you set padEmptyLines to false
, no padding will be added to empty lines.