Skip to content
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

[RFC]: add syntax highlighting support to the REPL #2072

Open
3 tasks done
kgryte opened this issue Mar 27, 2024 · 0 comments · May be fixed by #2254
Open
3 tasks done

[RFC]: add syntax highlighting support to the REPL #2072

kgryte opened this issue Mar 27, 2024 · 0 comments · May be fixed by #2254
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.

Comments

@kgryte
Copy link
Member

kgryte commented Mar 27, 2024

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

  • I have read and understood the Code of Conduct.
  • Searched for existing issues and pull requests.
  • The issue name begins with RFC:.
@kgryte kgryte added Enhancement Issue or pull request for enhancing existing functionality. RFC Request for comments. Feature requests and proposed changes. Needs Discussion Needs further discussion. REPL Issue or pull request specific to the project REPL. priority: Normal Normal priority concern or feature request. JavaScript Issue involves or relates to JavaScript. difficulty: 4 Likely to be moderately difficult. labels Mar 27, 2024
@Snehil-Shah Snehil-Shah linked a pull request May 20, 2024 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant