Skip to content

Add basic C++ syntax highlighting to FileViewer#15

Open
alexisM8 wants to merge 3 commits into
zmeadows:masterfrom
alexisM8:syntax-highlighting
Open

Add basic C++ syntax highlighting to FileViewer#15
alexisM8 wants to merge 3 commits into
zmeadows:masterfrom
alexisM8:syntax-highlighting

Conversation

@alexisM8

@alexisM8 alexisM8 commented Apr 5, 2026

Copy link
Copy Markdown

This PR introduces basic syntax highlighting support for C++ source files in FileViewer.

Features:

  • Token-based lexer for C++ (keywords, strings, comments, numbers, preprocessor)
  • Support for single-line (//) and multi-line (/* */) comments with stateful lexing
  • Custom rendering using ImGui DrawList for colored text

Notes:

  • Lexer is line-based with minimal state (LexState) carried across lines
  • Only .cpp/.hpp-style files are currently supported
    • any file will be syntax-highlighted it just will look bad if its not a c-sytle language

Tested on:

  • .cpp / .hpp files
  • Mixed comment styles
  • Large files (basic performance)

Future improvements (optional):

  • Token caching
  • More complete C++ parsing
  • Gutter interaction refinements

Before:
Screenshot 2026-05-09 at 3 51 49 PM

After:
Screenshot 2026-05-09 at 3 50 17 PM

ps: very cool project :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant