gyscos / cursive

A Text User Interface library for the Rust programming language
MIT License
4.25k stars 244 forks source link

Issue with tab character in SelectView item #363

Open julienXX opened 5 years ago

julienXX commented 5 years ago

This is a bug report

Problem description

When adding an item containing a tab character in a SelectView the text is truncated.

Some code to reproduce the issue:

extern crate native_tls;

use cursive::traits::*;
use cursive::views::{Dialog, SelectView};
use cursive::Cursive;

fn main() {
    let mut select = SelectView::new();

    select.add_item("there is a \ttab", 1);
    select.add_item("there is no tab", 2);

    let mut siv = Cursive::default();

    siv.add_layer(
        Dialog::around(select.fixed_size((20, 10)))
    );

    siv.run();
}

Here is the output I get: image

Environment

gyscos commented 5 years ago

Hi, and thanks for the report! Indeed, tab characters are not very well handled. It's possible ncurses doesn't even support them?

tabs in general can be confusing as they would try to align to some column, independently of the current View offset. In general it's recommended to uses spaces and manual alignment.

gyscos commented 5 years ago

Possible way forward:

I think the printer solution is probably the best long-term wise; especially if we start caching the screen state more extensively.