Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

termion style ansi api #87

Closed
prabirshrestha opened this issue Jan 30, 2019 · 10 comments
Closed

termion style ansi api #87

prabirshrestha opened this issue Jan 30, 2019 · 10 comments

Comments

@prabirshrestha
Copy link
Contributor

I do like how it is very easy to get started with termion because it just uses ansi escape sequences. Would it be possible to support something similar in crossterm?

let stdout = MouseTerminal::from(AlternateScreen::from(io::stdout().into_raw_mode().unwrap()));
write!(stdout,
    "{}{}{}{}Hi{}",
    cursor::Hide, 
    clear::All,
    cursor::Goto(0,0),
    color::Fg(color::Red),
    cursor::Show);
stdout.flush();

For terminals that do not support it might need to add custom parser though it could be a bit slow.

@TimonPost
Copy link
Member

I do have those on my todo list, however, it is a bit difficult to realize.

@TimonPost TimonPost mentioned this issue Feb 6, 2019
4 tasks
@TimonPost
Copy link
Member

I have implemented it and will be soon usable.

preview

println!("{} Underlined {} No Underline", Attribute::Underlined, Attribute::NoUnderline);
println!("{}{} Red on Yellow", Colored::Fg(Color::Red), Colored::Bg(Color::Yellow));
println!("{}", "aa".green())

@TimonPost
Copy link
Member

Closing this will be soon available in crossterm_style 0.2

@prabirshrestha
Copy link
Contributor Author

Looking forward to it. Checked the source out and seems like I only see it for colors. Are there plans to support cursors and clear screen?

@TimonPost
Copy link
Member

Yes, that might come in the future.

@prabirshrestha
Copy link
Contributor Author

Great. Looking forward for those so I can migrate to crossterm instead of termion.

@prabirshrestha
Copy link
Contributor Author

Any plans on bringing cursor and clear api? Let me know if I should file a new issue to track it.

@TimonPost
Copy link
Member

TimonPost commented Apr 13, 2019

I am not sure if that is something I want, I was thinking about it, but does it really make sense to make the cursor move with a write operation like: write!(stdout, "{}", Cursor::Goto(10,20)).

@prabirshrestha
Copy link
Contributor Author

My thought was that there would be applications that just uses those sequence so instead of me parsing and converting crossterm, it would automatically do it for me.

One thing I miss a lot on windows is tmux. Imagine if I could spawn a pty process and just directly pipe it to crossterm. It also allows one to easily create other emebedded terminal support such as in vim with crossterm very easily. Creating apps like these would be very easy if crossterm natively supported it. https://github.com/wez/wezterm.

Other interesting cases I can see is having OpenGL or directx for backends. So if I wanted to created a gvim I can easily use the gui backends instead of terminal. As a dev consuming crossterm I would be very happy because all the hard work is handled by crossterm.

@TimonPost
Copy link
Member

Crossterm supports a similar feature with the command API since version 0.10

december1981 pushed a commit to december1981/crossterm that referenced this issue Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants