-
Notifications
You must be signed in to change notification settings - Fork 91
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
Terminal support for handling color text display with ANSI escape sequences #154
Comments
Happy to be assigned the task The ansi/VT100 standards allow for the the escape sequences 'esc [ nnn m; to be used to set/reset the foreground and background colour of text. Investigations show the change can be effected in https://github.com/espruino/EspruinoTools/blob/master/core/terminal.js. In summary the new escape sequences need to be trapped and used to effect the creation of additional HTML to be sent to the terminal canvas in the browser plugin. In more detail terminal.js functions handleRecievedCharacter() and updateTerminal() will be modified and a new function terminalCodesToHtml() (a modified version of Osteele's library) will be added.
Initial versions of these changes have been made and will be tested in the fork https://github.com/SimonGAndrews/EspruinoTools Notes on testing to follow here (all comments welcome) |
This sounds like a great idea to me. However, I'm not entirely sure about: master...SimonGAndrews:EspruinoTools:master Specifically I'm very unsure about including escape characters in termText. I think this will break other things (clicking, deleting, and also stepping over coloured text with arrow keys) as we assume that As far as I can tell if you set the cursor color, right now it only sets the color for that line, not for subsequent lines? Also...
I'm open to suggestions, but it feels like in For each terminal line we could have an array of |
ok, thanks Gordon, Ill get a test for the areas you suggest would break, as Ive not seen that in a node standalone build of the WebIDE. What other builds would need testing ? will have another go next week. |
Ok slept on this and will abandon current approach. |
New version of terminal.js ready for my detailed testing shared in my branch (plan B) as above. |
handleReceivedCharacter() now uses a simple state machine approach to handling the control sequences. It makes adding new sequences pretty straight fprward, but seemed necessary to handle the more complicated delimited control sequences. A new function buildAttribSpans() is used by updateTerminal() to construct HTML spans with stryles based upon the Theres a slightly complicated method to get from attributes to HTML styles which is based upon a lookup object in attributes[{}]. The new function setActiveStyles(obj) uses attributes[{}] to convert contents of termAttribute[] to the HTML styles currently active into activeStyles[]. An HTML style string containing all active styles is achieved with |
I will be testing in windows , building the nw version of the app. Ill post the tests im doing. |
Great, thanks for this! I'll try and take a proper look at this next week. Please could you try forking EspruinoWebIDE with your new EspruinoTools, then enable GitHub pages for it? It should then be possible for anyone to just go to https://simongandrews.github.io/EspruinoWebIDE and try it out, a bit like you can for https://espruino.github.io/EspruinoWebIDE/ |
Just to confirm, it's these changes? master...SimonGAndrews:EspruinoTools:Plan-B-(issue-#154) The state machine looks really tidy. About the only thing I'd say (and I'm not sure this really matters that much) is that right now you do:
But if you did:
I imagine it would be a lot faster processing characters as they came in... And I guess you could merge in |
Thanks @gfwilliams for feedback. I'll sort a clone of espruinoWebIde using my changed Espruino tools fork as a submodule as suggested. Found a couple of bugs already with fixes WIP. Will be using my espruinoTools master branch now. |
Excellent - thanks! When you're ready let me know here and I'll have a test and merge in :) |
quick status - testing slowly but surely. My fork for webIDE now links to my modified fork of EspruinoTools core terminal. |
Great! The code looks really nice to me on master...SimonGAndrews:EspruinoTools:master - let me know when you feel it's tested enough and ready to merge :) |
Formalising suggested enhancement to provide support for the display of coloured text in the terminal window of the WebIDE (and other usage of the core terminal module) as per forum discussion https://forum.espruino.com/conversations/380403/#comment16713624.
Suggestion is to allow console.log from Espruino to embed standard ANSI/VT100 set/reset display attribute sequences to enable changes to foreground and background colours of the text displayed in the terminal window.
The text was updated successfully, but these errors were encountered: