martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.27k stars 261 forks source link

Which device file does the auto-completion write into? #832

Closed ghost closed 4 years ago

ghost commented 4 years ago

I just connected hterm (hterm.org) by creating a pty pair and sending data to the master pty via websocket. Slave is connected to my shell.

vis works fine, but the only problem is that the auto-completion :Tab writes into the terminal which started the websocket and not to the master pty as I would expect! Is there any reason for this? xterm.js in Visual Studio Code works fine though.

Here is how I create the pty pair in Python (websocket connection writes into the master):

SH = ["rc"]                                                                         
OPTS = ["-l"]                                                                          

# Generating a master, slave pair.                                                                                        

M, S = openpty()                                                                                

MRD = open(M, "rb", buffering=0)                                          
MWR = open(M, "wb", buffering=0)                                                                                            

SRD = open(S, "rb", buffering=0)                               
SWR = open(S, "wb", buffering=0)

def fork():
    proc = run(SH + OPTS, stdin=SRD, stdout=SWR, stderr=SWR)

t = Thread(target=fork)
t.daemon=True
t.start()
martanne commented 4 years ago

Hi, the completion currently uses the vis-menu(1) utility which re-opens /dev/tty and uses it to receive interactive input and draw its user interface.