Skip to main content

twk 0.2.0 copy "twk: ^0.2.0" to clipboard
twk: ^0.2.0 copied to clipboard

Flutter's widget model for terminal UIs in Dart: layout, text, focus, the mouse, scrolling, editing, overlays, navigation and animation.

Changelog #

0.2.0 #

  • After a Ctrl+C ended the inline session, a program that handles SIGINT and goes on gets a new session for its next prompt or progress. The prompt was cancelled at once with PromptCancelReason.endOfInput, and a progress was written as lines, because stdin was taken for closed. Cli.close() still ends the console for good. FakeCliTerminal opens its inline terminal again once the last one is closed.

  • Cli.suspend(run) hands the terminal to another program while run runs, one that reads the terminal itself (sudo asking for a password, a package manager, a pager, an editor), and takes it back after. The inline session's region stays with the cursor on the line below it, raw mode is off and the session's input paused, and the session is drawn again below what was printed. Such a program used to print in the middle of the region and never get what was typed.

  • Each pipeline that draws a theme mark the terminal can't draw one column wide (Glyphs.cursor: '日') is warned once in its own log, where only the first of the pipelines sharing a segmenter was: the verdict is kept for the segmenter, and the warning came only with measuring it.

  • Cli.close() closes the terminal when the inline session failed to open, where it threw the open's error again and left the terminal open.

  • A line Cli logs or writes while its inline session is still opening (cli.info right after cli.progress) goes above the session once it is open. It was written to stdout while the opening session flushed it, and threw "StreamSink is bound to a stream".

  • In visual order the rest of the user's text a widget paints itself reads as a Text draws it, each label through a TextPainter the render object keeps: the labels of a ProgressList, the messages and lines of the Console, the labels of Gauge and LineGauge, of BarChart and Heatmap (their legend too), the axis titles, labels and dataset names of a Chart, the labels a DotCanvas's draw function sets, the month and weekday names of a Calendar and the key labels of the entries of menus. They drew שלום עולם where Text draws םלוע םולש. A label too long is cut at its end, where it was, in the same columns. Marks, digits and box glyphs stay on Canvas.text, in stored order.

  • An OptionList row's label too long for the row is laid out at the room it has and cut at its end with the theme's ellipsis, as a Text with TextOverflow.ellipsis is; it was laid out at its natural width and the canvas clipped its right edge, so in visual order a right-to-left label lost its start, which is on the right.

  • In visual order, where a right-to-left label is drawn as it reads, the rows of an OptionList (its label with its marks, which are now spans of one run in the mark style and no longer split it, and its detail), the tabs of a TabBar and the titles and entries of a MenuBar's and a context menu's menus read as a Text draws them: they drew שלום עולם where Text draws םלוע םולש. Each paints its labels through a TextPainter it keeps while the label is the same, laid out again only when it, the segmenter or the text order changes. Their cuts, widths and the columns a click finds are those of stored order, as before.

  • In visual order, where a row of right-to-left text is drawn as it reads, a click finds the target drawn under it: the crumb of Breadcrumbs, the segment of SegmentedButton, the page of Pagination, the step of Stepper, the arrow of ValueStepper, the key of a pressable KeyHintsBar, and a ChipList chip's ×, which a click on the label took for it while the × was drawn on the left. They found it in a table of columns summed in stored order; they now ask the row's paragraph which text it drew there (RenderParagraph.cellAt). The hidden cursor rests on the active one where it is drawn too: ActiveItem(text: (start, end)) rests it on the first cell its child Text draws of that text, found at each layout, as column gives a fixed one.

  • The drawn mark of a theme field is one module: Marks (a CellMark or TextMark descriptor for each mark of Glyphs) and ThemeMarks (ThemeMarks.of(context).text(Marks.close); in a render object ThemeMarks.ofObject(this, canvas.segmenter).cell(Marks.cursor, glyphs)), which keeps the one width rule (a mark is used only where it is one column and one code point, else it is Glyphs.ascii's), a cache for each segmenter and the one warning for each (field, glyph). Glyphs stays plain strings. The helpers cellRune, optionalCellRune, textMark, checkboxMarks, switchMarks, radioMarks, buttonEdgeMarks and lineMark (internal, hidden from the exports) and rampOf are gone, as are the private copies of the rule in the charts, the dot grid, the skeleton, the scrollbar, the menu, the split, the window and twk_rich. Behaviour that the one rule changes:

    • a mark in text is checked wherever it is drawn: the close of a Chip, Callout and Window, the arrows of a ValueStepper, a Pagination (previous, next), the separator and check of a SegmentedButton, the up and down of a NumberInput, a Select and a DatePicker, the kind icons of a StatusMessage, a Callout and a toast, the cursor of a list and a file picker, the expanded and collapsed of an ExpansionTile, the next of Breadcrumbs, the bullet mask of a TextField, the radio brackets, and the marks of twk_rich's markdown (bullets, checkboxes, quote bar, table borders and lines) and diff; one that is two columns wide is the ASCII one, with one warning, where it was drawn as it was and shifted the row;
    • the dash drawn as text in a row (a Stepper, a Callout's title, a raised Window's minimise) is ASCII where the line is not one column;
    • a Window's focus mark with an empty cursor draws nothing, where it drew >; a Slider with an empty trackHorizontal draws a blank, where it drew -, as a Scrollbar does;
    • a SkeletonTheme(glyph:) or a light shade that is not one column wide is the ASCII shade . (with one warning), where the skeleton drew a blank in reverse video;
    • LineGauge(type:) under Glyphs.ascii (lines ASCII) is ASCII, as the docs of Glyphs said: the ASCII theme beats a widget's BorderType;
    • a Split and a menu keep a border type whose pieces are all one column (as the charts do), where they kept it by the terminal's ambiguous width.
  • FocusNode.takesText (and Focus(takesText:)) says that a node takes the keys that are characters as text: TextField and TextArea say it unless read-only. FocusManagerKeys.activeKeys, so a KeyHintsBar and showKeyHelp, no longer list a binding of a layer above such a node on a character key (q), which the field takes, and a click on a hint cannot type it into the field; keys with Ctrl or Alt stay.

  • KeyBindings(unmatched: UnmatchedKeys.replay) replays the held first keys to the nodes a key walks, past what a dialog's keysSkip skips, where it gave them to the app's bindings between the navigator and the dialog.

  • A cell's style id is a StyleId (package:twk_core, exported by package:twk), apart from a pen id, which stays an int: the effect cell's EffectCell.style, childStyle and underStyle are one, and so are the style arguments of a RenderEffect's effectCell.

  • Scrollbar and the bar of Box read the axis from the scrollable inside, as Flutter's Scrollbar does. Scrollbar(axis:) is nullable and null by default: the outermost scrollable of either axis, where it was vertical by default. So Scrollbar() around content whose outermost scrollable is horizontal now shows that one, in a row at the bottom; to keep the column around content that scrolls both ways, give axis: Axis.vertical. A given axis picks that axis's scrollable, the bar to each axis of content that scrolls both. An inner scrollable of the other axis never takes the bar of an outer one.

  • Box(scrollbar:) takes a ScrollbarVisibility?, as LogView does, where it took an Axis?: .always, .onScroll (the border's own line shows while the thumb is hidden) or .never; null for none. The bar is on the right side for a vertical scrollable and on the bottom for a horizontal one; the border must have that side and a bottom title cannot share it with a horizontal bar, as asserted.

0.1.0 #

The first release.

  • The framework: Widget, StatelessWidget, StatefulWidget and State, InheritedWidget, keys and GlobalKey, LayoutBuilder, BuildContext; ChangeNotifier, ValueNotifier and Listenable.
  • runApp: fullscreen, inline below the shell's history (Static commits finished lines into the scrollback) or in a fixed viewport; AppBinding with frame callbacks, notifications, the window title and hot reload through twk run.
  • Style and text: Style with colors, attributes, underline colors and links; Text and Text.rich, wrapping, ellipsis and bidirectional text; Theme with built-in dark and light themes, the default ones picked by the terminal's background, Theme.adaptive to choose them and Theme.terminal for the terminal's own colors.
  • Layout: Row, Column, Flex, Stack, Grid, Wrap, Box with borders that merge, Padding, Align, SizedBox, SplitView.
  • Focus and input: the focus tree, Focus, KeyBindings, Shortcuts and hinted keys; the mouse by hit test (Listener, MouseRegion).
  • Scrolling and data: ListView, Scrollbar, Table (also over a data source), TreeView, DirectoryTree, charts, sparklines and gauges.
  • Editing: TextField, TextArea, Form and FormField.
  • Overlays: dialogs, menus, MenuBar, ContextMenu, toasts, tooltips, CommandPalette.
  • Navigation and controls: Navigator and routes, tabs, buttons, switches, checkboxes, radio groups, sliders, Stepper, progress bars and spinners.
  • Animation: tickers, AnimationController, implicit animations.
  • Semantics and a screen-reader mode; debug aids: the frame overlay, the repaint rainbow, the log console, tree dumps and VM service extensions.
  • Program output with ANSI sequences as styled text: parseAnsi, AnsiStream as it arrives, and stripAnsi.
  • package:twk/hooks.dart, hooks in the flutter_hooks style, and package:twk/provider.dart, Provider's API.
  • package:twk/cli.dart, the console of a command-line tool that is no app: messages by level, any widget printed, prompts, progress and a traceback, as a terminal, a pipe or CI takes them.
  • A dart2wasm build for the web.
1
likes
160
points
1.21k
downloads
screenshot

Documentation

API reference

Publisher

verified publisherpro100.dev

Weekly Downloads

Flutter's widget model for terminal UIs in Dart: layout, text, focus, the mouse, scrolling, editing, overlays, navigation and animation.

Repository (GitHub)
View/report issues
Contributing

Topics

#terminal #tui #cli #widget #console

License

MIT (license)

Dependencies

meta, stack_trace, twk_core

More

Packages that depend on twk