-
Notifications
You must be signed in to change notification settings - Fork 485
Conversation
src/backend/crossterm.rs
Outdated
@@ -151,7 +129,7 @@ impl Backend for CrosstermBackend { | |||
} | |||
s.object_style.attrs = cell.style.modifier.into(); | |||
|
|||
self.crossterm.paint(s).map_err(convert_error)?; | |||
write!(io::stdout(), "{}", s); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this locking stdout every time you write ? Shouldn't you lock once and write to StdoutLock
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure since you have to pass write! a mutable write object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could misunderstand the documentation but for me locking outside the for loop would avoid the implicit synchronization. Furthermore, the struct returned by io::stdout().lock()
is also writable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I will take a look at if this could be done more efficiently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the lock out of the loop, by doing this we only lock outside the loop, this lock is then used in the loop for drawing all cells.
Cargo.toml
Outdated
@@ -17,8 +17,9 @@ travis-ci = { repository = "fdehau/tui-rs" } | |||
appveyor = { repository = "fdehau/tui-rs" } | |||
|
|||
[features] | |||
default = ["termion"] | |||
default = ["crossterm"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be changed when finished
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I would rather not change the default backend for now. termion
has been stable for a longer period of time. I could reconsider this in the future when crossterm
reaches a stable release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed, I have this for testing, once the changes are accepted I'll change it back.
Woops, I messed up my git, I'll create an new PR later. |
Updated the version of crossterm, notice that it has API breaking changes. The 0.9.^ version has a lot of improvements.