diff --git a/programs/develop/cedit/CEDIT b/programs/develop/cedit/CEDIT index 3b4f16b51b..94946da8ee 100644 Binary files a/programs/develop/cedit/CEDIT and b/programs/develop/cedit/CEDIT differ diff --git a/programs/develop/cedit/CEDIT.INI b/programs/develop/cedit/CEDIT.INI index d26ed5c9f1..130b3e0c64 100644 --- a/programs/develop/cedit/CEDIT.INI +++ b/programs/develop/cedit/CEDIT.INI @@ -1,3 +1,8 @@ +[paths] +build= +run= +debug= + [color_Dark] text=207,208,209 back=31,34,39 diff --git a/programs/develop/cedit/README.TXT b/programs/develop/cedit/README.TXT index 1b9dcc717e..666674cc22 100644 --- a/programs/develop/cedit/README.TXT +++ b/programs/develop/cedit/README.TXT @@ -13,6 +13,10 @@ ctrl+Z отменить ctrl+Y вернуть ctrl+G перейти на строку... + ctrl+Del удалить строку + ctrl+D дублировать строку + ctrl+Up переместить строку вверх + ctrl+Down переместить строку вниз ctrl+S сохранить ctrl+O открыть diff --git a/programs/develop/cedit/SRC/CEdit.ob07 b/programs/develop/cedit/SRC/CEdit.ob07 index 6e007d379b..f8d1c06624 100644 --- a/programs/develop/cedit/SRC/CEdit.ob07 +++ b/programs/develop/cedit/SRC/CEdit.ob07 @@ -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 diff --git a/programs/develop/cedit/SRC/Lines.ob07 b/programs/develop/cedit/SRC/Lines.ob07 index e1338e2c1c..27b79acade 100644 --- a/programs/develop/cedit/SRC/Lines.ob07 +++ b/programs/develop/cedit/SRC/Lines.ob07 @@ -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; diff --git a/programs/develop/cedit/SRC/List.ob07 b/programs/develop/cedit/SRC/List.ob07 index c93b8434c7..a4309a44f7 100644 --- a/programs/develop/cedit/SRC/List.ob07 +++ b/programs/develop/cedit/SRC/List.ob07 @@ -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; diff --git a/programs/develop/cedit/SRC/Text.ob07 b/programs/develop/cedit/SRC/Text.ob07 index 321e07040d..f66cae6f4b 100644 --- a/programs/develop/cedit/SRC/Text.ob07 +++ b/programs/develop/cedit/SRC/Text.ob07 @@ -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;