1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Improve editor syntax highlighting of include statements.

This commit is contained in:
Jonas 'Sortie' Termansen 2014-08-02 11:49:12 +02:00
parent e97032761e
commit 29ca566d43

View file

@ -174,6 +174,7 @@ void editor_colorize(struct editor* editor)
STATE_LINE_COMMENT, STATE_LINE_COMMENT,
STATE_MULTI_LINE_COMMENT, STATE_MULTI_LINE_COMMENT,
STATE_PREPROCESSOR, STATE_PREPROCESSOR,
STATE_PREPROCESSOR_VALUE,
STATE_SINGLE_QUOTE, STATE_SINGLE_QUOTE,
STATE_DOUBLE_QUOTE, STATE_DOUBLE_QUOTE,
STATE_NUMBER, STATE_NUMBER,
@ -202,9 +203,15 @@ void editor_colorize(struct editor* editor)
state = STATE_INIT; state = STATE_INIT;
// The character makes you enter a new state. // The character makes you enter a new state.
if ( !fixed_state )
if ( !fixed_state && state == STATE_INIT && c == L'#' ) {
if ( state == STATE_INIT && c == L'#' )
state = STATE_PREPROCESSOR; state = STATE_PREPROCESSOR;
if ( state == STATE_PREPROCESSOR && c == '<' )
state = STATE_PREPROCESSOR_VALUE, fixed_state = 1;
if ( state == STATE_PREPROCESSOR && c == '"' )
state = STATE_PREPROCESSOR_VALUE, fixed_state = 1;
}
// TODO: Detect NULL as a value. // TODO: Detect NULL as a value.
@ -430,7 +437,8 @@ void editor_colorize(struct editor* editor)
if ( state == STATE_SINGLE_QUOTE || if ( state == STATE_SINGLE_QUOTE ||
state == STATE_DOUBLE_QUOTE || state == STATE_DOUBLE_QUOTE ||
state == STATE_NUMBER ) state == STATE_NUMBER ||
state == STATE_PREPROCESSOR_VALUE )
color = 5; color = 5;
if ( state == STATE_PREPROCESSOR ) if ( state == STATE_PREPROCESSOR )
@ -454,6 +462,10 @@ void editor_colorize(struct editor* editor)
state = STATE_INIT, fixed_state = 1; state = STATE_INIT, fixed_state = 1;
if ( state == STATE_DOUBLE_QUOTE && !escaped && c == L'"' ) if ( state == STATE_DOUBLE_QUOTE && !escaped && c == L'"' )
state = STATE_INIT, fixed_state = 1; state = STATE_INIT, fixed_state = 1;
if ( state == STATE_PREPROCESSOR_VALUE && c == '>' )
state = STATE_PREPROCESSOR;
if ( state == STATE_PREPROCESSOR_VALUE && c == '"' )
state = STATE_PREPROCESSOR;
} }
if ( (state == STATE_SINGLE_QUOTE || state == STATE_DOUBLE_QUOTE) ) if ( (state == STATE_SINGLE_QUOTE || state == STATE_DOUBLE_QUOTE) )
@ -483,6 +495,7 @@ void editor_colorize(struct editor* editor)
if ( state == STATE_LINE_COMMENT || if ( state == STATE_LINE_COMMENT ||
state == STATE_PREPROCESSOR || state == STATE_PREPROCESSOR ||
state == STATE_PREPROCESSOR_VALUE ||
state == STATE_SINGLE_QUOTE || state == STATE_SINGLE_QUOTE ||
state == STATE_DOUBLE_QUOTE ) state == STATE_DOUBLE_QUOTE )
{ {