Re: Mimicking a shell

2020-01-06 Thread Jan via Digitalmars-d-learn
I think the suggestion of angel would be most fitting for my 
case. As angel said, the using the C code for D would be a 
relatively small refactor.


if you want to send like a synthetic arrow keystroke, well, 
things get ugly again, it will need to send the right series of 
bytes based on what terminal the program thinks you are.


Using arrow key etc. would be very beneficial for my case. So I 
thank Adam for his solution, but I prefer angel's one.


Thanks guys :)



Re: Mimicking a shell

2020-01-04 Thread Adam D. Ruppe via Digitalmars-d-learn

On Saturday, 4 January 2020 at 18:43:13 UTC, Jan wrote:

I am using Linux (Fedora).


ok, the starting point is `openpty` which gives you a 
communication pipe that the other program sees as a terminal. 
from there if you are just forwarding you can perhaps shoot bytes 
to and from without interpreting them.


but if you want to send like a synthetic arrow keystroke, well, 
things get ugly again, it will need to send the right series of 
bytes based on what terminal the program thinks you are.


Like "\033[C" is right arrow on xterm, probably a reasonably safe 
bet you can make that work. hit ctrl+v then a key in your 
terminal to see the output. ^[ == "\033" btw there.



Thanks, @angel. I'll take a look at your suggestion :)


yes good luck!


Re: Mimicking a shell

2020-01-04 Thread Jan via Digitalmars-d-learn

On Sunday, 29 December 2019 at 19:21:53 UTC, Adam D. Ruppe wrote:

On Sunday, 29 December 2019 at 17:03:14 UTC, Jan wrote:

Is there a way to forward all input and output from a shell?


yes, but it is platform specific and can be a decent amount of 
code.


what OS are you on?


I am using Linux (Fedora).

Thanks, @angel. I'll take a look at your suggestion :)


Re: Mimicking a shell

2019-12-29 Thread angel via Digitalmars-d-learn

On Sunday, 29 December 2019 at 17:03:14 UTC, Jan wrote:

Hi,

Is there a way to forward all input and output from a shell? 
This implies that e.g. pressing the left arrow on the keyboard 
is immediately being forwarded to the shell and that the output 
from a shell would be *exactly* the same as output from my D 
program (that would include the prompt and VGA colouring).


Kind regards,
Jan


IMHO, this is kinda what you need:
https://github.com/greenduck/shell-tunnel/blob/master/shell-tunnel.c

Sorry, this code is in C, but converting it to D would be fairly 
straight forward.


Re: Mimicking a shell

2019-12-29 Thread Adam D. Ruppe via Digitalmars-d-learn

On Sunday, 29 December 2019 at 17:03:14 UTC, Jan wrote:

Is there a way to forward all input and output from a shell?


yes, but it is platform specific and can be a decent amount of 
code.


what OS are you on?


Mimicking a shell

2019-12-29 Thread Jan via Digitalmars-d-learn

Hi,

Is there a way to forward all input and output from a shell? This 
implies that e.g. pressing the left arrow on the keyboard is 
immediately being forwarded to the shell and that the output from 
a shell would be *exactly* the same as output from my D program 
(that would include the prompt and VGA colouring).


Kind regards,
Jan