unixwork / xnedit

A fast and classic X11 text editor, based on NEdit, with full unicode support and antialiased text rendering.
Other
82 stars 12 forks source link

add syntax for C99 style comments when language mode is C #37

Closed efa closed 2 years ago

efa commented 3 years ago

// C99 comments (single line) are not italics like happen for C89 comments (multi line)

efa commented 3 years ago

in the past a Nedit's maillist subscriber sent me some steps to add C99 comments recognition by menu Prefences, Default Settings, Syntax Highlighting but I cannot find that anymore, maybe lost on an old work computer installation and I cannot find the email too

unixwork commented 3 years ago

Preferences -> Default Settings -> Syntax Highlighting -> Recognition Patterns

Language Mode: C New Pattern

Pattern Type: Pass 2 Highlight Style: Comment Pattern Name: commentc99 Starting Regular Expression: // Ending Regular Expression: (?<!\)$

I will add this to the next release. Can't do it yet, because I want to add some other syntax highlighting changes and want to do all in one go, because I need to create a patch for existing nedit.rc files and increment nedit.fileVersion. It is better to do this at the end before the release.

efa commented 3 years ago

there is the other related request: https://github.com/unixwork/xnedit/issues/21 for bool and other new (really old in 2021) keywords

efa commented 3 years ago

you probably mean: Ending Regular Expression: \(?<!\)$ instead of Ending Regular Expression: (?<!\)$

efa commented 3 years ago

and maybe need something similar for comments on preprocessor lines

unixwork commented 3 years ago

Actually (?<!\\)$

markdown killed one \

efa commented 3 years ago

I didn't even used lookbehind negative regexp: (?<!pattern) Did it mean: look for strings that is \\ and are at the of a line, and skip (negative)?

efa commented 3 years ago

other C99 new syntax hightlight other than the one asked in #21 should be the fixed size type: https://en.cppreference.com/w/c/types/integer

efa commented 3 years ago

other new types are:

ptrdiff_t
off_t
ssize_t
size_t
wchar_t

gcc -std=gnu99 accept those complex:

float complex      
long complex       
complex            
double complex     
long double complex
unixwork commented 3 years ago

size_t is not new in C99. It is also not a type of the language, just a typedef.

The best solution would probably be to highlight all words that end with _t, because that are probably always types (no sane C programmer would end a variable or function name with _t).

complex is similar to bool, it is not a language keyword, just a define. The language keywords are _Complex or _Bool. The libc provides headers for these defines (stdbool.h, complex.h), but the libc has a lot of defines and I can't add highlighting for everything.

unixwork commented 2 years ago

xnedit 1.4.0 has updated C syntax highlighting