diff --git a/programs/develop/cedit/CEDIT b/programs/develop/cedit/CEDIT index 6ea1a8e2ca..4140bce0a9 100644 Binary files a/programs/develop/cedit/CEDIT and b/programs/develop/cedit/CEDIT differ diff --git a/programs/develop/cedit/SRC/CEdit.ob07 b/programs/develop/cedit/SRC/CEdit.ob07 index 270b96804c..6cabac0f87 100644 --- a/programs/develop/cedit/SRC/CEdit.ob07 +++ b/programs/develop/cedit/SRC/CEdit.ob07 @@ -28,7 +28,7 @@ IMPORT RW, Ini, EB := EditBox, Tabs, Toolbar, SB := StatusBar; CONST - HEADER = "CEdit (18-mar-2023)"; + HEADER = "CEdit (29-mar-2023)"; ShellFilter = ""; EditFilter = "sh|inc|txt|asm|ob07|c|cpp|h|pas|pp|lua|ini|json"; @@ -412,6 +412,9 @@ BEGIN CheckBox.draw(CS); CheckBox.draw(WH); END; + IF ~search OR (searchText = "") THEN + T.wordSel(text) + END; drawText; NotFound; Replaced; @@ -1633,11 +1636,31 @@ END HideSearch; PROCEDURE KeyDown (key: INTEGER); VAR - keyCode: INTEGER; - shift, ctrl: BOOLEAN; + keyCode, ah: INTEGER; + shift, ctrl, rep: BOOLEAN; BEGIN K.getKBState(shift, ctrl); + rep := FALSE; keyCode := key DIV 65536; + + (* Numpad *) + ah := (key DIV 256) MOD 256; + CASE keyCode OF + |83: IF ah = 46 THEN keyCode := 52 END (* . / Del *) + |82: IF ah = 48 THEN keyCode := 11 END (* 0 / Ins *) + |79: IF ah = 49 THEN keyCode := 2 END (* 1 / End *) + |80: IF ah = 50 THEN keyCode := 3 END (* 2 / Down *) + |81: IF ah = 51 THEN keyCode := 4 END (* 3 / PgDn *) + |75: IF ah = 52 THEN keyCode := 5 END (* 4 / <- *) + |76: IF ah = 55 THEN keyCode := -1 END (* 5 / --- *) + |77: IF ah = 54 THEN keyCode := 7 END (* 6 / -> *) + |71: IF ah = 55 THEN keyCode := 8 END (* 7 / Home *) + |72: IF ah = 56 THEN keyCode := 9 END (* 8 / Up *) + |73: IF ah = 57 THEN keyCode := 10 END (* 9 / PgUp *) + ELSE + (* nothing to do *) + END; + IF confirm THEN IF keyCode = 28 THEN (* Enter *) save(text); @@ -1647,7 +1670,9 @@ BEGIN END; key := -1 ELSE - IF keyCode = 61 THEN (* F3 *) + IF keyCode = -1 THEN + key := -1 + ELSIF keyCode = 61 THEN (* F3 *) key := -1; IF search & (searchText # "") THEN IF shift THEN @@ -1779,17 +1804,26 @@ BEGIN END ELSE T.input(text, E.cp866[key DIV 256 MOD 256]); + IF key DIV 256 MOD 256 = 13 THEN + rep := TRUE + END; key := -1 END END; IF key >= 0 THEN - T.key(text, key, shift, ctrl) + T.key(text, key, shift, ctrl); + IF ((key = 38) OR (key = 40) OR (key = ORD("D"))) & ctrl THEN + rep := TRUE + END END END END END; IF key # -2 THEN - repaint + repaint; + IF rep THEN + repaint + END END END KeyDown; diff --git a/programs/develop/cedit/SRC/Lines.ob07 b/programs/develop/cedit/SRC/Lines.ob07 index 00f41286e8..f918545a41 100644 --- a/programs/develop/cedit/SRC/Lines.ob07 +++ b/programs/develop/cedit/SRC/Lines.ob07 @@ -231,14 +231,14 @@ END resize; PROCEDURE getChar* (line: tLine; i: INTEGER): WCHAR; VAR - res: WCHAR; + res: WCHAR; BEGIN - IF i >= line.length THEN - res := 0X - ELSE - SYSTEM.GET(line.ptr + i*WCHAR_SIZE, res) - END - RETURN res + IF (0 <= i) & (i < line.length) THEN + SYSTEM.GET(line.ptr + i*WCHAR_SIZE, res) + ELSE + res := 0X + END + RETURN res END getChar; diff --git a/programs/develop/cedit/SRC/Search.ob07 b/programs/develop/cedit/SRC/Search.ob07 index ffcf5e69d4..15dcd257fa 100644 --- a/programs/develop/cedit/SRC/Search.ob07 +++ b/programs/develop/cedit/SRC/Search.ob07 @@ -115,10 +115,24 @@ BEGIN END next; +PROCEDURE add* (list: List.tList; pos: INTEGER); +VAR + item: tPos; +BEGIN + item := list.last(tPos); + IF (item = NIL) OR (item.cnt = itemSize) THEN + NEW(item); + item.cnt := 0; + List.append(list, item) + END; + item.pos[item.cnt] := pos; + INC(item.cnt) +END add; + + PROCEDURE find* (text: tBuffer; s: ARRAY OF WCHAR; whole: BOOLEAN; list: List.tList; offset: INTEGER); VAR k, pos, n, i, x, prev_item_pos: INTEGER; - item: tPos; c1, c2: WCHAR; flag: BOOLEAN; BEGIN @@ -147,14 +161,7 @@ BEGIN END; IF ~flag & (x >= prev_item_pos) THEN prev_item_pos := x + n; - item := list.last(tPos); - IF (item = NIL) OR (item.cnt = itemSize) THEN - NEW(item); - item.cnt := 0; - List.append(list, item) - END; - item.pos[item.cnt] := x + offset; - INC(item.cnt) + add(list, x + offset) END END; INC(pos, SYSTEM.SIZE(INTEGER)); diff --git a/programs/develop/cedit/SRC/Text.ob07 b/programs/develop/cedit/SRC/Text.ob07 index f1d744dc76..0d539cc36f 100644 --- a/programs/develop/cedit/SRC/Text.ob07 +++ b/programs/develop/cedit/SRC/Text.ob07 @@ -878,17 +878,6 @@ VAR BEGIN - IF ~_copy THEN - cnt := -lenEOL; - line := text.first(tLine); - WHILE line # NIL DO - INC(cnt, lenEOL); - line.pos := cnt; - INC(cnt, line.length); - NextLine(line) - END - END; - first := getLine2(text, textStart.Y); line := first; @@ -926,9 +915,30 @@ BEGIN END plain; -PROCEDURE _search (text: tText; s: ARRAY OF WCHAR; cs, whole: BOOLEAN; textStart, textEnd: tPoint): BOOLEAN; +PROCEDURE ClearSearch (text: tText); VAR pos: List.tItem; + line: tLine; + cnt: INTEGER; +BEGIN + cnt := -lenEOL; + line := text.first(tLine); + WHILE line # NIL DO + INC(cnt, lenEOL); + line.pos := cnt; + INC(cnt, line.length); + NextLine(line) + END; + + WHILE text.foundList.count # 0 DO + pos := List.pop(text.foundList); + DISPOSE(pos) + END +END ClearSearch; + + +PROCEDURE _search (text: tText; s: ARRAY OF WCHAR; cs, whole: BOOLEAN; textStart, textEnd: tPoint): BOOLEAN; +VAR res: BOOLEAN; plainText, idxData: CB.tBuffer; first: tLine; @@ -937,10 +947,6 @@ BEGIN res := TRUE; plainText := NIL; idxData := NIL; - WHILE text.foundList.count # 0 DO - pos := List.pop(text.foundList); - DISPOSE(pos) - END; text.whole := whole; text.cs := cs; text.searchText := s; @@ -969,25 +975,148 @@ END _search; PROCEDURE search* (text: tText; s: ARRAY OF WCHAR; cs, whole: BOOLEAN): BOOLEAN; VAR textStart, textEnd: tPoint; -(* - PROCEDURE _getSelect (text: tText; VAR selBeg, selEnd: tPoint); - BEGIN - selBeg := text.cursor^; - selEnd := text.select^; - IF (selBeg.Y > selEnd.Y) OR (selBeg.Y = selEnd.Y) & (selBeg.X > selEnd.X) THEN - selBeg := text.select^; - selEnd := text.cursor^ - END - END _getSelect;*) - BEGIN textStart.Y := 0; textStart.X := 0; textEnd.Y := text.count - 1; textEnd.X := text.last(tLine).length; - //_getSelect(text, textStart, textEnd) + ClearSearch(text) RETURN _search(text, s, cs, whole, textStart, textEnd) END search; +PROCEDURE fasm_anon (text: tText); +VAR + textStart, textEnd: tPoint; + res, frw, back, label, anon_label: BOOLEAN; + Y1, Y2, i, k, j: INTEGER; + line, Label: tLine; + str: ARRAY 8 OF WCHAR; + + + PROCEDURE anon (line: tLine): BOOLEAN; + VAR + i: INTEGER; + BEGIN + i := leadingSpaces(line) + RETURN (Lines.getChar(line, i) = "@") & + (Lines.getChar(line, i + 1) = "@") & + (Lines.getChar(line, i + 2) = ":") + END anon; + + +BEGIN + frw := FALSE; + back := FALSE; + label := FALSE; + line := text.curLine; + + i := text.cursor.X; + j := 0; + FOR k := i - 3 TO i + 2 DO + str[j] := U.lcase(Lines.getChar(line, k)); + INC(j) + END; + j := 3; + + anon_label := anon(line); + + IF str[j] = "@" THEN + IF str[j + 1] = "f" THEN + frw := TRUE + ELSIF (str[j + 1] = "b") OR (str[j + 1] = "r") THEN + back := TRUE + ELSIF anon_label & (((str[j + 1] = "@") & (str[j + 2] = ":")) OR + ((str[j - 1] = "@") & (str[j + 1] = ":"))) THEN + label := TRUE + END + ELSIF str[j - 1] = "@" THEN + IF str[j] = "f" THEN + frw := TRUE + ELSIF (str[j] = "b") OR (str[j] = "r") THEN + back := TRUE + ELSIF anon_label & (str[j] = ":") & (str[j - 2] = "@") THEN + label := TRUE + END + ELSIF anon_label & (str[j] = ":") & (str[j - 1] = "@") & (str[j - 2] = "@") THEN + label := TRUE + ELSIF (str[j - 1] = "f") & (str[j - 2] = "@") THEN + frw := TRUE + ELSIF ((str[j - 1] = "b") OR (str[j - 1] = "r")) & (str[j - 2] = "@") THEN + back := TRUE + ELSIF anon_label & (str[j - 1] = ":") & (str[j - 2] = "@") & (str[j - 3] = "@") THEN + label := TRUE + END; + + IF back OR frw OR label THEN + Y1 := text.cursor.Y; + Y2 := Y1; + + IF label THEN + Label := line; + DEC(Y1) + ELSE + Label := NIL + END; + + line := getLine2(text, Y1); + WHILE (Y1 > 0) & ~anon(line) DO + PrevLine(line); + DEC(Y1) + END; + + line := getLine2(text, Y2); + IF anon(line) THEN + NextLine(line); + INC(Y2) + END; + + WHILE (Y2 < text.count) & ~anon(line) DO + NextLine(line); + INC(Y2) + END; + + IF Y1 < 0 THEN + Y1 := 0 + ELSIF back THEN + Label := getLine2(text, Y1) + END; + textStart.Y := Y1; textStart.X := 0; + IF Y2 = text.count THEN + DEC(Y2); + textEnd.X := text.last(tLine).length + ELSIF frw THEN + Label := getLine2(text, Y2); + textEnd.X := 0 + END; + textEnd.Y := Y2; + ClearSearch(text); + text.smallMove := FALSE; + IF (Label # NIL) & ~anon(Label) THEN + Label := NIL + END + END; + + IF frw THEN + res := _search(text, "@f", FALSE, FALSE, textStart, textEnd); + IF Label # NIL THEN + Search.add(text.foundList, Label.pos + leadingSpaces(Label)) + END + ELSIF back THEN + IF Label # NIL THEN + Search.add(text.foundList, Label.pos + leadingSpaces(Label)) + END; + res := _search(text, "@b", FALSE, FALSE, textStart, textEnd); + res := _search(text, "@r", FALSE, FALSE, textStart, textEnd) + ELSIF label THEN + res := _search(text, "@f", FALSE, FALSE, textStart, text.cursor^); + IF Label # NIL THEN + Search.add(text.foundList, Label.pos + leadingSpaces(Label)) + END; + res := _search(text, "@b", FALSE, FALSE, text.cursor^, textEnd); + res := _search(text, "@r", FALSE, FALSE, text.cursor^, textEnd) + END +END fasm_anon; + + PROCEDURE modify (text: tText); BEGIN text.modified := TRUE; @@ -2034,6 +2163,9 @@ BEGIN END; IF search(text, str, Lang.isCS(text.lang), TRUE) THEN END; text.wordSel := FALSE + END; + IF (text.lang = Lang.langFasm) & ~selected(text) THEN + fasm_anon(text) END END wordSel; diff --git a/programs/develop/cedit/SRC/Utils.ob07 b/programs/develop/cedit/SRC/Utils.ob07 index 73a4ff135e..2f47db88d0 100644 --- a/programs/develop/cedit/SRC/Utils.ob07 +++ b/programs/develop/cedit/SRC/Utils.ob07 @@ -200,6 +200,13 @@ BEGIN END lower; +PROCEDURE lcase* (ch: WCHAR): WCHAR; +BEGIN + IF lower(ch) THEN END + RETURN ch +END lcase; + + PROCEDURE lowcase* (VAR s: ARRAY OF WCHAR); VAR i: INTEGER;