forked from KolibriOS/kolibrios
CEdit: bugfixes, added ctrl+E (select word), added c-- keywords, small GUI changes
git-svn-id: svn://kolibrios.org@9410 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
0954251dbc
commit
efffea0644
Binary file not shown.
@ -54,7 +54,7 @@ KW2 =
|
|||||||
KW3 =
|
KW3 =
|
||||||
|
|
||||||
[lang_C]
|
[lang_C]
|
||||||
KW1 = auto,break,case,char,const,continue,default,do,double,else,enum,extern,float,for,goto,if,int,long,register,return,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile,while
|
KW1 = auto,break,case,char,const,continue,default,do,double,else,enum,extern,float,for,goto,if,int,long,register,return,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile,while,dword,byte,bool,NULL
|
||||||
KW2 = define,error,include,elif,if,line,else,ifdef,pragma,endif,ifndef,undef
|
KW2 = define,error,include,elif,if,line,else,ifdef,pragma,endif,ifndef,undef
|
||||||
KW3 =
|
KW3 =
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
ctrl+D дублировать строку
|
ctrl+D дублировать строку
|
||||||
ctrl+Up переместить строку вверх
|
ctrl+Up переместить строку вверх
|
||||||
ctrl+Down переместить строку вниз
|
ctrl+Down переместить строку вниз
|
||||||
|
ctrl+E выделить слово
|
||||||
|
|
||||||
Tab увеличить отступ для выделенного текста
|
Tab увеличить отступ для выделенного текста
|
||||||
shift+
|
shift+
|
||||||
|
@ -28,7 +28,7 @@ IMPORT
|
|||||||
RW, Ini, EB := EditBox, Icons, Tabs, Timer;
|
RW, Ini, EB := EditBox, Icons, Tabs, Timer;
|
||||||
|
|
||||||
CONST
|
CONST
|
||||||
HEADER = "CEdit (27-nov-2021)";
|
HEADER = "CEdit (08-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";
|
||||||
@ -393,21 +393,42 @@ BEGIN
|
|||||||
END toolbarIcons;
|
END toolbarIcons;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE WriteModified (x, y: INTEGER);
|
PROCEDURE getIdx (text: T.tText): INTEGER;
|
||||||
|
VAR
|
||||||
|
i: INTEGER;
|
||||||
|
BEGIN
|
||||||
|
i := 0;
|
||||||
|
WHILE texts[i] # text DO
|
||||||
|
INC(i)
|
||||||
|
END
|
||||||
|
RETURN i
|
||||||
|
END getIdx;
|
||||||
|
|
||||||
|
|
||||||
|
PROCEDURE MarkModified;
|
||||||
BEGIN
|
BEGIN
|
||||||
modified := text.modified;
|
modified := text.modified;
|
||||||
K.DrawRect(x, TOP + canvas.height + scrollWidth, 8*fontWidth, BOTTOM - scrollWidth + 1, K.winColor);
|
Tabs.modify(tabs, getIdx(text), modified)
|
||||||
IF modified THEN
|
END MarkModified;
|
||||||
K.DrawText866(x, y, K.textColor, "modified")
|
|
||||||
END
|
|
||||||
END WriteModified;
|
PROCEDURE SetCaption (fileName: RW.tFileName);
|
||||||
|
VAR
|
||||||
|
header: RW.tFileName;
|
||||||
|
BEGIN
|
||||||
|
header := HEADER;
|
||||||
|
IF text.fileName # "" THEN
|
||||||
|
U.append8(header, " - ");
|
||||||
|
U.append8(header, text.fileName)
|
||||||
|
END;
|
||||||
|
K.SetCaption(header)
|
||||||
|
END SetCaption;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE DrawState (text: T.tText; width, height: INTEGER);
|
PROCEDURE DrawState (text: T.tText; width, height: INTEGER);
|
||||||
VAR
|
VAR
|
||||||
y: INTEGER;
|
y: INTEGER;
|
||||||
s: ARRAY 24 OF WCHAR;
|
s: ARRAY 24 OF WCHAR;
|
||||||
header: RW.tFileName;
|
|
||||||
BEGIN
|
BEGIN
|
||||||
eol := T.getEol(text);
|
eol := T.getEol(text);
|
||||||
enc := T.getEnc(text);
|
enc := T.getEnc(text);
|
||||||
@ -415,16 +436,11 @@ BEGIN
|
|||||||
U.append(s, RW.eolNames[eol]);
|
U.append(s, RW.eolNames[eol]);
|
||||||
U.append(s, 20X + 20X);
|
U.append(s, 20X + 20X);
|
||||||
U.append(s, E.names[enc]);
|
U.append(s, E.names[enc]);
|
||||||
header := HEADER;
|
SetCaption(text.fileName);
|
||||||
IF text.fileName # "" THEN
|
|
||||||
U.append8(header, " - ");
|
|
||||||
U.append8(header, text.fileName)
|
|
||||||
END;
|
|
||||||
K.SetCaption(header);
|
|
||||||
K.DrawRect(LEFT + 16*fontWidth, TOP + canvas.height + scrollWidth, width - (LEFT + 16*fontWidth), BOTTOM - scrollWidth + 1, K.winColor);
|
K.DrawRect(LEFT + 16*fontWidth, TOP + canvas.height + scrollWidth, width - (LEFT + 16*fontWidth), BOTTOM - scrollWidth + 1, K.winColor);
|
||||||
y := height - (BOTTOM - scrollWidth) + (BOTTOM - scrollWidth - 16) DIV 2;
|
y := height - (BOTTOM - scrollWidth) + (BOTTOM - scrollWidth - 16) DIV 2;
|
||||||
K.DrawText(width - (LENGTH(s) + 10)*fontWidth, y, K.textColor, s);
|
K.DrawText(width - LENGTH(s)*fontWidth, y, K.textColor, s);
|
||||||
WriteModified(width - 8*fontWidth, y)
|
MarkModified
|
||||||
END DrawState;
|
END DrawState;
|
||||||
|
|
||||||
|
|
||||||
@ -468,7 +484,7 @@ BEGIN
|
|||||||
IF (enc # T.getEnc(text)) OR (eol # T.getEol(text)) THEN
|
IF (enc # T.getEnc(text)) OR (eol # T.getEol(text)) THEN
|
||||||
DrawState(text, width, height)
|
DrawState(text, width, height)
|
||||||
ELSIF modified # text.modified THEN
|
ELSIF modified # text.modified THEN
|
||||||
WriteModified(width - 8*fontWidth, y)
|
MarkModified
|
||||||
END;
|
END;
|
||||||
|
|
||||||
T.getScroll(text, scrollX, scrollY);
|
T.getScroll(text, scrollX, scrollY);
|
||||||
@ -675,8 +691,13 @@ END OpenFile;
|
|||||||
|
|
||||||
|
|
||||||
PROCEDURE error (s: RW.tFileName);
|
PROCEDURE error (s: RW.tFileName);
|
||||||
|
VAR
|
||||||
|
temp: RW.tFileName;
|
||||||
BEGIN
|
BEGIN
|
||||||
K.Run("/rd/1/@notify", s)
|
temp := "'CEdit: ";
|
||||||
|
U.append8(temp, s);
|
||||||
|
U.append8(temp, "' -E");
|
||||||
|
K.Run("/rd/1/@notify", temp)
|
||||||
END error;
|
END error;
|
||||||
|
|
||||||
|
|
||||||
@ -684,9 +705,8 @@ PROCEDURE saveError (name: RW.tFileName);
|
|||||||
VAR
|
VAR
|
||||||
s: RW.tFileName;
|
s: RW.tFileName;
|
||||||
BEGIN
|
BEGIN
|
||||||
s := "'cedit: error saving file ";
|
s := "error saving file ";
|
||||||
U.append8(s, name);
|
U.append8(s, name);
|
||||||
U.append8(s, "' -E");
|
|
||||||
error(s)
|
error(s)
|
||||||
END saveError;
|
END saveError;
|
||||||
|
|
||||||
@ -716,18 +736,6 @@ BEGIN
|
|||||||
END saveAs;
|
END saveAs;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE getIdx (text: T.tText): INTEGER;
|
|
||||||
VAR
|
|
||||||
i: INTEGER;
|
|
||||||
BEGIN
|
|
||||||
i := 0;
|
|
||||||
WHILE texts[i] # text DO
|
|
||||||
INC(i)
|
|
||||||
END
|
|
||||||
RETURN i
|
|
||||||
END getIdx;
|
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE Switch (txt: T.tText);
|
PROCEDURE Switch (txt: T.tText);
|
||||||
BEGIN
|
BEGIN
|
||||||
Tabs.switch(tabs, curText);
|
Tabs.switch(tabs, curText);
|
||||||
@ -748,7 +756,8 @@ BEGIN
|
|||||||
curText := getIdx(text);
|
curText := getIdx(text);
|
||||||
Switch(text);
|
Switch(text);
|
||||||
saveAs(text)
|
saveAs(text)
|
||||||
END
|
END;
|
||||||
|
Tabs.modify(tabs, getIdx(text), text.modified)
|
||||||
END
|
END
|
||||||
END save;
|
END save;
|
||||||
|
|
||||||
@ -756,14 +765,18 @@ END save;
|
|||||||
PROCEDURE saveAll;
|
PROCEDURE saveAll;
|
||||||
VAR
|
VAR
|
||||||
i: INTEGER;
|
i: INTEGER;
|
||||||
|
txt: T.tText;
|
||||||
BEGIN
|
BEGIN
|
||||||
i := textsCount - 1;
|
i := textsCount - 1;
|
||||||
WHILE i >= 0 DO
|
WHILE i >= 0 DO
|
||||||
IF texts[i].modified THEN
|
txt := texts[i];
|
||||||
save(texts[i])
|
IF txt.modified THEN
|
||||||
|
T.switch(txt);
|
||||||
|
save(txt)
|
||||||
END;
|
END;
|
||||||
DEC(i)
|
DEC(i)
|
||||||
END;
|
END;
|
||||||
|
T.switch(text)
|
||||||
END saveAll;
|
END saveAll;
|
||||||
|
|
||||||
|
|
||||||
@ -845,7 +858,7 @@ BEGIN
|
|||||||
T.SetPos(nov, 0, 0);
|
T.SetPos(nov, 0, 0);
|
||||||
insert(textsCount, nov)
|
insert(textsCount, nov)
|
||||||
ELSE
|
ELSE
|
||||||
error("'cedit: too many files' -E")
|
error("too many files")
|
||||||
END
|
END
|
||||||
END NewFile;
|
END NewFile;
|
||||||
|
|
||||||
@ -901,7 +914,7 @@ BEGIN
|
|||||||
IF n = -1 THEN
|
IF n = -1 THEN
|
||||||
nov := T.open(fileName, err);
|
nov := T.open(fileName, err);
|
||||||
IF nov = NIL THEN
|
IF nov = NIL THEN
|
||||||
error("'cedit: error opening file' -E")
|
error("error opening file")
|
||||||
ELSE
|
ELSE
|
||||||
insert(textsCount, nov);
|
insert(textsCount, nov);
|
||||||
T.SetPos(nov, 0, 0)
|
T.SetPos(nov, 0, 0)
|
||||||
@ -911,7 +924,7 @@ BEGIN
|
|||||||
END
|
END
|
||||||
END
|
END
|
||||||
ELSE
|
ELSE
|
||||||
error("'cedit: too many files' -E")
|
error("too many files")
|
||||||
END
|
END
|
||||||
END open;
|
END open;
|
||||||
|
|
||||||
@ -1050,9 +1063,9 @@ END Script;
|
|||||||
PROCEDURE ShowSearchPanel (goto: BOOLEAN);
|
PROCEDURE ShowSearchPanel (goto: BOOLEAN);
|
||||||
VAR
|
VAR
|
||||||
i: INTEGER;
|
i: INTEGER;
|
||||||
flag: BOOLEAN;
|
(*flag: BOOLEAN;*)
|
||||||
BEGIN
|
BEGIN
|
||||||
flag := FALSE;
|
(*flag := FALSE;*)
|
||||||
IF T.selected(text) & ~goto THEN
|
IF T.selected(text) & ~goto THEN
|
||||||
T.getSelectedText(text, new_searchText);
|
T.getSelectedText(text, new_searchText);
|
||||||
IF new_searchText # "" THEN
|
IF new_searchText # "" THEN
|
||||||
@ -1064,7 +1077,7 @@ BEGIN
|
|||||||
searchText := new_searchText;
|
searchText := new_searchText;
|
||||||
EB.setValue(FindEdit, searchText);
|
EB.setValue(FindEdit, searchText);
|
||||||
notFound := ~T.search(text, searchText, cs, whole);
|
notFound := ~T.search(text, searchText, cs, whole);
|
||||||
flag := TRUE
|
(*flag := TRUE*)
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
END;
|
END;
|
||||||
@ -1074,12 +1087,10 @@ BEGIN
|
|||||||
search := FALSE;
|
search := FALSE;
|
||||||
Search
|
Search
|
||||||
END;
|
END;
|
||||||
IF flag THEN
|
IF goto THEN
|
||||||
SetFocus(FindEdit, FALSE)
|
SetFocus(GotoEdit, TRUE)
|
||||||
ELSIF goto THEN
|
|
||||||
SetFocus(GotoEdit, TRUE)
|
|
||||||
ELSE
|
ELSE
|
||||||
SetFocus(FindEdit, TRUE)
|
SetFocus(FindEdit, (*~flag*)TRUE)
|
||||||
END
|
END
|
||||||
END ShowSearchPanel;
|
END ShowSearchPanel;
|
||||||
|
|
||||||
@ -1737,6 +1748,9 @@ BEGIN
|
|||||||
ELSIF (keyCode = 34) & ctrl THEN (* ctrl+G *)
|
ELSIF (keyCode = 34) & ctrl THEN (* ctrl+G *)
|
||||||
key := -1;
|
key := -1;
|
||||||
ShowSearchPanel(TRUE)
|
ShowSearchPanel(TRUE)
|
||||||
|
ELSIF (keyCode = 18) & ctrl THEN (* ctrl+E *)
|
||||||
|
key := -1;
|
||||||
|
T.selectWord(text)
|
||||||
ELSE
|
ELSE
|
||||||
IF EditBox_Focus(FindEdit) THEN
|
IF EditBox_Focus(FindEdit) THEN
|
||||||
IF keyCode = 15 THEN (* Tab *)
|
IF keyCode = 15 THEN (* Tab *)
|
||||||
@ -2040,6 +2054,7 @@ BEGIN
|
|||||||
END;
|
END;
|
||||||
K.SetEventsMask({0, 1, 2, 5, 6, 31})
|
K.SetEventsMask({0, 1, 2, 5, 6, 31})
|
||||||
ELSE
|
ELSE
|
||||||
|
SetCaption(text.fileName);
|
||||||
K.SetEventsMask({0, 30, 31})
|
K.SetEventsMask({0, 30, 31})
|
||||||
END;
|
END;
|
||||||
draw_window
|
draw_window
|
||||||
@ -2138,7 +2153,7 @@ BEGIN
|
|||||||
ELSE
|
ELSE
|
||||||
text := T.open(fileName, err);
|
text := T.open(fileName, err);
|
||||||
IF text = NIL THEN
|
IF text = NIL THEN
|
||||||
error("'cedit: error opening file' -E");
|
error("error opening file");
|
||||||
K.Exit
|
K.Exit
|
||||||
ELSE
|
ELSE
|
||||||
U.getPath(fileName, filePath)
|
U.getPath(fileName, filePath)
|
||||||
|
@ -32,7 +32,8 @@ TYPE
|
|||||||
|
|
||||||
tItem = POINTER TO RECORD (List.tItem)
|
tItem = POINTER TO RECORD (List.tItem)
|
||||||
|
|
||||||
val: RW.tFileName
|
val: RW.tFileName;
|
||||||
|
modified: BOOLEAN
|
||||||
|
|
||||||
END;
|
END;
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ TYPE
|
|||||||
END;
|
END;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE drawTab (t: tTabs; id, x, y, width, height: INTEGER; s: ARRAY OF CHAR);
|
PROCEDURE drawTab (t: tTabs; id, x, y, width, height: INTEGER; s: ARRAY OF CHAR; modified: BOOLEAN);
|
||||||
VAR
|
VAR
|
||||||
x2, y2, color: INTEGER;
|
x2, y2, color: INTEGER;
|
||||||
BEGIN
|
BEGIN
|
||||||
@ -68,13 +69,17 @@ BEGIN
|
|||||||
K.DrawLine(x2 - 1, y2, x, y2, K.borderColor);
|
K.DrawLine(x2 - 1, y2, x, y2, K.borderColor);
|
||||||
END;
|
END;
|
||||||
K.DrawLine(x, y2, x, y, K.borderColor);
|
K.DrawLine(x, y2, x, y, K.borderColor);
|
||||||
K.DrawText866bk(x + K.fontWidth, y + (height - K.fontHeight) DIV 2, K.textColor, color, s);
|
|
||||||
|
K.DrawText866bk(x + K.fontWidth + K.fontWidth DIV 2, y + (height - K.fontHeight) DIV 2, K.textColor, color, s);
|
||||||
|
IF modified THEN
|
||||||
|
K.DrawText866bk(x + K.fontWidth DIV 2, y + (height - K.fontHeight) DIV 2, K.textColor, color, "*")
|
||||||
|
END;
|
||||||
K.CreateButton(id + ORD({30}) + btnID, x + 1, y - 1, width - 1, height - 1, color, "");
|
K.CreateButton(id + ORD({30}) + btnID, x + 1, y - 1, width - 1, height - 1, color, "");
|
||||||
END drawTab;
|
END drawTab;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE tabWidth (tab: tItem): INTEGER;
|
PROCEDURE tabWidth (tab: tItem): INTEGER;
|
||||||
RETURN (LENGTH(tab.val) + 2)*K.fontWidth
|
RETURN (LENGTH(tab.val) + 3)*K.fontWidth
|
||||||
END tabWidth;
|
END tabWidth;
|
||||||
|
|
||||||
|
|
||||||
@ -135,7 +140,7 @@ BEGIN
|
|||||||
WHILE (item # NIL) & (x <= xmax) DO
|
WHILE (item # NIL) & (x <= xmax) DO
|
||||||
width := tabWidth(item(tItem));
|
width := tabWidth(item(tItem));
|
||||||
IF x + width - 1 <= xmax THEN
|
IF x + width - 1 <= xmax THEN
|
||||||
drawTab(t, n, x + 1, y, width, t.height, item(tItem).val)
|
drawTab(t, n, x + 1, y, width, t.height, item(tItem).val, item(tItem).modified)
|
||||||
END;
|
END;
|
||||||
INC(n);
|
INC(n);
|
||||||
INC(x, width);
|
INC(x, width);
|
||||||
@ -150,10 +155,23 @@ VAR
|
|||||||
BEGIN
|
BEGIN
|
||||||
NEW(item);
|
NEW(item);
|
||||||
item.val := s;
|
item.val := s;
|
||||||
|
item.modified := FALSE;
|
||||||
List.append(t.strings, item);
|
List.append(t.strings, item);
|
||||||
END add;
|
END add;
|
||||||
|
|
||||||
|
|
||||||
|
PROCEDURE modify* (t: tTabs; n: INTEGER; val: BOOLEAN);
|
||||||
|
VAR
|
||||||
|
item: List.tItem;
|
||||||
|
BEGIN
|
||||||
|
item := List.getItem(t.strings, n);
|
||||||
|
IF item(tItem).modified # val THEN
|
||||||
|
item(tItem).modified := val;
|
||||||
|
draw(t)
|
||||||
|
END
|
||||||
|
END modify;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE rename* (t: tTabs; n: INTEGER; s: ARRAY OF CHAR);
|
PROCEDURE rename* (t: tTabs; n: INTEGER; s: ARRAY OF CHAR);
|
||||||
VAR
|
VAR
|
||||||
item: List.tItem;
|
item: List.tItem;
|
||||||
|
@ -1834,7 +1834,6 @@ END wordSel;
|
|||||||
PROCEDURE getWordPos (line: tLine; pos: INTEGER): INTEGER;
|
PROCEDURE getWordPos (line: tLine; pos: INTEGER): INTEGER;
|
||||||
VAR
|
VAR
|
||||||
c: WCHAR;
|
c: WCHAR;
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
c := getChar(line, pos);
|
c := getChar(line, pos);
|
||||||
IF isWordChar(c) THEN
|
IF isWordChar(c) THEN
|
||||||
|
Loading…
Reference in New Issue
Block a user