diff --git a/datafiles/data/themes/default.zip b/datafiles/data/themes/default.zip index 26c999e1a..ac9ddd50a 100644 Binary files a/datafiles/data/themes/default.zip and b/datafiles/data/themes/default.zip differ diff --git a/scripts/hlsl_draw/hlsl_draw.gml b/scripts/hlsl_draw/hlsl_draw.gml index aec34cfe9..821f3dbb5 100644 --- a/scripts/hlsl_draw/hlsl_draw.gml +++ b/scripts/hlsl_draw/hlsl_draw.gml @@ -15,33 +15,38 @@ var constant = ["MATRIX_VIEW", "MATRIX_PROJECTION", "MATRIX_WORLD", "MATRIX_WORL for( var i = 0, n = array_length(constant); i < n; i++ ) global.glsl_constant[? constant[i]] = 1; -global.HLSL_BREAK_TOKEN = [" ", "(", ")", "[", "]", "{", "}", ".", ",", ";", "+", "-", "*", "/", "^", "="]; +global.HLSL_BREAK_TOKEN = [" ", "(", ")", "[", "]", "{", "}", ".", ",", ";", "+", "-", "*", "/", "^", "=", "//"]; function hlsl_token_splice(str) { var st = []; var ss = str; - var sp; - var cc; + var sp, cc, del; do { - sp = 999999; + sp = 999999; + del = ""; + for( var i = 0, n = array_length(global.HLSL_BREAK_TOKEN); i < n; i++ ) { - var _pos = string_pos(global.HLSL_BREAK_TOKEN[i], ss); - if(_pos != 0) sp = min(sp, _pos); + var _del = global.HLSL_BREAK_TOKEN[i]; + var _pos = string_pos(_del, ss); + + if(_pos != 0 && _pos < sp || (_pos == sp && string_length(del) < string_length(_del))) { + sp = _pos; + del = _del; + } } - if(sp == 999999) { //no delim left + if(del == "") { //no delim left array_push(st, ss); break; } var _ss = string_copy(ss, 1, sp - 1); array_push(st, _ss); + array_push(st, del); - cc = string_char_at(ss, sp); - array_push(st, cc); - - ss = string_copy(ss, sp + 1, string_length(ss) - sp); + var dl = string_length(del); + ss = string_copy(ss, sp + dl, string_length(ss) - sp - dl + 1); } until(sp == 0); return st; @@ -50,15 +55,20 @@ function hlsl_token_splice(str) { function draw_code_hlsl(_x, _y, str) { var tx = _x; var ty = _y; - var words = hlsl_token_splice(str); + var words = hlsl_token_splice(str); + var comment = false; for( var j = 0; j < array_length(words); j++ ) { var word = words[j]; var wordNoS = string_trim(word); + if(wordNoS == "//") comment = true; + draw_set_color(COLORS._main_text); - if(word == "(" || word == ")" || word == "[" || word == "]" || word == "{" || word == "}") + if(comment) + draw_set_color(COLORS.lua_highlight_comment); + else if(word == "(" || word == ")" || word == "[" || word == "]" || word == "{" || word == "}") draw_set_color(COLORS.lua_highlight_bracklet); else if(ds_map_exists(global.glsl_reserved, word)) draw_set_color(COLORS.lua_highlight_keyword); diff --git a/scripts/luaHighlight/luaHighlight.gml b/scripts/luaHighlight/luaHighlight.gml index fafb6ba72..6e8c84de7 100644 --- a/scripts/luaHighlight/luaHighlight.gml +++ b/scripts/luaHighlight/luaHighlight.gml @@ -8,33 +8,38 @@ var reserved = ["and", "break", "do", "else", "elseif", "end", "false", for( var i = 0, n = array_length(reserved); i < n; i++ ) global.lua_reserved[? reserved[i]] = 1; -global.CODE_BREAK_TOKEN = [" ", "(", ")", "[", "]", "{", "}", ",", ";", "+", "-", "*", "/", "^", "="]; +global.CODE_BREAK_TOKEN = [" ", "(", ")", "[", "]", "{", "}", ",", ";", "+", "-", "*", "/", "^", "=", "--"]; function lua_token_splice(str) { var st = []; var ss = str; - var sp; - var cc; + var sp, cc, del; do { sp = 999999; + del = ""; + for( var i = 0, n = array_length(global.CODE_BREAK_TOKEN); i < n; i++ ) { - var _pos = string_pos(global.CODE_BREAK_TOKEN[i], ss); - if(_pos != 0) sp = min(sp, _pos); + var _del = global.CODE_BREAK_TOKEN[i]; + var _pos = string_pos(_del, ss); + + if(_pos != 0 && _pos < sp || (_pos == sp && string_length(del) < string_length(_del))) { + sp = _pos; + del = _del; + } } - if(sp == 999999) { //no delim left + if(del == "") { //no delim left array_push(st, ss); break; } var _ss = string_copy(ss, 1, sp - 1); array_push(st, _ss); + array_push(st, del); - cc = string_char_at(ss, sp); - array_push(st, cc); - - ss = string_copy(ss, sp + 1, string_length(ss) - sp); + var dl = string_length(del); + ss = string_copy(ss, sp + dl, string_length(ss) - sp - dl + 1); } until(sp == 0); return st; @@ -47,6 +52,7 @@ function draw_code_lua(_x, _y, str) { var isStr = true; var strSpl = string_splice(str, "\""); var amo = array_length(strSpl); + var comment = false; var word; for( var i = 0; i < amo; i++ ) { @@ -66,13 +72,17 @@ function draw_code_lua(_x, _y, str) { } var words = lua_token_splice(_w); - + for( var j = 0; j < array_length(words); j++ ) { word = words[j]; var wordNoS = string_trim(word); + if(wordNoS == "//") comment = true; + draw_set_color(COLORS._main_text); - if(word == "(" || word == ")" || word == "[" || word == "]" || word == "{" || word == "}") + if(comment) + draw_set_color(COLORS.lua_highlight_comment); + else if(word == "(" || word == ")" || word == "[" || word == "]" || word == "{" || word == "}") draw_set_color(COLORS.lua_highlight_bracklet); else if(ds_map_exists(global.lua_reserved, word)) draw_set_color(COLORS.lua_highlight_keyword); diff --git a/scripts/textArea/textArea.gml b/scripts/textArea/textArea.gml index cbaff5b83..69be431b6 100644 --- a/scripts/textArea/textArea.gml +++ b/scripts/textArea/textArea.gml @@ -580,16 +580,12 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor draw_text_path(ch_x, ch_y, _str); break; case TEXT_AREA_FORMAT.codeLUA : - if(syntax_highlight) - draw_code_lua(ch_x, ch_y, _str); - else - draw_text_add(ch_x, ch_y, _str); + if(syntax_highlight) draw_code_lua(ch_x, ch_y, _str); + else draw_text_add(ch_x, ch_y, _str); break; case TEXT_AREA_FORMAT.codeHLSL : - if(syntax_highlight) - draw_code_hlsl(ch_x, ch_y, _str); - else - draw_text_add(ch_x, ch_y, _str); + if(syntax_highlight) draw_code_hlsl(ch_x, ch_y, _str); + else draw_text_add(ch_x, ch_y, _str); break; }