CEdit: bugfixes, renaming system colors, update box_lib wrapper

git-svn-id: svn://kolibrios.org@9628 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Anton Krotov 2022-01-12 21:15:22 +00:00
parent 2ed999004a
commit 082ddccdfc
12 changed files with 238 additions and 184 deletions

Binary file not shown.

View File

@ -0,0 +1,68 @@
(*
Copyright 2022 Anton Krotov
This file is part of CEdit.
CEdit is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
CEdit is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with CEdit. If not, see <http://www.gnu.org/licenses/>.
*)
MODULE Args;
IMPORT SYSTEM, KOSAPI;
VAR
argc*: INTEGER;
PROCEDURE ptr2str (ptr: INTEGER; VAR s: ARRAY OF CHAR);
VAR
i, n: INTEGER;
BEGIN
i := -1;
n := LEN(s) - 1;
REPEAT
INC(i);
SYSTEM.GET(ptr, s[i]);
INC(ptr)
UNTIL (i = n) OR (s[i] = 0X);
s[i] := 0X
END ptr2str;
PROCEDURE GetArg* (n: INTEGER; VAR s: ARRAY OF CHAR);
BEGIN
IF n = 0 THEN
ptr2str(KOSAPI.GetName(), s)
ELSIF (n = 1) & (argc = 2) THEN
ptr2str(KOSAPI.GetCommandLine(), s)
ELSE
s[0] := 0X
END
END GetArg;
PROCEDURE main;
VAR
c: CHAR;
BEGIN
SYSTEM.GET(KOSAPI.GetCommandLine(), c);
argc := ORD(c # 0X) + 1
END main;
BEGIN
main
END Args.

View File

@ -20,7 +20,7 @@
MODULE CEdit; MODULE CEdit;
IMPORT IMPORT
OpenDlg, K := KolibriOS, OpenDlg, K := KolibriOS, Args,
U := Utils, Lines, Menu, List, U := Utils, Lines, Menu, List,
G := Graph, T := Text, E := Encodings, G := Graph, T := Text, E := Encodings,
CB := Clipboard, Languages, CB := Clipboard, Languages,
@ -28,7 +28,7 @@ IMPORT
RW, Ini, EB := EditBox, Tabs, Toolbar, SB := StatusBar; RW, Ini, EB := EditBox, Tabs, Toolbar, SB := StatusBar;
CONST CONST
HEADER = "CEdit (08-jan-2022)"; HEADER = "CEdit (13-jan-2022)";
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";
@ -181,6 +181,7 @@ VAR
textsCount, curText: INTEGER; textsCount, curText: INTEGER;
winWidth, winHeight: INTEGER; winWidth, winHeight: INTEGER;
SkinHeight: INTEGER;
AppPath, runScript, buildScript, debugScript: RW.tFileName; AppPath, runScript, buildScript, debugScript: RW.tFileName;
OD: OpenDlg.Dialog; OD: OpenDlg.Dialog;
confirm, notFound, menuFindClicked, search, searchOpened: BOOLEAN; confirm, notFound, menuFindClicked, search, searchOpened: BOOLEAN;
@ -282,9 +283,9 @@ BEGIN
right := left + width - 1; right := left + width - 1;
x := minWidth DIV 2 + left; x := minWidth DIV 2 + left;
y := (height - fontHeight) DIV 2 + top; y := (height - fontHeight) DIV 2 + top;
K.DrawRect(left, top, width, height, K.winColor); K.DrawRect(left, top, width, height, K.colors.work);
Rect(left, top, right, bottom, K.borderColor); Rect(left, top, right, bottom, K.colors.line);
K.DrawText(x, y, K.textColor, s); K.DrawText(x, y, K.colors.work_text, s);
END Message; END Message;
@ -404,7 +405,7 @@ BEGIN
CheckBox.paint(WH); CheckBox.paint(WH);
END; END;
G.SetColor(canvas, K.borderColor); G.SetColor(canvas, K.colors.line);
G.VLine(canvas, 0, 0, canvas.height - 1); G.VLine(canvas, 0, 0, canvas.height - 1);
G.DrawCanvas(canvas, LEFT, TOP); G.DrawCanvas(canvas, LEFT, TOP);
NotFound; NotFound;
@ -453,7 +454,7 @@ BEGIN
DEC(top, Tabs.tabHeight); DEC(top, Tabs.tabHeight);
right := left + EditBox_Width + SEARCH_PADDING*2; right := left + EditBox_Width + SEARCH_PADDING*2;
bottom := top + 395 + btnHeight + SEARCH_PADDING; bottom := top + 395 + btnHeight + SEARCH_PADDING;
Rect(left, top, right, bottom, K.borderColor); Rect(left, top, right, bottom, K.colors.line);
K.CreateButton(btnCloseSearch, right - 20, top, 20, 20, 0EF999FH, ""); K.CreateButton(btnCloseSearch, right - 20, top, 20, 20, 0EF999FH, "");
K.DrawLine(right - 14, top + 5, right - 5, top + 14, 0FFFFFFH); K.DrawLine(right - 14, top + 5, right - 5, top + 14, 0FFFFFFH);
@ -463,15 +464,15 @@ BEGIN
K.DrawLine(right - 15, top + 15, right - 5, top + 5, 0FFFFFFH); K.DrawLine(right - 15, top + 15, right - 5, top + 5, 0FFFFFFH);
K.DrawLine(right - 14, top + 15, right - 5, top + 6, 0FFFFFFH); K.DrawLine(right - 14, top + 15, right - 5, top + 6, 0FFFFFFH);
K.CreateButton(btnHideSearch, right - 40, top, 20, 20, K.btnColor, ""); K.CreateButton(btnHideSearch, right - 40, top, 20, 20, K.colors.button, "");
K.DrawLine(right - 34, top + 14, right - 26, top + 14, K.btnTextColor); K.DrawLine(right - 34, top + 14, right - 26, top + 14, K.colors.button_text);
K.DrawLine(right - 34, top + 15, right - 26, top + 15, K.btnTextColor); K.DrawLine(right - 34, top + 15, right - 26, top + 15, K.colors.button_text);
INC(top, 15); INC(top, 15);
INC(left, SEARCH_PADDING); INC(left, SEARCH_PADDING);
K.DrawText866(left, top, K.textColor, "find"); K.DrawText866(left, top, K.colors.work_text, "find");
K.DrawText866(left, top + 55, K.textColor, "replace with"); K.DrawText866(left, top + 55, K.colors.work_text, "replace with");
K.DrawText866(left, top + 330, K.textColor, "go to line"); K.DrawText866(left, top + 330, K.colors.work_text, "go to line");
BKW.top := top + 110; BKW.top := top + 110;
BKW.left := left; BKW.left := left;
CS.top := top + 140; CS.top := top + 140;
@ -488,10 +489,10 @@ BEGIN
EB.paint(ReplaceEdit); EB.paint(ReplaceEdit);
EB.paint(GotoEdit); EB.paint(GotoEdit);
y := top + 200; y := top + 200;
K.CreateButton(btnFindNext, left, y, btnWidth, btnHeight, K.btnColor, "next"); INC(y, btnHeight + 10); K.CreateButton(btnFindNext, left, y, btnWidth, btnHeight, K.colors.button, "next"); INC(y, btnHeight + 10);
K.CreateButton(btnReplace, left, y, btnWidth, btnHeight, K.btnColor, "replace"); INC(y, btnHeight + 10); K.CreateButton(btnReplace, left, y, btnWidth, btnHeight, K.colors.button, "replace"); INC(y, btnHeight + 10);
K.CreateButton(btnReplaceAll, left, y, btnWidth + 5*fontWidth - 2, btnHeight, K.btnColor, "replace all"); K.CreateButton(btnReplaceAll, left, y, btnWidth + 5*fontWidth - 2, btnHeight, K.colors.button, "replace all");
K.CreateButton(btnGoto, left, top + 380, btnWidth, btnHeight, K.btnColor, "go"); K.CreateButton(btnGoto, left, top + 380, btnWidth, btnHeight, K.colors.button, "go");
END SearchPanel; END SearchPanel;
@ -500,7 +501,7 @@ VAR
width, height: INTEGER; width, height: INTEGER;
BEGIN BEGIN
K.BeginDraw; K.BeginDraw;
K.CreateWindow(30 + K.GetTickCount() MOD 128, 30 + K.GetTickCount() MOD 128, winWidth, winHeight, K.winColor, 73H, 0, 0, ""); K.CreateWindow(30 + K.GetTickCount() MOD 128, 30 + K.GetTickCount() MOD 128, winWidth, winHeight, K.colors.work, 73H, 0, 0, "");
IF (text # NIL) & ~K.RolledUp() THEN IF (text # NIL) & ~K.RolledUp() THEN
IF confirm THEN IF confirm THEN
resetTimer resetTimer
@ -508,10 +509,10 @@ BEGIN
confirm := FALSE; confirm := FALSE;
K.ClientSize(width, height); K.ClientSize(width, height);
K.DrawRect(0, 0, width, TOP - 1, K.winColor); K.DrawRect(0, 0, width, TOP - 1, K.colors.work);
K.DrawRect(0, 0, LEFT, height, K.winColor); K.DrawRect(0, 0, LEFT, height, K.colors.work);
K.DrawRect(width - RIGHT_PADDING, 0, RIGHT_PADDING, height, K.winColor); K.DrawRect(width - RIGHT_PADDING, 0, RIGHT_PADDING, height, K.colors.work);
K.DrawRect(LEFT + canvas.width + 1, TOP + canvas.height + 1, scrollWidth - 1, scrollWidth - 1, K.winColor); K.DrawRect(LEFT + canvas.width + 1, TOP + canvas.height + 1, scrollWidth - 1, scrollWidth - 1, K.colors.work);
Menu.DrawMain(mainMenu); Menu.DrawMain(mainMenu);
Toolbar.draw(toolbar); Toolbar.draw(toolbar);
@ -688,11 +689,11 @@ BEGIN
top := (canvas.height - height) DIV 2 + TOP; top := (canvas.height - height) DIV 2 + TOP;
right := left + width - 1; right := left + width - 1;
bottom := top + height - 1; bottom := top + height - 1;
K.DrawRect(left, top, width, height, K.winColor); K.DrawRect(left, top, width, height, K.colors.work);
Rect(left, top, right, bottom, K.borderColor); Rect(left, top, right, bottom, K.colors.line);
K.DrawText866(left + (width - 10*fontWidth) DIV 2, top + 10, K.textColor, "save file?"); K.DrawText866(left + (width - 10*fontWidth) DIV 2, top + 10, K.colors.work_text, "save file?");
K.CreateButton(btnYes, left + 10, top + 35, btnWidth, btnHeight, K.btnColor, "yes"); K.CreateButton(btnYes, left + 10, top + 35, btnWidth, btnHeight, K.colors.button, "yes");
K.CreateButton(btnNo, left + 20 + btnWidth, top + 35, btnWidth, btnHeight, K.btnColor, "no"); K.CreateButton(btnNo, left + 20 + btnWidth, top + 35, btnWidth, btnHeight, K.colors.button, "no");
END Confirm; END Confirm;
@ -773,21 +774,28 @@ BEGIN
END SwitchTab; END SwitchTab;
PROCEDURE open; PROCEDURE open (_fileName: RW.tFileName): BOOLEAN;
VAR VAR
fileName: RW.tFileName; fileName: RW.tFileName;
nov: T.tText; nov: T.tText;
err, n: INTEGER; err, n: INTEGER;
res: BOOLEAN;
BEGIN BEGIN
res := TRUE;
IF textsCount < maxTexts THEN IF textsCount < maxTexts THEN
OD._type := OpenDlg.topen; fileName := _fileName;
OpenFile(fileName, EditFilter); IF fileName = "" THEN
OD._type := OpenDlg.topen;
OpenFile(fileName, EditFilter)
END;
IF fileName # "" THEN IF fileName # "" THEN
n := getFileNum(fileName); n := getFileNum(fileName);
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("error opening file") error("error opening file");
SwitchTab(curText);
res := FALSE
ELSE ELSE
T.SetPos(nov, 0, 0); T.SetPos(nov, 0, 0);
insert(textsCount, nov); insert(textsCount, nov);
@ -799,11 +807,21 @@ BEGIN
END END
END END
ELSE ELSE
error("too many files") error("too many files");
res := FALSE
END END
RETURN res
END open; END open;
PROCEDURE OpenDial;
VAR
res: BOOLEAN;
BEGIN
res := open("")
END OpenDial;
PROCEDURE createSearchForm; PROCEDURE createSearchForm;
BEGIN BEGIN
EB.create(LEFT_PADDING, TOP + 20, EditBox_Width, EDITBOX_MAXCHARS, FindEdit); EB.create(LEFT_PADDING, TOP + 20, EditBox_Width, EDITBOX_MAXCHARS, FindEdit);
@ -1132,7 +1150,7 @@ BEGIN
|menuNew: |menuNew:
NewFile NewFile
|menuOpen: |menuOpen:
open OpenDial
|menuSave: |menuSave:
save(text); save(text);
repaint repaint
@ -1672,7 +1690,7 @@ BEGIN
key := -1 key := -1
|22: key := ORD("U") |22: key := ORD("U")
|24: key := -1; |24: key := -1;
open OpenDial
|30: key := ORD("A") |30: key := ORD("A")
|31: key := -1; |31: key := -1;
save(text) save(text)
@ -1765,7 +1783,7 @@ BEGIN
NewFile; NewFile;
repaint repaint
|btnOpen: |btnOpen:
open OpenDial
|btnSave: |btnSave:
save(text); save(text);
repaint repaint
@ -1916,21 +1934,25 @@ END MouseEvent;
PROCEDURE Redraw (VAR resized: BOOLEAN; VAR width, height, cliWidth, cliHeight: INTEGER); PROCEDURE Redraw (VAR resized: BOOLEAN; VAR width, height, cliWidth, cliHeight: INTEGER);
BEGIN BEGIN
K.GetSystemColors; K.GetSystemColors;
IF ~K.RolledUp() THEN IF ~K.RolledUp() THEN
K.ClientSize(width, height); K.ClientSize(width, height);
IF (width # cliWidth) OR (height # cliHeight) THEN IF (width # cliWidth) OR (height # cliHeight) THEN
cliWidth := width; cliWidth := width;
cliHeight := height; cliHeight := height;
resize; resize;
resized := TRUE resized := TRUE
END; END;
K.SetEventsMask({0, 1, 2, 5, 6, 31}) K.SetEventsMask({0, 1, 2, 5, 6, 31})
ELSE ELSE
SetCaption(text.fileName); SetCaption(text.fileName);
K.SetEventsMask({0, 30, 31}) K.SetEventsMask({0, 30, 31})
END; END;
draw_window draw_window;
IF SkinHeight # K.SkinHeight() THEN
SkinHeight := K.SkinHeight();
Redraw(resized, width, height, cliWidth, cliHeight)
END
END Redraw; END Redraw;
@ -1950,11 +1972,10 @@ END ScrollChange;
PROCEDURE main; PROCEDURE main;
VAR VAR
err: INTEGER;
fileName, filePath: RW.tFileName; fileName, filePath: RW.tFileName;
width, height, cliWidth, cliHeight: INTEGER; width, height, cliWidth, cliHeight: INTEGER;
resized: BOOLEAN; resized: BOOLEAN;
firstClickX, firstClickY, time, blink: INTEGER; firstClickX, firstClickY, time, blink, i: INTEGER;
BEGIN BEGIN
header := ""; header := "";
K.GetSystemColors; K.GetSystemColors;
@ -1964,7 +1985,7 @@ BEGIN
curText := 0; curText := 0;
mainTID := K.ThreadID(); mainTID := K.ThreadID();
K.SetIPC(IPC); K.SetIPC(IPC);
U.ptr2str(K.GetName(), AppPath); Args.GetArg(0, AppPath);
Ini.load(AppPath); Ini.load(AppPath);
leftButton := FALSE; leftButton := FALSE;
resized := FALSE; resized := FALSE;
@ -1976,7 +1997,8 @@ BEGIN
cliWidth := winWidth; cliWidth := winWidth;
cliHeight := winHeight; cliHeight := winHeight;
LEFT := LEFT_PADDING; LEFT := LEFT_PADDING;
canvas := G.CreateCanvas(winWidth - (LEFT + RIGHT + 11 + RIGHT_PADDING), winHeight - (TOP + BOTTOM + 5) - K.SkinHeight()); SkinHeight := K.SkinHeight();
canvas := G.CreateCanvas(winWidth - (LEFT + RIGHT + 11 + RIGHT_PADDING), winHeight - (TOP + BOTTOM + 5) - SkinHeight);
tabs := Tabs.create(); tabs := Tabs.create();
Tabs.setArea(tabs, LEFT, TOP - Tabs.tabHeight, canvas.width, Tabs.tabHeight); Tabs.setArea(tabs, LEFT, TOP - Tabs.tabHeight, canvas.width, Tabs.tabHeight);
font1 := G.CreateFont(1, "", {}); font1 := G.CreateFont(1, "", {});
@ -1985,7 +2007,6 @@ BEGIN
G.SetFont(canvas, font); G.SetFont(canvas, font);
T.init(resetTimer); T.init(resetTimer);
T.setCanvas(canvas); T.setCanvas(canvas);
U.ptr2str(K.GetCommandLine(), fileName);
context := CreateContextMenu(); context := CreateContextMenu();
menuFile := CreateMenuFile(); menuFile := CreateMenuFile();
@ -2034,25 +2055,28 @@ BEGIN
Toolbar.add(toolbar, btnRun, 53, ""); Toolbar.add(toolbar, btnRun, 53, "");
Ini.getSettings(buildScript, runScript, debugScript); Ini.getSettings(buildScript, runScript, debugScript);
IF fileName = "" THEN
filePath := "/sys";
IF Args.argc = 1 THEN
text := T.New(); text := T.New();
filePath := "/sys" insert(0, text);
ELSE T.SetPos(text, 0, 0)
text := T.open(fileName, err);
IF text = NIL THEN
error("error opening file");
K.Exit
ELSE
U.getPath(fileName, filePath)
END
END; END;
OD := OpenDlg.Create(draw_window, OpenDlg.topen, filePath, ""); FOR i := 1 TO Args.argc - 1 DO
insert(0, text); Args.GetArg(i, fileName);
IF open(fileName) THEN
U.getPath(fileName, filePath)
END
END;
IF textsCount = 0 THEN
K.Exit
END;
SwitchTab(textsCount - 1);
Scroll.init(ScrollChange); Scroll.init(ScrollChange);
Scroll.create(FALSE, canvas.width + 1, scrollWidth, scrollWidth, scrollWidth*3 DIV 2, hScroll); Scroll.create(FALSE, canvas.width + 1, scrollWidth, scrollWidth, scrollWidth*3 DIV 2, hScroll);
Scroll.create(TRUE, scrollWidth, canvas.height + 2, scrollWidth, scrollWidth*3 DIV 2, vScroll); Scroll.create(TRUE, scrollWidth, canvas.height + 2, scrollWidth, scrollWidth*3 DIV 2, vScroll);
T.resize(canvas.width, canvas.height); T.resize(canvas.width, canvas.height);
T.SetPos(text, 0, 0);
confirm := FALSE; confirm := FALSE;
notFound := FALSE; notFound := FALSE;
menuFindClicked := FALSE; menuFindClicked := FALSE;
@ -2065,6 +2089,9 @@ BEGIN
cs := FALSE; cs := FALSE;
whole := FALSE; whole := FALSE;
replaced := 0; replaced := 0;
OD := OpenDlg.Create(draw_window, OpenDlg.topen, filePath, "");
K.SetEventsMask({0, 1, 2, 5, 6, 31}); K.SetEventsMask({0, 1, 2, 5, 6, 31});
Menu.init(resetTimer); Menu.init(resetTimer);
draw_window; draw_window;

View File

@ -1,5 +1,5 @@
(* (*
Copyright 2021 Anton Krotov Copyright 2021, 2022 Anton Krotov
This file is part of CEdit. This file is part of CEdit.
@ -48,11 +48,11 @@ VAR
BEGIN BEGIN
canvas := chkbox.canvas; canvas := chkbox.canvas;
IF canvas # NIL THEN IF canvas # NIL THEN
G.SetColor(canvas, K.winColor); G.SetColor(canvas, K.colors.work);
G.clear(canvas); G.clear(canvas);
G.SetColor(canvas, bColor); G.SetColor(canvas, bColor);
G.FillRect(canvas, 0, 0, fontHeight - 1, fontHeight - 1); G.FillRect(canvas, 0, 0, fontHeight - 1, fontHeight - 1);
G.SetColor(canvas, K.borderColor); G.SetColor(canvas, K.colors.line);
G.Rect(canvas, 0, 0, fontHeight - 1, fontHeight - 1); G.Rect(canvas, 0, 0, fontHeight - 1, fontHeight - 1);
IF chkbox.value THEN IF chkbox.value THEN
G.SetColor(canvas, fColor); G.SetColor(canvas, fColor);
@ -65,8 +65,8 @@ BEGIN
G.DLine(canvas, 2, 6, 5, -1); G.DLine(canvas, 2, 6, 5, -1);
G.DLine(canvas, 7, 13, 8, 1); G.DLine(canvas, 7, 13, 8, 1);
END; END;
G.SetTextColor(canvas, K.textColor); G.SetTextColor(canvas, K.colors.work_text);
G.SetBkColor(canvas, K.winColor); G.SetBkColor(canvas, K.colors.work);
G.TextOut2(canvas, fontHeight + padding, 0, chkbox.text, LENGTH(chkbox.text)); G.TextOut2(canvas, fontHeight + padding, 0, chkbox.text, LENGTH(chkbox.text));
G.DrawCanvas(canvas, chkbox.left, chkbox.top) G.DrawCanvas(canvas, chkbox.left, chkbox.top)
END END

View File

@ -48,33 +48,13 @@ TYPE
offset, cl_curs_x, cl_curs_y, shift, shift_old, height, char_width: INTEGER offset, cl_curs_x, cl_curs_y, shift, shift_old, height, char_width: INTEGER
END; END;
EditBoxKey = PROCEDURE (eb: tEditBox);
VAR VAR
key_proc: EditBoxKey;
paint *: PROCEDURE (eb: tEditBox); paint *: PROCEDURE (eb: tEditBox);
mouse *: PROCEDURE (eb: tEditBox); mouse *: PROCEDURE (eb: tEditBox);
_setValue : PROCEDURE (eb: tEditBox; text: INTEGER); _setValue : PROCEDURE (eb: tEditBox; text: INTEGER);
key *: PROCEDURE (eb: tEditBox; key: INTEGER);
PROCEDURE _key (key: INTEGER; key_proc: EditBoxKey; text: tEditBox);
BEGIN
SYSTEM.CODE(
08BH, 045H, 008H, (* mov eax, dword [ebp + 8] *)
08BH, 055H, 00CH, (* mov edx, dword [ebp + 12] *)
08BH, 04DH, 010H, (* mov ecx, dword [ebp + 16] *)
051H, (* push ecx *)
0FFH, 0D2H (* call edx *)
)
END _key;
PROCEDURE key* (text: tEditBox; key: INTEGER);
BEGIN
_key(key, key_proc, text)
END key;
PROCEDURE getValue* (text: tEditBox; VAR str: ARRAY OF CHAR); PROCEDURE getValue* (text: tEditBox; VAR str: ARRAY OF CHAR);
@ -144,8 +124,8 @@ VAR
BEGIN BEGIN
Lib := KOSAPI.LoadLib("/sys/lib/box_lib.obj"); Lib := KOSAPI.LoadLib("/sys/lib/box_lib.obj");
ASSERT(Lib # 0); ASSERT(Lib # 0);
GetProc(Lib, SYSTEM.ADR(paint), "edit_box"); GetProc(Lib, SYSTEM.ADR(paint), "edit_box_draw");
GetProc(Lib, SYSTEM.ADR(key_proc), "edit_box_key"); GetProc(Lib, SYSTEM.ADR(key), "edit_box_key_safe");
GetProc(Lib, SYSTEM.ADR(mouse), "edit_box_mouse"); GetProc(Lib, SYSTEM.ADR(mouse), "edit_box_mouse");
GetProc(Lib, SYSTEM.ADR(_setValue), "edit_box_set_text"); GetProc(Lib, SYSTEM.ADR(_setValue), "edit_box_set_text");
END main; END main;

View File

@ -1,5 +1,5 @@
(* (*
Copyright 2021 Anton Krotov Copyright 2021, 2022 Anton Krotov
This file is part of CEdit. This file is part of CEdit.
@ -28,18 +28,18 @@ CONST
VAR VAR
winColor*, textColor*, btnColor*, btnTextColor*, colors*: RECORD
borderColor*, (*darkColor,*) lightColor*: INTEGER; rsrvd,
taskbar,
dark*,
PROCEDURE GetCommandLine* (): INTEGER; light*,
RETURN KOSAPI.GetCommandLine() window_title*,
END GetCommandLine; work*,
button*,
button_text*,
PROCEDURE GetName* (): INTEGER; work_text*,
RETURN KOSAPI.GetName() line*: INTEGER
END GetName; END;
PROCEDURE CreateWindow* (x, y, w, h, color, style, hcolor, hstyle: INTEGER; htext: ARRAY OF CHAR); PROCEDURE CreateWindow* (x, y, w, h, color, style, hcolor, hstyle: INTEGER; htext: ARRAY OF CHAR);
@ -152,7 +152,7 @@ END DrawText69;
PROCEDURE DrawText866* (x, y, color: INTEGER; text: ARRAY OF CHAR); PROCEDURE DrawText866* (x, y, color: INTEGER; text: ARRAY OF CHAR);
BEGIN BEGIN
KOSAPI.sysfunc6(4, x*65536 + y, color + LSL(0D0H, 24), SYSTEM.ADR(text[0]), 0, winColor) KOSAPI.sysfunc6(4, x*65536 + y, color + LSL(0D0H, 24), SYSTEM.ADR(text[0]), 0, colors.work)
END DrawText866; END DrawText866;
@ -179,7 +179,7 @@ BEGIN
KOSAPI.sysfunc5(8, LSL(Left, 16) + Width, LSL(Top, 16) + Height, id, Color); KOSAPI.sysfunc5(8, LSL(Left, 16) + Width, LSL(Top, 16) + Height, id, Color);
x := Left + (Width - fontWidth * LENGTH(Caption)) DIV 2; x := Left + (Width - fontWidth * LENGTH(Caption)) DIV 2;
y := Top + (Height - fontHeight) DIV 2 + 1; y := Top + (Height - fontHeight) DIV 2 + 1;
DrawText(x, y, btnTextColor, Caption) DrawText(x, y, colors.button_text, Caption)
END CreateButton; END CreateButton;
@ -330,18 +330,8 @@ END SendIPC;
PROCEDURE GetSystemColors*; PROCEDURE GetSystemColors*;
VAR
buf: ARRAY 10 OF INTEGER;
BEGIN BEGIN
ASSERT(LEN(buf) >= 10); KOSAPI.sysfunc4(48, 3, SYSTEM.ADR(colors), 40)
KOSAPI.sysfunc4(48, 3, SYSTEM.ADR(buf[0]), 40);
(*darkColor := buf[2];*)
lightColor := buf[3];
winColor := buf[5];
btnColor := buf[6];
btnTextColor := buf[7];
textColor := buf[8];
borderColor := buf[9];
END GetSystemColors; END GetSystemColors;
@ -409,4 +399,6 @@ BEGIN
END PutPixel; END PutPixel;
BEGIN
GetSystemColors
END KolibriOS. END KolibriOS.

View File

@ -1,5 +1,5 @@
(* (*
Copyright 2021 Anton Krotov Copyright 2021, 2022 Anton Krotov
This file is part of CEdit. This file is part of CEdit.
@ -134,15 +134,15 @@ VAR
menuColor, textColor, n: INTEGER; menuColor, textColor, n: INTEGER;
BEGIN BEGIN
IF item.menu.tid # 0 THEN IF item.menu.tid # 0 THEN
menuColor := K.textColor; menuColor := K.colors.work_text;
textColor := K.winColor textColor := K.colors.work
ELSE ELSE
menuColor := K.winColor; menuColor := K.colors.work;
textColor := K.textColor textColor := K.colors.work_text
END; END;
n := LENGTH(item.text); n := LENGTH(item.text);
K.DrawRect(item.x, 0, n*fontWidth + 2, MainMenuHeight, menuColor); K.DrawRect(item.x, 0, n*fontWidth + 2, MainMenuHeight, menuColor);
K.CreateButton(item.id + ORD({30}), item.x, 0, n*fontWidth + 2, MainMenuHeight, K.btnColor, ""); K.CreateButton(item.id + ORD({30}), item.x, 0, n*fontWidth + 2, MainMenuHeight, K.colors.button, "");
K.DrawText(item.x + 1, (MainMenuHeight - K.fontHeight) DIV 2 + 1, textColor, item.text) K.DrawText(item.x + 1, (MainMenuHeight - K.fontHeight) DIV 2 + 1, textColor, item.text)
END drawMainItem; END drawMainItem;
@ -217,7 +217,7 @@ END escape;
PROCEDURE repaint (m: tMenu); PROCEDURE repaint (m: tMenu);
VAR VAR
y, i, X, Y: INTEGER; y, i, X, Y, Y1: INTEGER;
item: tItem; item: tItem;
BkColor, TextColor: INTEGER; BkColor, TextColor: INTEGER;
canvas: G.tCanvas; canvas: G.tCanvas;
@ -269,12 +269,14 @@ BEGIN
G.SetColor(canvas, TextColor); G.SetColor(canvas, TextColor);
IF item.check = 1 THEN IF item.check = 1 THEN
G.DLine(canvas, 4, 7, Y + 5, -1); G.DLine(canvas, 4, 7, Y + 5, -1);
G.DLine(canvas, 4, 7, Y + 6, -1); G.DLine(canvas, 4, 7, Y + 6, -1);
G.DLine(canvas, 7, 12, Y + 8, 1); G.DLine(canvas, 7, 12, Y + 8, 1);
G.DLine(canvas, 7, 12, Y + 9, 1); G.DLine(canvas, 7, 12, Y + 9, 1)
ELSIF item.check = 2 THEN ELSIF item.check = 2 THEN
G.FillRect(canvas, 6, y + fontHeight DIV 2 - 4, 10, y + fontHeight DIV 2) Y1 := y + fontHeight DIV 2 - 2;
G.FillRect(canvas, 7, Y1 - 2, 9, Y1 + 2);
G.FillRect(canvas, 6, Y1 - 1, 10, Y1 + 1)
END; END;
IF item.child # NIL THEN IF item.child # NIL THEN

View File

@ -1,5 +1,5 @@
(* (*
Copyright 2021 Anton Krotov Copyright 2021, 2022 Anton Krotov
This file is part of CEdit. This file is part of CEdit.
@ -95,9 +95,9 @@ END TextOut;
PROCEDURE draw* (left, top: INTEGER); PROCEDURE draw* (left, top: INTEGER);
BEGIN BEGIN
G.SetColor(SB.canvas, K.winColor); G.SetColor(SB.canvas, K.colors.work);
G.SetBkColor(SB.canvas, K.winColor); G.SetBkColor(SB.canvas, K.colors.work);
G.SetTextColor(SB.canvas, K.textColor); G.SetTextColor(SB.canvas, K.colors.work_text);
G.clear(SB.canvas); G.clear(SB.canvas);
TextOut(1, SB.pos); TextOut(1, SB.pos);
TextOut(16*K.fontWidth, SB.sel); TextOut(16*K.fontWidth, SB.sel);

View File

@ -1,5 +1,5 @@
(* (*
Copyright 2021 Anton Krotov Copyright 2021, 2022 Anton Krotov
This file is part of CEdit. This file is part of CEdit.
@ -61,25 +61,25 @@ BEGIN
IF id = t.current THEN IF id = t.current THEN
INC(height, curTabHeight - tabHeight); INC(height, curTabHeight - tabHeight);
DEC(y, curTabHeight - tabHeight); DEC(y, curTabHeight - tabHeight);
color := K.lightColor color := K.colors.light
ELSE ELSE
color := K.winColor color := K.colors.work
END; END;
DEC(x); INC(width); DEC(x); INC(width);
x2 := x + width - 1; x2 := x + width - 1;
y2 := y + height - 1; y2 := y + height - 1;
K.DrawRect(x, y, width, height, color); K.DrawRect(x, y, width, height, color);
K.DrawLine(x, y, x2, y, K.borderColor); K.DrawLine(x, y, x2, y, K.colors.line);
K.DrawLine(x2, y, x2, y2, K.borderColor); K.DrawLine(x2, y, x2, y2, K.colors.line);
IF id # t.current THEN IF id # t.current THEN
K.DrawLine(x2 - 1, y2, x, y2, K.borderColor); K.DrawLine(x2 - 1, y2, x, y2, K.colors.line);
END; END;
K.DrawLine(x, y2, x, y, K.borderColor); K.DrawLine(x, y2, x, y, K.colors.line);
K.DrawText866bk(x + K.fontWidth + K.fontWidth DIV 2, 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.colors.work_text, color, s);
IF modified THEN IF modified THEN
K.DrawText866bk(x + K.fontWidth DIV 2, y + (height - K.fontHeight) DIV 2, K.textColor, color, "*") K.DrawText866bk(x + K.fontWidth DIV 2, y + (height - K.fontHeight) DIV 2, K.colors.work_text, color, "*")
END; 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;
@ -115,13 +115,13 @@ VAR
BEGIN BEGIN
y := t.y; y := t.y;
x := t.x; x := t.x;
K.DrawRect(x, y - (curTabHeight - tabHeight), t.width + (2*scrWidth + 2), t.height + (curTabHeight - tabHeight) - 1, K.winColor); K.DrawRect(x, y - (curTabHeight - tabHeight), t.width + (2*scrWidth + 2), t.height + (curTabHeight - tabHeight) - 1, K.colors.work);
IF Width(t, 0, t.strings.count - 1) > t.width THEN IF Width(t, 0, t.strings.count - 1) > t.width THEN
INC(x, 2*scrWidth); INC(x, 2*scrWidth);
K.DeleteButton(btnLeft); K.DeleteButton(btnLeft);
K.DeleteButton(btnRight); K.DeleteButton(btnRight);
K.CreateButton(btnLeft, t.x, y, scrWidth, t.height - 1, K.btnColor, "<"); K.CreateButton(btnLeft, t.x, y, scrWidth, t.height - 1, K.colors.button, "<");
K.CreateButton(btnRight, t.x + scrWidth, y, scrWidth, t.height - 1, K.btnColor, ">"); K.CreateButton(btnRight, t.x + scrWidth, y, scrWidth, t.height - 1, K.colors.button, ">");
scroll := TRUE scroll := TRUE
ELSE ELSE
t.first := 0; t.first := 0;
@ -145,8 +145,8 @@ BEGIN
t.first := n t.first := n
END; END;
K.DrawRect(x, y, t.width, t.height - 1, K.winColor); K.DrawRect(x, y, t.width, t.height - 1, K.colors.work);
K.DrawLine(x, y + tabHeight - 1, x + t.width - 1 + 2*scrWidth*(1 - ORD(scroll)), y + tabHeight - 1, K.borderColor); K.DrawLine(x, y + tabHeight - 1, x + t.width - 1 + 2*scrWidth*(1 - ORD(scroll)), y + tabHeight - 1, K.colors.line);
item := List.getItem(t.strings, t.first); item := List.getItem(t.strings, t.first);
n := t.first; n := t.first;
WHILE (item # NIL) & (x <= xmax) DO WHILE (item # NIL) & (x <= xmax) DO

View File

@ -1,5 +1,5 @@
(* (*
Copyright 2021 Anton Krotov Copyright 2021, 2022 Anton Krotov
This file is part of CEdit. This file is part of CEdit.
@ -77,12 +77,12 @@ END drawIcons;
PROCEDURE setColors (VAR toolbar: tToolbar); PROCEDURE setColors (VAR toolbar: tToolbar);
BEGIN BEGIN
toolbar.colors.back := 0F2EFECH;//K.lightColor; toolbar.colors.back := 0F2EFECH;
toolbar.colors.text := 00000FFH; toolbar.colors.text := 00000FFH;
toolbar.colors.disText := 0808080H;//K.borderColor; toolbar.colors.disText := 0808080H;
toolbar.colors.light := 0FEFEFEH; toolbar.colors.light := 0FEFEFEH;
toolbar.colors.shadow := 09F9C9AH;//K.borderColor; toolbar.colors.shadow := 09F9C9AH;
toolbar.colors.window := K.winColor toolbar.colors.window := K.colors.work
END setColors; END setColors;

View File

@ -1,5 +1,5 @@
(* (*
Copyright 2021 Anton Krotov Copyright 2021, 2022 Anton Krotov
This file is part of CEdit. This file is part of CEdit.
@ -352,21 +352,6 @@ BEGIN
END sgn; END sgn;
PROCEDURE ptr2str* (ptr: INTEGER; VAR s: ARRAY OF CHAR);
VAR
i, n: INTEGER;
BEGIN
i := -1;
n := LEN(s) - 1;
REPEAT
INC(i);
SYSTEM.GET(ptr, s[i]);
INC(ptr)
UNTIL (i = n) OR (s[i] = 0X);
s[i] := 0X
END ptr2str;
PROCEDURE between* (a, b, c: INTEGER): BOOLEAN; PROCEDURE between* (a, b, c: INTEGER): BOOLEAN;
RETURN (a <= b) & (b <= c) RETURN (a <= b) & (b <= c)
END between; END between;

View File

@ -1,5 +1,5 @@
(* (*
Copyright 2021 Anton Krotov Copyright 2021, 2022 Anton Krotov
This file is part of CEdit. This file is part of CEdit.
@ -76,7 +76,7 @@ END create;
PROCEDURE Rect (canvas: G.tCanvas; left, top, right, bottom: INTEGER); PROCEDURE Rect (canvas: G.tCanvas; left, top, right, bottom: INTEGER);
BEGIN BEGIN
G.FillRect(canvas, left, top, right, bottom); G.FillRect(canvas, left, top, right, bottom);
G.SetColor(canvas, K.borderColor); G.SetColor(canvas, K.colors.line);
G.Rect(canvas, left, top, right, bottom); G.Rect(canvas, left, top, right, bottom);
END Rect; END Rect;
@ -93,9 +93,9 @@ VAR
color: INTEGER; color: INTEGER;
BEGIN BEGIN
IF c THEN IF c THEN
color := K.btnColor color := K.colors.button
ELSE ELSE
color := K.btnTextColor color := K.colors.button_text
END; END;
G.SetColor(canvas, color) G.SetColor(canvas, color)
END SetColor; END SetColor;
@ -106,19 +106,19 @@ BEGIN
width := scroll.width; width := scroll.width;
height := scroll.height; height := scroll.height;
canvas := scroll.canvas; canvas := scroll.canvas;
G.SetColor(canvas, K.lightColor); G.SetColor(canvas, K.colors.light);
G.clear(canvas); G.clear(canvas);
G.SetColor(canvas, K.borderColor); G.SetColor(canvas, K.colors.line);
G.Rect(canvas, 0, 0, width - 1, height - 1); G.Rect(canvas, 0, 0, width - 1, height - 1);
IF scroll.vertical THEN IF scroll.vertical THEN
SetColor(canvas, ~scroll.Dec); SetColor(canvas, ~scroll.Dec);
Rect(canvas, 0, 0, width - 1, btn - 1); Rect(canvas, 0, 0, width - 1, btn - 1);
SetColor(canvas, ~scroll.Inc); SetColor(canvas, ~scroll.Inc);
Rect(canvas, 0, height - btn, width - 1, height - 1); Rect(canvas, 0, height - btn, width - 1, height - 1);
G.SetColor(canvas, K.btnColor); G.SetColor(canvas, K.colors.button);
Rect(canvas, 0, btn + scroll.pos - 1, width - 1, btn + scroll.pos + scroll.sliderSize - 1); Rect(canvas, 0, btn + scroll.pos - 1, width - 1, btn + scroll.pos + scroll.sliderSize - 1);
G.SetColor(canvas, K.btnTextColor); G.SetColor(canvas, K.colors.button_text);
y := btn + scroll.pos + scroll.sliderSize DIV 2 - 1; y := btn + scroll.pos + scroll.sliderSize DIV 2 - 1;
G.HLine(canvas, y, width DIV 4, 3*width DIV 4); G.HLine(canvas, y, width DIV 4, 3*width DIV 4);
@ -141,10 +141,10 @@ BEGIN
Rect(canvas, 0, 0, btn - 1, height - 1); Rect(canvas, 0, 0, btn - 1, height - 1);
SetColor(canvas, ~scroll.Inc); SetColor(canvas, ~scroll.Inc);
Rect(canvas, width - btn, 0, width - 1, height - 1); Rect(canvas, width - btn, 0, width - 1, height - 1);
G.SetColor(canvas, K.btnColor); G.SetColor(canvas, K.colors.button);
Rect(canvas, btn + scroll.pos - 1, 0, btn + scroll.pos + scroll.sliderSize - 1, height - 1); Rect(canvas, btn + scroll.pos - 1, 0, btn + scroll.pos + scroll.sliderSize - 1, height - 1);
G.SetColor(canvas, K.btnTextColor); G.SetColor(canvas, K.colors.button_text);
x := btn + scroll.pos + scroll.sliderSize DIV 2 - 1; x := btn + scroll.pos + scroll.sliderSize DIV 2 - 1;
G.VLine(canvas, x, height DIV 4, 3*height DIV 4); G.VLine(canvas, x, height DIV 4, 3*height DIV 4);