[RFC]: add syntax highlighting support to the REPL #2072
Labels
difficulty: 4
Likely to be moderately difficult.
Enhancement
Issue or pull request for enhancing existing functionality.
JavaScript
Issue involves or relates to JavaScript.
Needs Discussion
Needs further discussion.
priority: Normal
Normal priority concern or feature request.
REPL
Issue or pull request specific to the project REPL.
RFC
Request for comments. Feature requests and proposed changes.
Description
This RFC proposes adding syntax highlighting to the REPL. Currently, when a user types commands in the REPL, no syntax highlighting is applied. It would be nice to provide at least basic syntax highlighting as is commonly available in modern IDEs.
Syntax highlighting would be accomplished via ANSI escape codes. One of the trickier aspects will be stripping those ANSI escape codes from commands prior to evaluation, saving to a history file, or if a user attempts to copy terminal contents.
One possible option for avoiding stripping is maintaining two command lists: one the text that a user actually enters (i.e., "raw" text) and another which contains "display" text (i.e., text with ANSI markup). What gets executed is the raw text, but what gets actually written to the terminal is the display text.
Additionally, as syntax highlighting is dependent on proper contrast with the terminal background, we'd likely want to support theming. In which case, we need to design associated APIs and support providing a theme on REPL instantiation.
It would also probably be worthwhile adding a built-in command to allow dynamically changing the theme during the REPL session (e.g.,
switchTheme( theme )
).Theming should likely be disabled with the REPL is not TTY.
Related Issues
No.
Questions
No.
Other
Potential resources:
Checklist
RFC:
.The text was updated successfully, but these errors were encountered: