forked from KolibriOS/kolibrios
CEdit: bugfix; file saving optimized
git-svn-id: svn://kolibrios.org@9452 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
36abfafd64
commit
f1469998c7
Binary file not shown.
@ -28,7 +28,7 @@ IMPORT
|
||||
RW, Ini, EB := EditBox, Tabs, Toolbar;
|
||||
|
||||
CONST
|
||||
HEADER = "CEdit (20-dec-2021)";
|
||||
HEADER = "CEdit (21-dec-2021)";
|
||||
|
||||
ShellFilter = "";
|
||||
EditFilter = "SH|INC|TXT|ASM|OB07|C|CPP|H|PAS|PP|LUA|INI|JSON";
|
||||
|
@ -27,7 +27,9 @@ TYPE
|
||||
END;
|
||||
|
||||
tBoolItem = POINTER TO RECORD (List.tItem)
|
||||
adr: INTEGER; val: BOOLEAN; save: BOOLEAN
|
||||
line: Lines.tLine;
|
||||
adr: INTEGER;
|
||||
val, save: BOOLEAN
|
||||
END;
|
||||
|
||||
tUntypedPtr = POINTER TO RECORD (List.tItem)
|
||||
@ -118,7 +120,10 @@ END clear;
|
||||
|
||||
PROCEDURE save* (guard: tGuard);
|
||||
VAR
|
||||
item: List.tItem;
|
||||
item: List.tItem;
|
||||
boolItem: tBoolItem;
|
||||
cur: List.tItem;
|
||||
del: BOOLEAN;
|
||||
BEGIN
|
||||
item := CL.Log.first;
|
||||
WHILE item # NIL DO
|
||||
@ -127,7 +132,22 @@ BEGIN
|
||||
END;
|
||||
item := item.next
|
||||
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;
|
||||
|
||||
|
||||
@ -145,11 +165,12 @@ BEGIN
|
||||
END changeWord;
|
||||
|
||||
|
||||
PROCEDURE changeBool (VAR v: BOOLEAN; x: BOOLEAN);
|
||||
PROCEDURE changeBool (line: Lines.tLine; VAR v: BOOLEAN; x: BOOLEAN);
|
||||
VAR
|
||||
item: tBoolItem;
|
||||
BEGIN
|
||||
NEW(item);
|
||||
item.line := line;
|
||||
item.adr := SYSTEM.ADR(v);
|
||||
item.val := x;
|
||||
item.save := FALSE;
|
||||
@ -207,30 +228,15 @@ BEGIN
|
||||
END delCurSaved;
|
||||
|
||||
|
||||
PROCEDURE changeBool2 (VAR v: BOOLEAN; x: BOOLEAN);
|
||||
PROCEDURE changeBool2 (line: Lines.tLine; VAR v: BOOLEAN; x: BOOLEAN);
|
||||
VAR
|
||||
item, boolItem: tBoolItem;
|
||||
cur: List.tItem;
|
||||
del: BOOLEAN;
|
||||
item: tBoolItem;
|
||||
BEGIN
|
||||
NEW(item);
|
||||
item.line := line;
|
||||
item.adr := SYSTEM.ADR(v);
|
||||
item.val := x;
|
||||
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)
|
||||
END changeBool2;
|
||||
|
||||
|
@ -38,7 +38,7 @@ TYPE
|
||||
END;
|
||||
|
||||
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);
|
||||
|
||||
PTypedPtr = PROCEDURE (p: List.tItem);
|
||||
@ -63,15 +63,15 @@ BEGIN
|
||||
END movInt;
|
||||
|
||||
|
||||
PROCEDURE movBool (VAR v: BOOLEAN; x: BOOLEAN);
|
||||
PROCEDURE movBool (line: tLine; VAR v: BOOLEAN; x: BOOLEAN);
|
||||
BEGIN
|
||||
_movBool(v, x)
|
||||
_movBool(line, v, x)
|
||||
END movBool;
|
||||
|
||||
|
||||
PROCEDURE movBool2 (VAR v: BOOLEAN; x: BOOLEAN);
|
||||
PROCEDURE movBool2 (line: tLine; VAR v: BOOLEAN; x: BOOLEAN);
|
||||
BEGIN
|
||||
_movBool2(v, x)
|
||||
_movBool2(line, v, x)
|
||||
END movBool2;
|
||||
|
||||
|
||||
@ -146,8 +146,8 @@ BEGIN
|
||||
line.modified := FALSE;
|
||||
line.saved := FALSE;
|
||||
IF ~temp THEN
|
||||
movBool(line.modified, FALSE);
|
||||
movBool(line.saved, FALSE)
|
||||
movBool(line, line.modified, FALSE);
|
||||
movBool(line, line.saved, FALSE)
|
||||
END;
|
||||
line.cin := 0;
|
||||
line.cout := 0;
|
||||
@ -194,8 +194,8 @@ END tabWidth;
|
||||
PROCEDURE save* (line: tLine);
|
||||
BEGIN
|
||||
IF ~line.temp THEN
|
||||
movBool2(line.saved, TRUE);
|
||||
movBool2(line.modified, FALSE)
|
||||
movBool2(line, line.saved, TRUE);
|
||||
movBool2(line, line.modified, FALSE)
|
||||
END;
|
||||
line.modified := FALSE;
|
||||
line.saved := TRUE
|
||||
@ -384,8 +384,8 @@ END fixTabs;
|
||||
PROCEDURE modify* (line: tLine);
|
||||
BEGIN
|
||||
IF ~line.temp THEN
|
||||
movBool(line.modified, TRUE);
|
||||
movBool(line.saved, FALSE)
|
||||
movBool(line, line.modified, TRUE);
|
||||
movBool(line, line.saved, FALSE)
|
||||
END;
|
||||
line.modified := TRUE;
|
||||
line.saved := FALSE;
|
||||
|
@ -1368,9 +1368,6 @@ BEGIN
|
||||
IF RW.putString(file, line, Len) # Len THEN
|
||||
res := FALSE
|
||||
END;
|
||||
IF line.modified THEN
|
||||
Lines.save(line)
|
||||
END;
|
||||
NextLine(line);
|
||||
IF line # NIL THEN
|
||||
IF ~RW.newLine(file) THEN
|
||||
@ -1389,6 +1386,15 @@ BEGIN
|
||||
IF res THEN
|
||||
text.modified := FALSE;
|
||||
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
|
||||
END
|
||||
END;
|
||||
@ -1495,7 +1501,7 @@ BEGIN
|
||||
n := selEnd.Y - selBeg.Y;
|
||||
cnt := 0;
|
||||
WHILE n >= 0 DO
|
||||
INC(cnt, line.length + lenEOL);
|
||||
INC(cnt, line.length + (lenEOL + 1));
|
||||
NextLine(line);
|
||||
DEC(n)
|
||||
END;
|
||||
|
Loading…
Reference in New Issue
Block a user