Open
Conversation
I enabled ReadWritePair for other platforms that are not unix by removing any `#[cfg(unix)]`. I also updated TermRead to be an Iterator over Keys and not bytes. This gurantees a cross platform read of keys because they differ between wasm, unix and windows.
Its better to have only one place that checks if the TermTarget is a ReadWritePair instead of having them everywhere in the code. As the way input is read is determined by the TermTarget it made sense to move it there. I still need to implement the functionality for a ReadWritePairSource though
… Keys into utf8 Renamed fields to clarify their new purpose. The utility function keys_to_utf8 will handle converting BackSpaces and Enter keys. Other functionality like arrow keys and delete may be implemented in the future
Maybe the errors need to be changed? io::ErrorKind::ResourceBusy requires to add the: #![feature(io_error_more)] attribute
…capacity and dropping long unicode chars This is required by the Read trait implementation
Collaborator
|
This PR looks generally promising but has significant conflicts against master. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently console only reads input from stdin. However a ReadWritePair option has already been added. Unfortunately only writing works for ReadWritePair. This PR adds functionality for a custom input source.
See issue #108
See other (I think incomplete) pr addressing this issue: #123
This would complete the work of #93
Therefore the following lines have been changed:
console/src/term.rs
Line 291 in 51425fc
console/src/term.rs
Line 617 in 51425fc
console/src/term.rs
Line 623 in 51425fc
console/src/term.rs
Line 343 in 51425fc
console/src/term.rs
Line 278 in 51425fc
ReadWritePair was also modified. Previously it required an input source of type Read (enables reading of bytes)
This has been changed to an iterator over Keys because Keys are a cross platform solution. Else we would need to parse the input differently depending on the os of the user. Now the user has a nice interface for defining his own input source.
Functionality may be expanded in the future to support more keys, or to automatically convert something like Key::Char('\n') to Key::Enter or at least warn the user.
This pr should be a good start adding an essential feature.
Please take a look at the commits from last to newest. They contain a description of what has been changed.