CEdit: bugfix; file saving optimized

git-svn-id: svn://kolibrios.org@9452 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Anton Krotov 2021-12-21 16:19:39 +00:00
parent 36abfafd64
commit f1469998c7
5 changed files with 50 additions and 38 deletions

Binary file not shown.

View File

@ -28,7 +28,7 @@ IMPORT
RW, Ini, EB := EditBox, Tabs, Toolbar; RW, Ini, EB := EditBox, Tabs, Toolbar;
CONST CONST
HEADER = "CEdit (20-dec-2021)"; HEADER = "CEdit (21-dec-2021)";
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

@ -27,7 +27,9 @@ TYPE
END; END;
tBoolItem = POINTER TO RECORD (List.tItem) tBoolItem = POINTER TO RECORD (List.tItem)
adr: INTEGER; val: BOOLEAN; save: BOOLEAN line: Lines.tLine;
adr: INTEGER;
val, save: BOOLEAN
END; END;
tUntypedPtr = POINTER TO RECORD (List.tItem) tUntypedPtr = POINTER TO RECORD (List.tItem)
@ -119,6 +121,9 @@ END clear;
PROCEDURE save* (guard: tGuard); PROCEDURE save* (guard: tGuard);
VAR VAR
item: List.tItem; item: List.tItem;
boolItem: tBoolItem;
cur: List.tItem;
del: BOOLEAN;
BEGIN BEGIN
item := CL.Log.first; item := CL.Log.first;
WHILE item # NIL DO WHILE item # NIL DO
@ -127,7 +132,22 @@ BEGIN
END; END;
item := item.next item := item.next
END; END;
guard.saved := TRUE guard.saved := TRUE;
cur := CL.guard.prev;
WHILE cur # NIL DO
IF cur IS tBoolItem THEN
boolItem := cur(tBoolItem);
del := boolItem.save & boolItem.line.modified
ELSE
del := FALSE
END;
cur := cur.prev;
IF del THEN
List.delete(CL.Log, boolItem);
DISPOSE(boolItem)
END
END
END save; END save;
@ -145,11 +165,12 @@ BEGIN
END changeWord; END changeWord;
PROCEDURE changeBool (VAR v: BOOLEAN; x: BOOLEAN); PROCEDURE changeBool (line: Lines.tLine; VAR v: BOOLEAN; x: BOOLEAN);
VAR VAR
item: tBoolItem; item: tBoolItem;
BEGIN BEGIN
NEW(item); NEW(item);
item.line := line;
item.adr := SYSTEM.ADR(v); item.adr := SYSTEM.ADR(v);
item.val := x; item.val := x;
item.save := FALSE; item.save := FALSE;
@ -207,30 +228,15 @@ BEGIN
END delCurSaved; END delCurSaved;
PROCEDURE changeBool2 (VAR v: BOOLEAN; x: BOOLEAN); PROCEDURE changeBool2 (line: Lines.tLine; VAR v: BOOLEAN; x: BOOLEAN);
VAR VAR
item, boolItem: tBoolItem; item: tBoolItem;
cur: List.tItem;
del: BOOLEAN;
BEGIN BEGIN
NEW(item); NEW(item);
item.line := line;
item.adr := SYSTEM.ADR(v); item.adr := SYSTEM.ADR(v);
item.val := x; item.val := x;
item.save := TRUE; item.save := TRUE;
cur := CL.guard.prev;
WHILE cur # NIL DO
IF cur IS tBoolItem THEN
boolItem := cur(tBoolItem);
del := boolItem.save & (boolItem.adr = SYSTEM.ADR(v)) & (boolItem.val = x)
ELSE
del := FALSE
END;
cur := cur.prev;
IF del THEN
List.delete(CL.Log, boolItem);
DISPOSE(boolItem)
END
END;
List.insert(CL.Log, CL.guard.prev, item) List.insert(CL.Log, CL.guard.prev, item)
END changeBool2; END changeBool2;

View File

@ -38,7 +38,7 @@ TYPE
END; END;
PmovInt = PROCEDURE (VAR v: INTEGER; x: INTEGER); PmovInt = PROCEDURE (VAR v: INTEGER; x: INTEGER);
PmovBool = PROCEDURE (VAR v: BOOLEAN; x: BOOLEAN); PmovBool = PROCEDURE (line: tLine; VAR v: BOOLEAN; x: 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);
@ -63,15 +63,15 @@ BEGIN
END movInt; END movInt;
PROCEDURE movBool (VAR v: BOOLEAN; x: BOOLEAN); PROCEDURE movBool (line: tLine; VAR v: BOOLEAN; x: BOOLEAN);
BEGIN BEGIN
_movBool(v, x) _movBool(line, v, x)
END movBool; END movBool;
PROCEDURE movBool2 (VAR v: BOOLEAN; x: BOOLEAN); PROCEDURE movBool2 (line: tLine; VAR v: BOOLEAN; x: BOOLEAN);
BEGIN BEGIN
_movBool2(v, x) _movBool2(line, v, x)
END movBool2; END movBool2;
@ -146,8 +146,8 @@ BEGIN
line.modified := FALSE; line.modified := FALSE;
line.saved := FALSE; line.saved := FALSE;
IF ~temp THEN IF ~temp THEN
movBool(line.modified, FALSE); movBool(line, line.modified, FALSE);
movBool(line.saved, FALSE) movBool(line, line.saved, FALSE)
END; END;
line.cin := 0; line.cin := 0;
line.cout := 0; line.cout := 0;
@ -194,8 +194,8 @@ END tabWidth;
PROCEDURE save* (line: tLine); PROCEDURE save* (line: tLine);
BEGIN BEGIN
IF ~line.temp THEN IF ~line.temp THEN
movBool2(line.saved, TRUE); movBool2(line, line.saved, TRUE);
movBool2(line.modified, FALSE) movBool2(line, line.modified, FALSE)
END; END;
line.modified := FALSE; line.modified := FALSE;
line.saved := TRUE line.saved := TRUE
@ -384,8 +384,8 @@ END fixTabs;
PROCEDURE modify* (line: tLine); PROCEDURE modify* (line: tLine);
BEGIN BEGIN
IF ~line.temp THEN IF ~line.temp THEN
movBool(line.modified, TRUE); movBool(line, line.modified, TRUE);
movBool(line.saved, FALSE) movBool(line, line.saved, FALSE)
END; END;
line.modified := TRUE; line.modified := TRUE;
line.saved := FALSE; line.saved := FALSE;

View File

@ -1368,9 +1368,6 @@ BEGIN
IF RW.putString(file, line, Len) # Len THEN IF RW.putString(file, line, Len) # Len THEN
res := FALSE res := FALSE
END; END;
IF line.modified THEN
Lines.save(line)
END;
NextLine(line); NextLine(line);
IF line # NIL THEN IF line # NIL THEN
IF ~RW.newLine(file) THEN IF ~RW.newLine(file) THEN
@ -1389,6 +1386,15 @@ BEGIN
IF res THEN IF res THEN
text.modified := FALSE; text.modified := FALSE;
ChangeLog.save(text.edition); ChangeLog.save(text.edition);
line := text.first(tLine);
WHILE line # NIL DO
IF line.modified THEN
Lines.save(line)
END;
NextLine(line)
END;
IF File.Delete(tempFile) THEN END IF File.Delete(tempFile) THEN END
END END
END; END;
@ -1495,7 +1501,7 @@ BEGIN
n := selEnd.Y - selBeg.Y; n := selEnd.Y - selBeg.Y;
cnt := 0; cnt := 0;
WHILE n >= 0 DO WHILE n >= 0 DO
INC(cnt, line.length + lenEOL); INC(cnt, line.length + (lenEOL + 1));
NextLine(line); NextLine(line);
DEC(n) DEC(n)
END; END;