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; RW, Ini, EB := EditBox, Tabs, Toolbar, SB := StatusBar;
CONST CONST
HEADER = "CEdit (24-feb-2023)"; HEADER = "CEdit (26-feb-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";

View File

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

View File

@ -1,5 +1,5 @@
(* (*
Copyright 2021, 2022 Anton Krotov Copyright 2021-2023 Anton Krotov
This file is part of CEdit. This file is part of CEdit.
@ -21,7 +21,7 @@ MODULE Ini;
IMPORT IMPORT
SYSTEM, RW, Text, Utils, File, List, Languages, KolibriOS, Lines; SYSTEM, RW, Text, Utils, File, List, Languages, Lines;
CONST CONST
@ -167,11 +167,11 @@ BEGIN
autoBrackets := get_int(IniFileName, "settings", "auto_brackets", 0) # 0; autoBrackets := get_int(IniFileName, "settings", "auto_brackets", 0) # 0;
trimSpace := get_int(IniFileName, "settings", "trim_space", 1) # 0; trimSpace := get_int(IniFileName, "settings", "trim_space", 1) # 0;
font := get_int(IniFileName, "settings", "font", 1); font := get_int(IniFileName, "settings", "font", 1);
IF ~((0 <= font) & (font <= 2)) THEN IF (font < 0) OR (font > 2) THEN
font := 1 font := 1
END; END;
theme := get_int(IniFileName, "settings", "theme", 0); 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 theme := 0
END; END;
getStr("settings", "build", buildScript); 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. This file is part of CEdit.
@ -39,7 +39,7 @@ TYPE
END; END;
PmovInt = PROCEDURE (VAR v: INTEGER; x: INTEGER); 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); PmovPtr = PROCEDURE (VAR v: List.tItem; x: List.tItem);
PTypedPtr = PROCEDURE (p: List.tItem); PTypedPtr = PROCEDURE (p: List.tItem);
@ -57,7 +57,7 @@ TYPE
VAR VAR
_movInt: PmovInt; _movInt: PmovInt;
_movBool, _movBool2: PmovBool; _movBool: PmovBool;
_movPtr: PmovPtr; _movPtr: PmovPtr;
_typedPtr: PTypedPtr; _typedPtr: PTypedPtr;
_untypedPtr: PUntypedPtr; _untypedPtr: PUntypedPtr;
@ -123,18 +123,6 @@ BEGIN
END movInt; 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); PROCEDURE movPtr (VAR v: List.tItem; x: List.tItem);
BEGIN BEGIN
_movPtr(v, x) _movPtr(v, x)
@ -206,8 +194,7 @@ BEGIN
line.modified := FALSE; line.modified := FALSE;
line.saved := FALSE; line.saved := FALSE;
IF ~temp THEN IF ~temp THEN
movBool(line, line.modified, FALSE); _movBool(FALSE, line.modified, FALSE, line.saved, FALSE)
movBool(line, line.saved, FALSE)
END; END;
line.cin := 0; line.cin := 0;
line.cout := 0; line.cout := 0;
@ -272,8 +259,7 @@ END tabWidth;
PROCEDURE save* (line: tLine); PROCEDURE save* (line: tLine);
BEGIN BEGIN
IF ~line.temp THEN IF ~line.temp THEN
movBool2(line, line.saved, TRUE); _movBool(TRUE, line.modified, FALSE, line.saved, TRUE)
movBool2(line, line.modified, FALSE)
END; END;
line.modified := FALSE; line.modified := FALSE;
line.saved := TRUE line.saved := TRUE
@ -451,8 +437,7 @@ END fixTabs;
PROCEDURE modify* (line: tLine); PROCEDURE modify* (line: tLine);
BEGIN BEGIN
IF ~line.temp THEN IF ~line.temp THEN
movBool(line, line.modified, TRUE); _movBool(FALSE, line.modified, TRUE, line.saved, FALSE)
movBool(line, line.saved, FALSE)
END; END;
line.modified := TRUE; line.modified := TRUE;
line.saved := FALSE; line.saved := FALSE;
@ -532,12 +517,11 @@ BEGIN
END convert; 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 BEGIN
_movInt := movInt; _movInt := movInt;
_movPtr := movPtr; _movPtr := movPtr;
_movBool := movBool; _movBool := movBool;
_movBool2 := movBool2;
_typedPtr := typedPtr; _typedPtr := typedPtr;
_untypedPtr := untypedPtr; _untypedPtr := untypedPtr;
END init; END init;

View File

@ -68,7 +68,7 @@ TYPE
smallChange: INTEGER; smallChange: INTEGER;
modified*, smallMove, modified*, smallMove,
comments, guard, fasm*, comments, guard, fasm*,
search, cs, whole: BOOLEAN; search, cs, whole, wordSel: BOOLEAN;
edition*: tGuard; edition*: tGuard;
curLine: tLine; curLine: tLine;
lang*: INTEGER; lang*: INTEGER;
@ -929,7 +929,8 @@ BEGIN
text.modified := TRUE; text.modified := TRUE;
text.comments := TRUE; text.comments := TRUE;
text.search := TRUE; text.search := TRUE;
text.guard := TRUE text.guard := TRUE;
text.wordSel := TRUE
END modify; END modify;
@ -1055,7 +1056,8 @@ BEGIN
setSelect(text); setSelect(text);
text.foundSel := 0; text.foundSel := 0;
ShowCursor; ShowCursor;
text.CurX := -1 text.CurX := -1;
text.wordSel := TRUE
END SetPos; END SetPos;
@ -1992,6 +1994,7 @@ VAR
str: tString; str: tString;
curLine: tLine; curLine: tLine;
BEGIN BEGIN
IF text.wordSel THEN
curLine := text.curLine; curLine := text.curLine;
IF selected(text) & (text.cursor.Y = text.select.Y) THEN IF selected(text) & (text.cursor.Y = text.select.Y) THEN
getSelect(text, selBeg, selEnd); getSelect(text, selBeg, selEnd);
@ -2015,7 +2018,9 @@ BEGIN
IF text.searchText # str THEN IF text.searchText # str THEN
text.smallMove := FALSE text.smallMove := FALSE
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
END
END wordSel; END wordSel;
@ -2495,6 +2500,7 @@ BEGIN
text.cs := FALSE; text.cs := FALSE;
text.whole := FALSE; text.whole := FALSE;
text.guard := TRUE; text.guard := TRUE;
text.wordSel := FALSE;
text.edition := NIL; text.edition := NIL;
text.foundList := List.create(NIL); text.foundList := List.create(NIL);
text.searchText := ""; text.searchText := "";