# Text-UI View backend

DevFeed: [Text-UI View backend](<https://devfeed.tech/articles/text-ui-view-backend-22389.md>)

Original publisher: [Read original article](<https://www.red-lang.org/2024/06/text-ui-view-backend.html>)

Author: Nenad Rakocevic (noreply@blogger.com)

Published: 2024-06-11T14:02:00Z

Content type: release

Language: en

Sources: [Red](<https://devfeed.tech/sources/red.md>)

Topics: [Text-based user interface](<https://devfeed.tech/topics/tui.md>), [console](<https://devfeed.tech/topics/console.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>)

Tags: [ansi](<https://devfeed.tech/tags/ansi.md>), [backend](<https://devfeed.tech/tags/backend.md>), [backends](<https://devfeed.tech/tags/backends.md>), [block](<https://devfeed.tech/tags/block.md>), [button](<https://devfeed.tech/tags/button.md>), [circle](<https://devfeed.tech/tags/circle.md>), [code](<https://devfeed.tech/tags/code.md>), [color](<https://devfeed.tech/tags/color.md>), [colors](<https://devfeed.tech/tags/colors.md>), [commands](<https://devfeed.tech/tags/commands.md>), [console](<https://devfeed.tech/tags/console.md>), [drawing](<https://devfeed.tech/tags/drawing.md>), [engine](<https://devfeed.tech/tags/engine.md>), [event-loop](<https://devfeed.tech/tags/event-loop.md>), [examples](<https://devfeed.tech/tags/examples.md>), [field](<https://devfeed.tech/tags/field.md>), [graphics](<https://devfeed.tech/tags/graphics.md>), [text](<https://devfeed.tech/tags/text.md>), [ui](<https://devfeed.tech/tags/ui.md>), [view](<https://devfeed.tech/tags/view.md>)

## AI overview

Red/View now includes an incomplete but usable text-based UI backend with a subset of GUI features. It supports common widgets, block-based drawing commands and rich text, keyboard events, timers via the /rate facet, and multiple View facets. Mouse input is off by default and can be enabled with system/view/platform/mouse-event?: yes. Images use 24-bit RGB when the terminal supports it and otherwise fall back to 256 colors; text uses 256 colors, with limited ANSI escape support. The excerpt says it works on Linux, macOS, and Windows 10/11. Compiled code requires GUI-engine: 'terminal in the Red header block. Invoking view starts an event loop; Escape returns to the console. The excerpt also mentions requesters, image display, and Draw examples, while noting mouse support depends on the terminal.

## Source excerpt

Last year, qtxie worked on a toy text backend project and submitted a PR for that. After some extra additions and testing recently, it has now been merged even if it is still incomplete, it is usable enough. So, in addition to the shiny GUI backends in Red/View, now we have an old-school text-based user interfaces (TUI) backend for the View engine! The new TUI backend has currently a subset of the GUI backends features. Here is an overview: View styles: base, panel, button, check, radio, field, text, progress, rich-text, image and text-list. Draw commands: text, line, box, triangle, circle, ellipse (block-based for now). Rich-text supported in Draw. Keyboard handling: key-down and key events (which are the same event). Mouse handling: disabled by default. Use system/view/platform/mouse-event?: yes to enable it. Images support Truecolor (24-bit RGB) for image rendering if the terminal supports it, otherwise it falls back to 256 colors. Timers supported through /rate facet. Facets supported: /offset, /size, /text, /image, /color, /data, /enabled?, /visible?, /selected, /flags, /options, /pane, /rate, /para and /draw. Flags supported: password and all-over. Frames drawing using squared or rounded corners ( Limited ANSI escape codes support in /text facet, only Colors / Graphics Mode codes. Uses 256 colors for text. It should works fine on most of the terminals. Works on the big-3 platforms (Linux, macOS and Windows10/11). The pre-built CLI console binaries on our Download page now have View/VID included by default along with the TUI backend. You can use them to test and play with the TUI code examples here and in the TUI folder. To use the TUI backend in your own compiled code, you need to add the two following options in the Red header block: Needs: 'View Config: [GUI-engine: 'terminal] Here are a few examples, starting with a HelloWorld!: view [text "Hello TUI World!"] Hello TUI World! When view is invoked, an event loop is launched. In order to return back to the co