Viewport
class Viewport(content: Widget, width: Int?, height: Int? = null, scrollRight: Int = 0, scrollDown: Int = 0) : 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.
Example
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))
Content copied to clipboard
Will print the following:
╭──╮
│56│
│89│
╰──╯
╭──╮
│ │
│ 1│
╰──╯
Content copied to clipboard