diff --git a/programs/develop/cedit/CEDIT b/programs/develop/cedit/CEDIT index 8d719b543e..2c0b9fe451 100644 Binary files a/programs/develop/cedit/CEDIT and b/programs/develop/cedit/CEDIT differ diff --git a/programs/develop/cedit/CEDIT.INI b/programs/develop/cedit/CEDIT.INI index 140a3ae268..5bad974dea 100644 --- a/programs/develop/cedit/CEDIT.INI +++ b/programs/develop/cedit/CEDIT.INI @@ -67,11 +67,13 @@ KW3 = KW1 = auto,default,disabled,false,none,true KW2 = KW3 = +delim = = [lang_Fasm] KW1 = KW2 = KW3 = +delim = {}[]<>:,()&*/|+-\# [lang_JSON] KW1 = diff --git a/programs/develop/cedit/SRC/CEdit.ob07 b/programs/develop/cedit/SRC/CEdit.ob07 index 86d1aad3ed..f53ea8c07d 100644 --- a/programs/develop/cedit/SRC/CEdit.ob07 +++ b/programs/develop/cedit/SRC/CEdit.ob07 @@ -28,7 +28,7 @@ IMPORT RW, Ini, EB := EditBox, Icons, Tabs, Timer; CONST - header = "CEdit (14-sep-2021)"; + header = "CEdit (15-sep-2021)"; ShellFilter = ""; EditFilter = "SH|ASM|TXT|INC|OB07|C|CPP|H|PAS|PP|LUA|INI|JSON"; diff --git a/programs/develop/cedit/SRC/Graph.ob07 b/programs/develop/cedit/SRC/Graph.ob07 index 5ea7873401..5e4b763cf3 100644 --- a/programs/develop/cedit/SRC/Graph.ob07 +++ b/programs/develop/cedit/SRC/Graph.ob07 @@ -19,7 +19,7 @@ MODULE Graph; -IMPORT SYSTEM, K := KOSAPI, Lines; +IMPORT SYSTEM, K := KOSAPI, Lines, Languages; CONST @@ -247,11 +247,11 @@ BEGIN END clear; -PROCEDURE TextOut* (canvas: tCanvas; x, y: INTEGER; text: INTEGER; n: INTEGER); +PROCEDURE TextOut* (canvas: tCanvas; x, y: INTEGER; text: INTEGER; n: INTEGER; delimColor: INTEGER); CONST WCHAR_SIZE = 2; VAR - color, i: INTEGER; + color, i, ecx: INTEGER; c: WCHAR; BEGIN IF (0 <= y) & (y <= canvas.height - canvas.font.height - 1) THEN @@ -271,13 +271,17 @@ BEGIN WHILE n > 0 DO SYSTEM.GET(text + i*WCHAR_SIZE, c); IF ~Lines.isSpace(c) THEN - K.sysfunc6(4, x*65536 + y, LSL(28H + canvas.font.size, 24) + canvas.textColor, SYSTEM.ADR(c), 1, canvas.bitmap - 8) + IF Languages.isDelim(c) THEN + ecx := LSL(28H + canvas.font.size, 24) + delimColor + ELSE + ecx := LSL(28H + canvas.font.size, 24) + canvas.textColor + END; + K.sysfunc6(4, x*65536 + y, ecx, SYSTEM.ADR(c), 1, canvas.bitmap - 8) END; INC(x, canvas.font.width); INC(i); DEC(n) END - (*K.sysfunc6(4, x*65536 + y, LSL(28H + canvas.font.size, 24) + canvas.textColor, text + i*WCHAR_SIZE, n, canvas.bitmap - 8)*) END END END TextOut; @@ -285,7 +289,7 @@ END TextOut; PROCEDURE TextOut2* (canvas: tCanvas; x, y: INTEGER; text: ARRAY OF WCHAR; n: INTEGER); BEGIN - TextOut(canvas, x, y, SYSTEM.ADR(text[0]), n) + TextOut(canvas, x, y, SYSTEM.ADR(text[0]), n, canvas.textColor) END TextOut2; diff --git a/programs/develop/cedit/SRC/Languages.ob07 b/programs/develop/cedit/SRC/Languages.ob07 index 241b1912c2..f11a55f32e 100644 --- a/programs/develop/cedit/SRC/Languages.ob07 +++ b/programs/develop/cedit/SRC/Languages.ob07 @@ -37,12 +37,17 @@ TYPE words: ARRAY 200, 32 OF WCHAR; cnt: INTEGER END; + tDelimiters = ARRAY 256 OF BOOLEAN; + procGetStr = PROCEDURE (secName, keyName: ARRAY OF CHAR; VAR s: ARRAY OF CHAR); VAR - oberonKW, cKW, pascalKW, luaKW, iniKW, fasmKW, jsonKW: ARRAY 3 OF tKeyWords; + KW: ARRAY 8 OF ARRAY 3 OF tKeyWords; + Delim: ARRAY 8 OF tDelimiters; + + currentLang: INTEGER; PROCEDURE isCS* (lang: INTEGER): BOOLEAN; @@ -63,24 +68,23 @@ END checkKW; PROCEDURE isKey* (s: ARRAY OF WCHAR; lang, kwSet: INTEGER): BOOLEAN; -VAR - res: BOOLEAN; -BEGIN - DEC(kwSet); - res := FALSE; - CASE lang OF - |langC: res := checkKW(s, cKW[kwSet]) - |langOberon: res := checkKW(s, oberonKW[kwSet]) - |langPascal: res := checkKW(s, pascalKW[kwSet]) - |langLua: res := checkKW(s, luaKW[kwSet]) - |langIni: res := checkKW(s, iniKW[kwSet]) - |langFasm: res := checkKW(s, fasmKW[kwSet]) - |langJSON: res := checkKW(s, jsonKW[kwSet]) - END - RETURN res + RETURN checkKW(s, KW[lang][kwSet - 1]) END isKey; +PROCEDURE isDelim* (c: WCHAR): BOOLEAN; +VAR + res: BOOLEAN; +BEGIN + IF c <= 0FFX THEN + res := Delim[currentLang][ORD(c)] + ELSE + res := FALSE + END + RETURN res +END isDelim; + + PROCEDURE SkipString* (line: tLine; VAR pos: INTEGER; n: INTEGER); VAR quot: WCHAR; @@ -360,12 +364,21 @@ BEGIN END EnterKW; -PROCEDURE loadKW (VAR KW: ARRAY OF tKeyWords; getStr: procGetStr; lang: ARRAY OF CHAR); +PROCEDURE loadKW (VAR KW: ARRAY OF tKeyWords; VAR delim: tDelimiters; getStr: procGetStr; lang: ARRAY OF CHAR); VAR s: ARRAY 16*1024 OF CHAR; key: ARRAY 4 OF CHAR; i: INTEGER; BEGIN + FOR i := 0 TO LEN(delim) - 1 DO + delim[i] := FALSE + END; + getStr(lang, "delim", s); + i := 0; + WHILE s[i] # 0X DO + delim[ORD(s[i])] := TRUE; + INC(i) + END; key := "KW1"; FOR i := 0 TO 2 DO KW[i].cnt := 0; @@ -376,15 +389,23 @@ BEGIN END loadKW; +PROCEDURE setCurLang* (lang: INTEGER); +BEGIN + currentLang := lang +END setCurLang; + + PROCEDURE init* (getStr: procGetStr); BEGIN - loadKW(oberonKW, getStr, "lang_Oberon"); - loadKW(cKW, getStr, "lang_C"); - loadKW(pascalKW, getStr, "lang_Pascal"); - loadKW(luaKW, getStr, "lang_Lua"); - loadKW(iniKW, getStr, "lang_Ini"); - loadKW(fasmKW, getStr, "lang_Fasm"); - loadKW(jsonKW, getStr, "lang_JSON"); + currentLang := langText; + loadKW(KW[langText], Delim[langText], getStr, "lang_Text"); + loadKW(KW[langOberon], Delim[langOberon], getStr, "lang_Oberon"); + loadKW(KW[langC], Delim[langC], getStr, "lang_C"); + loadKW(KW[langPascal], Delim[langPascal], getStr, "lang_Pascal"); + loadKW(KW[langLua], Delim[langLua], getStr, "lang_Lua"); + loadKW(KW[langIni], Delim[langIni], getStr, "lang_Ini"); + loadKW(KW[langFasm], Delim[langFasm], getStr, "lang_Fasm"); + loadKW(KW[langJSON], Delim[langJSON], getStr, "lang_JSON"); END init; diff --git a/programs/develop/cedit/SRC/Text.ob07 b/programs/develop/cedit/SRC/Text.ob07 index 5c535971c1..aed18d7ce3 100644 --- a/programs/develop/cedit/SRC/Text.ob07 +++ b/programs/develop/cedit/SRC/Text.ob07 @@ -127,14 +127,16 @@ BEGIN text.lang := Lang.langJSON ELSE text.lang := Lang.langText - END + END; + Lang.setCurLang(text.lang) END setName; PROCEDURE setLang* (text: tText; lang: INTEGER); BEGIN text.lang := lang; - text.comments := TRUE + text.comments := TRUE; + Lang.setCurLang(text.lang) END setLang; @@ -293,11 +295,11 @@ VAR BEGIN SetColor(color, backColor); lexLen := MAX(MIN(line.length - lexStart, lexEnd - lexStart + 1), 0); - G.TextOut(canvas, padding.left + (lexStart - text.scroll.X) * charWidth, y, Lines.getPChar(line, lexStart), lexLen) + G.TextOut(canvas, padding.left + (lexStart - text.scroll.X) * charWidth, y, Lines.getPChar(line, lexStart), lexLen, color) END PrintLex; - PROCEDURE PrintComment (text: tText; line: tLine; VAR depth, i: INTEGER; y: INTEGER; backColor: INTEGER); + PROCEDURE PrintComment (text: tText; line: tLine; VAR depth, i: INTEGER; w, y: INTEGER; backColor: INTEGER); VAR lexStart: INTEGER; color: INTEGER; @@ -311,7 +313,7 @@ VAR ELSE color := colors.comment END; - lexStart := MAX(i - 2, 0); + lexStart := MAX(i - w, 0); ProcessComments(line, depth, i, 0, line.length - 1, text.lang); PrintLex(text, line, lexStart, i, y, color, backColor) END PrintComment; @@ -334,20 +336,6 @@ VAR END FL; - PROCEDURE isFASMdelim (c: WCHAR): BOOLEAN; - VAR - s: ARRAY 19 OF WCHAR; - i: INTEGER; - BEGIN - s := "{}[]<>:,()&*/|+-\#"; - i := LEN(s) - 2; - WHILE (i >= 0) & (c # s[i]) DO - DEC(i) - END - RETURN i >= 0 - END isFASMdelim; - - PROCEDURE ident (text: tText; VAR i: INTEGER; first, y: INTEGER; line: tLine; backColor: INTEGER; cs: BOOLEAN); VAR c: WCHAR; @@ -395,7 +383,7 @@ BEGIN n := line.length - 1; i := 0; IF (depth > 0) & (n >= 0) THEN - PrintComment(text, line, depth, i, y, backColor) + PrintComment(text, line, depth, i, 2, y, backColor) END; cond := 0; WHILE i <= n DO @@ -410,8 +398,6 @@ BEGIN String(text, line, i, y, backColor) ELSIF (U.isLetter(c) OR (c = "_")) THEN ident(text, i, i, y, line, backColor, Lang.isCS(lang)) - ELSIF isFASMdelim(c) THEN - PrintLex(text, line, i, i, y, colors.delim, backColor) ELSIF U.isDigit(c) THEN hex := FALSE; k := i; @@ -448,7 +434,7 @@ BEGIN ELSIF (c = "*") & (cond = 1) THEN depth := 1; INC(i); - PrintComment(text, line, depth, i, y, backColor); + PrintComment(text, line, depth, i, 2, y, backColor); cond := 0 ELSIF U.isLetter(c) OR (c = "_") OR (c = "'") OR (c = '"') THEN k := i; @@ -591,7 +577,7 @@ BEGIN IF cond = 1 THEN INC(depth); INC(i); - PrintComment(text, line, depth, i, y, backColor); + PrintComment(text, line, depth, i, 2, y, backColor); cond := 0 ELSE cond := 2 @@ -615,7 +601,7 @@ BEGIN IF Lang.LuaLong(line, i + 1) >= 0 THEN depth := Lang.LuaLong(line, i + 1)*2 + 1; INC(i); - PrintComment(text, line, depth, i, y, backColor) + PrintComment(text, line, depth, i, 2, y, backColor) ELSE PrintLex(text, line, i - 1, n, y, colors.comment, backColor); i := n @@ -630,7 +616,7 @@ BEGIN IF k >= 0 THEN depth := (k + 1)*2; INC(i, 2); - PrintComment(text, line, depth, i, y, backColor); + PrintComment(text, line, depth, i, 2, y, backColor); cond := 0 END ELSIF (c = "'") OR (c = '"') THEN @@ -698,7 +684,7 @@ BEGIN ELSIF (c = "*") & (cond = 1) THEN depth := 2; INC(i); - PrintComment(text, line, depth, i, y, backColor); + PrintComment(text, line, depth, i, 2, y, backColor); cond := 0 ELSIF c = "/" THEN IF cond = 2 THEN @@ -717,8 +703,8 @@ BEGIN ELSE depth := 1 END; - INC(i, 2); - PrintComment(text, line, depth, i, y, backColor); + INC(i); + PrintComment(text, line, depth, i, 1, y, backColor); cond := 0 ELSIF c = "#" THEN k := i; @@ -798,12 +784,10 @@ BEGIN i := n ELSIF c = '"' THEN String(text, line, i, y, backColor) - ELSIF c = "=" THEN - PrintLex(text, line, i, i, y, colors.delim, backColor) ELSIF c = "[" THEN depth := 1; - INC(i, 2); - PrintComment(text, line, depth, i, y, backColor) + INC(i); + PrintComment(text, line, depth, i, 1, y, backColor) ELSIF U.isDigit(c) THEN k := i; WHILE U.isDigit(getChar(line, i)) DO @@ -2014,7 +1998,7 @@ BEGIN x := pos*charWidth + padding.left; G.SetColor(canvas, colors.selback); G.FillRect(canvas, x - 2, y - inter DIV 2, x + 1 + Len*charWidth, y - inter DIV 2 + charHeight); - G.TextOut(canvas, pos*charWidth + padding.left, y, Lines.getPChar(line, firstCharIdx), Len) + G.TextOut(canvas, pos*charWidth + padding.left, y, Lines.getPChar(line, firstCharIdx), Len, colors.seltext) END drawSelect; @@ -2101,7 +2085,7 @@ BEGIN END; SetColor(colors.text, backColor); Len := MAX(line.length - text.scroll.X, 0); - G.TextOut(canvas, padding.left, y, Lines.getPChar(line, text.scroll.X), MIN(Len, textsize.X + 1)); + G.TextOut(canvas, padding.left, y, Lines.getPChar(line, text.scroll.X), MIN(Len, textsize.X + 1), colors.delim); IF text.lang # Lang.langText THEN parse(text, line, y, backColor, text.lang) END; @@ -2242,6 +2226,8 @@ BEGIN text.searchText := ""; text.foundSel := 0; text.CurX := -1; + text.lang := Lang.langText; + Lang.setCurLang(Lang.langText); setName(text, fileName); ASSERT(text = List.create(text)) RETURN text