Giter VIP home page Giter VIP logo

Comments (7)

timsneath avatar timsneath commented on July 1, 2024

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.

erf avatar erf commented on July 1, 2024

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.

timsneath avatar timsneath commented on July 1, 2024

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.

erf avatar erf commented on July 1, 2024

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.

erf avatar erf commented on July 1, 2024

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.

erf avatar erf commented on July 1, 2024

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.

erf avatar erf commented on July 1, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.