- highlight @@:/@f/@b/@r
- numpad support


git-svn-id: svn://kolibrios.org@9909 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Anton Krotov 2023-03-28 22:27:10 +00:00
parent 77a4688f6d
commit fbb49920de
6 changed files with 230 additions and 50 deletions

Binary file not shown.

View File

@ -28,7 +28,7 @@ IMPORT
RW, Ini, EB := EditBox, Tabs, Toolbar, SB := StatusBar; RW, Ini, EB := EditBox, Tabs, Toolbar, SB := StatusBar;
CONST CONST
HEADER = "CEdit (18-mar-2023)"; HEADER = "CEdit (29-mar-2023)";
ShellFilter = ""; ShellFilter = "";
EditFilter = "sh|inc|txt|asm|ob07|c|cpp|h|pas|pp|lua|ini|json"; EditFilter = "sh|inc|txt|asm|ob07|c|cpp|h|pas|pp|lua|ini|json";
@ -412,6 +412,9 @@ BEGIN
CheckBox.draw(CS); CheckBox.draw(CS);
CheckBox.draw(WH); CheckBox.draw(WH);
END; END;
IF ~search OR (searchText = "") THEN
T.wordSel(text)
END;
drawText; drawText;
NotFound; NotFound;
Replaced; Replaced;
@ -1633,11 +1636,31 @@ END HideSearch;
PROCEDURE KeyDown (key: INTEGER); PROCEDURE KeyDown (key: INTEGER);
VAR VAR
keyCode: INTEGER; keyCode, ah: INTEGER;
shift, ctrl: BOOLEAN; shift, ctrl, rep: BOOLEAN;
BEGIN BEGIN
K.getKBState(shift, ctrl); K.getKBState(shift, ctrl);
rep := FALSE;
keyCode := key DIV 65536; 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 confirm THEN
IF keyCode = 28 THEN (* Enter *) IF keyCode = 28 THEN (* Enter *)
save(text); save(text);
@ -1647,7 +1670,9 @@ BEGIN
END; END;
key := -1 key := -1
ELSE ELSE
IF keyCode = 61 THEN (* F3 *) IF keyCode = -1 THEN
key := -1
ELSIF keyCode = 61 THEN (* F3 *)
key := -1; key := -1;
IF search & (searchText # "") THEN IF search & (searchText # "") THEN
IF shift THEN IF shift THEN
@ -1779,17 +1804,26 @@ BEGIN
END END
ELSE ELSE
T.input(text, E.cp866[key DIV 256 MOD 256]); T.input(text, E.cp866[key DIV 256 MOD 256]);
IF key DIV 256 MOD 256 = 13 THEN
rep := TRUE
END;
key := -1 key := -1
END END
END; END;
IF key >= 0 THEN 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
END END
END; END;
IF key # -2 THEN IF key # -2 THEN
repaint repaint;
IF rep THEN
repaint
END
END END
END KeyDown; END KeyDown;

View File

@ -231,14 +231,14 @@ END resize;
PROCEDURE getChar* (line: tLine; i: INTEGER): WCHAR; PROCEDURE getChar* (line: tLine; i: INTEGER): WCHAR;
VAR VAR
res: WCHAR; res: WCHAR;
BEGIN BEGIN
IF i >= line.length THEN IF (0 <= i) & (i < line.length) THEN
res := 0X SYSTEM.GET(line.ptr + i*WCHAR_SIZE, res)
ELSE ELSE
SYSTEM.GET(line.ptr + i*WCHAR_SIZE, res) res := 0X
END END
RETURN res RETURN res
END getChar; END getChar;

View File

@ -115,10 +115,24 @@ BEGIN
END next; 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); PROCEDURE find* (text: tBuffer; s: ARRAY OF WCHAR; whole: BOOLEAN; list: List.tList; offset: INTEGER);
VAR VAR
k, pos, n, i, x, prev_item_pos: INTEGER; k, pos, n, i, x, prev_item_pos: INTEGER;
item: tPos;
c1, c2: WCHAR; c1, c2: WCHAR;
flag: BOOLEAN; flag: BOOLEAN;
BEGIN BEGIN
@ -147,14 +161,7 @@ BEGIN
END; END;
IF ~flag & (x >= prev_item_pos) THEN IF ~flag & (x >= prev_item_pos) THEN
prev_item_pos := x + n; prev_item_pos := x + n;
item := list.last(tPos); add(list, x + offset)
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)
END END
END; END;
INC(pos, SYSTEM.SIZE(INTEGER)); INC(pos, SYSTEM.SIZE(INTEGER));

View File

@ -878,17 +878,6 @@ VAR
BEGIN 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); first := getLine2(text, textStart.Y);
line := first; line := first;
@ -926,9 +915,30 @@ BEGIN
END plain; END plain;
PROCEDURE _search (text: tText; s: ARRAY OF WCHAR; cs, whole: BOOLEAN; textStart, textEnd: tPoint): BOOLEAN; PROCEDURE ClearSearch (text: tText);
VAR VAR
pos: List.tItem; 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; res: BOOLEAN;
plainText, idxData: CB.tBuffer; plainText, idxData: CB.tBuffer;
first: tLine; first: tLine;
@ -937,10 +947,6 @@ BEGIN
res := TRUE; res := TRUE;
plainText := NIL; plainText := NIL;
idxData := NIL; idxData := NIL;
WHILE text.foundList.count # 0 DO
pos := List.pop(text.foundList);
DISPOSE(pos)
END;
text.whole := whole; text.whole := whole;
text.cs := cs; text.cs := cs;
text.searchText := s; text.searchText := s;
@ -969,25 +975,148 @@ END _search;
PROCEDURE search* (text: tText; s: ARRAY OF WCHAR; cs, whole: BOOLEAN): BOOLEAN; PROCEDURE search* (text: tText; s: ARRAY OF WCHAR; cs, whole: BOOLEAN): BOOLEAN;
VAR VAR
textStart, textEnd: tPoint; 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 BEGIN
textStart.Y := 0; textStart.X := 0; textStart.Y := 0; textStart.X := 0;
textEnd.Y := text.count - 1; textEnd.X := text.last(tLine).length; 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) RETURN _search(text, s, cs, whole, textStart, textEnd)
END search; 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); PROCEDURE modify (text: tText);
BEGIN BEGIN
text.modified := TRUE; text.modified := TRUE;
@ -2034,6 +2163,9 @@ BEGIN
END; END;
IF search(text, str, Lang.isCS(text.lang), TRUE) THEN END; IF search(text, str, Lang.isCS(text.lang), TRUE) THEN END;
text.wordSel := FALSE text.wordSel := FALSE
END;
IF (text.lang = Lang.langFasm) & ~selected(text) THEN
fasm_anon(text)
END END
END wordSel; END wordSel;

View File

@ -200,6 +200,13 @@ BEGIN
END lower; END lower;
PROCEDURE lcase* (ch: WCHAR): WCHAR;
BEGIN
IF lower(ch) THEN END
RETURN ch
END lcase;
PROCEDURE lowcase* (VAR s: ARRAY OF WCHAR); PROCEDURE lowcase* (VAR s: ARRAY OF WCHAR);
VAR VAR
i: INTEGER; i: INTEGER;