-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preparsing onData Events #387
Comments
The
You could however hook into |
@mofux Thanks for your response
This statement in itself is not really what I was suggesting. Having semantic knowledge of sent or received data presumably will not dictate how the data is sent/received. How is it then that people can build these web terminals using Specifically what comes to mind is handling |
The way unix/posix connects/interacts with a terminal is well defined and has matured over decades. Basically all programs follow the terminal interface with its escape sequences and the shell job control idea of a TTY. Its that simple - build these interfaces on emulator side and use the sequences on app - and you are ready to go. |
@jerch Sure enough I tried simplifying my code wayyy down and it works as it should now! I was making wayyy to many assumptions about the format of the data output by the |
This issue will kind of touch the following:
#56
#384
So I noticed that running certain commands will result in an inconsistent number of
onData
event fires. Prior to this realization, my thought was to use each event fire to sort the data output from thepty
. For example, runningls
would output 1) the command executed (and tbh idr if that included the cwd prompt) 2) the results of the command and 3) the cwd prompt. Perfect! If this was the case for all command executions then it would be much easier to handle those events inxterm.js
.Thus, the idea is for
onData
events to be partitioned intoonExecCommand
,onOutput
andonCwdPrompt
listeners. As stated previously, sometimes the number ofonData
event fires is inconsistent (usingcat
for instance does not fire the cwd prompt in a separateonData
event). I had planned to attempt this with string matching however my ignorance ofnode-pty
source has me hoping for a more elegant solution which may or may not be incredibly difficult.Note that this suggestion does not utilize extraction of the error code (as for my use it doesn't seem needed if you are displaying everything in
xterm
). However, I do have an idea for this as well. The problem I am having is that theonData
events capture EVERYTHING. My idea (however feasible) would be to implement what I will coinpty.stealthWrite(<data>)
which writes to the pty in way that that the user can grabonStealthData
events. The purpose of this would be to sendonStealthData
events through a separate socket channel toxterm.js
where printing to the terminal could be handled differently than normal data events in thepty
. For most cases I don't see this being particularly difficult in the following pseudo-logic:This would allow the user to grab data from the
pty
that you can choose not to display inxterm.js
! More specifically, users can send standard bash commands to extract information from thepty
which can be arbitrarily displayed inxterm.js
(like$?
to get the error code of the last command).Eager to hear thoughts on this @jerch @Tyriar
The text was updated successfully, but these errors were encountered: