All Versions
26
Latest Version
Avg Release Cycle
38 days
Latest Release
58 days ago

Changelog History
Page 1

  • v0.12.0

    September 27, 2020

    πŸ”‹ Features

    • πŸ‘‰ Make it easier to work with string with multiple lines in Text (#361).

    πŸ›  Fixes

    • πŸ›  Fix a style leak in Graph so components drawn on top of the plotted data (i.e legend and axis
      πŸ’… titles) are not affected by the style of the Datasets (#388).
    • πŸ‘‰ Make sure BarChart shows bars with the max height only when the plotted data is actually equal
      to the max (#383).
  • v0.11.0

    September 20, 2020

    Β Features

    • βž• Add the dot character as a new type of canvas marker (#350).
    • πŸ‘Œ Support more style modifiers on Windows (#368).

    πŸ›  Fixes

    • πŸ’» Clearing the terminal through Terminal::clear will cause the whole UI to be redrawn (#380).
    • πŸ›  Fix incorrect output when the first diff to draw is on the second cell of the terminal (#347).
  • v0.10.0

    July 17, 2020

    πŸ’₯ Breaking changes

    Easier cursor management

    A new method has been added to Frame called set_cursor. It lets you specify where the cursor should be placed after the draw call. Furthermore like any other widgets, if you do not set a cursor position during a draw call, the cursor is automatically hidden.

    For example:

    fn draw_input(f: &mut Frame, app: &App) {
      if app.editing {
        let input_width = app.input.width() as u16;
        // The cursor will be placed just after the last character of the input
        f.set_cursor((input_width + 1, 0));
      } else {
        // We are no longer editing, the cursor does not have to be shown, set_cursor is not called and
        // thus automatically hidden.
      }
    }
    

    In order to make this possible, the draw closure takes in input &mut Frame instead of mut Frame.

    Advanced text styling

    It has been reported several times that the text styling capabilities were somewhat limited in many πŸš€ places of the crate. To solve the issue, this release includes a new set of text primitives that are now used by a majority of widgets to provide flexible text styling.

    Text is replaced by the following types:

    • πŸ’… Span: a string with a unique style.
    • πŸ’… Spans: a string with multiple styles.
    • πŸ’… Text: a multi-lines string with multiple styles.

    However, you do not always need this complexity so the crate provides From implementations to 0️⃣ let you use simple strings as a default and switch to the previous primitives when you need βž• additional styling capabilities.

    For example, the title of a Block can be set in the following ways:

    // A title with no styling
    Block::default().title("My title");
    // A yellow title
    Block::default().title(Span::styled("My title", Style::default().fg(Color::Yellow)));
    // A title where "My" is bold and "title" is a simple string
    Block::default().title(vec![
        Span::styled("My", Style::default().add_modifier(Modifier::BOLD)),
        Span::from("title")
    ]);
    
    • Buffer::set_spans and Buffer::set_span were added.
    • Paragraph::new expects an input that can be converted to a Text.
    • πŸ’… Block::title_style is deprecated.
    • Block::title expects a Spans.
    • Tabs expects a list of Spans.
    • Gauge custom label is now a Span.
    • Axis title and labels are Spans (as a consequence Chart no longer has generic bounds).

    Incremental styling

    πŸ’… Previously Style was used to represent an exhaustive set of style rules to be applied to an UI element. It implied that whenever you wanted to change even only one property you had to provide the πŸ’… complete style. For example, if you had a Block where you wanted to have a green background and a title in bold, you had to do the following:

    let style = Style::default().bg(Color::Green);
    Block::default()
      .style(style)
      .title("My title")
      // Here we reused the style otherwise the background color would have been reset
      .title_style(style.modifier(Modifier::BOLD));
    

    πŸš€ In this new release, you may now write this as:

    Block::default()
        .style(Style::default().bg(Color::Green))
        // The style is not overidden anymore, we simply add new style rule for the title.
        .title(Span::styled("My title", Style::default().add_modifier(Modifier::BOLD)))
    

    πŸ’… In addition, the crate now provides a method patch to combine two styles into a new set of style rules:

    let style = Style::default().modifer(Modifier::BOLD);
    let style = style.patch(Style::default().add_modifier(Modifier::ITALIC));
    // style.modifer == Modifier::BOLD | Modifier::ITALIC, the modifier has been enriched not overidden
    
    • πŸ’… Style::modifier has been removed in favor of Style::add_modifier and Style::remove_modifier.
    • πŸ’… Buffer::set_style has been added. Buffer::set_background is deprecated.
    • πŸ’… BarChart::style no longer set the style of the bars. Use BarChart::bar_style in replacement.
    • πŸ’… Gauge::style no longer set the style of the gauge. Use Gauge::gauge_style in replacement.

    List with item on multiple lines

    ♻️ The List widget has been refactored once again to support items with variable heights and complex styling.

    • List::new expects an input that can be converted to a Vec<ListItem> where ListItem is a wrapper around the item content to provide additional styling capabilities. ListItem contains a Text.
    • 🚚 List::items has been removed.
    // Before
    let items = vec![
      "Item1",
      "Item2",
      "Item3"
    ];
    List::default().items(items.iters());
    
    // After
    let items = vec![
      ListItem::new("Item1"),
      ListItem::new("Item2"),
      ListItem::new("Item3"),
    ];
    List::new(items);
    

    πŸ‘€ See the examples for more advanced usages.

    More wrapping options

    Paragraph::wrap expects Wrap instead of bool to let users decided whether they want to trim whitespaces when the text is wrapped.

    // before
    Paragraph::new(text).wrap(true)
    // after
    Paragraph::new(text).wrap(Wrap { trim: true }) // to have the same behavior
    Paragraph::new(text).wrap(Wrap { trim: false }) // to use the new behavior
    

    Horizontal scrolling in paragraph

    You can now scroll horizontally in Paragraph. The argument of Paragraph::scroll has thus be πŸ”„ changed from u16 to (u16, u16).

    πŸ”‹ Features

    πŸ’… Serialization of style

    πŸ’… You can now serialize and de-serialize Style using the optional serde feature.

  • v0.9.5

    May 21, 2020

    πŸ› Bug Fixes

    • πŸ›  Fix out of bounds panic in widgets::Tabs when the widget is rendered on small areas.
  • v0.9.4

    May 12, 2020

    πŸ› Bug Fixes

    • Ignore zero-width graphemes in Buffer::set_stringn.
  • v0.9.3

    May 11, 2020

    πŸ› Bug Fixes

    • πŸ›  Fix usize overflows in widgets::Chart when a dataset is empty.
  • v0.9.2

    May 10, 2020

    πŸ› Bug Fixes

    • πŸ›  Fix usize overflows in widgets::canvas::Line drawing algorithm.
  • v0.9.1

    April 16, 2020

    πŸ› Bug Fixes

    • The List widget now takes into account the width of the highlight_symbol when calculating the total width of its items. It prevents items to overflow outside of the widget area.
  • v0.9.0

    April 14, 2020

    πŸ”‹ Features

    • Introduce stateful widgets, i.e widgets that can take advantage of keeping some state around between two draw calls (#210 goes a bit more into the details).
    • πŸ‘ Allow a Table row to be selected. ```rust // State initialization let mut state = TableState::default();

    // In the terminal.draw closure let header = ["Col1", "Col2", "Col"]; let rows = [ Row::Data(["Row11", "Row12", "Row13"].into_iter()) ]; let table = Table::new(header.into_iter(), rows.into_iter()); f.render_stateful_widget(table, area, &mut state);

    // In response to some event: state.select(Some(1));

    * βž• Add a way to choose the type of border used to draw a block. You can now
    choose from plain, rounded, double and thick lines.
    * βž• Add a `graph_type` property on the `Dataset` of a `Chart` widget. By
    0️⃣ default it will be `Scatter` where the points are drawn as is. An other
    option is `Line` where a line will be draw between each consecutive points
    of the dataset.
    * πŸ’… Style methods are now const, allowing you to initialize const `Style`
    objects.
    * πŸ‘Œ Improve control over whether the legend in the `Chart` widget is shown or
    not. You can now set custom constraints using
    `Chart::hidden_legend_constraints`.
    * βž• Add `Table::header_gap` to add some space between the header and the first
    row.
    * βœ‚ Remove `log` from the dependencies
    * βž• Add a way to use a restricted set of unicode symbols in several widgets to
    πŸ‘Œ improve portability in exchange of a degraded output. (see `BarChart::bar_set`,
    `Sparkline::bar_set` and `Canvas::marker`). You can check how the
    `--enhanced-graphics` flag is used in the demos.
    
    ### πŸ’₯ Breaking Changes
    
    * `Widget::render` has been deleted. You should now use `Frame::render_widget`
    to render a widget on the corresponding `Frame`. This makes the `Widget`
    implementation totally decoupled from the `Frame`.
    ```rust
    // Before
    Block::default().render(&mut f, size);
    
    // After
    let block = Block::default();
    f.render_widget(block, size);
    
    • Widget::draw has been renamed to Widget::render and the signature has ⚑️ been updated to reflect that widgets are consumable objects. Thus the method takes self instead of &mut self. ```rust // Before impl Widget for MyWidget { fn draw(&mut self, area: Rect, buf: &mut Buffer) { } }

    /// After impl Widget for MyWidget { fn render(self, arera: Rect, buf: &mut Buffer) { } }

    * `Widget::background` has been replaced by `Buffer::set_background`
    ```rust
    // Before
    impl Widget for MyWidget {
      fn render(self, arera: Rect, buf: &mut Buffer) {
        self.background(area, buf, self.style.bg);
      }
    }
    
    // After
    impl Widget for MyWidget {
      fn render(self, arera: Rect, buf: &mut Buffer) {
        buf.set_background(area, self.style.bg);
      }
    }
    
    • ⚑️ Update the Shape trait for objects that can be draw on a Canvas widgets. Instead of returning an iterator over its points, a Shape is given a Painter object that provides a paint as well as a get_point method. This gives the Shape more information about the surface it will be drawn to. In particular, this change allows the Line shape to use a more precise and efficient drawing algorithm (Bresenham's line algorithm).
    • SelectableList has been deleted. You can now take advantage of the associated ListState of the List widget to select an item. ```rust // Before List::new(&["Item1", "Item2", "Item3"]) .select(Some(1)) .render(&mut f, area);

    // After

    // State initialization let mut state = ListState::default();

    // In the terminal.draw closure let list = List::new(&["Item1", "Item2", "Item3"]); f.render_stateful_widget(list, area, &mut state);

    // In response to some events state.select(Some(1));

    * 🚚 `widgets::Marker` has been moved to `symbols::Marker`
    
  • v0.8.0

    December 15, 2019

    πŸ’₯ Breaking Changes

    • ⬆️ Bump crossterm to 0.14.
    • βž• Add cross symbol to the symbols list.

    πŸ› Bug Fixes

    • πŸ’… Use the value of title_style to style the title of Axis.