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

C/C++ syntax highlighting #116

Closed
sonictk opened this issue Jul 29, 2019 · 14 comments
Closed

C/C++ syntax highlighting #116

sonictk opened this issue Jul 29, 2019 · 14 comments

Comments

@sonictk
Copy link

sonictk commented Jul 29, 2019

Not sure if this has actually been requested by anyone, but it would be nice to be at least able to highlight the standard keywords used in C/C++ in the source file window so that it's easier to identify areas of the code. Having everything be one colour makes a little hard to read code sometimes.

@anaymsinha
Copy link

It is doable and also a nice idea.

@x13pixels
Copy link
Owner

It has been asked for but I don't see it written up anywhere. Thanks for doing so.

@kmar
Copy link

kmar commented Apr 5, 2020

there's already an ImGUI component for this: https://github.com/BalazsJako/ImGuiColorTextEdit

@dbechrd
Copy link

dbechrd commented Nov 2, 2022

This is pretty much the only reason I don't use RemedyBG wayyyyyyyyyy more often. I love it, but I can't read my code as a gray blob. Even a simple, toned down colorscheme like Casey's 4Coder theme would improve readability 100x.

image

@Chinayang1
Copy link

How about GNU Emacs's Face mechanism that allow user to choose color for different kinds of word of programming language?

@ryuukk
Copy link

ryuukk commented Sep 24, 2023

Please export the function that handle the text rendering, so i can implement my own with colors

This issue is 4 years old and no progress were made

$30 software btw

@ryuukk
Copy link

ryuukk commented Sep 24, 2023

@x13pixels
Copy link
Owner

@ryuukk Apologies for the lack of progress on this. I don't use syntax highlighting but I understand that it is a useful feature to have when viewing code for many people. The library you pointed to in the previous comment was used as the basis for the text view in RemedyBG long ago. However, it has been largely gutted due to performance (and other) issues (like failing to syntax highlight properly). From the project's readme:

syntax highligthing of most languages - except C/C++ - is based on std::regex, which is diasppointingly slow..

I did intentionally note that syntax highlighting is not available in the project's page:

This project is in development and should be considered in "early access". There are certainly bugs as well as features on the roadmap. For example, the text window for displaying source code does not currently have any sort of syntax highlighting, although this planned for a future version.

Perhaps I incorrectly chose which features to work on in my limited time over the years (I'd much rather write a debugger than a text editor) and I, again, apologize for not getting to this sooner.

Anyway, happy to refund your money given viewing colorized text is an important feature for you and has not been implemented yet.

@n00bmind
Copy link

I've been reading up about the tree-sitter lib lately (https://tree-sitter.github.io/tree-sitter/), and it seems like a pretty capable thing. I haven't tried anything with it myself, so I cannot speak about how hefty of a dependency it is or how easy to use it is in practice, but what I gather from other people is that it at least looks decent.
Anyway, just an idea..

@kevyuu
Copy link

kevyuu commented Nov 24, 2023

Yeah, I would second tree-sitter recommendation. It should be faster and more accurate than regex. I really wish this feature exist.

@x13pixels
Copy link
Owner

Thanks for the suggestion @n00bmind. I'll take a look.

@x13pixels
Copy link
Owner

Doesn't look like tree-sitter is going to work out at this time. For example,

@kmar
Copy link

kmar commented Nov 26, 2023

ok, I've just open sourced my very simple highlighter (header only), it can be found here along with an example,
it doesn't use regexes
the link is here: https://github.com/kmar/syntax_highlight

it requires C++17 because of std::string_view, but well...
I use it in my private text editor, so it's battle-tested (except I don't use stl in my framework at all)

@x13pixels
Copy link
Owner

Implemented comment / keyword highlighting.

To ship in 0.3.9.7.

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

No branches or pull requests

9 participants