abitofevrything / dart_ncurses

MIT License
0 stars 1 forks source link

Is it possible to redirect a dart stream into a C FILE pointer? #1

Open natebot13 opened 1 year ago

natebot13 commented 1 year ago

I am trying to connect ncurses to a socket connection, and would need to be able to provide a different file pointer to the newterm constructor. Is this possible?

https://github.com/abitofevrything/dart_ncurses/blob/fd52d73e2a75ccc45956b99365d66ea66c72ee9d/lib/src/wrapper.dart#L799

abitofevrything commented 1 year ago

Hi, I am currently unaware of a way to convert a high-level Dart object (probably an IoSink) into a C FILE pointer, so this would not be possible from pure Dart.

However, if you can get hold of a FILE pointer through FFI, you can call defaultLibrary.newterm and pass the resulting pointer to NativeScreen.fromPointer to get a screen with a custom stdin/stdout.

Import the package:ncurses/bindings.dart package to get access to the NativeScreen extension.