Comments (7)
I'd be very happy to see a contribution of this kind! I have a number of ideas for this package, but it's very much a "weekends and evenings" project / labor of love, so I'd be delighted to see others join in the fun. Would you be interested in working on this feature?
from dart_console.
I'd like to help, but not very familiar with the low level stuff and streams right now. I did try to find a way to read from stdio asynchronously, you have the the stdio.listen
function, but it seem to close after first event. Do you know how i can keep listening to those events?
Also, do you know if it is possible to debug console apps from Android Studio?
BTW: How does this library compare to https://github.com/DirectMyFile/console.dart ?
from dart_console.
Implementing async input
I'd also need to do some research on this front. I know on VT-style terminals, you can "read with a timeout" and set that timeout (see the VMIN
and VTIME
constants in termios.dart). If there's something in the stream, I assume it would stay there until the next read?
There's some interesting commentary here: flutter/flutter#10677 that suggests that this is doable so long as there aren't other subscribers to stdin
, which seems to be the case in this scenario.
Debugging console apps from Android Studio
I don't know about this, I'm afraid. I think IntelliJ provides the means for this, but whether this is exposed from Android Studio, I don't know. I use Visual Studio Code for writing this library, which is very capable and supports debugging.
Comparing to DirectMyFile
I originally looked at their library and even contributed a fix or two. They've built something useful, however it's higher-level than dart_console
and exclusively uses VT terminal escape sequences, which can be restrictive if you want to build something that works on Windows or sets attributes that aren't available in that way (e.g. disabling Ctrl+C).
Dart FFI is a new feature in Dart 2.6 that provides a lower-level approach where you can make system calls, and dart_console
uses FFI for methods like enableRawMode()
. I wanted the chance to try FFI out, and this was a perfect marriage of convenience and interest!
from dart_console.
I did not know that the terminal would limit how you read input.. Hmm.. I would like to preferably read all characters until the end of the program or until i don't want to listen any more, but maybe that's not possible..? I did look at the comments in that Flutter issue, but not sure what to do with that.
I'm able to setup a run configuration for a Dart console app in Android Studio, but not sure how i launch and debug the terminal. Is it easy to set this up in VS Code?
I like that you seem to keep this library minimal, and with Dart FFI it's possible to do more!
from dart_console.
I seem to be able to do async IO using stdin.listen
, i think the problem occur when you try to do both sync and async io, as stated here:
Mixing synchronous and asynchronous reads is undefined.
Notice if you set rawmode=false
inside the listen
callback, you will end the stream. I think that is because the rawmode
setter does some sync io.
I made an async.dart
example in a branch here.
from dart_console.
I added a new commit to that branch with a minimal readKeyAsync
API example.
I also added unitType
to key. Also would it make sense to simplify readKey
, so that the control characters could be figured out later, perhaps by adding getters to the Key
class ?
Or we could refactor figuring out the escape characters so it could be reused by both sync and async read methods.
from dart_console.
Maybe this nonBlocking is needed for non-blocking io.
Also writeCharCode might be a cool API addition.
Btw, maybe the Library / API needs to decide to do either async or sync IO, as mentioned in a previous comment, Mixing synchronous and asynchronous reads is undefined.
.
from dart_console.
Related Issues (20)
- Example not working HOT 2
- Methods missing from docs / package on pub.dev HOT 1
- Type errors in dart_console-0.6.1 on Dart VM version: 2.9.0-17.0.dev.flutter-7e72c9ae7e HOT 4
- window resize event
- Problem with UTF8 terminal
- Ctrl+M is mapping to enter HOT 1
- 'NoSuchMethodError: The getter 'col' was called on null.' when running readLine() with writeLine() in while loop while holding enter.
- Support for more function keys HOT 1
- windowWidth and windowHeight do not update on window resize (linux)
- Is it possibile to use Console on different CMD window? HOT 1
- Last symbol cannot be deleted with delete key or Ctrl-D when using Console().readLine()
- If stdin is closed cursorPosition throws a RangeError HOT 4
- usage with not standard streams (not stdin/stdout)
- Is there a way to check whether a key has been pressed without blocking the flow of the program? HOT 4
- Regression in 1.1: RangeError in `Console.cursorPosition`
- Console.writeLine does not align correctly with characters that do not have width 1
- `Console.readLine()` doesn't allow users to paste text into terminal HOT 2
- Extend `Console.readLine()` API to allow tab-completion of commands in a prompt HOT 1
- Versionbump win32 to 3.0.0 HOT 1
- Accessing `cursorPosition` may print debugging information
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dart_console.