CEdit: optimization

git-svn-id: svn://kolibrios.org@9904 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Anton Krotov 2023-02-26 19:26:25 +00:00
parent 759e2688de
commit 9ea1f9a4a6
6 changed files with 67 additions and 84 deletions

Binary file not shown.

View File

@ -28,7 +28,7 @@ IMPORT
RW, Ini, EB := EditBox, Tabs, Toolbar, SB := StatusBar;
CONST
HEADER = "CEdit (24-feb-2023)";
HEADER = "CEdit (26-feb-2023)";
ShellFilter = "";
EditFilter = "sh|inc|txt|asm|ob07|c|cpp|h|pas|pp|lua|ini|json";

View File

@ -35,9 +35,8 @@ TYPE
map: SET;
data: ARRAY boolItemSize OF
RECORD
line: Lines.tLine;
adr: INTEGER;
val, save: BOOLEAN
adr1, adr2: INTEGER;
val1, val2, save: BOOLEAN
END
END;
@ -124,7 +123,8 @@ BEGIN
ELSIF item IS tBoolItem THEN
FOR i := 0 TO boolItemSize - 1 DO
IF i IN item(tBoolItem).map THEN
SYSTEM.PUT(item(tBoolItem).data[i].adr, item(tBoolItem).data[i].val)
SYSTEM.PUT(item(tBoolItem).data[i].adr1, item(tBoolItem).data[i].val1);
SYSTEM.PUT(item(tBoolItem).data[i].adr2, item(tBoolItem).data[i].val2)
END
END
END
@ -152,6 +152,7 @@ VAR
boolItem: tBoolItem;
cur: List.tItem;
i: INTEGER;
line_modified: BOOLEAN;
BEGIN
item := CL.Log.first;
WHILE item # NIL DO
@ -167,9 +168,11 @@ BEGIN
IF cur IS tBoolItem THEN
boolItem := cur(tBoolItem);
FOR i := 0 TO boolItemSize - 1 DO
IF (i IN boolItem.map) & boolItem.data[i].save &
boolItem.data[i].line.modified THEN
EXCL(boolItem.map, i)
IF (i IN boolItem.map) & boolItem.data[i].save THEN
SYSTEM.GET(boolItem.data[i].adr1, line_modified);
IF line_modified THEN
EXCL(boolItem.map, i)
END
END
END
END;
@ -244,7 +247,8 @@ BEGIN
boolItem := cur(tBoolItem);
FOR i := 0 TO boolItemSize - 1 DO
IF (i IN boolItem.map) & boolItem.data[i].save THEN
SYSTEM.PUT(boolItem.data[i].adr, ~boolItem.data[i].val);
SYSTEM.PUT(boolItem.data[i].adr1, ~boolItem.data[i].val1);
SYSTEM.PUT(boolItem.data[i].adr2, ~boolItem.data[i].val2);
EXCL(boolItem.map, i)
END
END
@ -258,13 +262,13 @@ BEGIN
END delCurSaved;
PROCEDURE _changeBool (fn2: BOOLEAN; line: Lines.tLine; VAR v: BOOLEAN; x: BOOLEAN);
PROCEDURE changeBool (save: BOOLEAN; VAR v1: BOOLEAN; x1: BOOLEAN; VAR v2: BOOLEAN; x2: BOOLEAN);
VAR
item: tBoolItem;
cur: List.tItem;
i: INTEGER;
BEGIN
IF fn2 THEN
IF save THEN
cur := CL.guard.prev
ELSE
IF ~CL.isLast THEN
@ -274,7 +278,7 @@ BEGIN
END;
WHILE (cur # NIL) & ~(cur IS tGuard) &
(~(cur IS tBoolItem) OR (cur(tBoolItem).map = fillMap)) DO
( ~(cur IS tBoolItem) (*OR (cur(tBoolItem).map = fillMap)*) ) DO
cur := cur.prev
END;
IF (cur IS tBoolItem) & (cur(tBoolItem).map # fillMap) THEN
@ -282,7 +286,7 @@ BEGIN
ELSE
NEW(item);
item.map := {};
IF fn2 THEN
IF save THEN
List.insert(CL.Log, CL.guard.prev, item)
ELSE
List.append(CL.Log, item)
@ -292,30 +296,19 @@ BEGIN
i := 0;
WHILE i < boolItemSize DO
IF ~(i IN item.map) THEN
item.data[i].line := line;
item.data[i].adr := SYSTEM.ADR(v);
item.data[i].val := x;
item.data[i].save := fn2;
item.data[i].adr1 := SYSTEM.ADR(v1);
item.data[i].val1 := x1;
item.data[i].adr2 := SYSTEM.ADR(v2);
item.data[i].val2 := x2;
item.data[i].save := save;
INCL(item.map, i);
i := boolItemSize
END;
INC(i)
END
END _changeBool;
PROCEDURE changeBool (line: Lines.tLine; VAR v: BOOLEAN; x: BOOLEAN);
BEGIN
_changeBool(FALSE, line, v, x)
END changeBool;
PROCEDURE changeBool2 (line: Lines.tLine; VAR v: BOOLEAN; x: BOOLEAN);
BEGIN
_changeBool(TRUE, line, v, x)
END changeBool2;
PROCEDURE changeInt* (VAR v: INTEGER; x: INTEGER);
BEGIN
changeWord(SYSTEM.ADR(v), SYSTEM.ADR(x))
@ -421,5 +414,5 @@ END destroy;
BEGIN
List.init(changeInt, changePtr);
Lines.init(changeInt, changePtr, changeBool, changeBool2, typedPtr, untypedPtr)
Lines.init(changeInt, changePtr, changeBool, typedPtr, untypedPtr)
END ChangeLog.

View File

@ -1,5 +1,5 @@
(*
Copyright 2021, 2022 Anton Krotov
Copyright 2021-2023 Anton Krotov
This file is part of CEdit.
@ -21,7 +21,7 @@ MODULE Ini;
IMPORT
SYSTEM, RW, Text, Utils, File, List, Languages, KolibriOS, Lines;
SYSTEM, RW, Text, Utils, File, List, Languages, Lines;
CONST
@ -167,11 +167,11 @@ BEGIN
autoBrackets := get_int(IniFileName, "settings", "auto_brackets", 0) # 0;
trimSpace := get_int(IniFileName, "settings", "trim_space", 1) # 0;
font := get_int(IniFileName, "settings", "font", 1);
IF ~((0 <= font) & (font <= 2)) THEN
IF (font < 0) OR (font > 2) THEN
font := 1
END;
theme := get_int(IniFileName, "settings", "theme", 0);
IF ~((0 <= theme) & (theme <= sections.count - 1)) THEN
IF (theme < 0) OR (theme >= sections.count) THEN
theme := 0
END;
getStr("settings", "build", buildScript);

View File

@ -1,5 +1,5 @@
(*
Copyright 2021, 2022 Anton Krotov
Copyright 2021-2023 Anton Krotov
This file is part of CEdit.
@ -39,7 +39,7 @@ TYPE
END;
PmovInt = PROCEDURE (VAR v: INTEGER; x: INTEGER);
PmovBool = PROCEDURE (line: tLine; VAR v: BOOLEAN; x: BOOLEAN);
PmovBool = PROCEDURE (save: BOOLEAN; VAR v1: BOOLEAN; x1: BOOLEAN; VAR v2: BOOLEAN; x2: BOOLEAN);
PmovPtr = PROCEDURE (VAR v: List.tItem; x: List.tItem);
PTypedPtr = PROCEDURE (p: List.tItem);
@ -57,7 +57,7 @@ TYPE
VAR
_movInt: PmovInt;
_movBool, _movBool2: PmovBool;
_movBool: PmovBool;
_movPtr: PmovPtr;
_typedPtr: PTypedPtr;
_untypedPtr: PUntypedPtr;
@ -123,18 +123,6 @@ BEGIN
END movInt;
PROCEDURE movBool (line: tLine; VAR v: BOOLEAN; x: BOOLEAN);
BEGIN
_movBool(line, v, x)
END movBool;
PROCEDURE movBool2 (line: tLine; VAR v: BOOLEAN; x: BOOLEAN);
BEGIN
_movBool2(line, v, x)
END movBool2;
PROCEDURE movPtr (VAR v: List.tItem; x: List.tItem);
BEGIN
_movPtr(v, x)
@ -206,8 +194,7 @@ BEGIN
line.modified := FALSE;
line.saved := FALSE;
IF ~temp THEN
movBool(line, line.modified, FALSE);
movBool(line, line.saved, FALSE)
_movBool(FALSE, line.modified, FALSE, line.saved, FALSE)
END;
line.cin := 0;
line.cout := 0;
@ -272,8 +259,7 @@ END tabWidth;
PROCEDURE save* (line: tLine);
BEGIN
IF ~line.temp THEN
movBool2(line, line.saved, TRUE);
movBool2(line, line.modified, FALSE)
_movBool(TRUE, line.modified, FALSE, line.saved, TRUE)
END;
line.modified := FALSE;
line.saved := TRUE
@ -451,8 +437,7 @@ END fixTabs;
PROCEDURE modify* (line: tLine);
BEGIN
IF ~line.temp THEN
movBool(line, line.modified, TRUE);
movBool(line, line.saved, FALSE)
_movBool(FALSE, line.modified, TRUE, line.saved, FALSE)
END;
line.modified := TRUE;
line.saved := FALSE;
@ -532,12 +517,11 @@ BEGIN
END convert;
PROCEDURE init* (movInt: PmovInt; movPtr: PmovPtr; movBool, movBool2: PmovBool; typedPtr: PTypedPtr; untypedPtr: PUntypedPtr);
PROCEDURE init* (movInt: PmovInt; movPtr: PmovPtr; movBool: PmovBool; typedPtr: PTypedPtr; untypedPtr: PUntypedPtr);
BEGIN
_movInt := movInt;
_movPtr := movPtr;
_movBool := movBool;
_movBool2 := movBool2;
_typedPtr := typedPtr;
_untypedPtr := untypedPtr;
END init;

View File

@ -68,7 +68,7 @@ TYPE
smallChange: INTEGER;
modified*, smallMove,
comments, guard, fasm*,
search, cs, whole: BOOLEAN;
search, cs, whole, wordSel: BOOLEAN;
edition*: tGuard;
curLine: tLine;
lang*: INTEGER;
@ -929,7 +929,8 @@ BEGIN
text.modified := TRUE;
text.comments := TRUE;
text.search := TRUE;
text.guard := TRUE
text.guard := TRUE;
text.wordSel := TRUE
END modify;
@ -1055,7 +1056,8 @@ BEGIN
setSelect(text);
text.foundSel := 0;
ShowCursor;
text.CurX := -1
text.CurX := -1;
text.wordSel := TRUE
END SetPos;
@ -1992,30 +1994,33 @@ VAR
str: tString;
curLine: tLine;
BEGIN
curLine := text.curLine;
IF selected(text) & (text.cursor.Y = text.select.Y) THEN
getSelect(text, selBeg, selEnd);
x1 := selBeg.X;
x2 := selEnd.X;
n := getString(curLine, x1, x2 - x1, str);
ELSE
str := ""
END;
IF str # "" THEN
i := 0;
WHILE (i < n) & isWordChar(str[i]) DO
INC(i)
END;
IF (i # n) OR
((x1 > 0) & isWordChar(Lines.getChar(curLine, x1 - 1))) OR
((x2 < curLine.length) & isWordChar(Lines.getChar(curLine, x2))) THEN
str := ""
END
END;
IF text.searchText # str THEN
text.smallMove := FALSE
END;
IF search(text, str, Lang.isCS(text.lang), TRUE) THEN END
IF text.wordSel THEN
curLine := text.curLine;
IF selected(text) & (text.cursor.Y = text.select.Y) THEN
getSelect(text, selBeg, selEnd);
x1 := selBeg.X;
x2 := selEnd.X;
n := getString(curLine, x1, x2 - x1, str);
ELSE
str := ""
END;
IF str # "" THEN
i := 0;
WHILE (i < n) & isWordChar(str[i]) DO
INC(i)
END;
IF (i # n) OR
((x1 > 0) & isWordChar(Lines.getChar(curLine, x1 - 1))) OR
((x2 < curLine.length) & isWordChar(Lines.getChar(curLine, x2))) THEN
str := ""
END
END;
IF text.searchText # str THEN
text.smallMove := FALSE
END;
IF search(text, str, Lang.isCS(text.lang), TRUE) THEN END;
text.wordSel := FALSE
END
END wordSel;
@ -2495,6 +2500,7 @@ BEGIN
text.cs := FALSE;
text.whole := FALSE;
text.guard := TRUE;
text.wordSel := FALSE;
text.edition := NIL;
text.foundList := List.create(NIL);
text.searchText := "";