nakst / gf

A GDB frontend for Linux.
MIT License
1.82k stars 61 forks source link

fix(#88): fix incorrect syntax highlighting for preprocessor directives. #128

Closed s4my closed 1 year ago

s4my commented 1 year ago

This PR is a fix for the issue #88.

Note: The luigi2.h is littered with white spaces, so the 1st commit gets rid of them. The 2nd commit is the actual fix.

s4my commented 1 year ago

I was thinking about adding an enum inside of the UIDrawStringHighlighted() function to define the lex states, and replace all the random numbers the lexState is equated to with meaningful states making the code more readable:

enum lexStates {
    DEFAULT,
    COMMENT,
    STRING,
    NUMBER,
    OPERATOR,
    PREPROCESSOR,
};

Then for e.g., replace lexState = 5 with lexState = PREPROCESSOR. what do you think ?
Of course if you have any nitpicks for the names or the syntax please do tell.

s4my commented 1 year ago

I also would suggest to rename lexState to tokenType thus lexStates to tokenTypes.

nakst commented 1 year ago

I was thinking about adding an enum inside of the UIDrawStringHighlighted() function to define the lex states, and replace all the random numbers the lexState is equated to with meaningful states making the code more readable:

enum lexStates {
  DEFAULT,
  COMMENT,
  STRING,
  NUMBER,
  OPERATOR,
  PREPROCESSOR,
};

Then for e.g., replace lexState = 5 with lexState = PREPROCESSOR. what do you think ? Of course if you have any nitpicks for the names or the syntax please do tell.

You could do,

typedef enum _UICodeTokenType {
    UI_CODE_TOKEN_TYPE_DEFAULT,
    // ...
} _UICodeTokenType;