CEDIT: new version by akron1

git-svn-id: svn://kolibrios.org@9073 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2021-07-21 16:13:29 +00:00
parent f195324958
commit f73a566b8b
11 changed files with 696 additions and 520 deletions

Binary file not shown.

View File

@ -7,7 +7,7 @@
ctrl+L преобразовать буквы A..Z слева от курсора в a..z
ctrl+U преобразовать буквы a..z слева от курсора в A..Z
ctrl+F показать панель поиска
Esc скрыть панель поиска
Esc закрыть панель поиска
F3 найти следующий
shift+F3 найти предыдущий
ctrl+Z отменить

File diff suppressed because it is too large Load Diff

View File

@ -27,7 +27,7 @@ TYPE
END;
tBoolItem = POINTER TO RECORD (List.tItem)
adr: INTEGER; val: BOOLEAN
adr: INTEGER; val: BOOLEAN; save: BOOLEAN
END;
(*
tUntypedPtr = POINTER TO RECORD (List.tItem)
@ -39,7 +39,7 @@ TYPE
END;
*)
tGuard* = POINTER TO RECORD (List.tItem)
saved*: BOOLEAN
END;
tLog* = POINTER TO RECORD
@ -123,6 +123,21 @@ BEGIN
END clear;
PROCEDURE save* (guard: tGuard);
VAR
item: List.tItem;
BEGIN
item := CL.Log.first;
WHILE item # NIL DO
IF item IS tGuard THEN
item(tGuard).saved := FALSE
END;
item := item.next
END;
guard.saved := TRUE
END save;
PROCEDURE changeWord (adrV, adrX: INTEGER);
VAR
item: tIntItem;
@ -144,6 +159,7 @@ BEGIN
NEW(item);
item.adr := SYSTEM.ADR(v);
item.val := x;
item.save := FALSE;
IF ~CL.isLast THEN
clear(CL.guard)
END;
@ -151,6 +167,81 @@ BEGIN
END changeBool;
PROCEDURE delSaved*;
VAR
boolItem: tBoolItem;
cur: List.tItem;
del: BOOLEAN;
BEGIN
cur := CL.guard.next;
WHILE cur # NIL DO
IF cur IS tBoolItem THEN
boolItem := cur(tBoolItem);
del := boolItem.save
ELSE
del := FALSE
END;
cur := cur.next;
IF del THEN
List.delete(CL.Log, boolItem);
DISPOSE(boolItem)
END
END
END delSaved;
PROCEDURE delCurSaved*;
VAR
boolItem: tBoolItem;
cur: List.tItem;
del: BOOLEAN;
BEGIN
cur := CL.guard.prev;
WHILE (cur # NIL) & ~(cur IS tGuard) DO
IF cur IS tBoolItem THEN
boolItem := cur(tBoolItem);
del := boolItem.save
ELSE
del := FALSE
END;
cur := cur.prev;
IF del THEN
SYSTEM.PUT(boolItem.adr, ~boolItem.val);
List.delete(CL.Log, boolItem);
DISPOSE(boolItem)
END
END
END delCurSaved;
PROCEDURE changeBool2 (VAR v: BOOLEAN; x: BOOLEAN);
VAR
item, boolItem: tBoolItem;
cur: List.tItem;
del: BOOLEAN;
BEGIN
NEW(item);
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;
PROCEDURE changeInt (VAR v: INTEGER; x: INTEGER);
BEGIN
changeWord(SYSTEM.ADR(v), SYSTEM.ADR(x))
@ -205,5 +296,5 @@ END create;
BEGIN
List.init(changeInt, changePtr);
Lines.init(changeInt, changePtr, changeBool(*, typedPtr, untypedPtr*))
Lines.init(changeInt, changePtr, changeBool, changeBool2(*, typedPtr, untypedPtr*))
END ChangeLog.

View File

@ -118,11 +118,8 @@ END appends;
PROCEDURE eol* (buffer: tBuffer);
VAR
s: ARRAY 2 OF WCHAR;
BEGIN
s[0] := 0DX; s[1] := 0AX;
appends(buffer, s, 0, 1)
appends(buffer, 0DX + 0AX, 0, 1)
END eol;

View File

@ -29,6 +29,7 @@ TYPE
VAR
cpW1251*, cp866*: CP;
names*: ARRAY 4, 16 OF WCHAR;
UNI*: ARRAY 65536, 2 OF INTEGER;
@ -121,6 +122,10 @@ END setUNI;
BEGIN
names[CP866] := "CP866";
names[W1251] := "Windows-1251";
names[UTF8] := "UTF-8";
names[UTF8BOM] := "UTF-8-BOM";
InitW1251(cpW1251);
InitCP866(cp866);
setUNI

View File

@ -265,6 +265,36 @@ BEGIN
END Create;
PROCEDURE Copy* (From, To: ARRAY OF CHAR): BOOLEAN;
VAR
buf, size: INTEGER;
outFile: FS;
res: BOOLEAN;
BEGIN
res := FALSE;
size := FileSize(From);
IF size > 0 THEN
buf := Load(From, size)
ELSE
buf := -1;
size := 0
END;
IF buf # 0 THEN
outFile := Create(To);
IF outFile # NIL THEN
IF size # 0 THEN
res := Write(outFile, buf, size) = size
END;
Close(outFile)
END;
IF size # 0 THEN
buf := KOSAPI.free(buf)
END
END
RETURN res
END Copy;
PROCEDURE DirExists* (FName: ARRAY OF CHAR): BOOLEAN;
VAR
fd: rFD;

View File

@ -27,7 +27,7 @@ CONST
langNone* = 0; langC* = 1; langOberon* = 2; langPascal* = 3;
langFasm* = 4; langLua* = 5; langIni* = 6;
csLang = {langNone, langC, langOberon, langLua, langIni};
csLang = {langC, langOberon, langLua, langIni};
TYPE

View File

@ -46,7 +46,7 @@ TYPE
VAR
_movInt: PmovInt;
_movBool: PmovBool;
_movBool, _movBool2: PmovBool;
_movPtr: PmovPtr;
(* _typedPtr: PTypedPtr;
_untypedPtr: PUntypedPtr;*)
@ -66,6 +66,12 @@ BEGIN
END movBool;
PROCEDURE movBool2 (VAR v: BOOLEAN; x: BOOLEAN);
BEGIN
_movBool2(v, x)
END movBool2;
PROCEDURE movPtr (VAR v: List.tItem; x: List.tItem);
BEGIN
_movPtr(v, x)
@ -174,8 +180,8 @@ END modify;
PROCEDURE save* (line: tLine);
BEGIN
IF ~line.temp THEN
movBool(line.saved, TRUE);
movBool(line.modified, FALSE)
movBool2(line.saved, TRUE);
movBool2(line.modified, FALSE)
END;
line.modified := FALSE;
line.saved := TRUE
@ -416,11 +422,12 @@ BEGIN
END chCase;
PROCEDURE init* (movInt: PmovInt; movPtr: PmovPtr; movBool: PmovBool(*; typedPtr: PTypedPtr; untypedPtr: PUntypedPtr*));
PROCEDURE init* (movInt: PmovInt; movPtr: PmovPtr; movBool, movBool2: PmovBool(*; typedPtr: PTypedPtr; untypedPtr: PUntypedPtr*));
BEGIN
_movInt := movInt;
_movPtr := movPtr;
_movBool := movBool;
_movBool2 := movBool2;
(* _typedPtr := typedPtr;
_untypedPtr := untypedPtr;*)
END init;

View File

@ -71,7 +71,7 @@ BEGIN
END;
K.DrawLine(x, y2, x, y, K.borderColor);
K.DrawText866bk(x + K.fontWidth, y + (height - K.fontHeight) DIV 2, K.textColor, color, s);
K.CreateButton(id + ORD({30}) + btnID, x, y - 1, width, height - 1, color, "");
K.CreateButton(id + ORD({30}) + btnID, x + 1, y - 1, width - 1, height - 1, color, "");
END drawTab;

View File

@ -27,7 +27,7 @@ IMPORT
E := Encodings,
CB := Clipboard,
K := KolibriOS,
ChangeLog,
ChangeLog, File,
Lang := Languages;
@ -37,8 +37,6 @@ CONST
TAB = RW.TAB_SIZE;
lenEOL = CB.lenEOL;
SHIFT* = 0; CTRL* = 1;
mark_width = 2;
pad_left = mark_width + 3;
pad_top = 0;
@ -1187,20 +1185,19 @@ END scroll;
PROCEDURE save* (text: tText; name: RW.tFileName; enc, nl: INTEGER): BOOLEAN;
CONST
tempFile = "/tmp0/1/cedit~.tmp";
VAR
line: tLine;
file: RW.tOutput;
res: BOOLEAN;
Len: INTEGER;
(* item: List.tItem;*)
BEGIN
ChangeLog.setGuard(text.edition);
res := TRUE;
file := RW.create(name, enc, nl);
file := RW.create(tempFile, enc, nl);
IF file # NIL THEN
(* IF ChangeLog.Log.last IS ChangeLog.tGuard THEN
item := List.pop(ChangeLog.Log);
DISPOSE(item)
END;*)
ChangeLog.delSaved;
line := text.first(tLine);
WHILE (line # NIL) & res DO
Len := Lines.trimLength(line);
@ -1219,14 +1216,21 @@ BEGIN
END;
IF ~RW.close(file) THEN
res := FALSE
END;
IF res THEN
text.modified := FALSE
END
ELSE
res := FALSE
END;
text.guard := TRUE
IF res THEN
res := File.Copy(tempFile, name);
IF res THEN
text.modified := FALSE;
ChangeLog.save(text.edition);
IF File.Delete(tempFile) THEN END
END
END;
IF ~res THEN
ChangeLog.delCurSaved
END
RETURN res
END save;
@ -1262,8 +1266,7 @@ BEGIN
IF item # NIL THEN
guard := item(tGuard);
text.edition := guard;
text.modified := TRUE
text.edition := guard
END;
item := ChangeLog.CL.Log.first;
@ -1272,7 +1275,8 @@ BEGIN
item := item.next
END;
redoGuard(text, guard);
ChangeLog.setGuard(guard)
ChangeLog.setGuard(guard);
text.modified := ~guard.saved
END undo;
@ -1291,7 +1295,8 @@ BEGIN
guard := item(tGuard);
redoGuard(text, guard)
END;
ChangeLog.setGuard(guard)
ChangeLog.setGuard(guard);
text.modified := ~guard.saved
END redo;
@ -1432,19 +1437,42 @@ PROCEDURE gotoLabel* (text: tText; frw: BOOLEAN);
VAR
line: tLine;
n: INTEGER;
PROCEDURE search (VAR line: tLine; VAR n: INTEGER; frw: BOOLEAN);
BEGIN
IF frw THEN
WHILE (line # NIL) & ~line.label DO
NextLine(line);
INC(n)
END
ELSE
WHILE (line # NIL) & ~line.label DO
PrevLine(line);
DEC(n)
END
END
END search;
BEGIN
n := text.cursor.Y;
line := text.curLine;
IF frw THEN
REPEAT
line := line.next(tLine);
INC(n)
UNTIL (line = NIL) OR line.label
NextLine(line);
INC(n)
ELSE
REPEAT
line := line.prev(tLine);
DEC(n)
UNTIL (line = NIL) OR line.label
PrevLine(line);
DEC(n)
END;
search(line, n, frw);
IF line = NIL THEN
IF frw THEN
n := 0;
line := text.first(tLine)
ELSE
n := text.count - 1;
line := text.last(tLine)
END;
search(line, n, frw)
END;
IF line # NIL THEN
IF goto(text, n + 1) THEN END
@ -1615,9 +1643,9 @@ BEGIN
END wordSel;
PROCEDURE key* (text: tText; code: INTEGER; shift: SET);
PROCEDURE key* (text: tText; code: INTEGER; shift, ctrl: BOOLEAN);
BEGIN
IF SHIFT IN shift THEN
IF shift THEN
setSelect(text)
ELSE
IF (33 <= code) & (code <= 40) THEN
@ -1627,27 +1655,27 @@ BEGIN
CASE code OF
|33:
IF CTRL IN shift THEN
IF ctrl THEN
UpDown(text, text.scroll.Y - text.cursor.Y)
ELSE
text.scroll.Y := MAX(text.scroll.Y - textsize.Y, 0);
UpDown(text, -textsize.Y)
END
|34:
IF CTRL IN shift THEN
IF ctrl THEN
UpDown(text, MIN(text.scroll.Y + textsize.Y - 1, text.count - 1) - text.cursor.Y)
ELSE
text.scroll.Y := MIN(text.scroll.Y + textsize.Y, text.count - 1);
UpDown(text, textsize.Y)
END
|35:
IF CTRL IN shift THEN
IF ctrl THEN
SetPos(text, text.last(tLine).length, text.count - 1)
ELSE
SetPos(text, text.curLine.length, text.cursor.Y)
END
|36:
IF CTRL IN shift THEN
IF ctrl THEN
SetPos(text, 0, 0)
ELSE
SetPos(text, 0, text.cursor.Y)
@ -1659,7 +1687,7 @@ BEGIN
SetPos(text, text.cursor.X - 1, text.cursor.Y)
END
|38:
IF CTRL IN shift THEN
IF ctrl THEN
upLine(text)
ELSE
UpDown(text, -1)
@ -1671,49 +1699,49 @@ BEGIN
SetPos(text, text.cursor.X + 1, text.cursor.Y)
END
|40:
IF CTRL IN shift THEN
IF ctrl THEN
downLine(text)
ELSE
UpDown(text, 1)
END
|46:
IF CTRL IN shift THEN
IF ctrl THEN
delLine(text)
ELSE
delete(text); ShowCursor; drawCursor := TRUE
END
|ORD("C"):
IF CTRL IN shift THEN
IF ctrl THEN
IF selected(text) THEN
copy(text)
END
END
|ORD("X"):
IF CTRL IN shift THEN
IF ctrl THEN
IF selected(text) THEN
copy(text);
delSelect(text)
END
END
|ORD("V"):
IF CTRL IN shift THEN
IF ctrl THEN
IF CB.available() THEN
paste(text)
END
END
|ORD("A"):
IF CTRL IN shift THEN
IF ctrl THEN
text.select2.X := 0;
text.select2.Y := 0;
text.select := text.select2;
SetPos(text, text.last(tLine).length, text.count - 1)
END
|ORD("L"), ORD("U"):
IF CTRL IN shift THEN
IF ctrl THEN
changeCase(text, code = ORD("U"))
END
|ORD("D"):
IF CTRL IN shift THEN
IF ctrl THEN
dupLine(text)
END
ELSE
@ -1842,8 +1870,9 @@ BEGIN
IF text.guard THEN
NEW(guard);
List.append(ChangeLog.CL.Log, guard);
guard.saved := ChangeLog.isFirstGuard(guard);
text.edition := guard;
text.guard := FALSE;
text.guard := FALSE
ELSE
guard := text.edition
END;