cedit: new version by akron1

git-svn-id: svn://kolibrios.org@9010 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2021-07-06 09:22:02 +00:00
parent fc1e21eb8c
commit 04f5e134b4
7 changed files with 149 additions and 14 deletions

Binary file not shown.

View File

@ -1,3 +1,8 @@
[paths]
build=
run=
debug=
[color_Dark]
text=207,208,209
back=31,34,39

View File

@ -13,6 +13,10 @@
ctrl+Z отменить
ctrl+Y вернуть
ctrl+G перейти на строку...
ctrl+Del удалить строку
ctrl+D дублировать строку
ctrl+Up переместить строку вверх
ctrl+Down переместить строку вниз
ctrl+S сохранить
ctrl+O открыть

View File

@ -28,7 +28,7 @@ IMPORT
RW, Ini, box_lib, Icons;
CONST
header = "CEdit (15-jun-2021)";
header = "CEdit (06-jul-2021)";
ShellFilter = "";
EditFilter = "SH|ASM|TXT|INC|OB07|C|CPP|H|PAS|PP|LUA|INI";
@ -345,6 +345,9 @@ BEGIN
K.DeleteButton(btnNo);
confirm := FALSE
END;
IF ~search THEN
T.wordSel(text)
END;
T.draw(text);
K.ClientSize(width, height);
y := height - (BOTTOM - scrollWidth) + (BOTTOM - scrollWidth - 16) DIV 2;
@ -1286,11 +1289,11 @@ BEGIN
cs := FALSE;
whole := FALSE;
replaced := 0;
Ini.getStr("paths", "build", buildScript);
Ini.getStr("paths", "run", runScript);
Ini.getStr("paths", "debug", debugScript);
draw_window;
repaint;
buildScript := "";
runScript := "";
debugScript := "";
WHILE TRUE DO
CASE K.WaitForEvent() OF
|1:
@ -1405,6 +1408,7 @@ BEGIN
|30: key := ORD("A")
|31: key := -1;
save
|32: key := ORD("D")
|38: key := ORD("L")
|44: T.undo(text);
key := -1

View File

@ -210,6 +210,12 @@ BEGIN
END setChar;
PROCEDURE move* (src, dst: tLine);
BEGIN
SYSTEM.MOVE(src.ptr, dst.ptr, (MIN(src.length, dst.length) + 1)*WCHAR_SIZE)
END move;
PROCEDURE concat* (line: tLine; s: ARRAY OF WCHAR);
VAR
Len: INTEGER;

View File

@ -164,6 +164,35 @@ BEGIN
END _insert;
PROCEDURE _exchange* (list: tList; a, b: tItem);
VAR
a0, b0: tItem;
BEGIN
IF (a # NIL) & (b # NIL) THEN
ASSERT((a.next = b) & (b.prev = a));
a0 := a.prev;
b0 := b.next;
movPtr(b.prev, a0);
movPtr(a.next, b0);
movPtr(b.next, a);
movPtr(a.prev, b);
IF (a0 # NIL) & (b0 # NIL) THEN
movPtr(a0.next, b);
movPtr(b0.prev, a);
ELSIF (a0 # NIL) & (b0 = NIL) THEN
movPtr(a0.next, b);
movPtr(list.last, a)
ELSIF (a0 = NIL) & (b0 # NIL) THEN
movPtr(b0.prev, a);
movPtr(list.first, b)
ELSIF (a0 = NIL) & (b0 = NIL) THEN
movPtr(list.first, b);
movPtr(list.last, a)
END
END
END _exchange;
PROCEDURE append* (list: tList; item: tItem);
BEGIN
item.prev := list.last;

View File

@ -1506,6 +1506,83 @@ BEGIN
END delLine;
PROCEDURE dupLine (text: tText);
VAR
newLine, curLine: tLine;
BEGIN
curLine := text.curLine;
newLine := Lines.create(FALSE);
Lines.modify(newLine);
modify(text);
Lines.insert3(newLine, 0, curLine.length);
List._insert(text, curLine, newLine);
Lines.move(curLine, newLine)
END dupLine;
PROCEDURE exchange (text: tText; first, second: tLine);
BEGIN
List._exchange(text, first, second);
Lines.modify(text.curLine);
modify(text);
UpDown(text, 0)
END exchange;
PROCEDURE upLine (text: tText);
BEGIN
IF text.cursor.Y > 0 THEN
DEC(text.cursor.Y);
exchange(text, text.curLine.prev(tLine), text.curLine)
END
END upLine;
PROCEDURE downLine (text: tText);
BEGIN
IF text.cursor.Y < text.count - 1 THEN
INC(text.cursor.Y);
exchange(text, text.curLine, text.curLine.next(tLine))
END
END downLine;
PROCEDURE isWordChar (c: WCHAR): BOOLEAN;
RETURN U.isLetter(c) OR U.isDigit(c) OR (c = "_")
END isWordChar;
PROCEDURE wordSel* (text: tText);
VAR
n, i, x1, x2: INTEGER;
selBeg, selEnd: tPoint;
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(getChar(curLine, x1 - 1))) OR
((x2 < curLine.length) & isWordChar(getChar(curLine, x2))) THEN
str := ""
END
END;
IF search(text, str, TRUE, TRUE) THEN END
END wordSel;
PROCEDURE key* (text: tText; code: INTEGER; shift: SET);
BEGIN
IF SHIFT IN shift THEN
@ -1550,7 +1627,11 @@ BEGIN
SetPos(text, text.cursor.X - 1, text.cursor.Y)
END
|38:
UpDown(text, -1)
IF CTRL IN shift THEN
upLine(text)
ELSE
UpDown(text, -1)
END
|39:
IF (text.cursor.X = text.curLine.length) & (text.curLine.next # NIL) THEN
SetPos(text, 0, text.cursor.Y + 1)
@ -1558,10 +1639,17 @@ BEGIN
SetPos(text, text.cursor.X + 1, text.cursor.Y)
END
|40:
UpDown(text, 1)
|46: delete(text); ShowCursor; drawCursor := TRUE
IF CTRL IN shift THEN
downLine(text)
ELSE
UpDown(text, 1)
END
|46:
IF CTRL IN shift THEN
delLine(text)
ELSE
delete(text); ShowCursor; drawCursor := TRUE
END
|ORD("C"):
IF CTRL IN shift THEN
IF selected(text) THEN
@ -1592,6 +1680,10 @@ BEGIN
IF CTRL IN shift THEN
changeCase(text, code = ORD("U"))
END
|ORD("D"):
IF CTRL IN shift THEN
dupLine(text)
END
ELSE
END
END key;
@ -1612,11 +1704,6 @@ PROCEDURE selectWord* (text: tText);
VAR
cursorX, x1, x2: INTEGER;
line: tLine;
PROCEDURE isWordChar (c: WCHAR): BOOLEAN;
RETURN U.isLetter(c) OR U.isDigit(c) OR (c = "_")
END isWordChar;
BEGIN
resetSelect(text);
cursorX := text.cursor.X;