CEDIT: menu changes

git-svn-id: svn://kolibrios.org@9190 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Anton Krotov 2021-09-14 16:33:15 +00:00
parent 4918685b4a
commit 86da2194d2
7 changed files with 80 additions and 367 deletions

Binary file not shown.

View File

@ -8,7 +8,9 @@
ctrl+U преобразовать в верхний регистр ctrl+U преобразовать в верхний регистр
ctrl+F показать панель поиска ctrl+F показать панель поиска
Esc закрыть панель поиска; закрыть меню Esc закрыть панель поиска; закрыть меню
shift+Esc скрыть (свернуть) панель поиска
F10 открыть главное меню F10 открыть главное меню
shift+F10 открыть контекстное меню
F3 найти следующий F3 найти следующий
shift+F3 найти предыдущий shift+F3 найти предыдущий
ctrl+Z отменить ctrl+Z отменить

View File

@ -28,7 +28,7 @@ IMPORT
RW, Ini, EB := EditBox, Icons, Tabs, Timer; RW, Ini, EB := EditBox, Icons, Tabs, Timer;
CONST CONST
header = "CEdit (11-sep-2021)"; header = "CEdit (14-sep-2021)";
ShellFilter = ""; ShellFilter = "";
EditFilter = "SH|ASM|TXT|INC|OB07|C|CPP|H|PAS|PP|LUA|INI|JSON"; EditFilter = "SH|ASM|TXT|INC|OB07|C|CPP|H|PAS|PP|LUA|INI|JSON";
@ -55,8 +55,8 @@ CONST
btnReplace = 61; btnReplace = 61;
btnReplaceAll = 62; btnReplaceAll = 62;
btnGoto = 63; btnGoto = 63;
btnCloseFind = 64; btnCloseSearch = 64;
btnHideFind = 65; btnHideSearch = 65;
mainMenuBtn = 70; mainMenuBtn = 70;
@ -82,10 +82,9 @@ CONST
menuEditX = menuFileX + 4*fontWidth + 9; menuEditX = menuFileX + 4*fontWidth + 9;
menuSearchX = menuEditX + 4*fontWidth + 9; menuSearchX = menuEditX + 4*fontWidth + 9;
menuEncodingX = menuSearchX + 6*fontWidth + 9; menuEncodingX = menuSearchX + 6*fontWidth + 9;
menuEOLX = menuEncodingX + 8*fontWidth + 9; menuViewX = menuEncodingX + 8*fontWidth + 9;
menuViewX = menuEOLX + 3*fontWidth + 9; menuLanguageX = menuViewX + 4*fontWidth + 9;
menuSyntaxX = menuViewX + 4*fontWidth + 9; menuProgramX = menuLanguageX + 8*fontWidth + 9;
menuProgramX = menuSyntaxX + 6*fontWidth + 9;
menuToolsX = menuProgramX + 7*fontWidth + 9; menuToolsX = menuProgramX + 7*fontWidth + 9;
menuCut = 1; menuCut = 1;
@ -115,7 +114,7 @@ CONST
menuColors = 1000; menuColors = 1000;
menuMaxColors = menuColors + Ini.MAX_SECTIONS - 1; menuMaxColors = menuColors + Ini.MAX_SECTIONS - 1;
menuNone = 30; menuText = 30;
menuC = 31; menuC = 31;
menuFasm = 32; menuFasm = 32;
menuIni = 33; menuIni = 33;
@ -135,6 +134,7 @@ CONST
menuUTF8 = 61; menuUTF8 = 61;
menuCP866 = 62; menuCP866 = 62;
menuWin1251 = 63; menuWin1251 = 63;
menuEOL = 140;
menuPipet = 70; menuPipet = 70;
menuBoard = 71; menuBoard = 71;
@ -161,9 +161,9 @@ CONST
menuNextBookmark = 132; menuNextBookmark = 132;
menuPrevBookmark = 133; menuPrevBookmark = 133;
menuLF = 140; menuLF = 141;
menuCRLF = 141; menuCRLF = 142;
menuCR = 142; menuCR = 143;
maxTexts = 32; maxTexts = 32;
@ -198,8 +198,8 @@ VAR
mainTID, delay: INTEGER; mainTID, delay: INTEGER;
context, menuFile, menuEdit, menuSearch, menuEncoding, context, menuFile, menuEdit, menuSearch, menuEncoding,
menuEOL, menuView, menuSyntax, menuProgram, menuTools, menuView, menuLanguage, menuProgram, menuTools,
subCurLine, subIndent, subCase, subBookmark: Menu.tMenu; subCurLine, subIndent, subCase, subBookmark, subEOL: Menu.tMenu;
mainMenu: Menu.tMain; mainMenu: Menu.tMain;
@ -520,7 +520,7 @@ BEGIN
bottom := top + 395 + btnHeight + SEARCH_PADDING; bottom := top + 395 + btnHeight + SEARCH_PADDING;
color := K.borderColor; color := K.borderColor;
Rect(left, top, right, bottom, color); Rect(left, top, right, bottom, color);
K.CreateButton(btnCloseFind, 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);
K.DrawLine(right - 15, top + 5, right - 5, top + 15, 0FFFFFFH); K.DrawLine(right - 15, top + 5, right - 5, top + 15, 0FFFFFFH);
K.DrawLine(right - 15, top + 6, right - 6, top + 15, 0FFFFFFH); K.DrawLine(right - 15, top + 6, right - 6, top + 15, 0FFFFFFH);
@ -528,7 +528,7 @@ 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(btnHideFind, right - 40, top, 20, 20, K.btnColor, ""); K.CreateButton(btnHideSearch, right - 40, top, 20, 20, K.btnColor, "");
K.DrawLine(right - 34, top + 14, right - 26, top + 14, K.btnTextColor); K.DrawLine(right - 34, top + 14, right - 26, top + 14, K.btnTextColor);
K.DrawLine(right - 34, top + 15, right - 26, top + 15, K.btnTextColor); K.DrawLine(right - 34, top + 15, right - 26, top + 15, K.btnTextColor);
@ -703,7 +703,7 @@ BEGIN
IF OD.FileName = "" THEN IF OD.FileName = "" THEN
OD.FileName := "NewFile."; OD.FileName := "NewFile.";
CASE text.lang OF CASE text.lang OF
|Languages.langNone: ext := "txt" |Languages.langText: ext := "txt"
|Languages.langC: ext := "c" |Languages.langC: ext := "c"
|Languages.langFasm: ext := "asm" |Languages.langFasm: ext := "asm"
|Languages.langIni: ext := "ini" |Languages.langIni: ext := "ini"
@ -1045,19 +1045,19 @@ END Close;
PROCEDURE CloseMenu; PROCEDURE CloseMenu;
BEGIN BEGIN
Menu.close(menuFile); Menu.close(subEOL);
Menu.close(menuEdit);
Menu.close(menuSearch);
Menu.close(menuEncoding);
Menu.close(menuEOL);
Menu.close(menuView);
Menu.close(menuSyntax);
Menu.close(menuProgram);
Menu.close(menuTools);
Menu.close(subCurLine); Menu.close(subCurLine);
Menu.close(subIndent); Menu.close(subIndent);
Menu.close(subCase); Menu.close(subCase);
Menu.close(subBookmark); Menu.close(subBookmark);
Menu.close(menuFile);
Menu.close(menuEdit);
Menu.close(menuSearch);
Menu.close(menuEncoding);
Menu.close(menuView);
Menu.close(menuLanguage);
Menu.close(menuProgram);
Menu.close(menuTools);
Menu.close(context) Menu.close(context)
END CloseMenu; END CloseMenu;
@ -1161,11 +1161,6 @@ BEGIN
Menu.option(menu, menuCP866, text.enc = E.CP866); Menu.option(menu, menuCP866, text.enc = E.CP866);
Menu.option(menu, menuWin1251, text.enc = E.W1251); Menu.option(menu, menuWin1251, text.enc = E.W1251);
INC(x, menuEncodingX) INC(x, menuEncodingX)
ELSIF menu = menuEOL THEN
Menu.option(menu, menuCRLF, text.eol = RW.EOL_CRLF);
Menu.option(menu, menuLF, text.eol = RW.EOL_LF);
Menu.option(menu, menuCR, text.eol = RW.EOL_CR);
INC(x, menuEOLX)
ELSIF menu = menuView THEN ELSIF menu = menuView THEN
Menu.check(menu, menuNumbers, text.numbers); Menu.check(menu, menuNumbers, text.numbers);
Menu.check(menu, menuFontSize, font = font2); Menu.check(menu, menuFontSize, font = font2);
@ -1173,8 +1168,8 @@ BEGIN
Menu.option(menu, menuColors + i, Ini.curSectionNum = i) Menu.option(menu, menuColors + i, Ini.curSectionNum = i)
END; END;
INC(x, menuViewX) INC(x, menuViewX)
ELSIF menu = menuSyntax THEN ELSIF menu = menuLanguage THEN
Menu.option(menu, menuNone, text.lang = Languages.langNone); Menu.option(menu, menuText, text.lang = Languages.langText);
Menu.option(menu, menuC, text.lang = Languages.langC); Menu.option(menu, menuC, text.lang = Languages.langC);
Menu.option(menu, menuFasm, text.lang = Languages.langFasm); Menu.option(menu, menuFasm, text.lang = Languages.langFasm);
Menu.option(menu, menuIni, text.lang = Languages.langIni); Menu.option(menu, menuIni, text.lang = Languages.langIni);
@ -1182,7 +1177,7 @@ BEGIN
Menu.option(menu, menuLua, text.lang = Languages.langLua); Menu.option(menu, menuLua, text.lang = Languages.langLua);
Menu.option(menu, menuOberon, text.lang = Languages.langOberon); Menu.option(menu, menuOberon, text.lang = Languages.langOberon);
Menu.option(menu, menuPascal, text.lang = Languages.langPascal); Menu.option(menu, menuPascal, text.lang = Languages.langPascal);
INC(x, menuSyntaxX) INC(x, menuLanguageX)
ELSIF menu = menuProgram THEN ELSIF menu = menuProgram THEN
Menu.setEnabled(menu, menuBuild, buildScript # ""); Menu.setEnabled(menu, menuBuild, buildScript # "");
Menu.setEnabled(menu, menuDebug, debugScript # ""); Menu.setEnabled(menu, menuDebug, debugScript # "");
@ -1204,6 +1199,10 @@ BEGIN
Menu.setEnabled(subCase, menuUpper, selected); Menu.setEnabled(subCase, menuUpper, selected);
Menu.setEnabled(subCase, menuLower, selected); Menu.setEnabled(subCase, menuLower, selected);
Menu.option(subEOL, menuCRLF, text.eol = RW.EOL_CRLF);
Menu.option(subEOL, menuLF, text.eol = RW.EOL_LF);
Menu.option(subEOL, menuCR, text.eol = RW.EOL_CR);
IF menu # NIL THEN IF menu # NIL THEN
Timer.kill; Timer.kill;
IF Menu.opened(menu) THEN IF Menu.opened(menu) THEN
@ -1332,8 +1331,8 @@ BEGIN
font := font1 font := font1
END; END;
resize resize
|menuNone: |menuText:
T.setLang(text, Languages.langNone) T.setLang(text, Languages.langText)
|menuC: |menuC:
T.setLang(text, Languages.langC) T.setLang(text, Languages.langC)
|menuFasm: |menuFasm:
@ -1552,6 +1551,9 @@ BEGIN
Menu.AddMenuItem(menu, menuUTF8, E.names[E.UTF8]); Menu.AddMenuItem(menu, menuUTF8, E.names[E.UTF8]);
Menu.AddMenuItem(menu, menuCP866, E.names[E.CP866]); Menu.AddMenuItem(menu, menuCP866, E.names[E.CP866]);
Menu.AddMenuItem(menu, menuWin1251, E.names[E.W1251]); Menu.AddMenuItem(menu, menuWin1251, E.names[E.W1251]);
Menu.delimiter(menu);
Menu.AddMenuItem(menu, menuEOL, "EOL");
Menu.child(menu, subEOL);
RETURN Menu.create(menu, MenuItemClick, MenuKeyDown) RETURN Menu.create(menu, MenuItemClick, MenuKeyDown)
END CreateMenuEncoding; END CreateMenuEncoding;
@ -1591,7 +1593,7 @@ BEGIN
END CreateMenuView; END CreateMenuView;
PROCEDURE CreateMenuSyntax (): Menu.tMenu; PROCEDURE CreateMenuLanguage (): Menu.tMenu;
VAR VAR
menu: List.tList; menu: List.tList;
BEGIN BEGIN
@ -1604,9 +1606,9 @@ BEGIN
Menu.AddMenuItem(menu, menuOberon, "Oberon"); Menu.AddMenuItem(menu, menuOberon, "Oberon");
Menu.AddMenuItem(menu, menuPascal, "Pascal"); Menu.AddMenuItem(menu, menuPascal, "Pascal");
Menu.delimiter(menu); Menu.delimiter(menu);
Menu.AddMenuItem(menu, menuNone, "none"); Menu.AddMenuItem(menu, menuText, "Text");
RETURN Menu.create(menu, MenuItemClick, MenuKeyDown) RETURN Menu.create(menu, MenuItemClick, MenuKeyDown)
END CreateMenuSyntax; END CreateMenuLanguage;
PROCEDURE CreateMenuProgram (): Menu.tMenu; PROCEDURE CreateMenuProgram (): Menu.tMenu;
@ -1685,6 +1687,16 @@ BEGIN
END CreateMenuBookmark; END CreateMenuBookmark;
PROCEDURE HideSearch;
BEGIN
SetFocus(FindEdit, FALSE);
searchOpened := FALSE;
LEFT := searchLeft;
resize;
draw_window
END HideSearch;
PROCEDURE KeyDown (key: INTEGER); PROCEDURE KeyDown (key: INTEGER);
VAR VAR
keyCode: INTEGER; keyCode: INTEGER;
@ -1725,13 +1737,21 @@ BEGIN
Script(runScript) Script(runScript)
END END
ELSIF keyCode = 68 THEN (* F10 *) ELSIF keyCode = 68 THEN (* F10 *)
key := -1; IF shift THEN
ShowMenu(context)
ELSE
ShowMenu(menuFile) ShowMenu(menuFile)
END;
key := -1
ELSIF keyCode = 1 THEN (* Esc *) ELSIF keyCode = 1 THEN (* Esc *)
key := -1;
IF search THEN IF search THEN
IF shift THEN
HideSearch
ELSE
Search Search
END END
END;
key := -1
ELSIF (keyCode = 55) & (key DIV 256 MOD 256 = 52) THEN (* PrtScn *) ELSIF (keyCode = 55) & (key DIV 256 MOD 256 = 52) THEN (* PrtScn *)
key := -1 key := -1
ELSIF (keyCode = 14) & shift THEN (* shift+Backspace *) ELSIF (keyCode = 14) & shift THEN (* shift+Backspace *)
@ -1886,14 +1906,10 @@ BEGIN
repaint repaint
|btnSearch: |btnSearch:
ShowSearchPanel ShowSearchPanel
|btnCloseFind: |btnCloseSearch:
Search Search
|btnHideFind: |btnHideSearch:
SetFocus(FindEdit, FALSE); HideSearch
searchOpened := FALSE;
LEFT := searchLeft;
resize;
draw_window
|btnUndo: |btnUndo:
T.undo(text); T.undo(text);
repaint repaint
@ -2109,10 +2125,11 @@ BEGIN
subBookmark := CreateMenuBookmark(); subBookmark := CreateMenuBookmark();
menuSearch := CreateMenuSearch(); menuSearch := CreateMenuSearch();
subBookmark.parent := menuSearch; subBookmark.parent := menuSearch;
subEOL := CreateMenuEOL();
menuEncoding := CreateMenuEncoding(); menuEncoding := CreateMenuEncoding();
menuEOL := CreateMenuEOL(); subEOL.parent := menuEncoding;
menuView := CreateMenuView(); menuView := CreateMenuView();
menuSyntax := CreateMenuSyntax(); menuLanguage := CreateMenuLanguage();
menuProgram := CreateMenuProgram(); menuProgram := CreateMenuProgram();
menuTools := CreateMenuTools(); menuTools := CreateMenuTools();
@ -2121,9 +2138,8 @@ BEGIN
Menu.AddMainItem(mainMenu, "edit", menuEdit); Menu.AddMainItem(mainMenu, "edit", menuEdit);
Menu.AddMainItem(mainMenu, "search", menuSearch); Menu.AddMainItem(mainMenu, "search", menuSearch);
Menu.AddMainItem(mainMenu, "encoding", menuEncoding); Menu.AddMainItem(mainMenu, "encoding", menuEncoding);
Menu.AddMainItem(mainMenu, "eol", menuEOL);
Menu.AddMainItem(mainMenu, "view", menuView); Menu.AddMainItem(mainMenu, "view", menuView);
Menu.AddMainItem(mainMenu, "syntax", menuSyntax); Menu.AddMainItem(mainMenu, "language", menuLanguage);
Menu.AddMainItem(mainMenu, "program", menuProgram); Menu.AddMainItem(mainMenu, "program", menuProgram);
Menu.AddMainItem(mainMenu, "tools", menuTools); Menu.AddMainItem(mainMenu, "tools", menuTools);
@ -2164,13 +2180,7 @@ BEGIN
Timer.create(mainTID); Timer.create(mainTID);
WHILE TRUE DO WHILE TRUE DO
CASE K.WaitForEvent() OF CASE K.WaitForEvent() OF
|1: (*IF Menu.redraw THEN*) |1: Redraw(resized, width, height, cliWidth, cliHeight)
Redraw(resized, width, height, cliWidth, cliHeight)
(*ELSE
Menu.Redraw;
K.CreateWindow(30 + K.GetTickCount() MOD 128, 30 + K.GetTickCount() MOD 128, winWidth, winHeight, K.winColor, 73H, 0, 0, header);
repaint
END*)
|2: KeyDown(K.GetKey()) |2: KeyDown(K.GetKey())
|3: BtnClick |3: BtnClick
|6: MouseEvent(resized, firstClickX, firstClickY, time) |6: MouseEvent(resized, firstClickX, firstClickY, time)

View File

@ -24,7 +24,7 @@ IMPORT Lines;
CONST CONST
langNone* = 0; langC* = 1; langOberon* = 2; langPascal* = 3; langText* = 0; langC* = 1; langOberon* = 2; langPascal* = 3;
langFasm* = 4; langLua* = 5; langIni* = 6; langJSON* = 7; langFasm* = 4; langLua* = 5; langIni* = 6; langJSON* = 7;
csLang = {langC, langOberon, langLua, langIni, langJSON}; csLang = {langC, langOberon, langLua, langIni, langJSON};
@ -317,7 +317,7 @@ END Ini;
PROCEDURE comments* (line: tLine; VAR depth, cond, pos: INTEGER; n: INTEGER; lang: INTEGER); PROCEDURE comments* (line: tLine; VAR depth, cond, pos: INTEGER; n: INTEGER; lang: INTEGER);
BEGIN BEGIN
CASE lang OF CASE lang OF
|langNone: |langText:
|langFasm: |langFasm:
|langC, |langC,
langJSON: C(line, depth, cond, pos, n) langJSON: C(line, depth, cond, pos, n)

View File

@ -20,7 +20,7 @@
MODULE Menu; MODULE Menu;
IMPORT IMPORT
SYSTEM, G := Graph, List, K := KolibriOS, U := Utils, KOSAPI; SYSTEM, G := Graph, List, K := KolibriOS, KOSAPI;
CONST CONST
fontHeight = 22; fontHeight = 22;
@ -91,7 +91,6 @@ VAR
TIDs: ARRAY maxLEVEL + 1 OF INTEGER; TIDs: ARRAY maxLEVEL + 1 OF INTEGER;
resetTimer: tProc; resetTimer: tProc;
_open: PROCEDURE (m: tMenu; x, y: INTEGER); _open: PROCEDURE (m: tMenu; x, y: INTEGER);
(*redraw*: BOOLEAN;*)
(* (*
backColor, foreColor, selBackColor, selForeColor, backColor, foreColor, selBackColor, selForeColor,
disBackColor, disForeColor, disSelBackColor, disSelForeColor: INTEGER; disBackColor, disForeColor, disSelBackColor, disSelForeColor: INTEGER;
@ -354,7 +353,6 @@ BEGIN
close(p); close(p);
p := p.parent p := p.parent
END; END;
(*redraw := TRUE;*)
exit(m) exit(m)
END END
END click; END click;
@ -373,7 +371,6 @@ END isActive;
PROCEDURE closeChild (m: tMenu); PROCEDURE closeChild (m: tMenu);
BEGIN BEGIN
IF m.child # NIL THEN IF m.child # NIL THEN
(*redraw := FALSE;*)
close(m.child); close(m.child);
m.child := NIL m.child := NIL
END END
@ -639,18 +636,11 @@ BEGIN
RETURN m RETURN m
END create; END create;
(*
PROCEDURE Redraw*;
BEGIN
redraw := TRUE
END Redraw;
*)
PROCEDURE init* (_resetTimer: tProc); PROCEDURE init* (_resetTimer: tProc);
VAR VAR
i: INTEGER; i: INTEGER;
BEGIN BEGIN
(*Redraw;*)
resetTimer := _resetTimer; resetTimer := _resetTimer;
_open := open; _open := open;
FOR i := 0 TO maxLEVEL DO FOR i := 0 TO maxLEVEL DO

View File

@ -126,7 +126,7 @@ BEGIN
ELSIF ext = "JSON" THEN ELSIF ext = "JSON" THEN
text.lang := Lang.langJSON text.lang := Lang.langJSON
ELSE ELSE
text.lang := Lang.langNone text.lang := Lang.langText
END END
END setName; END setName;
@ -2057,7 +2057,7 @@ VAR
guard: tGuard; guard: tGuard;
BEGIN BEGIN
IF text.search & search(text, text.searchText, text.cs, text.whole) THEN END; IF text.search & search(text, text.searchText, text.cs, text.whole) THEN END;
IF (text.lang # Lang.langNone) & text.comments THEN IF (text.lang # Lang.langText) & text.comments THEN
Comments(text) Comments(text)
END; END;
IF text.guard THEN IF text.guard THEN
@ -2102,7 +2102,7 @@ BEGIN
SetColor(colors.text, backColor); SetColor(colors.text, backColor);
Len := MAX(line.length - text.scroll.X, 0); Len := MAX(line.length - text.scroll.X, 0);
G.TextOut(canvas, padding.left, y, Lines.getPChar(line, text.scroll.X), MIN(Len, textsize.X + 1)); G.TextOut(canvas, padding.left, y, Lines.getPChar(line, text.scroll.X), MIN(Len, textsize.X + 1));
IF text.lang # Lang.langNone THEN IF text.lang # Lang.langText THEN
parse(text, line, y, backColor, text.lang) parse(text, line, y, backColor, text.lang)
END; END;
mark(line, y - inter DIV 2); mark(line, y - inter DIV 2);
@ -2330,7 +2330,7 @@ BEGIN
ELSE ELSE
errno := 1 errno := 1
END; END;
IF (text # NIL) & (text.lang # Lang.langNone) THEN IF (text # NIL) & (text.lang # Lang.langText) THEN
Comments(text) Comments(text)
END END
RETURN text RETURN text

View File

@ -1,289 +0,0 @@
(*
Copyright 2016, 2017, 2020, 2021 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 box_lib;
IMPORT sys := SYSTEM, KOSAPI;
CONST
CHECKBOX_IS_SET* = 1;
TYPE
checkbox* = POINTER TO RECORD
left_s*: INTEGER;
top_s*: INTEGER;
ch_text_margin*: INTEGER;
color: INTEGER;
border_color: INTEGER;
text_color: INTEGER;
text: INTEGER;
flags*: SET;
(* Users can use members above this *)
size_of_str: INTEGER
END;
scrollbar* = POINTER TO RECORD
x_w: INTEGER;
y_h*: INTEGER;
btn_height: INTEGER;
type: INTEGER;
max_area*: INTEGER;
cur_area*: INTEGER;
position*: INTEGER;
back_color: INTEGER;
front_color: INTEGER;
line_color: INTEGER;
redraw: INTEGER;
delta: WCHAR;
delta2: WCHAR;
r_size_x: WCHAR;
r_start_x: WCHAR;
r_size_y: WCHAR;
r_start_y: WCHAR;
m_pos: INTEGER;
m_pos2: INTEGER;
m_keys: INTEGER;
run_size: INTEGER;
position2: INTEGER;
work_size: INTEGER;
all_redraw: INTEGER;
ar_offset: INTEGER
END;
edit_box* = POINTER TO RECORD
width*,
left*,
top*,
color*,
shift_color,
focus_border_color,
blur_border_color,
text_color*,
max: INTEGER;
text*: INTEGER;
mouse_variable: edit_box;
flags*,
size,
pos: INTEGER;
(* The following struct members are not used by the users of API *)
offset, cl_curs_x, cl_curs_y, shift, shift_old, height, char_width: INTEGER
END;
EditBoxKey = PROCEDURE (eb: edit_box);
VAR
check_box_draw2 *: PROCEDURE (cb: checkbox);
check_box_mouse2 *: PROCEDURE (cb: checkbox);
init_checkbox2 : PROCEDURE (cb: checkbox);
scrollbar_h_draw *: PROCEDURE (sb: scrollbar);
scrollbar_h_mouse *: PROCEDURE (sb: scrollbar);
scrollbar_v_draw *: PROCEDURE (sb: scrollbar);
scrollbar_v_mouse *: PROCEDURE (sb: scrollbar);
edit_box_draw *: PROCEDURE (eb: edit_box);
__edit_box_key : EditBoxKey;
edit_box_mouse *: PROCEDURE (eb: edit_box);
edit_box_set_text *: PROCEDURE (eb: edit_box; text: INTEGER);
PROCEDURE _edit_box_key (key: INTEGER; key_proc: EditBoxKey; text: edit_box);
BEGIN
sys.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 _edit_box_key;
PROCEDURE edit_box_key* (text: edit_box; key: INTEGER);
BEGIN
_edit_box_key(key, __edit_box_key, text)
END edit_box_key;
PROCEDURE edit_box_get_value* (text: edit_box; VAR str: ARRAY OF CHAR);
VAR
ptr, max, i: INTEGER;
BEGIN
ptr := text.text;
max := text.max;
ASSERT(max < LEN(str));
i := 0;
REPEAT
sys.GET(ptr, str[i]);
INC(i);
INC(ptr)
UNTIL (str[i - 1] = 0X) OR (i = max);
str[i] := 0X
END edit_box_get_value;
PROCEDURE memset(adr: INTEGER; c: CHAR; n: INTEGER);
BEGIN
WHILE n > 0 DO
sys.PUT(adr, c);
INC(adr);
DEC(n)
END
END memset;
PROCEDURE check_box_set_value* (cb: checkbox; value: BOOLEAN);
BEGIN
IF cb # NIL THEN
IF value THEN
INCL(cb.flags, CHECKBOX_IS_SET)
ELSE
EXCL(cb.flags, CHECKBOX_IS_SET)
END
END
END check_box_set_value;
PROCEDURE check_box_get_value* (cb: checkbox): BOOLEAN;
VAR res: BOOLEAN;
BEGIN
res := FALSE;
IF cb # NIL THEN
res := CHECKBOX_IS_SET IN cb.flags
END
RETURN res
END check_box_get_value;
PROCEDURE kolibri_new_check_box* (tlx, tly, sizex, sizey: INTEGER; label_text: ARRAY OF CHAR; text_margin: INTEGER): checkbox;
VAR new_checkbox: checkbox;
BEGIN
NEW(new_checkbox);
new_checkbox.left_s := tlx * 65536 + sizex;
new_checkbox.top_s := tly * 65536 + sizey;
new_checkbox.ch_text_margin := text_margin;
new_checkbox.color := 80808080H;
new_checkbox.border_color := 0000FF00H;
new_checkbox.text_color := 00000000H;
new_checkbox.text := KOSAPI.malloc(LENGTH(label_text) + 1);
sys.MOVE(sys.ADR(label_text[0]), new_checkbox.text, LENGTH(label_text));
new_checkbox.flags := {3};
init_checkbox2(new_checkbox)
RETURN new_checkbox
END kolibri_new_check_box;
PROCEDURE kolibri_scrollbar*(sb: scrollbar; x_w, y_h, btn_height, max_area, cur_area, position, back_color, front_color, line_color: INTEGER): scrollbar;
BEGIN
memset(sys.ADR(sb^), 0X, sys.SIZE(scrollbar));
sb.x_w := x_w;
sb.y_h := y_h;
sb.btn_height := btn_height;
sb.type := 1;
sb.max_area := max_area;
sb.cur_area := cur_area;
sb.position := position;
sb.line_color := line_color;
sb.back_color := back_color;
sb.front_color := front_color;
sb.ar_offset := 1;
sb.all_redraw := 1
RETURN sb
END kolibri_scrollbar;
PROCEDURE kolibri_new_scrollbar*(x_w, y_h, btn_height, max_area, cur_area, position, back_color, front_color, line_color: INTEGER): scrollbar;
VAR sb: scrollbar;
BEGIN
NEW(sb);
RETURN kolibri_scrollbar(sb, x_w, y_h, btn_height, max_area, cur_area, position, back_color, front_color, line_color)
END kolibri_new_scrollbar;
PROCEDURE kolibri_new_edit_box* (tlx, tly, width, max_chars: INTEGER; editbox_interlock: edit_box): edit_box;
VAR
new_textbox: edit_box;
BEGIN
NEW(new_textbox);
new_textbox.width := width;
new_textbox.left := tlx;
new_textbox.top := tly;
new_textbox.color := 0FFFFFFH;
new_textbox.shift_color := 06A9480H;
new_textbox.focus_border_color := 0;
new_textbox.blur_border_color := 06A9480H;
new_textbox.text_color := 0;
new_textbox.max := max_chars;
new_textbox.text := KOSAPI.malloc(max_chars + 2);
ASSERT(new_textbox.text # 0);
new_textbox.mouse_variable := editbox_interlock;
new_textbox.flags := 0
RETURN new_textbox
END kolibri_new_edit_box;
PROCEDURE main;
VAR Lib: INTEGER;
PROCEDURE GetProc(Lib, v: INTEGER; name: ARRAY OF CHAR);
VAR a: INTEGER;
BEGIN
a := KOSAPI.GetProcAdr(name, Lib);
ASSERT(a # 0);
sys.PUT(v, a)
END GetProc;
BEGIN
Lib := KOSAPI.LoadLib("/rd/1/lib/box_lib.obj");
ASSERT(Lib # 0);
GetProc(Lib, sys.ADR(check_box_draw2), "check_box_draw2");
GetProc(Lib, sys.ADR(check_box_mouse2), "check_box_mouse2");
GetProc(Lib, sys.ADR(init_checkbox2), "init_checkbox2");
GetProc(Lib, sys.ADR(scrollbar_h_draw), "scrollbar_h_draw");
GetProc(Lib, sys.ADR(scrollbar_h_mouse), "scrollbar_h_mouse");
GetProc(Lib, sys.ADR(scrollbar_v_draw), "scrollbar_v_draw");
GetProc(Lib, sys.ADR(scrollbar_v_mouse), "scrollbar_v_mouse");
GetProc(Lib, sys.ADR(edit_box_draw), "edit_box");
GetProc(Lib, sys.ADR(__edit_box_key), "edit_box_key");
GetProc(Lib, sys.ADR(edit_box_mouse), "edit_box_mouse");
GetProc(Lib, sys.ADR(edit_box_set_text), "edit_box_set_text");
END main;
BEGIN
main
END box_lib.