forked from KolibriOS/kolibrios
CEdit: refactoring
oberon07: update examples git-svn-id: svn://kolibrios.org@9648 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
3cace9dd7a
commit
0eb1f22eab
Binary file not shown.
@ -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 (16-jan-2022)";
|
HEADER = "CEdit (18-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";
|
||||||
@ -169,6 +169,9 @@ CONST
|
|||||||
|
|
||||||
maxTexts = 32;
|
maxTexts = 32;
|
||||||
|
|
||||||
|
SHIFT = Menu.SHIFT;
|
||||||
|
CTRL = Menu.CTRL;
|
||||||
|
|
||||||
|
|
||||||
VAR
|
VAR
|
||||||
header: RW.tFileName;
|
header: RW.tFileName;
|
||||||
@ -199,8 +202,6 @@ VAR
|
|||||||
|
|
||||||
replaced: INTEGER;
|
replaced: INTEGER;
|
||||||
|
|
||||||
mainTID: INTEGER;
|
|
||||||
|
|
||||||
context, menuFile, menuEdit, menuSearch, menuEncoding,
|
context, menuFile, menuEdit, menuSearch, menuEncoding,
|
||||||
menuView, menuLanguage, menuProgram, menuTools,
|
menuView, menuLanguage, menuProgram, menuTools,
|
||||||
subCurLine, subIndent, subCase, subBookmark, subEOL: Menu.tMenu;
|
subCurLine, subIndent, subCase, subBookmark, subEOL: Menu.tMenu;
|
||||||
@ -211,8 +212,6 @@ VAR
|
|||||||
|
|
||||||
toolbar: Toolbar.tToolbar;
|
toolbar: Toolbar.tToolbar;
|
||||||
|
|
||||||
IPC: ARRAY 64 OF INTEGER;
|
|
||||||
|
|
||||||
CursorTime, CurrentTime: INTEGER;
|
CursorTime, CurrentTime: INTEGER;
|
||||||
timerEnabled: BOOLEAN;
|
timerEnabled: BOOLEAN;
|
||||||
|
|
||||||
@ -924,16 +923,6 @@ BEGIN
|
|||||||
END CloseMenu;
|
END CloseMenu;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE MenuItemClick (menu: Menu.tMenu; id: INTEGER);
|
|
||||||
VAR
|
|
||||||
msg: ARRAY 2 OF INTEGER;
|
|
||||||
BEGIN
|
|
||||||
msg[0] := id;
|
|
||||||
msg[1] := 8;
|
|
||||||
K.SendIPC(mainTID, msg)
|
|
||||||
END MenuItemClick;
|
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE goto;
|
PROCEDURE goto;
|
||||||
VAR
|
VAR
|
||||||
gotoVal: INTEGER;
|
gotoVal: INTEGER;
|
||||||
@ -1114,34 +1103,18 @@ BEGIN
|
|||||||
END setScript;
|
END setScript;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE receiveIPC;
|
PROCEDURE ClickMenu;
|
||||||
VAR
|
VAR
|
||||||
scrollIPC: BOOLEAN;
|
|
||||||
item: List.tItem;
|
item: List.tItem;
|
||||||
BEGIN
|
BEGIN
|
||||||
scrollIPC := FALSE;
|
IF Menu.MenuItem < 0 THEN
|
||||||
IF IPC[0] = mainTID THEN
|
item := List.getItem(mainMenu, (-Menu.MenuItem - mainMenuBtn) MOD mainMenu.count);
|
||||||
IF IPC[2] = Scroll.ScrollIPC THEN
|
|
||||||
Scroll.receiveIPC(IPC, scrollIPC)
|
|
||||||
END;
|
|
||||||
IF ~scrollIPC THEN
|
|
||||||
IPC[2] := 0
|
|
||||||
END
|
|
||||||
ELSE
|
|
||||||
IF ~Menu.isSender(IPC[0]) THEN
|
|
||||||
IPC[2] := 0
|
|
||||||
ELSE
|
|
||||||
IF IPC[2] < 0 THEN
|
|
||||||
item := List.getItem(mainMenu, (-IPC[2] - mainMenuBtn) MOD mainMenu.count);
|
|
||||||
IF item # NIL THEN
|
IF item # NIL THEN
|
||||||
ShowMenu(item(Menu.tMainItem).menu)
|
ShowMenu(item(Menu.tMainItem).menu)
|
||||||
END;
|
END;
|
||||||
IPC[2] := 0
|
Menu.SetItem(0)
|
||||||
END
|
|
||||||
END
|
|
||||||
END;
|
END;
|
||||||
IF ~scrollIPC THEN
|
CASE Menu.MenuItem OF
|
||||||
CASE IPC[2] OF
|
|
||||||
|0:
|
|0:
|
||||||
|menuCut: T.key(text, ORD("X"), FALSE, TRUE)
|
|menuCut: T.key(text, ORD("X"), FALSE, TRUE)
|
||||||
|menuCopy: T.key(text, ORD("C"), FALSE, TRUE)
|
|menuCopy: T.key(text, ORD("C"), FALSE, TRUE)
|
||||||
@ -1250,7 +1223,7 @@ BEGIN
|
|||||||
|menuSysFunc:
|
|menuSysFunc:
|
||||||
K.Run("/sys/docpack", "f")
|
K.Run("/sys/docpack", "f")
|
||||||
|menuColors..menuMaxColors:
|
|menuColors..menuMaxColors:
|
||||||
Ini.selectSection(IPC[2] - menuColors)
|
Ini.selectSection(Menu.MenuItem - menuColors)
|
||||||
|menuMoveUp:
|
|menuMoveUp:
|
||||||
T.MoveLines(text, FALSE)
|
T.MoveLines(text, FALSE)
|
||||||
|menuMoveDown:
|
|menuMoveDown:
|
||||||
@ -1268,70 +1241,8 @@ BEGIN
|
|||||||
|menuLower:
|
|menuLower:
|
||||||
T.chCase(text, FALSE)
|
T.chCase(text, FALSE)
|
||||||
END;
|
END;
|
||||||
IPC[0] := 0;
|
Menu.SetItem(0)
|
||||||
IPC[1] := 0
|
END ClickMenu;
|
||||||
END
|
|
||||||
END receiveIPC;
|
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE MenuKeyDown (menu: Menu.tMenu; key: INTEGER): BOOLEAN;
|
|
||||||
VAR
|
|
||||||
menuItem: INTEGER;
|
|
||||||
shift, ctrl: BOOLEAN;
|
|
||||||
BEGIN
|
|
||||||
menuItem := -1;
|
|
||||||
K.getKBState(shift, ctrl);
|
|
||||||
IF ctrl THEN
|
|
||||||
CASE key DIV 65536 OF
|
|
||||||
|17: menuItem := menuClose
|
|
||||||
|21: menuItem := menuRedo
|
|
||||||
|30: menuItem := menuSelectAll
|
|
||||||
|32: menuItem := menuDuplicate
|
|
||||||
|33,
|
|
||||||
35: menuItem := menuFind
|
|
||||||
|34: menuItem := menuGoto
|
|
||||||
|44: menuItem := menuUndo
|
|
||||||
|45: menuItem := menuCut
|
|
||||||
|46: menuItem := menuCopy
|
|
||||||
|47: menuItem := menuPaste
|
|
||||||
|24: menuItem := menuOpen
|
|
||||||
|31: menuItem := menuSave
|
|
||||||
|49: menuItem := menuNew
|
|
||||||
|67: menuItem := menuBuild
|
|
||||||
|83: menuItem := menuRemove
|
|
||||||
|22: menuItem := menuUpper
|
|
||||||
|38: menuItem := menuLower
|
|
||||||
|60: menuItem := menuToggleBookmark
|
|
||||||
|72: menuItem := menuMoveUp
|
|
||||||
|80: menuItem := menuMoveDown
|
|
||||||
ELSE
|
|
||||||
END
|
|
||||||
ELSE
|
|
||||||
IF key DIV 65536 = 83 THEN
|
|
||||||
menuItem := menuDelete
|
|
||||||
ELSIF key DIV 65536 = 67 THEN
|
|
||||||
menuItem := menuRun
|
|
||||||
ELSIF key DIV 65536 = 15 THEN
|
|
||||||
menuItem := menuIncInd
|
|
||||||
ELSIF (key DIV 65536 = 14) & shift THEN
|
|
||||||
menuItem := menuDecInd
|
|
||||||
ELSIF key DIV 65536 = 60 THEN
|
|
||||||
IF shift THEN
|
|
||||||
menuItem := menuPrevBookmark
|
|
||||||
ELSE
|
|
||||||
menuItem := menuNextBookmark
|
|
||||||
END
|
|
||||||
END
|
|
||||||
END;
|
|
||||||
IF menuItem # -1 THEN
|
|
||||||
IF Menu.isEnabled(menu, menuItem) THEN
|
|
||||||
MenuItemClick(menu, menuItem)
|
|
||||||
ELSE
|
|
||||||
menuItem := -1
|
|
||||||
END
|
|
||||||
END
|
|
||||||
RETURN menuItem # -1
|
|
||||||
END MenuKeyDown;
|
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE CreateContextMenu (): Menu.tMenu;
|
PROCEDURE CreateContextMenu (): Menu.tMenu;
|
||||||
@ -1348,7 +1259,7 @@ BEGIN
|
|||||||
Menu.AddMenuItem(menu, menuDelete, "delete");
|
Menu.AddMenuItem(menu, menuDelete, "delete");
|
||||||
Menu.delimiter(menu);
|
Menu.delimiter(menu);
|
||||||
Menu.AddMenuItem(menu, menuSelectAll, "select all ctrl-A");
|
Menu.AddMenuItem(menu, menuSelectAll, "select all ctrl-A");
|
||||||
RETURN Menu.create(menu, MenuItemClick, MenuKeyDown)
|
RETURN Menu.create(menu)
|
||||||
END CreateContextMenu;
|
END CreateContextMenu;
|
||||||
|
|
||||||
|
|
||||||
@ -1367,7 +1278,7 @@ BEGIN
|
|||||||
Menu.AddMenuItem(menu, menuClose, "close ctrl-W");
|
Menu.AddMenuItem(menu, menuClose, "close ctrl-W");
|
||||||
Menu.delimiter(menu);
|
Menu.delimiter(menu);
|
||||||
Menu.AddMenuItem(menu, menuExit, "exit");
|
Menu.AddMenuItem(menu, menuExit, "exit");
|
||||||
RETURN Menu.create(menu, MenuItemClick, MenuKeyDown)
|
RETURN Menu.create(menu)
|
||||||
END CreateMenuFile;
|
END CreateMenuFile;
|
||||||
|
|
||||||
|
|
||||||
@ -1392,7 +1303,7 @@ BEGIN
|
|||||||
Menu.child(menu, subIndent);
|
Menu.child(menu, subIndent);
|
||||||
Menu.AddMenuItem(menu, menuCase, "case");
|
Menu.AddMenuItem(menu, menuCase, "case");
|
||||||
Menu.child(menu, subCase);
|
Menu.child(menu, subCase);
|
||||||
RETURN Menu.create(menu, MenuItemClick, MenuKeyDown)
|
RETURN Menu.create(menu)
|
||||||
END CreateMenuEdit;
|
END CreateMenuEdit;
|
||||||
|
|
||||||
|
|
||||||
@ -1408,7 +1319,7 @@ BEGIN
|
|||||||
Menu.delimiter(menu);
|
Menu.delimiter(menu);
|
||||||
Menu.AddMenuItem(menu, menuBookmark, "bookmark");
|
Menu.AddMenuItem(menu, menuBookmark, "bookmark");
|
||||||
Menu.child(menu, subBookmark);
|
Menu.child(menu, subBookmark);
|
||||||
RETURN Menu.create(menu, MenuItemClick, MenuKeyDown)
|
RETURN Menu.create(menu)
|
||||||
END CreateMenuSearch;
|
END CreateMenuSearch;
|
||||||
|
|
||||||
|
|
||||||
@ -1424,7 +1335,7 @@ BEGIN
|
|||||||
Menu.delimiter(menu);
|
Menu.delimiter(menu);
|
||||||
Menu.AddMenuItem(menu, menuEOL, "EOL");
|
Menu.AddMenuItem(menu, menuEOL, "EOL");
|
||||||
Menu.child(menu, subEOL);
|
Menu.child(menu, subEOL);
|
||||||
RETURN Menu.create(menu, MenuItemClick, MenuKeyDown)
|
RETURN Menu.create(menu)
|
||||||
END CreateMenuEncoding;
|
END CreateMenuEncoding;
|
||||||
|
|
||||||
|
|
||||||
@ -1436,7 +1347,7 @@ BEGIN
|
|||||||
Menu.AddMenuItem(menu, menuCRLF, RW.eolNames[RW.EOL_CRLF]);
|
Menu.AddMenuItem(menu, menuCRLF, RW.eolNames[RW.EOL_CRLF]);
|
||||||
Menu.AddMenuItem(menu, menuLF, RW.eolNames[RW.EOL_LF]);
|
Menu.AddMenuItem(menu, menuLF, RW.eolNames[RW.EOL_LF]);
|
||||||
Menu.AddMenuItem(menu, menuCR, RW.eolNames[RW.EOL_CR]);
|
Menu.AddMenuItem(menu, menuCR, RW.eolNames[RW.EOL_CR]);
|
||||||
RETURN Menu.create(menu, MenuItemClick, MenuKeyDown)
|
RETURN Menu.create(menu)
|
||||||
END CreateMenuEOL;
|
END CreateMenuEOL;
|
||||||
|
|
||||||
|
|
||||||
@ -1459,7 +1370,7 @@ BEGIN
|
|||||||
colors := colors.next(Ini.tSection)
|
colors := colors.next(Ini.tSection)
|
||||||
END;
|
END;
|
||||||
|
|
||||||
RETURN Menu.create(menu, MenuItemClick, MenuKeyDown)
|
RETURN Menu.create(menu)
|
||||||
END CreateMenuView;
|
END CreateMenuView;
|
||||||
|
|
||||||
|
|
||||||
@ -1477,7 +1388,7 @@ BEGIN
|
|||||||
Menu.AddMenuItem(menu, menuPascal, "Pascal");
|
Menu.AddMenuItem(menu, menuPascal, "Pascal");
|
||||||
Menu.delimiter(menu);
|
Menu.delimiter(menu);
|
||||||
Menu.AddMenuItem(menu, menuText, "Text");
|
Menu.AddMenuItem(menu, menuText, "Text");
|
||||||
RETURN Menu.create(menu, MenuItemClick, MenuKeyDown)
|
RETURN Menu.create(menu)
|
||||||
END CreateMenuLanguage;
|
END CreateMenuLanguage;
|
||||||
|
|
||||||
|
|
||||||
@ -1494,7 +1405,7 @@ BEGIN
|
|||||||
Menu.delimiter(menu);
|
Menu.delimiter(menu);
|
||||||
Menu.AddMenuItem(menu, menuDebug, "debug");
|
Menu.AddMenuItem(menu, menuDebug, "debug");
|
||||||
Menu.AddMenuItem(menu, menuDebugScript, "script");
|
Menu.AddMenuItem(menu, menuDebugScript, "script");
|
||||||
RETURN Menu.create(menu, MenuItemClick, MenuKeyDown)
|
RETURN Menu.create(menu)
|
||||||
END CreateMenuProgram;
|
END CreateMenuProgram;
|
||||||
|
|
||||||
|
|
||||||
@ -1507,7 +1418,7 @@ BEGIN
|
|||||||
Menu.AddMenuItem(menu, menuMagnify, "magnify");
|
Menu.AddMenuItem(menu, menuMagnify, "magnify");
|
||||||
Menu.AddMenuItem(menu, menuBoard, "board");
|
Menu.AddMenuItem(menu, menuBoard, "board");
|
||||||
Menu.AddMenuItem(menu, menuSysFunc, "system functions");
|
Menu.AddMenuItem(menu, menuSysFunc, "system functions");
|
||||||
RETURN Menu.create(menu, MenuItemClick, MenuKeyDown)
|
RETURN Menu.create(menu)
|
||||||
END CreateMenuTools;
|
END CreateMenuTools;
|
||||||
|
|
||||||
|
|
||||||
@ -1520,7 +1431,7 @@ BEGIN
|
|||||||
Menu.AddMenuItem(menu, menuMoveDown, "move down ctrl-Down");
|
Menu.AddMenuItem(menu, menuMoveDown, "move down ctrl-Down");
|
||||||
Menu.AddMenuItem(menu, menuDuplicate, "duplicate ctrl-D");
|
Menu.AddMenuItem(menu, menuDuplicate, "duplicate ctrl-D");
|
||||||
Menu.AddMenuItem(menu, menuRemove, "remove ctrl-Del");
|
Menu.AddMenuItem(menu, menuRemove, "remove ctrl-Del");
|
||||||
RETURN Menu.create(menu, MenuItemClick, MenuKeyDown)
|
RETURN Menu.create(menu)
|
||||||
END CreateMenuCurLine;
|
END CreateMenuCurLine;
|
||||||
|
|
||||||
|
|
||||||
@ -1531,7 +1442,7 @@ BEGIN
|
|||||||
menu := List.create(NIL);
|
menu := List.create(NIL);
|
||||||
Menu.AddMenuItem(menu, menuIncInd, "increase Tab");
|
Menu.AddMenuItem(menu, menuIncInd, "increase Tab");
|
||||||
Menu.AddMenuItem(menu, menuDecInd, "decrease shift-Bksp");
|
Menu.AddMenuItem(menu, menuDecInd, "decrease shift-Bksp");
|
||||||
RETURN Menu.create(menu, MenuItemClick, MenuKeyDown)
|
RETURN Menu.create(menu)
|
||||||
END CreateMenuIndent;
|
END CreateMenuIndent;
|
||||||
|
|
||||||
|
|
||||||
@ -1542,7 +1453,7 @@ BEGIN
|
|||||||
menu := List.create(NIL);
|
menu := List.create(NIL);
|
||||||
Menu.AddMenuItem(menu, menuUpper, "UPPER ctrl-U");
|
Menu.AddMenuItem(menu, menuUpper, "UPPER ctrl-U");
|
||||||
Menu.AddMenuItem(menu, menuLower, "lower ctrl-L");
|
Menu.AddMenuItem(menu, menuLower, "lower ctrl-L");
|
||||||
RETURN Menu.create(menu, MenuItemClick, MenuKeyDown)
|
RETURN Menu.create(menu)
|
||||||
END CreateMenuCase;
|
END CreateMenuCase;
|
||||||
|
|
||||||
|
|
||||||
@ -1554,10 +1465,44 @@ BEGIN
|
|||||||
Menu.AddMenuItem(menu, menuToggleBookmark, "toggle ctrl-F2");
|
Menu.AddMenuItem(menu, menuToggleBookmark, "toggle ctrl-F2");
|
||||||
Menu.AddMenuItem(menu, menuNextBookmark, "next F2");
|
Menu.AddMenuItem(menu, menuNextBookmark, "next F2");
|
||||||
Menu.AddMenuItem(menu, menuPrevBookmark, "previous shift-F2");
|
Menu.AddMenuItem(menu, menuPrevBookmark, "previous shift-F2");
|
||||||
RETURN Menu.create(menu, MenuItemClick, MenuKeyDown)
|
RETURN Menu.create(menu)
|
||||||
END CreateMenuBookmark;
|
END CreateMenuBookmark;
|
||||||
|
|
||||||
|
|
||||||
|
PROCEDURE Shortcuts;
|
||||||
|
BEGIN
|
||||||
|
Menu.AddShortcut(17 + CTRL, menuClose);
|
||||||
|
Menu.AddShortcut(21 + CTRL, menuRedo);
|
||||||
|
Menu.AddShortcut(30 + CTRL, menuSelectAll);
|
||||||
|
Menu.AddShortcut(32 + CTRL, menuDuplicate);
|
||||||
|
Menu.AddShortcut(33 + CTRL, menuFind);
|
||||||
|
Menu.AddShortcut(35 + CTRL, menuFind);
|
||||||
|
Menu.AddShortcut(34 + CTRL, menuGoto);
|
||||||
|
Menu.AddShortcut(44 + CTRL, menuUndo);
|
||||||
|
Menu.AddShortcut(45 + CTRL, menuCut);
|
||||||
|
Menu.AddShortcut(46 + CTRL, menuCopy);
|
||||||
|
Menu.AddShortcut(47 + CTRL, menuPaste);
|
||||||
|
Menu.AddShortcut(24 + CTRL, menuOpen);
|
||||||
|
Menu.AddShortcut(31 + CTRL, menuSave);
|
||||||
|
Menu.AddShortcut(49 + CTRL, menuNew);
|
||||||
|
Menu.AddShortcut(67 + CTRL, menuBuild);
|
||||||
|
Menu.AddShortcut(83 + CTRL, menuRemove);
|
||||||
|
Menu.AddShortcut(22 + CTRL, menuUpper);
|
||||||
|
Menu.AddShortcut(38 + CTRL, menuLower);
|
||||||
|
Menu.AddShortcut(60 + CTRL, menuToggleBookmark);
|
||||||
|
Menu.AddShortcut(72 + CTRL, menuMoveUp);
|
||||||
|
Menu.AddShortcut(80 + CTRL, menuMoveDown);
|
||||||
|
Menu.AddShortcut(83, menuDelete);
|
||||||
|
Menu.AddShortcut(67, menuRun);
|
||||||
|
Menu.AddShortcut(15, menuIncInd);
|
||||||
|
Menu.AddShortcut(14 + SHIFT, menuDecInd);
|
||||||
|
Menu.AddShortcut(60 + SHIFT, menuPrevBookmark);
|
||||||
|
Menu.AddShortcut(60, menuNextBookmark);
|
||||||
|
Menu.AddShortcut(61 + SHIFT, menuFindPrev);
|
||||||
|
Menu.AddShortcut(61, menuFindNext);
|
||||||
|
END Shortcuts;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE HideSearch;
|
PROCEDURE HideSearch;
|
||||||
BEGIN
|
BEGIN
|
||||||
SetFocus(FindEdit, FALSE);
|
SetFocus(FindEdit, FALSE);
|
||||||
@ -1732,6 +1677,7 @@ VAR
|
|||||||
middle, exit: BOOLEAN;
|
middle, exit: BOOLEAN;
|
||||||
menu: Menu.tMenu;
|
menu: Menu.tMenu;
|
||||||
BEGIN
|
BEGIN
|
||||||
|
exit := FALSE;
|
||||||
btn := K.ButtonCode(middle);
|
btn := K.ButtonCode(middle);
|
||||||
IF U.between(Tabs.btnID, btn, Tabs.btnID + maxTexts - 1) THEN
|
IF U.between(Tabs.btnID, btn, Tabs.btnID + maxTexts - 1) THEN
|
||||||
DEC(btn, Tabs.btnID);
|
DEC(btn, Tabs.btnID);
|
||||||
@ -1756,58 +1702,45 @@ BEGIN
|
|||||||
btn := 0
|
btn := 0
|
||||||
END
|
END
|
||||||
END;
|
END;
|
||||||
|
|
||||||
CASE btn OF
|
CASE btn OF
|
||||||
|Tabs.btnLeft: Tabs.scroll(tabs, -1); switch := TRUE; repaint
|
|
||||||
|Tabs.btnRight: Tabs.scroll(tabs, +1); switch := TRUE; repaint
|
|
||||||
|
|
||||||
|0:
|
|0:
|
||||||
|
|Tabs.btnLeft, Tabs.btnRight:
|
||||||
|
Tabs.scroll(tabs, btn);
|
||||||
|
switch := TRUE
|
||||||
|btnNo:
|
|btnNo:
|
||||||
exit := closing;
|
exit := closing;
|
||||||
closeFile(FALSE, curText);
|
closeFile(FALSE, curText);
|
||||||
repaint;
|
repaint
|
||||||
IF exit THEN
|
|
||||||
Close
|
|
||||||
END
|
|
||||||
|btnYes:
|
|btnYes:
|
||||||
exit := closing;
|
exit := closing;
|
||||||
save(text);
|
save(text);
|
||||||
IF ~text.modified THEN
|
IF ~text.modified THEN
|
||||||
closeFile(FALSE, curText)
|
closeFile(FALSE, curText)
|
||||||
END;
|
END;
|
||||||
repaint;
|
|
||||||
IF exit THEN
|
|
||||||
Close
|
|
||||||
END
|
|
||||||
|btnClose:
|
|
||||||
Close
|
|
||||||
|btnNew:
|
|
||||||
NewFile;
|
|
||||||
repaint
|
repaint
|
||||||
|
|btnClose:
|
||||||
|
exit := TRUE
|
||||||
|
|btnNew:
|
||||||
|
NewFile
|
||||||
|btnOpen:
|
|btnOpen:
|
||||||
OpenDial
|
OpenDial
|
||||||
|btnSave:
|
|btnSave:
|
||||||
save(text);
|
save(text)
|
||||||
repaint
|
|
||||||
|btnSearch:
|
|btnSearch:
|
||||||
ShowSearchPanel(FALSE);
|
ShowSearchPanel(FALSE)
|
||||||
repaint
|
|
||||||
|btnCloseSearch:
|
|btnCloseSearch:
|
||||||
Search
|
Search
|
||||||
|btnHideSearch:
|
|btnHideSearch:
|
||||||
HideSearch
|
HideSearch
|
||||||
|btnUndo:
|
|btnUndo:
|
||||||
T.undo(text);
|
T.undo(text)
|
||||||
repaint
|
|
||||||
|btnRedo:
|
|btnRedo:
|
||||||
T.redo(text);
|
T.redo(text)
|
||||||
repaint
|
|
||||||
|btnUpper:
|
|btnUpper:
|
||||||
T.chCase(text, TRUE);
|
T.chCase(text, TRUE)
|
||||||
repaint
|
|
||||||
|btnLower:
|
|btnLower:
|
||||||
T.chCase(text, FALSE);
|
T.chCase(text, FALSE)
|
||||||
repaint
|
|
||||||
|btnBuild:
|
|btnBuild:
|
||||||
Script(buildScript)
|
Script(buildScript)
|
||||||
|btnRun:
|
|btnRun:
|
||||||
@ -1815,22 +1748,24 @@ BEGIN
|
|||||||
|btnFindNext:
|
|btnFindNext:
|
||||||
IF searchText # "" THEN
|
IF searchText # "" THEN
|
||||||
notFound := ~T.findNext(text, BKW.value);
|
notFound := ~T.findNext(text, BKW.value);
|
||||||
SetFocus(FindEdit, FALSE);
|
SetFocus(FindEdit, FALSE)
|
||||||
repaint
|
|
||||||
END
|
END
|
||||||
|btnReplace:
|
|btnReplace:
|
||||||
T.replace(text, replaceText, LENGTH(searchText));
|
T.replace(text, replaceText, LENGTH(searchText));
|
||||||
SetFocus(FindEdit, FALSE);
|
SetFocus(FindEdit, FALSE)
|
||||||
repaint
|
|
||||||
|btnReplaceAll:
|
|btnReplaceAll:
|
||||||
notFound := ~T.search(text, searchText, cs, whole);
|
notFound := ~T.search(text, searchText, cs, whole);
|
||||||
IF ~notFound THEN
|
IF ~notFound THEN
|
||||||
replaced := T.replaceAll(text, replaceText, LENGTH(searchText));
|
replaced := T.replaceAll(text, replaceText, LENGTH(searchText));
|
||||||
END;
|
END;
|
||||||
SetFocus(FindEdit, FALSE);
|
SetFocus(FindEdit, FALSE)
|
||||||
repaint
|
|
||||||
|btnGoto:
|
|btnGoto:
|
||||||
goto;
|
goto
|
||||||
|
END;
|
||||||
|
|
||||||
|
IF exit THEN
|
||||||
|
Close
|
||||||
|
ELSE
|
||||||
repaint
|
repaint
|
||||||
END
|
END
|
||||||
END BtnClick;
|
END BtnClick;
|
||||||
@ -1884,6 +1819,7 @@ BEGIN
|
|||||||
|
|
||||||
Scroll.mouse(hScroll);
|
Scroll.mouse(hScroll);
|
||||||
Scroll.mouse(vScroll);
|
Scroll.mouse(vScroll);
|
||||||
|
msState := K.MouseState();
|
||||||
T.getScroll(text, scrollX, scrollY);
|
T.getScroll(text, scrollX, scrollY);
|
||||||
IF (hScroll.value # scrollX) OR (vScroll.value # scrollY) THEN
|
IF (hScroll.value # scrollX) OR (vScroll.value # scrollY) THEN
|
||||||
T.scroll(text, hScroll.value - scrollX, vScroll.value - scrollY);
|
T.scroll(text, hScroll.value - scrollX, vScroll.value - scrollY);
|
||||||
@ -1935,7 +1871,13 @@ END MouseEvent;
|
|||||||
|
|
||||||
|
|
||||||
PROCEDURE Redraw (VAR resized: BOOLEAN; VAR width, height, cliWidth, cliHeight: INTEGER);
|
PROCEDURE Redraw (VAR resized: BOOLEAN; VAR width, height, cliWidth, cliHeight: INTEGER);
|
||||||
|
VAR
|
||||||
|
onClose: BOOLEAN;
|
||||||
BEGIN
|
BEGIN
|
||||||
|
onClose := (Menu.MenuItem = menuClose) OR (Menu.MenuItem = menuExit);
|
||||||
|
IF ~onClose THEN
|
||||||
|
ClickMenu
|
||||||
|
END;
|
||||||
K.GetSystemColors;
|
K.GetSystemColors;
|
||||||
IF ~K.RolledUp() THEN
|
IF ~K.RolledUp() THEN
|
||||||
K.ClientSize(width, height);
|
K.ClientSize(width, height);
|
||||||
@ -1945,7 +1887,7 @@ BEGIN
|
|||||||
resize;
|
resize;
|
||||||
resized := TRUE
|
resized := TRUE
|
||||||
END;
|
END;
|
||||||
K.SetEventsMask({0, 1, 2, 5, 6, 31})
|
K.SetEventsMask({0, 1, 2, 5, 31})
|
||||||
ELSE
|
ELSE
|
||||||
SetCaption(text.fileName);
|
SetCaption(text.fileName);
|
||||||
K.SetEventsMask({0, 30, 31})
|
K.SetEventsMask({0, 30, 31})
|
||||||
@ -1954,15 +1896,16 @@ BEGIN
|
|||||||
IF SkinHeight # K.SkinHeight() THEN
|
IF SkinHeight # K.SkinHeight() THEN
|
||||||
SkinHeight := K.SkinHeight();
|
SkinHeight := K.SkinHeight();
|
||||||
Redraw(resized, width, height, cliWidth, cliHeight)
|
Redraw(resized, width, height, cliWidth, cliHeight)
|
||||||
|
END;
|
||||||
|
IF onClose THEN
|
||||||
|
ClickMenu
|
||||||
END
|
END
|
||||||
END Redraw;
|
END Redraw;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE ScrollChange;
|
PROCEDURE ScrollChange;
|
||||||
BEGIN
|
BEGIN
|
||||||
Scroll.change(hScroll);
|
T.scroll(text, hScroll.btn, vScroll.btn);
|
||||||
Scroll.change(vScroll);
|
|
||||||
T.scroll(text, ORD(hScroll.Inc) - ORD(hScroll.Dec), ORD(vScroll.Inc) - ORD(vScroll.Dec));
|
|
||||||
IF menuActive THEN
|
IF menuActive THEN
|
||||||
draw_window;
|
draw_window;
|
||||||
menuActive := FALSE
|
menuActive := FALSE
|
||||||
@ -1985,8 +1928,6 @@ BEGIN
|
|||||||
closing := FALSE;
|
closing := FALSE;
|
||||||
textsCount := 0;
|
textsCount := 0;
|
||||||
curText := 0;
|
curText := 0;
|
||||||
mainTID := K.ThreadID();
|
|
||||||
K.SetIPC(IPC);
|
|
||||||
Args.GetArg(0, AppPath);
|
Args.GetArg(0, AppPath);
|
||||||
Ini.load(AppPath);
|
Ini.load(AppPath);
|
||||||
leftButton := FALSE;
|
leftButton := FALSE;
|
||||||
@ -2010,6 +1951,7 @@ BEGIN
|
|||||||
T.init(resetTimer);
|
T.init(resetTimer);
|
||||||
T.setCanvas(canvas);
|
T.setCanvas(canvas);
|
||||||
|
|
||||||
|
Menu.init(resetTimer);
|
||||||
context := CreateContextMenu();
|
context := CreateContextMenu();
|
||||||
menuFile := CreateMenuFile();
|
menuFile := CreateMenuFile();
|
||||||
subCurLine := CreateMenuCurLine();
|
subCurLine := CreateMenuCurLine();
|
||||||
@ -2039,6 +1981,7 @@ BEGIN
|
|||||||
Menu.AddMainItem(mainMenu, "language", menuLanguage);
|
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);
|
||||||
|
Shortcuts;
|
||||||
|
|
||||||
Toolbar.create(toolbar, LEFT_PADDING + 5, toolbarTop);
|
Toolbar.create(toolbar, LEFT_PADDING + 5, toolbarTop);
|
||||||
Toolbar.add(toolbar, btnNew, 2, "");
|
Toolbar.add(toolbar, btnNew, 2, "");
|
||||||
@ -2075,9 +2018,8 @@ BEGIN
|
|||||||
END;
|
END;
|
||||||
SwitchTab(textsCount - 1);
|
SwitchTab(textsCount - 1);
|
||||||
|
|
||||||
Scroll.init(ScrollChange);
|
Scroll.create(FALSE, canvas.width + 1, scrollWidth, scrollWidth, scrollWidth*3 DIV 2, ScrollChange, 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, ScrollChange, 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);
|
||||||
confirm := FALSE;
|
confirm := FALSE;
|
||||||
notFound := FALSE;
|
notFound := FALSE;
|
||||||
@ -2094,8 +2036,7 @@ BEGIN
|
|||||||
|
|
||||||
OD := OpenDlg.Create(draw_window, OpenDlg.topen, filePath, "");
|
OD := OpenDlg.Create(draw_window, OpenDlg.topen, filePath, "");
|
||||||
|
|
||||||
K.SetEventsMask({0, 1, 2, 5, 6, 31});
|
K.SetEventsMask({0, 1, 2, 5, 31});
|
||||||
Menu.init(resetTimer);
|
|
||||||
draw_window;
|
draw_window;
|
||||||
blink := Ini.blink;
|
blink := Ini.blink;
|
||||||
IF blink <= 0 THEN
|
IF blink <= 0 THEN
|
||||||
@ -2112,13 +2053,13 @@ BEGIN
|
|||||||
T.toggleCursor;
|
T.toggleCursor;
|
||||||
repaint
|
repaint
|
||||||
END;
|
END;
|
||||||
|
|
||||||
CASE K.EventTimeout(10) OF
|
CASE K.EventTimeout(10) OF
|
||||||
|0:
|
|0:
|
||||||
|1: Redraw(resized, width, height, cliWidth, cliHeight)
|
|1: Redraw(resized, width, height, cliWidth, cliHeight)
|
||||||
|2: KeyDown(K.GetKey())
|
|2: KeyDown(K.GetKey())
|
||||||
|3: BtnClick
|
|3: BtnClick
|
||||||
|6: MouseEvent(resized, firstClickX, firstClickY, time)
|
|6: MouseEvent(resized, firstClickX, firstClickY, time)
|
||||||
|7: receiveIPC
|
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
END main;
|
END main;
|
||||||
|
@ -323,18 +323,6 @@ PROCEDURE GetControlKeys* (): SET;
|
|||||||
END GetControlKeys;
|
END GetControlKeys;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE SetIPC* (buffer: ARRAY OF INTEGER);
|
|
||||||
BEGIN
|
|
||||||
KOSAPI.sysfunc4(60, 1, SYSTEM.ADR(buffer[0]), LEN(buffer)*SYSTEM.SIZE(INTEGER))
|
|
||||||
END SetIPC;
|
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE SendIPC* (tid: INTEGER; msg: ARRAY OF INTEGER);
|
|
||||||
BEGIN
|
|
||||||
KOSAPI.sysfunc5(60, 2, tid, SYSTEM.ADR(msg[0]), SYSTEM.SIZE(INTEGER)*LEN(msg))
|
|
||||||
END SendIPC;
|
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE GetSystemColors*;
|
PROCEDURE GetSystemColors*;
|
||||||
BEGIN
|
BEGIN
|
||||||
KOSAPI.sysfunc4(48, 3, SYSTEM.ADR(colors), 40)
|
KOSAPI.sysfunc4(48, 3, SYSTEM.ADR(colors), 40)
|
||||||
|
@ -44,6 +44,9 @@ CONST
|
|||||||
disSelBackColor = 0E4E4E4H;
|
disSelBackColor = 0E4E4E4H;
|
||||||
disSelForeColor = disForeColor;
|
disSelForeColor = disForeColor;
|
||||||
|
|
||||||
|
SHIFT* = 256;
|
||||||
|
CTRL* = 512;
|
||||||
|
|
||||||
|
|
||||||
TYPE
|
TYPE
|
||||||
|
|
||||||
@ -64,9 +67,7 @@ TYPE
|
|||||||
font: G.tFont;
|
font: G.tFont;
|
||||||
canvas: G.tCanvas;
|
canvas: G.tCanvas;
|
||||||
|
|
||||||
items: List.tList;
|
items: List.tList
|
||||||
click: PROCEDURE (menu: tMenu; id: INTEGER);
|
|
||||||
key: PROCEDURE (menu: tMenu; key: INTEGER): BOOLEAN
|
|
||||||
END;
|
END;
|
||||||
|
|
||||||
tItem* = POINTER TO RECORD (List.tItem)
|
tItem* = POINTER TO RECORD (List.tItem)
|
||||||
@ -83,15 +84,20 @@ TYPE
|
|||||||
main: tMain
|
main: tMain
|
||||||
END;
|
END;
|
||||||
|
|
||||||
|
tShortcut = POINTER TO RECORD (List.tItem)
|
||||||
|
key, MenuItem: INTEGER
|
||||||
|
END;
|
||||||
|
|
||||||
tClick = PROCEDURE (menu: tMenu; id: INTEGER);
|
tClick = PROCEDURE (menu: tMenu; id: INTEGER);
|
||||||
tKey = PROCEDURE (menu: tMenu; key: INTEGER): BOOLEAN;
|
|
||||||
tProc = PROCEDURE;
|
tProc = PROCEDURE;
|
||||||
|
|
||||||
VAR
|
VAR
|
||||||
|
MenuItem*: INTEGER;
|
||||||
stack: ARRAY maxLEVEL + 1, 2500 OF INTEGER;
|
stack: ARRAY maxLEVEL + 1, 2500 OF INTEGER;
|
||||||
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);
|
||||||
|
shortcuts: List.tList;
|
||||||
(*
|
(*
|
||||||
backColor, foreColor, selBackColor, selForeColor,
|
backColor, foreColor, selBackColor, selForeColor,
|
||||||
disBackColor, disForeColor, disSelBackColor, disSelForeColor: INTEGER;
|
disBackColor, disForeColor, disSelBackColor, disSelForeColor: INTEGER;
|
||||||
@ -322,6 +328,12 @@ BEGIN
|
|||||||
END close;
|
END close;
|
||||||
|
|
||||||
|
|
||||||
|
PROCEDURE SetItem* (id: INTEGER);
|
||||||
|
BEGIN
|
||||||
|
MenuItem := id
|
||||||
|
END SetItem;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE click (m: tMenu; i: INTEGER);
|
PROCEDURE click (m: tMenu; i: INTEGER);
|
||||||
VAR
|
VAR
|
||||||
item: List.tItem;
|
item: List.tItem;
|
||||||
@ -338,7 +350,7 @@ BEGIN
|
|||||||
END
|
END
|
||||||
END;
|
END;
|
||||||
IF id # -1 THEN
|
IF id # -1 THEN
|
||||||
m.click(m, id);
|
SetItem(id);
|
||||||
p := m.parent;
|
p := m.parent;
|
||||||
WHILE p # NIL DO
|
WHILE p # NIL DO
|
||||||
p.child := NIL;
|
p.child := NIL;
|
||||||
@ -391,6 +403,25 @@ BEGIN
|
|||||||
END submenu;
|
END submenu;
|
||||||
|
|
||||||
|
|
||||||
|
PROCEDURE getShortcut (key: INTEGER): BOOLEAN;
|
||||||
|
VAR
|
||||||
|
item: tShortcut;
|
||||||
|
res: INTEGER;
|
||||||
|
BEGIN
|
||||||
|
item := shortcuts.first(tShortcut);
|
||||||
|
WHILE (item # NIL) & (item.key # key) DO
|
||||||
|
item := item.next(tShortcut)
|
||||||
|
END;
|
||||||
|
IF item # NIL THEN
|
||||||
|
res := item.MenuItem
|
||||||
|
ELSE
|
||||||
|
res := 0
|
||||||
|
END;
|
||||||
|
SetItem(res)
|
||||||
|
RETURN res # 0
|
||||||
|
END getShortcut;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE [stdcall] window (m: tMenu);
|
PROCEDURE [stdcall] window (m: tMenu);
|
||||||
VAR
|
VAR
|
||||||
x, y: INTEGER;
|
x, y: INTEGER;
|
||||||
@ -409,43 +440,40 @@ BEGIN
|
|||||||
draw_window(m)
|
draw_window(m)
|
||||||
|2:
|
|2:
|
||||||
K.getKBState(shift, ctrl);
|
K.getKBState(shift, ctrl);
|
||||||
key := K.GetKey();
|
key := K.GetKey() DIV 65536;
|
||||||
IF ~shift & ~ ctrl THEN
|
IF shift THEN
|
||||||
IF key DIV 65536 = 72 THEN
|
INC(key, SHIFT)
|
||||||
|
END;
|
||||||
|
IF ctrl THEN
|
||||||
|
INC(key, CTRL)
|
||||||
|
END;
|
||||||
|
|
||||||
|
CASE key OF
|
||||||
|
|72:
|
||||||
m.selItem := (m.selItem - 1) MOD m.items.count
|
m.selItem := (m.selItem - 1) MOD m.items.count
|
||||||
ELSIF key DIV 65536 = 80 THEN
|
|80:
|
||||||
m.selItem := (m.selItem + 1) MOD m.items.count
|
m.selItem := (m.selItem + 1) MOD m.items.count
|
||||||
ELSIF key DIV 65536 = 28 THEN
|
|28:
|
||||||
IF m.selItem >= 0 THEN
|
IF m.selItem >= 0 THEN
|
||||||
click(m, m.selItem)
|
click(m, m.selItem)
|
||||||
END;
|
END;
|
||||||
m.cliItem := -1
|
m.cliItem := -1
|
||||||
ELSIF key DIV 65536 = 77 THEN
|
|77:
|
||||||
IF ~submenu(m, TRUE) THEN
|
IF ~submenu(m, TRUE) THEN
|
||||||
click(m, -(getMainID(m) + 1))
|
click(m, -(getMainID(m) + 1))
|
||||||
END;
|
END;
|
||||||
m.cliItem := -1
|
m.cliItem := -1
|
||||||
ELSIF key DIV 65536 = 75 THEN
|
|75:
|
||||||
IF m.parent # NIL THEN
|
IF m.parent # NIL THEN
|
||||||
escape(m)
|
escape(m)
|
||||||
ELSE
|
ELSE
|
||||||
click(m, -(getMainID(m) - 1))
|
click(m, -(getMainID(m) - 1))
|
||||||
END;
|
END;
|
||||||
m.cliItem := -1
|
m.cliItem := -1
|
||||||
ELSIF key DIV 65536 = 1 THEN
|
|1:
|
||||||
escape(m)
|
escape(m)
|
||||||
ELSE
|
ELSE
|
||||||
IF m.key(m, key) THEN
|
IF getShortcut(key) THEN
|
||||||
IF m.parent # NIL THEN
|
|
||||||
temp := m.parent.tid;
|
|
||||||
m.parent.tid := 0;
|
|
||||||
K.ExitID(temp)
|
|
||||||
END;
|
|
||||||
exit(m)
|
|
||||||
END
|
|
||||||
END
|
|
||||||
ELSE
|
|
||||||
IF m.key(m, key) THEN
|
|
||||||
IF m.parent # NIL THEN
|
IF m.parent # NIL THEN
|
||||||
temp := m.parent.tid;
|
temp := m.parent.tid;
|
||||||
m.parent.tid := 0;
|
m.parent.tid := 0;
|
||||||
@ -593,7 +621,7 @@ BEGIN
|
|||||||
END isEnabled;
|
END isEnabled;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE create* (items: List.tList; click: tClick; key: tKey): tMenu;
|
PROCEDURE create* (items: List.tList): tMenu;
|
||||||
VAR
|
VAR
|
||||||
m: tMenu;
|
m: tMenu;
|
||||||
maxLength: INTEGER;
|
maxLength: INTEGER;
|
||||||
@ -606,8 +634,6 @@ BEGIN
|
|||||||
m.child := NIL;
|
m.child := NIL;
|
||||||
m.mainID := 0;
|
m.mainID := 0;
|
||||||
m.items := items;
|
m.items := items;
|
||||||
m.click := click;
|
|
||||||
m.key := key;
|
|
||||||
maxLength := 0;
|
maxLength := 0;
|
||||||
item := items.first(tItem);
|
item := items.first(tItem);
|
||||||
WHILE item # NIL DO
|
WHILE item # NIL DO
|
||||||
@ -623,10 +649,23 @@ BEGIN
|
|||||||
END create;
|
END create;
|
||||||
|
|
||||||
|
|
||||||
|
PROCEDURE AddShortcut* (key, MenuItem: INTEGER);
|
||||||
|
VAR
|
||||||
|
item: tShortcut;
|
||||||
|
BEGIN
|
||||||
|
NEW(item);
|
||||||
|
item.key := key;
|
||||||
|
item.MenuItem := MenuItem;
|
||||||
|
List.append(shortcuts, item)
|
||||||
|
END AddShortcut;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE init* (_resetTimer: tProc);
|
PROCEDURE init* (_resetTimer: tProc);
|
||||||
VAR
|
VAR
|
||||||
i: INTEGER;
|
i: INTEGER;
|
||||||
BEGIN
|
BEGIN
|
||||||
|
SetItem(0);
|
||||||
|
shortcuts := List.create(NIL);
|
||||||
resetTimer := _resetTimer;
|
resetTimer := _resetTimer;
|
||||||
_open := open;
|
_open := open;
|
||||||
FOR i := 0 TO maxLEVEL DO
|
FOR i := 0 TO maxLEVEL DO
|
||||||
|
@ -206,11 +206,11 @@ BEGIN
|
|||||||
END delete;
|
END delete;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE scroll* (t: tTabs; n: INTEGER);
|
PROCEDURE scroll* (t: tTabs; btn: INTEGER);
|
||||||
VAR
|
VAR
|
||||||
pos: INTEGER;
|
pos: INTEGER;
|
||||||
BEGIN
|
BEGIN
|
||||||
pos := t.first + n;
|
pos := t.first + ORD(btn = btnRight) - ORD(btn = btnLeft);
|
||||||
IF pos < 0 THEN
|
IF pos < 0 THEN
|
||||||
pos := 0
|
pos := 0
|
||||||
ELSIF pos >= t.strings.count THEN
|
ELSIF pos >= t.strings.count THEN
|
||||||
|
@ -23,38 +23,35 @@ IMPORT G := Graph, K := KolibriOS, U := Utils;
|
|||||||
|
|
||||||
CONST
|
CONST
|
||||||
|
|
||||||
ScrollIPC* = 0;
|
|
||||||
DELAY = 40;
|
DELAY = 40;
|
||||||
|
|
||||||
TYPE
|
TYPE
|
||||||
|
|
||||||
|
tProcedure = PROCEDURE;
|
||||||
|
|
||||||
tScroll* = RECORD
|
tScroll* = RECORD
|
||||||
vertical, Inc*, Dec*, mouse: BOOLEAN;
|
vertical, mouse: BOOLEAN;
|
||||||
top*, left*,
|
top*, left*,
|
||||||
width*, height*: INTEGER; (* read only *)
|
width*, height*: INTEGER; (* read only *)
|
||||||
btnSize, sliderSize: INTEGER;
|
btnSize, sliderSize: INTEGER;
|
||||||
pos, Slider, pos0, maxVal*, value*: INTEGER;
|
pos, Slider, pos0, maxVal*, value*: INTEGER;
|
||||||
canvas*: G.tCanvas
|
canvas: G.tCanvas;
|
||||||
END;
|
change: tProcedure;
|
||||||
|
|
||||||
tProcedure* = PROCEDURE;
|
|
||||||
|
|
||||||
VAR
|
|
||||||
|
|
||||||
ScrollChange: tProcedure;
|
|
||||||
delay: INTEGER;
|
delay: INTEGER;
|
||||||
|
btn*: INTEGER
|
||||||
|
END;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE MouseUp (VAR scroll: tScroll);
|
PROCEDURE MouseUp (VAR scroll: tScroll);
|
||||||
BEGIN
|
BEGIN
|
||||||
scroll.Slider := -1;
|
scroll.Slider := -1;
|
||||||
scroll.Inc := FALSE;
|
scroll.btn := 0;
|
||||||
scroll.Dec := FALSE;
|
|
||||||
scroll.mouse := FALSE;
|
scroll.mouse := FALSE;
|
||||||
|
scroll.delay := DELAY
|
||||||
END MouseUp;
|
END MouseUp;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE create* (vertical: BOOLEAN; width, height: INTEGER; btnSize, sliderSize: INTEGER; VAR scroll: tScroll);
|
PROCEDURE create* (vertical: BOOLEAN; width, height: INTEGER; btnSize, sliderSize: INTEGER; change: tProcedure; VAR scroll: tScroll);
|
||||||
VAR
|
VAR
|
||||||
res: tScroll;
|
res: tScroll;
|
||||||
BEGIN
|
BEGIN
|
||||||
@ -69,6 +66,7 @@ BEGIN
|
|||||||
res.pos := 0;
|
res.pos := 0;
|
||||||
res.maxVal := 0;
|
res.maxVal := 0;
|
||||||
res.canvas := G.CreateCanvas(width, height);
|
res.canvas := G.CreateCanvas(width, height);
|
||||||
|
res.change := change;
|
||||||
scroll := res
|
scroll := res
|
||||||
END create;
|
END create;
|
||||||
|
|
||||||
@ -111,9 +109,9 @@ BEGIN
|
|||||||
G.SetColor(canvas, K.colors.line);
|
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.btn # -1);
|
||||||
Rect(canvas, 0, 0, width - 1, btn - 1);
|
Rect(canvas, 0, 0, width - 1, btn - 1);
|
||||||
SetColor(canvas, ~scroll.Inc);
|
SetColor(canvas, scroll.btn # 1);
|
||||||
Rect(canvas, 0, height - btn, width - 1, height - 1);
|
Rect(canvas, 0, height - btn, width - 1, height - 1);
|
||||||
G.SetColor(canvas, K.colors.button);
|
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);
|
||||||
@ -129,17 +127,17 @@ BEGIN
|
|||||||
x1 := (width - d) DIV 2;
|
x1 := (width - d) DIV 2;
|
||||||
x2 := x1 + d;
|
x2 := x1 + d;
|
||||||
|
|
||||||
SetColor(canvas, scroll.Dec);
|
SetColor(canvas, scroll.btn = -1);
|
||||||
y := (btn - d DIV 2) DIV 2 + d DIV 2 - 1;
|
y := (btn - d DIV 2) DIV 2 + d DIV 2 - 1;
|
||||||
G.Triangle(canvas, x1 - 1, y, x2, y, G.triUp);
|
G.Triangle(canvas, x1 - 1, y, x2, y, G.triUp);
|
||||||
|
|
||||||
SetColor(canvas, scroll.Inc);
|
SetColor(canvas, scroll.btn = 1);
|
||||||
y := y + height - btn - d DIV 2 + 1;
|
y := y + height - btn - d DIV 2 + 1;
|
||||||
G.Triangle(canvas, x1 - 1, y, x2, y, G.triDown);
|
G.Triangle(canvas, x1 - 1, y, x2, y, G.triDown);
|
||||||
ELSE
|
ELSE
|
||||||
SetColor(canvas, ~scroll.Dec);
|
SetColor(canvas, scroll.btn # -1);
|
||||||
Rect(canvas, 0, 0, btn - 1, height - 1);
|
Rect(canvas, 0, 0, btn - 1, height - 1);
|
||||||
SetColor(canvas, ~scroll.Inc);
|
SetColor(canvas, scroll.btn # 1);
|
||||||
Rect(canvas, width - btn, 0, width - 1, height - 1);
|
Rect(canvas, width - btn, 0, width - 1, height - 1);
|
||||||
G.SetColor(canvas, K.colors.button);
|
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);
|
||||||
@ -155,11 +153,11 @@ BEGIN
|
|||||||
y1 := (height - d) DIV 2;
|
y1 := (height - d) DIV 2;
|
||||||
y2 := y1 + d;
|
y2 := y1 + d;
|
||||||
|
|
||||||
SetColor(canvas, scroll.Dec);
|
SetColor(canvas, scroll.btn = -1);
|
||||||
x := (btn - d DIV 2) DIV 2 + d DIV 2 - 1;
|
x := (btn - d DIV 2) DIV 2 + d DIV 2 - 1;
|
||||||
G.Triangle(canvas, x, y1 - 1, x, y2, G.triLeft);
|
G.Triangle(canvas, x, y1 - 1, x, y2, G.triLeft);
|
||||||
|
|
||||||
SetColor(canvas, scroll.Inc);
|
SetColor(canvas, scroll.btn = 1);
|
||||||
x := x + width - btn - d DIV 2 + 1;
|
x := x + width - btn - d DIV 2 + 1;
|
||||||
G.Triangle(canvas, x, y1 - 1, x, y2, G.triRight);
|
G.Triangle(canvas, x, y1 - 1, x, y2, G.triRight);
|
||||||
END;
|
END;
|
||||||
@ -219,17 +217,6 @@ BEGIN
|
|||||||
END setValue;
|
END setValue;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE change* (VAR scroll: tScroll);
|
|
||||||
BEGIN
|
|
||||||
IF scroll.Inc THEN
|
|
||||||
setValue(scroll, scroll.value + 1)
|
|
||||||
ELSIF scroll.Dec THEN
|
|
||||||
setValue(scroll, scroll.value - 1)
|
|
||||||
END;
|
|
||||||
draw(scroll)
|
|
||||||
END change;
|
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE ceil (p, q: INTEGER): INTEGER;
|
PROCEDURE ceil (p, q: INTEGER): INTEGER;
|
||||||
RETURN p DIV q + ORD(p MOD q # 0)
|
RETURN p DIV q + ORD(p MOD q # 0)
|
||||||
END ceil;
|
END ceil;
|
||||||
@ -306,38 +293,34 @@ BEGIN
|
|||||||
END MouseMove;
|
END MouseMove;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE SendIPC;
|
PROCEDURE button (VAR scroll: tScroll);
|
||||||
VAR
|
VAR
|
||||||
msg: ARRAY 2 OF INTEGER;
|
btn: INTEGER;
|
||||||
BEGIN
|
BEGIN
|
||||||
msg[0] := ScrollIPC;
|
WHILE scroll.btn # 0 DO
|
||||||
msg[1] := 8;
|
btn := scroll.btn;
|
||||||
K.SendIPC(K.ThreadID(), msg)
|
setValue(scroll, scroll.value + btn);
|
||||||
END SendIPC;
|
draw(scroll);
|
||||||
|
IF scroll.change # NIL THEN
|
||||||
|
scroll.change
|
||||||
PROCEDURE receiveIPC* (VAR IPC: ARRAY OF INTEGER; VAR scrollIPC: BOOLEAN);
|
|
||||||
BEGIN
|
|
||||||
scrollIPC := FALSE;
|
|
||||||
ScrollChange;
|
|
||||||
IF 0 IN K.MouseState() THEN
|
|
||||||
WHILE (0 IN K.MouseState()) & (delay > 0) DO
|
|
||||||
K.Pause(1);
|
|
||||||
DEC(delay)
|
|
||||||
END;
|
END;
|
||||||
IF delay = 0 THEN
|
scroll.btn := 0;
|
||||||
IPC[0] := 0;
|
IF 0 IN K.MouseState() THEN
|
||||||
IPC[1] := 0;
|
WHILE (0 IN K.MouseState()) & (scroll.delay > 0) DO
|
||||||
scrollIPC := TRUE;
|
K.Pause(1);
|
||||||
SendIPC;
|
DEC(scroll.delay)
|
||||||
delay := 4
|
END;
|
||||||
|
IF scroll.delay = 0 THEN
|
||||||
|
scroll.btn := btn;
|
||||||
|
scroll.delay := 3
|
||||||
ELSE
|
ELSE
|
||||||
delay := DELAY
|
scroll.delay := DELAY
|
||||||
END
|
END
|
||||||
ELSE
|
ELSE
|
||||||
delay := DELAY
|
scroll.delay := DELAY
|
||||||
END
|
END
|
||||||
END receiveIPC;
|
END
|
||||||
|
END button;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE MouseDown (VAR scroll: tScroll; x, y: INTEGER);
|
PROCEDURE MouseDown (VAR scroll: tScroll; x, y: INTEGER);
|
||||||
@ -359,11 +342,9 @@ BEGIN
|
|||||||
scroll.pos0 := scroll.pos;
|
scroll.pos0 := scroll.pos;
|
||||||
scroll.Slider := c
|
scroll.Slider := c
|
||||||
ELSIF U.between(0, c, scroll.btnSize - 1) THEN
|
ELSIF U.between(0, c, scroll.btnSize - 1) THEN
|
||||||
scroll.Dec := TRUE;
|
scroll.btn := -1
|
||||||
SendIPC
|
|
||||||
ELSIF U.between(size - scroll.btnSize, c, size - 1) THEN
|
ELSIF U.between(size - scroll.btnSize, c, size - 1) THEN
|
||||||
scroll.Inc := TRUE;
|
scroll.btn := 1
|
||||||
SendIPC
|
|
||||||
ELSE
|
ELSE
|
||||||
setPos(scroll, c - scroll.btnSize - scroll.sliderSize DIV 2);
|
setPos(scroll, c - scroll.btnSize - scroll.sliderSize DIV 2);
|
||||||
scroll.pos0 := scroll.pos;
|
scroll.pos0 := scroll.pos;
|
||||||
@ -389,15 +370,9 @@ BEGIN
|
|||||||
ELSIF scroll.mouse THEN
|
ELSIF scroll.mouse THEN
|
||||||
MouseUp(scroll);
|
MouseUp(scroll);
|
||||||
draw(scroll)
|
draw(scroll)
|
||||||
END
|
END;
|
||||||
|
button(scroll)
|
||||||
END mouse;
|
END mouse;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE init* (_ScrollChange: tProcedure);
|
|
||||||
BEGIN
|
|
||||||
delay := DELAY;
|
|
||||||
ScrollChange := _ScrollChange
|
|
||||||
END init;
|
|
||||||
|
|
||||||
|
|
||||||
END Scroll.
|
END Scroll.
|
5
programs/develop/oberon07/samples/BUILD_ALL.SH
Normal file
5
programs/develop/oberon07/samples/BUILD_ALL.SH
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#SHS
|
||||||
|
/kolibrios/develop/oberon07/compiler.kex HW.ob07 kosexe -out /tmp0/1/HW.kex -stk 1
|
||||||
|
/kolibrios/develop/oberon07/compiler.kex HW_con.ob07 kosexe -out /tmp0/1/HW_con.kex -stk 1
|
||||||
|
/kolibrios/develop/oberon07/compiler.kex Dialogs.ob07 kosexe -out /tmp0/1/Dialogs.kex -stk 1
|
||||||
|
exit
|
@ -1,59 +1,85 @@
|
|||||||
MODULE Dialogs;
|
MODULE Dialogs;
|
||||||
|
|
||||||
IMPORT KOSAPI, sys := SYSTEM, OpenDlg, ColorDlg;
|
IMPORT
|
||||||
|
KOSAPI, SYSTEM, OpenDlg, ColorDlg;
|
||||||
|
|
||||||
VAR header: ARRAY 1024 OF CHAR; back_color: INTEGER;
|
|
||||||
|
|
||||||
PROCEDURE WindowRedrawStatus(p: INTEGER);
|
CONST
|
||||||
|
btnNone = 0;
|
||||||
|
btnClose = 1;
|
||||||
|
btnOpen = 17;
|
||||||
|
btnColor = 18;
|
||||||
|
|
||||||
|
|
||||||
|
VAR
|
||||||
|
header: ARRAY 1024 OF CHAR;
|
||||||
|
back_color: INTEGER;
|
||||||
|
|
||||||
|
|
||||||
|
PROCEDURE BeginDraw;
|
||||||
BEGIN
|
BEGIN
|
||||||
KOSAPI.sysfunc2(12, p)
|
KOSAPI.sysfunc2(12, 1)
|
||||||
END WindowRedrawStatus;
|
END BeginDraw;
|
||||||
|
|
||||||
PROCEDURE DefineAndDrawWindow(x, y, w, h, color, style, hcolor, hstyle, htext: INTEGER);
|
|
||||||
|
PROCEDURE EndDraw;
|
||||||
BEGIN
|
BEGIN
|
||||||
KOSAPI.sysfunc6(0, x * 65536 + w, y * 65536 + h, color + LSL(style, 24), hcolor + LSL(hstyle, 24), htext)
|
KOSAPI.sysfunc2(12, 2)
|
||||||
|
END EndDraw;
|
||||||
|
|
||||||
|
|
||||||
|
PROCEDURE DefineAndDrawWindow (left, top, width, height, color, style, hcolor, hstyle: INTEGER; header: ARRAY OF CHAR);
|
||||||
|
BEGIN
|
||||||
|
KOSAPI.sysfunc6(0, left*65536 + width, top*65536 + height, color + LSL(style, 24), hcolor + LSL(hstyle, 24), SYSTEM.ADR(header[0]))
|
||||||
END DefineAndDrawWindow;
|
END DefineAndDrawWindow;
|
||||||
|
|
||||||
PROCEDURE WaitForEvent(): INTEGER;
|
|
||||||
|
PROCEDURE WaitForEvent (): INTEGER;
|
||||||
RETURN KOSAPI.sysfunc1(10)
|
RETURN KOSAPI.sysfunc1(10)
|
||||||
END WaitForEvent;
|
END WaitForEvent;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE ExitApp;
|
PROCEDURE ExitApp;
|
||||||
BEGIN
|
BEGIN
|
||||||
KOSAPI.sysfunc1(-1)
|
KOSAPI.sysfunc1(-1)
|
||||||
END ExitApp;
|
END ExitApp;
|
||||||
|
|
||||||
PROCEDURE pause(t: INTEGER);
|
|
||||||
|
PROCEDURE pause (t: INTEGER);
|
||||||
BEGIN
|
BEGIN
|
||||||
KOSAPI.sysfunc2(5, t)
|
KOSAPI.sysfunc2(5, t)
|
||||||
END pause;
|
END pause;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE Buttons;
|
PROCEDURE Buttons;
|
||||||
|
|
||||||
PROCEDURE Button(id, X, Y, W, H: INTEGER; Caption: ARRAY OF CHAR);
|
PROCEDURE Button (id, X, Y, W, H: INTEGER; Caption: ARRAY OF CHAR);
|
||||||
VAR n, aux: INTEGER;
|
VAR
|
||||||
|
n: INTEGER;
|
||||||
BEGIN
|
BEGIN
|
||||||
n := LENGTH(Caption);
|
n := LENGTH(Caption);
|
||||||
aux := KOSAPI.sysfunc5(8, X * 65536 + W, Y * 65536 + H, id, 00C0C0C0H);
|
KOSAPI.sysfunc5(8, X*65536 + W, Y*65536 + H, id, 00C0C0C0H);
|
||||||
X := X + (W - 8 * n) DIV 2;
|
X := X + (W - 8*n) DIV 2;
|
||||||
Y := Y + (H - 14) DIV 2;
|
Y := Y + (H - 14) DIV 2;
|
||||||
aux := KOSAPI.sysfunc6(4, X * 65536 + Y, LSL(48, 24), sys.ADR(Caption[0]), n, 0)
|
KOSAPI.sysfunc6(4, X*65536 + Y, LSL(48, 24), SYSTEM.ADR(Caption[0]), n, 0)
|
||||||
END Button;
|
END Button;
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
Button(17, 5, 5, 70, 25, "open");
|
Button(btnOpen, 5, 5, 70, 25, "open");
|
||||||
Button(18, 85, 5, 70, 25, "color");
|
Button(btnColor, 85, 5, 70, 25, "color");
|
||||||
END Buttons;
|
END Buttons;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE draw_window;
|
PROCEDURE draw_window;
|
||||||
BEGIN
|
BEGIN
|
||||||
WindowRedrawStatus(1);
|
BeginDraw;
|
||||||
DefineAndDrawWindow(200, 200, 500, 100, back_color, 51, 0, 0, sys.ADR(header[0]));
|
DefineAndDrawWindow(200, 200, 500, 100, back_color, 51, 0, 0, header);
|
||||||
Buttons;
|
Buttons;
|
||||||
WindowRedrawStatus(2);
|
EndDraw;
|
||||||
END draw_window;
|
END draw_window;
|
||||||
|
|
||||||
PROCEDURE OpenFile(Open: OpenDlg.Dialog);
|
|
||||||
|
PROCEDURE OpenFile (Open: OpenDlg.Dialog);
|
||||||
BEGIN
|
BEGIN
|
||||||
IF Open # NIL THEN
|
IF Open # NIL THEN
|
||||||
OpenDlg.Show(Open, 500, 450);
|
OpenDlg.Show(Open, 500, 450);
|
||||||
@ -66,7 +92,8 @@ BEGIN
|
|||||||
END
|
END
|
||||||
END OpenFile;
|
END OpenFile;
|
||||||
|
|
||||||
PROCEDURE SelColor(Color: ColorDlg.Dialog);
|
|
||||||
|
PROCEDURE SelColor (Color: ColorDlg.Dialog);
|
||||||
BEGIN
|
BEGIN
|
||||||
IF Color # NIL THEN
|
IF Color # NIL THEN
|
||||||
ColorDlg.Show(Color);
|
ColorDlg.Show(Color);
|
||||||
@ -79,32 +106,54 @@ BEGIN
|
|||||||
END
|
END
|
||||||
END SelColor;
|
END SelColor;
|
||||||
|
|
||||||
|
|
||||||
|
PROCEDURE GetButton (): INTEGER;
|
||||||
|
VAR
|
||||||
|
btn: INTEGER;
|
||||||
|
BEGIN
|
||||||
|
btn := KOSAPI.sysfunc1(17);
|
||||||
|
IF btn MOD 256 = 0 THEN
|
||||||
|
btn := btn DIV 256
|
||||||
|
ELSE
|
||||||
|
btn := btnNone
|
||||||
|
END
|
||||||
|
RETURN btn
|
||||||
|
END GetButton;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE main;
|
PROCEDURE main;
|
||||||
VAR Open: OpenDlg.Dialog; Color: ColorDlg.Dialog; res, al: INTEGER;
|
CONST
|
||||||
|
EVENT_REDRAW = 1;
|
||||||
|
EVENT_KEY = 2;
|
||||||
|
EVENT_BUTTON = 3;
|
||||||
|
VAR
|
||||||
|
Open: OpenDlg.Dialog;
|
||||||
|
Color: ColorDlg.Dialog;
|
||||||
BEGIN
|
BEGIN
|
||||||
back_color := 00FFFFFFH;
|
back_color := 00FFFFFFH;
|
||||||
header := "Dialogs";
|
header := "Dialogs";
|
||||||
draw_window;
|
|
||||||
Open := OpenDlg.Create(draw_window, 0, "/sys", "ASM|TXT|INI");
|
Open := OpenDlg.Create(draw_window, 0, "/sys", "ASM|TXT|INI");
|
||||||
Color := ColorDlg.Create(draw_window);
|
Color := ColorDlg.Create(draw_window);
|
||||||
|
|
||||||
WHILE TRUE DO
|
WHILE TRUE DO
|
||||||
CASE WaitForEvent() OF
|
CASE WaitForEvent() OF
|
||||||
|1: draw_window
|
|EVENT_REDRAW:
|
||||||
|3: res := KOSAPI.sysfunc1(17);
|
draw_window
|
||||||
al := LSR(LSL(res, 24), 24);
|
|
||||||
res := LSR(res, 8);
|
|EVENT_KEY:
|
||||||
IF al = 0 THEN
|
|
||||||
CASE res OF
|
|EVENT_BUTTON:
|
||||||
| 1: ExitApp
|
CASE GetButton() OF
|
||||||
|17: OpenFile(Open)
|
|btnNone:
|
||||||
|18: SelColor(Color)
|
|btnClose: ExitApp
|
||||||
|
|btnOpen: OpenFile(Open)
|
||||||
|
|btnColor: SelColor(Color)
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
ELSE
|
|
||||||
END
|
|
||||||
END
|
END
|
||||||
END main;
|
END main;
|
||||||
|
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
main
|
main
|
||||||
END Dialogs.
|
END Dialogs.
|
@ -1,50 +1,78 @@
|
|||||||
MODULE HW;
|
MODULE HW;
|
||||||
|
|
||||||
IMPORT sys := SYSTEM, KOSAPI;
|
IMPORT
|
||||||
|
SYSTEM, KOSAPI;
|
||||||
|
|
||||||
PROCEDURE WindowRedrawStatus(p: INTEGER);
|
|
||||||
BEGIN
|
|
||||||
KOSAPI.sysfunc2(12, p)
|
|
||||||
END WindowRedrawStatus;
|
|
||||||
|
|
||||||
PROCEDURE DefineAndDrawWindow(x, y, w, h, color, style, hcolor, hstyle, htext: INTEGER);
|
PROCEDURE BeginDraw;
|
||||||
BEGIN
|
BEGIN
|
||||||
KOSAPI.sysfunc6(0, x * 65536 + w, y * 65536 + h, color + LSL(style, 24), hcolor + LSL(hstyle, 24), htext)
|
KOSAPI.sysfunc2(12, 1)
|
||||||
|
END BeginDraw;
|
||||||
|
|
||||||
|
|
||||||
|
PROCEDURE EndDraw;
|
||||||
|
BEGIN
|
||||||
|
KOSAPI.sysfunc2(12, 2)
|
||||||
|
END EndDraw;
|
||||||
|
|
||||||
|
|
||||||
|
PROCEDURE DefineAndDrawWindow (left, top, width, height, color, style, hcolor, hstyle: INTEGER; header: ARRAY OF CHAR);
|
||||||
|
BEGIN
|
||||||
|
KOSAPI.sysfunc6(0, left*65536 + width, top*65536 + height, color + LSL(style, 24), hcolor + LSL(hstyle, 24), SYSTEM.ADR(header[0]))
|
||||||
END DefineAndDrawWindow;
|
END DefineAndDrawWindow;
|
||||||
|
|
||||||
PROCEDURE WriteTextToWindow(x, y, color: INTEGER; text: ARRAY OF CHAR);
|
|
||||||
|
PROCEDURE WriteTextToWindow (x, y, color: INTEGER; text: ARRAY OF CHAR);
|
||||||
BEGIN
|
BEGIN
|
||||||
KOSAPI.sysfunc6(4, x * 65536 + y, color + LSL(48, 24), sys.ADR(text[0]), LENGTH(text), 0)
|
KOSAPI.sysfunc6(4, x*65536 + y, color + LSL(48, 24), SYSTEM.ADR(text[0]), LENGTH(text), 0)
|
||||||
END WriteTextToWindow;
|
END WriteTextToWindow;
|
||||||
|
|
||||||
PROCEDURE WaitForEvent(): INTEGER;
|
|
||||||
|
PROCEDURE WaitForEvent (): INTEGER;
|
||||||
RETURN KOSAPI.sysfunc1(10)
|
RETURN KOSAPI.sysfunc1(10)
|
||||||
END WaitForEvent;
|
END WaitForEvent;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE ExitApp;
|
PROCEDURE ExitApp;
|
||||||
BEGIN
|
BEGIN
|
||||||
KOSAPI.sysfunc1(-1)
|
KOSAPI.sysfunc1(-1)
|
||||||
END ExitApp;
|
END ExitApp;
|
||||||
|
|
||||||
PROCEDURE draw_window(header, text: ARRAY OF CHAR);
|
|
||||||
|
PROCEDURE draw_window (header, text: ARRAY OF CHAR);
|
||||||
|
CONST
|
||||||
|
WHITE = 0FFFFFFH;
|
||||||
|
RED = 0C00000H;
|
||||||
|
GREEN = 0008000H;
|
||||||
|
BLUE = 00000C0H;
|
||||||
|
GRAY = 0808080H;
|
||||||
BEGIN
|
BEGIN
|
||||||
WindowRedrawStatus(1);
|
BeginDraw;
|
||||||
DefineAndDrawWindow(200, 200, 200, 100, 0FFFFFFH, 51, 0, 0, sys.ADR(header));
|
DefineAndDrawWindow(200, 200, 300, 150, WHITE, 51, 0, 0, header);
|
||||||
WriteTextToWindow(10, 10, 0FF0000H, text);
|
WriteTextToWindow( 5, 10, RED, text);
|
||||||
WindowRedrawStatus(2);
|
WriteTextToWindow(35, 30, GREEN, text);
|
||||||
|
WriteTextToWindow(65, 50, BLUE, text);
|
||||||
|
WriteTextToWindow(95, 70, GRAY, text);
|
||||||
|
EndDraw
|
||||||
END draw_window;
|
END draw_window;
|
||||||
|
|
||||||
PROCEDURE Main(header, text: ARRAY OF CHAR);
|
|
||||||
|
PROCEDURE main (header, text: ARRAY OF CHAR);
|
||||||
|
CONST
|
||||||
|
EVENT_REDRAW = 1;
|
||||||
|
EVENT_KEY = 2;
|
||||||
|
EVENT_BUTTON = 3;
|
||||||
BEGIN
|
BEGIN
|
||||||
WHILE TRUE DO
|
WHILE TRUE DO
|
||||||
CASE WaitForEvent() OF
|
CASE WaitForEvent() OF
|
||||||
|1: draw_window(header, text)
|
|EVENT_REDRAW: draw_window(header, text)
|
||||||
|3: ExitApp
|
|EVENT_KEY: ExitApp
|
||||||
ELSE
|
|EVENT_BUTTON: ExitApp
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
END Main;
|
END main;
|
||||||
|
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
Main("HW", "Hello, world!")
|
main("Hello", "Hello, world!")
|
||||||
END HW.
|
END HW.
|
@ -1,9 +1,10 @@
|
|||||||
MODULE HW_con;
|
MODULE HW_con;
|
||||||
|
|
||||||
IMPORT Out, In, Console, DateTime;
|
IMPORT
|
||||||
|
Out, In, Console, DateTime;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE OutInt2(n: INTEGER);
|
PROCEDURE OutInt2 (n: INTEGER);
|
||||||
BEGIN
|
BEGIN
|
||||||
ASSERT((0 <= n) & (n <= 99));
|
ASSERT((0 <= n) & (n <= 99));
|
||||||
IF n < 10 THEN
|
IF n < 10 THEN
|
||||||
@ -13,12 +14,10 @@ BEGIN
|
|||||||
END OutInt2;
|
END OutInt2;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE OutMonth(n: INTEGER);
|
PROCEDURE OutMonth (n: INTEGER);
|
||||||
VAR
|
VAR
|
||||||
str: ARRAY 4 OF CHAR;
|
str: ARRAY 4 OF CHAR;
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
CASE n OF
|
CASE n OF
|
||||||
| 1: str := "jan"
|
| 1: str := "jan"
|
||||||
| 2: str := "feb"
|
| 2: str := "feb"
|
||||||
@ -33,31 +32,28 @@ BEGIN
|
|||||||
|11: str := "nov"
|
|11: str := "nov"
|
||||||
|12: str := "dec"
|
|12: str := "dec"
|
||||||
END;
|
END;
|
||||||
|
|
||||||
Out.String(str)
|
Out.String(str)
|
||||||
END OutMonth;
|
END OutMonth;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE main;
|
PROCEDURE main;
|
||||||
VAR
|
VAR
|
||||||
Year, Month, Day, Hour, Min, Sec, Msec: INTEGER;
|
Year, Month, Day,
|
||||||
|
Hour, Min, Sec, Msec: INTEGER;
|
||||||
BEGIN
|
BEGIN
|
||||||
Out.String("Hello, world!"); Out.Ln;
|
Out.String("Hello, world!"); Out.Ln;
|
||||||
Console.SetColor(Console.White, Console.Red);
|
Console.SetColor(Console.White, Console.Red);
|
||||||
DateTime.Now(Year, Month, Day, Hour, Min, Sec, Msec);
|
DateTime.Now(Year, Month, Day, Hour, Min, Sec, Msec);
|
||||||
Out.Int(Year, 0); Out.Char("-");
|
OutInt2(Day); Out.Char("-"); OutMonth(Month); Out.Char("-"); Out.Int(Year, 0); Out.Char(" ");
|
||||||
OutMonth(Month); Out.Char("-");
|
OutInt2(Hour); Out.Char(":"); OutInt2(Min); Out.Char(":"); OutInt2(Sec); Out.Ln;
|
||||||
OutInt2(Day); Out.Char(" ");
|
Console.SetColor(Console.Blue, Console.LightGray);
|
||||||
OutInt2(Hour); Out.Char(":");
|
Out.Ln; Out.String("press enter...");
|
||||||
OutInt2(Min); Out.Char(":");
|
In.Ln
|
||||||
OutInt2(Sec)
|
|
||||||
END main;
|
END main;
|
||||||
|
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
Console.open;
|
Console.open;
|
||||||
main;
|
main;
|
||||||
In.Ln;
|
|
||||||
Console.exit(TRUE)
|
Console.exit(TRUE)
|
||||||
END HW_con.
|
END HW_con.
|
Loading…
Reference in New Issue
Block a user