2021-05-23 11:43:28 +02:00
|
|
|
(*
|
2022-01-02 19:57:13 +01:00
|
|
|
Copyright 2021, 2022 Anton Krotov
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
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 CEdit;
|
|
|
|
|
|
|
|
IMPORT
|
2022-01-12 22:15:22 +01:00
|
|
|
OpenDlg, K := KolibriOS, Args,
|
2021-05-23 11:43:28 +02:00
|
|
|
U := Utils, Lines, Menu, List,
|
|
|
|
G := Graph, T := Text, E := Encodings,
|
|
|
|
CB := Clipboard, Languages,
|
2021-09-08 22:47:14 +02:00
|
|
|
ChangeLog, Scroll, CheckBox,
|
2021-12-29 16:38:29 +01:00
|
|
|
RW, Ini, EB := EditBox, Tabs, Toolbar, SB := StatusBar;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
CONST
|
2022-01-18 17:23:19 +01:00
|
|
|
HEADER = "CEdit (18-jan-2022)";
|
2021-05-23 11:43:28 +02:00
|
|
|
|
2021-06-05 17:18:11 +02:00
|
|
|
ShellFilter = "";
|
2021-10-03 19:44:42 +02:00
|
|
|
EditFilter = "SH|INC|TXT|ASM|OB07|C|CPP|H|PAS|PP|LUA|INI|JSON";
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
fontWidth = K.fontWidth;
|
|
|
|
fontHeight = K.fontHeight;
|
|
|
|
scrollWidth = 22;
|
|
|
|
|
|
|
|
btnClose = 1;
|
2021-12-20 20:09:01 +01:00
|
|
|
|
2021-05-23 11:43:28 +02:00
|
|
|
btnNew = 20;
|
|
|
|
btnOpen = 21;
|
|
|
|
btnSave = 22;
|
|
|
|
btnSearch = 23;
|
|
|
|
btnUndo = 24;
|
|
|
|
btnRedo = 25;
|
|
|
|
btnUpper = 26;
|
|
|
|
btnLower = 27;
|
|
|
|
btnBuild = 28;
|
|
|
|
btnRun = 29;
|
2021-09-03 01:15:33 +02:00
|
|
|
|
2021-05-23 11:43:28 +02:00
|
|
|
btnYes = 40;
|
|
|
|
btnNo = 41;
|
2021-10-03 19:44:42 +02:00
|
|
|
btnFindNext = 42;
|
|
|
|
btnReplace = 43;
|
|
|
|
btnReplaceAll = 44;
|
|
|
|
btnGoto = 45;
|
|
|
|
btnCloseSearch = 46;
|
|
|
|
btnHideSearch = 47;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
2021-10-03 19:44:42 +02:00
|
|
|
mainMenuBtn = 60;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
btnHeight = 25;
|
|
|
|
btnWidth = 75;
|
|
|
|
|
2021-12-20 20:09:01 +01:00
|
|
|
toolbarTop = Menu.MainMenuHeight + 3;
|
|
|
|
|
|
|
|
TOP = toolbarTop + Toolbar.BtnSize + 10 + Tabs.tabHeight;
|
2021-05-23 11:43:28 +02:00
|
|
|
RIGHT = scrollWidth - 2;
|
2021-06-15 19:33:16 +02:00
|
|
|
BOTTOM = scrollWidth + 18;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
2021-09-07 22:18:42 +02:00
|
|
|
minWinWidth = 635; minWinHeight = 550;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
SEARCH_PADDING = 10;
|
2021-12-22 16:56:11 +01:00
|
|
|
LEFT_PADDING = 1;
|
|
|
|
RIGHT_PADDING = 1;
|
|
|
|
|
2021-05-23 11:43:28 +02:00
|
|
|
EditBox_Width = 180;
|
|
|
|
EDITBOX_MAXCHARS = 500;
|
|
|
|
|
2021-12-22 16:56:11 +01:00
|
|
|
menuFileX = Menu.MainMenuX;
|
2021-09-11 22:57:43 +02:00
|
|
|
menuEditX = menuFileX + 4*fontWidth + 9;
|
|
|
|
menuSearchX = menuEditX + 4*fontWidth + 9;
|
|
|
|
menuEncodingX = menuSearchX + 6*fontWidth + 9;
|
2021-09-14 18:33:15 +02:00
|
|
|
menuViewX = menuEncodingX + 8*fontWidth + 9;
|
|
|
|
menuLanguageX = menuViewX + 4*fontWidth + 9;
|
|
|
|
menuProgramX = menuLanguageX + 8*fontWidth + 9;
|
2021-09-11 22:57:43 +02:00
|
|
|
menuToolsX = menuProgramX + 7*fontWidth + 9;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
menuCut = 1;
|
|
|
|
menuCopy = 2;
|
|
|
|
menuPaste = 3;
|
|
|
|
menuDelete = 4;
|
|
|
|
menuSelectAll = 5;
|
|
|
|
|
|
|
|
menuUndo = 6;
|
|
|
|
menuRedo = 7;
|
|
|
|
|
2021-09-03 01:15:33 +02:00
|
|
|
menuCurLine = 100;
|
|
|
|
menuIndent = 110;
|
|
|
|
menuCase = 120;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
menuNew = 10;
|
|
|
|
menuOpen = 11;
|
|
|
|
menuSave = 12;
|
|
|
|
menuSaveAs = 13;
|
2021-07-11 01:39:41 +02:00
|
|
|
menuSaveAll = 14;
|
|
|
|
menuFolder = 15;
|
|
|
|
menuClose = 16;
|
|
|
|
menuExit = 17;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
menuNumbers = 20;
|
2021-06-06 12:04:05 +02:00
|
|
|
menuFontSize = 21;
|
2021-05-23 11:43:28 +02:00
|
|
|
menuColors = 1000;
|
|
|
|
menuMaxColors = menuColors + Ini.MAX_SECTIONS - 1;
|
|
|
|
|
2021-09-14 18:33:15 +02:00
|
|
|
menuText = 30;
|
2021-05-23 11:43:28 +02:00
|
|
|
menuC = 31;
|
|
|
|
menuFasm = 32;
|
|
|
|
menuIni = 33;
|
2021-09-03 01:15:33 +02:00
|
|
|
menuJSON = 34;
|
|
|
|
menuLua = 35;
|
|
|
|
menuOberon = 36;
|
|
|
|
menuPascal = 37;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
menuBuild = 50;
|
|
|
|
menuBuildScript = 51;
|
|
|
|
menuRun = 52;
|
|
|
|
menuRunScript = 53;
|
|
|
|
menuDebug = 54;
|
|
|
|
menuDebugScript = 55;
|
|
|
|
|
|
|
|
menuUTF8BOM = 60;
|
|
|
|
menuUTF8 = 61;
|
|
|
|
menuCP866 = 62;
|
|
|
|
menuWin1251 = 63;
|
2021-09-14 18:33:15 +02:00
|
|
|
menuEOL = 140;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
menuPipet = 70;
|
2021-12-22 16:56:11 +01:00
|
|
|
menuMagnify = 71;
|
|
|
|
menuBoard = 72;
|
|
|
|
menuSysFunc = 73;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
2021-09-03 01:15:33 +02:00
|
|
|
menuFind = 80;
|
|
|
|
menuFindNext = 81;
|
|
|
|
menuFindPrev = 82;
|
|
|
|
menuGoto = 83;
|
|
|
|
menuBookmark = 130;
|
|
|
|
|
|
|
|
menuMoveUp = 101;
|
|
|
|
menuMoveDown = 102;
|
|
|
|
menuDuplicate = 103;
|
|
|
|
menuRemove = 104;
|
|
|
|
|
|
|
|
menuIncInd = 111;
|
|
|
|
menuDecInd = 112;
|
|
|
|
|
|
|
|
menuUpper = 121;
|
|
|
|
menuLower = 122;
|
|
|
|
|
|
|
|
menuToggleBookmark = 131;
|
|
|
|
menuNextBookmark = 132;
|
|
|
|
menuPrevBookmark = 133;
|
|
|
|
|
2021-09-14 18:33:15 +02:00
|
|
|
menuLF = 141;
|
|
|
|
menuCRLF = 142;
|
|
|
|
menuCR = 143;
|
2021-09-06 23:06:31 +02:00
|
|
|
|
2021-07-11 01:39:41 +02:00
|
|
|
maxTexts = 32;
|
|
|
|
|
2022-01-18 17:23:19 +01:00
|
|
|
SHIFT = Menu.SHIFT;
|
|
|
|
CTRL = Menu.CTRL;
|
|
|
|
|
2021-06-05 17:18:11 +02:00
|
|
|
|
2021-05-23 11:43:28 +02:00
|
|
|
VAR
|
2021-12-30 12:11:45 +01:00
|
|
|
header: RW.tFileName;
|
2021-05-23 11:43:28 +02:00
|
|
|
canvas: G.tCanvas;
|
2021-06-06 12:04:05 +02:00
|
|
|
font, font1, font2: G.tFont;
|
2021-07-11 01:39:41 +02:00
|
|
|
|
|
|
|
tabs: Tabs.tTabs;
|
2021-05-23 11:43:28 +02:00
|
|
|
text: T.tText;
|
2021-07-11 01:39:41 +02:00
|
|
|
texts: ARRAY maxTexts OF T.tText;
|
|
|
|
textsCount, curText: INTEGER;
|
|
|
|
|
2021-05-23 11:43:28 +02:00
|
|
|
winWidth, winHeight: INTEGER;
|
2022-01-12 22:15:22 +01:00
|
|
|
SkinHeight: INTEGER;
|
2022-01-13 16:13:47 +01:00
|
|
|
AppPath, runScript, buildScript, debugScript, CurFolder: RW.tFileName;
|
2021-05-23 11:43:28 +02:00
|
|
|
OD: OpenDlg.Dialog;
|
2021-12-29 16:38:29 +01:00
|
|
|
confirm, notFound, menuFindClicked, search, searchOpened: BOOLEAN;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
2021-07-21 18:13:29 +02:00
|
|
|
switch, closing: BOOLEAN;
|
2021-09-03 01:15:33 +02:00
|
|
|
leftButton: BOOLEAN;
|
2021-05-23 11:43:28 +02:00
|
|
|
LEFT: INTEGER;
|
|
|
|
|
2021-09-11 22:57:43 +02:00
|
|
|
FindEdit, ReplaceEdit, GotoEdit: EB.tEditBox;
|
2021-10-03 19:44:42 +02:00
|
|
|
hScroll, vScroll: Scroll.tScroll;
|
2021-09-08 22:47:14 +02:00
|
|
|
CS, WH, BKW: CheckBox.tCheckBox;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
new_searchText, searchText, replaceText, gotoText: T.tString;
|
|
|
|
cs, whole: BOOLEAN;
|
|
|
|
|
|
|
|
replaced: INTEGER;
|
|
|
|
|
2021-09-03 01:15:33 +02:00
|
|
|
context, menuFile, menuEdit, menuSearch, menuEncoding,
|
2021-09-14 18:33:15 +02:00
|
|
|
menuView, menuLanguage, menuProgram, menuTools,
|
|
|
|
subCurLine, subIndent, subCase, subBookmark, subEOL: Menu.tMenu;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
2021-09-11 22:57:43 +02:00
|
|
|
mainMenu: Menu.tMain;
|
|
|
|
|
2021-09-03 18:20:40 +02:00
|
|
|
menuActive: BOOLEAN;
|
|
|
|
|
2021-12-20 20:09:01 +01:00
|
|
|
toolbar: Toolbar.tToolbar;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
2021-12-20 20:09:01 +01:00
|
|
|
CursorTime, CurrentTime: INTEGER;
|
|
|
|
timerEnabled: BOOLEAN;
|
|
|
|
|
2021-05-23 11:43:28 +02:00
|
|
|
|
2021-09-11 22:57:43 +02:00
|
|
|
PROCEDURE EditBox_Focus (edit: EB.tEditBox): BOOLEAN;
|
2021-10-03 19:44:42 +02:00
|
|
|
RETURN 1 IN edit.flags
|
2021-05-23 11:43:28 +02:00
|
|
|
END EditBox_Focus;
|
|
|
|
|
|
|
|
|
2021-09-03 01:15:33 +02:00
|
|
|
PROCEDURE resetTimer;
|
|
|
|
BEGIN
|
|
|
|
IF EditBox_Focus(FindEdit) OR EditBox_Focus(ReplaceEdit) OR EditBox_Focus(GotoEdit) THEN
|
|
|
|
T.hideCursor;
|
2021-12-20 20:09:01 +01:00
|
|
|
timerEnabled := FALSE
|
2021-09-03 01:15:33 +02:00
|
|
|
ELSE
|
|
|
|
T.showCursor;
|
2021-12-20 20:09:01 +01:00
|
|
|
timerEnabled := TRUE
|
|
|
|
END;
|
|
|
|
CursorTime := CurrentTime
|
2021-09-03 01:15:33 +02:00
|
|
|
END resetTimer;
|
|
|
|
|
|
|
|
|
2021-10-03 19:44:42 +02:00
|
|
|
PROCEDURE EditBox_SetFocus (VAR edit: EB.tEditBox; value: BOOLEAN);
|
2021-05-23 11:43:28 +02:00
|
|
|
BEGIN
|
|
|
|
IF value THEN
|
2021-09-28 18:15:37 +02:00
|
|
|
INCL(edit.flags, 1)
|
2021-05-23 11:43:28 +02:00
|
|
|
ELSE
|
2021-09-28 18:15:37 +02:00
|
|
|
EXCL(edit.flags, 1)
|
2021-05-23 11:43:28 +02:00
|
|
|
END;
|
2021-07-21 18:13:29 +02:00
|
|
|
IF search & searchOpened THEN
|
2022-01-13 16:13:47 +01:00
|
|
|
EB.draw(edit)
|
2021-05-23 11:43:28 +02:00
|
|
|
END
|
|
|
|
END EditBox_SetFocus;
|
|
|
|
|
|
|
|
|
2021-10-03 19:44:42 +02:00
|
|
|
PROCEDURE SetFocus (VAR edit: EB.tEditBox; value: BOOLEAN);
|
2021-07-21 18:13:29 +02:00
|
|
|
BEGIN
|
|
|
|
EditBox_SetFocus(FindEdit, FALSE);
|
|
|
|
EditBox_SetFocus(ReplaceEdit, FALSE);
|
|
|
|
EditBox_SetFocus(GotoEdit, FALSE);
|
2021-09-03 01:15:33 +02:00
|
|
|
EditBox_SetFocus(edit, value);
|
|
|
|
resetTimer
|
2021-07-21 18:13:29 +02:00
|
|
|
END SetFocus;
|
|
|
|
|
|
|
|
|
2021-05-23 11:43:28 +02:00
|
|
|
PROCEDURE Rect (left, top, right, bottom, color: INTEGER);
|
|
|
|
BEGIN
|
|
|
|
K.DrawLine(left, top, right, top, color);
|
|
|
|
K.DrawLine(left, bottom, right, bottom, color);
|
|
|
|
K.DrawLine(left, top, left, bottom, color);
|
|
|
|
K.DrawLine(right, top, right, bottom, color);
|
|
|
|
END Rect;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE Message (s: ARRAY OF WCHAR);
|
|
|
|
CONST
|
|
|
|
minWidth = 30;
|
|
|
|
height = 40;
|
|
|
|
VAR
|
|
|
|
top, left, right, bottom, x, y, width: INTEGER;
|
|
|
|
BEGIN
|
2021-12-20 20:09:01 +01:00
|
|
|
timerEnabled := FALSE;
|
|
|
|
CursorTime := CurrentTime;
|
2021-05-23 11:43:28 +02:00
|
|
|
width := minWidth + LENGTH(s)*fontWidth;
|
|
|
|
left := (canvas.width - width) DIV 2 + LEFT;
|
|
|
|
top := (canvas.height - height) DIV 2 + TOP;
|
|
|
|
bottom := top + height - 1;
|
|
|
|
right := left + width - 1;
|
|
|
|
x := minWidth DIV 2 + left;
|
|
|
|
y := (height - fontHeight) DIV 2 + top;
|
2022-01-12 22:15:22 +01:00
|
|
|
K.DrawRect(left, top, width, height, K.colors.work);
|
|
|
|
Rect(left, top, right, bottom, K.colors.line);
|
|
|
|
K.DrawText(x, y, K.colors.work_text, s);
|
2021-05-23 11:43:28 +02:00
|
|
|
END Message;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE NotFound;
|
|
|
|
BEGIN
|
|
|
|
IF notFound THEN
|
|
|
|
Message("not found");
|
2021-09-03 18:20:40 +02:00
|
|
|
IF menuFindClicked THEN
|
|
|
|
menuFindClicked := FALSE
|
|
|
|
ELSE
|
|
|
|
notFound := FALSE
|
|
|
|
END;
|
2021-07-21 18:13:29 +02:00
|
|
|
SetFocus(FindEdit, TRUE)
|
2021-05-23 11:43:28 +02:00
|
|
|
END
|
|
|
|
END NotFound;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE Replaced;
|
|
|
|
VAR
|
|
|
|
s, s1: ARRAY 32 OF WCHAR;
|
|
|
|
BEGIN
|
|
|
|
IF replaced # 0 THEN
|
|
|
|
s := "replaced: ";
|
|
|
|
U.int2str(replaced, s1);
|
|
|
|
U.append(s, s1);
|
|
|
|
Message(s);
|
|
|
|
replaced := 0;
|
2021-07-21 18:13:29 +02:00
|
|
|
SetFocus(FindEdit, TRUE)
|
2021-05-23 11:43:28 +02:00
|
|
|
END
|
|
|
|
END Replaced;
|
|
|
|
|
|
|
|
|
2021-12-08 15:02:53 +01:00
|
|
|
PROCEDURE getIdx (text: T.tText): INTEGER;
|
|
|
|
VAR
|
|
|
|
i: INTEGER;
|
2021-05-23 11:43:28 +02:00
|
|
|
BEGIN
|
2021-12-08 15:02:53 +01:00
|
|
|
i := 0;
|
|
|
|
WHILE texts[i] # text DO
|
|
|
|
INC(i)
|
2021-05-23 11:43:28 +02:00
|
|
|
END
|
2021-12-08 15:02:53 +01:00
|
|
|
RETURN i
|
|
|
|
END getIdx;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE SetCaption (fileName: RW.tFileName);
|
|
|
|
VAR
|
2021-12-30 12:11:45 +01:00
|
|
|
newHeader: RW.tFileName;
|
2021-12-08 15:02:53 +01:00
|
|
|
BEGIN
|
2021-12-30 12:11:45 +01:00
|
|
|
newHeader := HEADER;
|
2021-12-08 15:02:53 +01:00
|
|
|
IF text.fileName # "" THEN
|
2021-12-30 12:11:45 +01:00
|
|
|
U.append8(newHeader, " - ");
|
|
|
|
U.append8(newHeader, text.fileName)
|
2021-12-08 15:02:53 +01:00
|
|
|
END;
|
2021-12-30 12:11:45 +01:00
|
|
|
IF newHeader # header THEN
|
|
|
|
header := newHeader;
|
|
|
|
K.SetCaption(header)
|
|
|
|
END
|
2021-12-08 15:02:53 +01:00
|
|
|
END SetCaption;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
|
2021-12-29 16:38:29 +01:00
|
|
|
PROCEDURE Status (text: T.tText; height: INTEGER);
|
2021-07-11 01:39:41 +02:00
|
|
|
VAR
|
2021-12-29 16:38:29 +01:00
|
|
|
line, col, chars, lines: INTEGER;
|
|
|
|
BEGIN
|
|
|
|
T.getPos(text, col, line);
|
|
|
|
T.getSelCnt(text, chars, lines);
|
|
|
|
SB.setWidth(canvas.width + scrollWidth);
|
|
|
|
SB.setPos(line, col);
|
|
|
|
SB.setSel(chars, lines);
|
|
|
|
SB.setEnc(RW.eolNames[T.getEol(text)], E.names[T.getEnc(text)]);
|
|
|
|
SB.draw(LEFT, height - BOTTOM + scrollWidth - 1);
|
|
|
|
Tabs.modify(tabs, getIdx(text), text.modified)
|
|
|
|
END Status;
|
2021-07-11 01:39:41 +02:00
|
|
|
|
|
|
|
|
2021-09-03 01:15:33 +02:00
|
|
|
PROCEDURE DrawScroll (VAR scroll: Scroll.tScroll; left, top, value, maxVal: INTEGER);
|
|
|
|
BEGIN
|
|
|
|
scroll.maxVal := maxVal;
|
|
|
|
scroll.left := left;
|
|
|
|
scroll.top := top;
|
|
|
|
Scroll.setValue(scroll, value);
|
2022-01-13 16:13:47 +01:00
|
|
|
Scroll.draw(scroll)
|
2021-09-03 01:15:33 +02:00
|
|
|
END DrawScroll;
|
|
|
|
|
|
|
|
|
2021-05-23 11:43:28 +02:00
|
|
|
PROCEDURE repaint;
|
|
|
|
VAR
|
2021-12-23 14:28:34 +01:00
|
|
|
width, height, scrollX, scrollY: INTEGER;
|
2021-05-23 11:43:28 +02:00
|
|
|
BEGIN
|
2021-12-22 16:56:11 +01:00
|
|
|
IF (text # NIL) & ~K.RolledUp() THEN
|
2021-05-23 11:43:28 +02:00
|
|
|
IF confirm THEN
|
|
|
|
K.DeleteButton(btnYes);
|
|
|
|
K.DeleteButton(btnNo);
|
2021-07-21 18:13:29 +02:00
|
|
|
confirm := FALSE;
|
2021-09-03 01:15:33 +02:00
|
|
|
resetTimer;
|
2021-07-21 18:13:29 +02:00
|
|
|
closing := FALSE
|
2021-05-23 11:43:28 +02:00
|
|
|
END;
|
2021-07-21 18:13:29 +02:00
|
|
|
IF ~search OR (searchText = "") THEN
|
2021-07-06 11:22:02 +02:00
|
|
|
T.wordSel(text)
|
|
|
|
END;
|
2021-05-23 11:43:28 +02:00
|
|
|
K.ClientSize(width, height);
|
2021-07-11 01:39:41 +02:00
|
|
|
IF switch THEN
|
2021-12-29 16:38:29 +01:00
|
|
|
Status(text, height);
|
2021-07-11 01:39:41 +02:00
|
|
|
Tabs.draw(tabs);
|
|
|
|
IF search & T.search(text, searchText, cs, whole) THEN END;
|
|
|
|
switch := FALSE
|
|
|
|
END;
|
|
|
|
T.draw(text);
|
2021-12-29 16:38:29 +01:00
|
|
|
Status(text, height);
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
T.getScroll(text, scrollX, scrollY);
|
2021-09-07 22:18:42 +02:00
|
|
|
DrawScroll(vScroll, LEFT + canvas.width, TOP - 1, scrollY, text.count - 1);
|
|
|
|
DrawScroll(hScroll, LEFT, TOP + canvas.height, scrollX, text.maxLength);
|
2021-09-08 22:47:14 +02:00
|
|
|
IF search & searchOpened THEN
|
2022-01-13 16:13:47 +01:00
|
|
|
CheckBox.draw(BKW);
|
|
|
|
CheckBox.draw(CS);
|
|
|
|
CheckBox.draw(WH);
|
2021-09-08 22:47:14 +02:00
|
|
|
END;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
2022-01-12 22:15:22 +01:00
|
|
|
G.SetColor(canvas, K.colors.line);
|
2022-01-08 22:10:10 +01:00
|
|
|
G.VLine(canvas, 0, 0, canvas.height - 1);
|
2021-05-23 11:43:28 +02:00
|
|
|
G.DrawCanvas(canvas, LEFT, TOP);
|
|
|
|
NotFound;
|
|
|
|
Replaced;
|
2021-12-20 20:09:01 +01:00
|
|
|
Toolbar.enable(toolbar, btnSave, text.modified);
|
|
|
|
Toolbar.enable(toolbar, btnUndo, ~ChangeLog.isFirstGuard(text.edition));
|
|
|
|
Toolbar.enable(toolbar, btnRedo, ~ChangeLog.isLastGuard(text.edition));
|
|
|
|
Toolbar.enable(toolbar, btnUpper, T.selected(text));
|
|
|
|
Toolbar.enable(toolbar, btnLower, T.selected(text));
|
|
|
|
Toolbar.enable(toolbar, btnBuild, buildScript # "");
|
|
|
|
Toolbar.enable(toolbar, btnRun, runScript # "");
|
|
|
|
Toolbar.drawIcons(toolbar)
|
2021-05-23 11:43:28 +02:00
|
|
|
END
|
|
|
|
END repaint;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE resize;
|
|
|
|
VAR
|
|
|
|
cliWidth, cliHeight: INTEGER;
|
|
|
|
BEGIN
|
|
|
|
K.WinSize(winWidth, winHeight);
|
|
|
|
IF winWidth < minWinWidth THEN
|
|
|
|
winWidth := minWinWidth
|
|
|
|
END;
|
|
|
|
IF winHeight < minWinHeight THEN
|
|
|
|
winHeight := minWinHeight
|
|
|
|
END;
|
|
|
|
K.SetWinSize(winWidth, winHeight);
|
|
|
|
K.WinSize(winWidth, winHeight);
|
|
|
|
K.ClientSize(cliWidth, cliHeight);
|
|
|
|
G.destroy(canvas);
|
2021-12-22 16:56:11 +01:00
|
|
|
canvas := G.CreateCanvas(cliWidth - (LEFT + RIGHT + 2 + RIGHT_PADDING), cliHeight - (TOP + BOTTOM + 1));
|
|
|
|
Tabs.setArea(tabs, LEFT, TOP - Tabs.tabHeight, cliWidth - (LEFT + RIGHT + 2 + RIGHT_PADDING), Tabs.tabHeight);
|
2021-05-23 11:43:28 +02:00
|
|
|
G.SetFont(canvas, font);
|
|
|
|
T.setCanvas(canvas);
|
|
|
|
T.resize(canvas.width, canvas.height);
|
2021-09-07 22:18:42 +02:00
|
|
|
Scroll.resize(vScroll, vScroll.width, canvas.height + 2);
|
|
|
|
Scroll.resize(hScroll, canvas.width + 1, hScroll.height);
|
2021-05-23 11:43:28 +02:00
|
|
|
END resize;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE SearchPanel (left, top: INTEGER);
|
|
|
|
VAR
|
2021-12-29 16:38:29 +01:00
|
|
|
y, right, bottom: INTEGER;
|
2021-05-23 11:43:28 +02:00
|
|
|
BEGIN
|
2021-07-13 12:30:43 +02:00
|
|
|
DEC(top, Tabs.tabHeight);
|
2021-05-23 11:43:28 +02:00
|
|
|
right := left + EditBox_Width + SEARCH_PADDING*2;
|
|
|
|
bottom := top + 395 + btnHeight + SEARCH_PADDING;
|
2022-01-12 22:15:22 +01:00
|
|
|
Rect(left, top, right, bottom, K.colors.line);
|
2021-12-29 16:38:29 +01:00
|
|
|
|
2021-09-14 18:33:15 +02:00
|
|
|
K.CreateButton(btnCloseSearch, right - 20, top, 20, 20, 0EF999FH, "");
|
2021-05-23 11:43:28 +02:00
|
|
|
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 + 6, right - 6, top + 15, 0FFFFFFH);
|
|
|
|
K.DrawLine(right - 15, top + 14, right - 6, 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);
|
|
|
|
|
2022-01-12 22:15:22 +01:00
|
|
|
K.CreateButton(btnHideSearch, right - 40, top, 20, 20, K.colors.button, "");
|
|
|
|
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.colors.button_text);
|
2021-07-21 18:13:29 +02:00
|
|
|
|
2021-05-23 11:43:28 +02:00
|
|
|
INC(top, 15);
|
|
|
|
INC(left, SEARCH_PADDING);
|
2022-01-12 22:15:22 +01:00
|
|
|
K.DrawText866(left, top, K.colors.work_text, "find");
|
|
|
|
K.DrawText866(left, top + 55, K.colors.work_text, "replace with");
|
|
|
|
K.DrawText866(left, top + 330, K.colors.work_text, "go to line");
|
2021-09-08 22:47:14 +02:00
|
|
|
BKW.top := top + 110;
|
|
|
|
BKW.left := left;
|
|
|
|
CS.top := top + 140;
|
|
|
|
CS.left := left;
|
|
|
|
WH.top := top + 170;
|
|
|
|
WH.left := left;
|
2021-05-23 11:43:28 +02:00
|
|
|
FindEdit.top := top + 20;
|
|
|
|
ReplaceEdit.top := top + 75;
|
|
|
|
GotoEdit.top := top + 350;
|
|
|
|
FindEdit.left := left;
|
|
|
|
ReplaceEdit.left := left;
|
|
|
|
GotoEdit.left := left;
|
2022-01-13 16:13:47 +01:00
|
|
|
EB.draw(FindEdit);
|
|
|
|
EB.draw(ReplaceEdit);
|
|
|
|
EB.draw(GotoEdit);
|
2021-05-23 11:43:28 +02:00
|
|
|
y := top + 200;
|
2022-01-12 22:15:22 +01:00
|
|
|
K.CreateButton(btnFindNext, left, y, btnWidth, btnHeight, K.colors.button, "next"); 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.colors.button, "replace all");
|
|
|
|
K.CreateButton(btnGoto, left, top + 380, btnWidth, btnHeight, K.colors.button, "go");
|
2021-05-23 11:43:28 +02:00
|
|
|
END SearchPanel;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE draw_window;
|
|
|
|
VAR
|
2021-12-20 20:09:01 +01:00
|
|
|
width, height: INTEGER;
|
2021-05-23 11:43:28 +02:00
|
|
|
BEGIN
|
|
|
|
K.BeginDraw;
|
2022-01-12 22:15:22 +01:00
|
|
|
K.CreateWindow(30 + K.GetTickCount() MOD 128, 30 + K.GetTickCount() MOD 128, winWidth, winHeight, K.colors.work, 73H, 0, 0, "");
|
2021-05-23 11:43:28 +02:00
|
|
|
IF (text # NIL) & ~K.RolledUp() THEN
|
2021-09-03 01:15:33 +02:00
|
|
|
IF confirm THEN
|
|
|
|
resetTimer
|
|
|
|
END;
|
2021-05-23 11:43:28 +02:00
|
|
|
confirm := FALSE;
|
|
|
|
K.ClientSize(width, height);
|
|
|
|
|
2022-01-12 22:15:22 +01:00
|
|
|
K.DrawRect(0, 0, width, TOP - 1, K.colors.work);
|
|
|
|
K.DrawRect(0, 0, LEFT, height, K.colors.work);
|
|
|
|
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.colors.work);
|
2021-09-11 22:57:43 +02:00
|
|
|
Menu.DrawMain(mainMenu);
|
2021-05-23 11:43:28 +02:00
|
|
|
|
2021-12-20 20:09:01 +01:00
|
|
|
Toolbar.draw(toolbar);
|
2021-12-29 16:38:29 +01:00
|
|
|
SetCaption(text.fileName);
|
|
|
|
Status(text, height);
|
2021-07-21 18:13:29 +02:00
|
|
|
IF search & searchOpened THEN
|
2021-12-22 16:56:11 +01:00
|
|
|
SearchPanel(LEFT_PADDING, TOP)
|
2021-05-23 11:43:28 +02:00
|
|
|
END;
|
2021-07-11 01:39:41 +02:00
|
|
|
Tabs.draw(tabs);
|
2021-05-23 11:43:28 +02:00
|
|
|
repaint
|
|
|
|
END;
|
|
|
|
K.EndDraw
|
|
|
|
END draw_window;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE mouse (VAR x, y: INTEGER);
|
|
|
|
VAR
|
2021-09-28 18:15:37 +02:00
|
|
|
msState: SET;
|
2021-05-23 11:43:28 +02:00
|
|
|
BEGIN
|
2021-09-28 18:15:37 +02:00
|
|
|
K.mouse(msState, x, y);
|
|
|
|
DEC(x, LEFT);
|
|
|
|
DEC(y, TOP)
|
2021-05-23 11:43:28 +02:00
|
|
|
END mouse;
|
|
|
|
|
|
|
|
|
2021-09-03 01:15:33 +02:00
|
|
|
PROCEDURE stopTimer;
|
|
|
|
BEGIN
|
|
|
|
T.hideCursor;
|
2021-12-20 20:09:01 +01:00
|
|
|
timerEnabled := FALSE;
|
|
|
|
CursorTime := CurrentTime;
|
2021-09-07 22:18:42 +02:00
|
|
|
repaint
|
2021-09-03 01:15:33 +02:00
|
|
|
END stopTimer;
|
|
|
|
|
|
|
|
|
2021-05-23 11:43:28 +02:00
|
|
|
PROCEDURE OpenFile (VAR FileName: RW.tFileName; filter: ARRAY OF CHAR);
|
|
|
|
BEGIN
|
2021-09-03 01:15:33 +02:00
|
|
|
stopTimer;
|
2021-05-23 11:43:28 +02:00
|
|
|
OpenDlg.SetFilter(OD, filter);
|
|
|
|
OpenDlg.Show(OD, 500, 400);
|
|
|
|
WHILE OD.status = 2 DO
|
|
|
|
K.Pause(30)
|
|
|
|
END;
|
|
|
|
IF OD.status = 1 THEN
|
|
|
|
COPY(OD.FilePath, FileName)
|
|
|
|
ELSE
|
|
|
|
FileName := ""
|
2021-09-03 01:15:33 +02:00
|
|
|
END;
|
|
|
|
resetTimer
|
2021-05-23 11:43:28 +02:00
|
|
|
END OpenFile;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE error (s: RW.tFileName);
|
2021-12-08 15:02:53 +01:00
|
|
|
VAR
|
|
|
|
temp: RW.tFileName;
|
2021-05-23 11:43:28 +02:00
|
|
|
BEGIN
|
2021-12-08 15:02:53 +01:00
|
|
|
temp := "'CEdit: ";
|
|
|
|
U.append8(temp, s);
|
|
|
|
U.append8(temp, "' -E");
|
2022-01-05 21:32:53 +01:00
|
|
|
K.Run("/sys/@notify", temp)
|
2021-05-23 11:43:28 +02:00
|
|
|
END error;
|
|
|
|
|
|
|
|
|
2021-07-11 01:39:41 +02:00
|
|
|
PROCEDURE saveError (name: RW.tFileName);
|
2021-05-23 11:43:28 +02:00
|
|
|
VAR
|
2021-07-11 01:39:41 +02:00
|
|
|
s: RW.tFileName;
|
|
|
|
BEGIN
|
2021-12-08 15:02:53 +01:00
|
|
|
s := "error saving file ";
|
2021-07-11 01:39:41 +02:00
|
|
|
U.append8(s, name);
|
|
|
|
error(s)
|
|
|
|
END saveError;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE saveAs (text: T.tText);
|
|
|
|
VAR
|
|
|
|
fileName, name: RW.tFileName;
|
2021-05-23 11:43:28 +02:00
|
|
|
ext: ARRAY 8 OF CHAR;
|
|
|
|
BEGIN
|
|
|
|
OD._type := OpenDlg.tsave;
|
|
|
|
U.getFileName(text.fileName, OD.FileName, U.SLASH);
|
|
|
|
IF OD.FileName = "" THEN
|
|
|
|
OD.FileName := "NewFile.";
|
2021-10-03 19:44:42 +02:00
|
|
|
Languages.getExt(text.lang, ext);
|
2021-05-23 11:43:28 +02:00
|
|
|
U.append8(OD.FileName, ext)
|
|
|
|
END;
|
|
|
|
OpenFile(fileName, EditFilter);
|
|
|
|
IF fileName # "" THEN
|
2021-09-06 23:06:31 +02:00
|
|
|
IF T.save(text, fileName) THEN
|
2021-07-11 01:39:41 +02:00
|
|
|
T.setName(text, fileName);
|
|
|
|
U.getFileName(fileName, name, U.SLASH);
|
|
|
|
Tabs.rename(tabs, curText, name)
|
2021-05-23 11:43:28 +02:00
|
|
|
ELSE
|
2021-07-11 01:39:41 +02:00
|
|
|
saveError(fileName)
|
2021-05-23 11:43:28 +02:00
|
|
|
END
|
|
|
|
END
|
|
|
|
END saveAs;
|
|
|
|
|
|
|
|
|
2021-07-11 01:39:41 +02:00
|
|
|
PROCEDURE Switch (txt: T.tText);
|
|
|
|
BEGIN
|
|
|
|
Tabs.switch(tabs, curText);
|
|
|
|
text := txt;
|
|
|
|
T.switch(txt);
|
|
|
|
switch := TRUE
|
|
|
|
END Switch;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE save (text: T.tText);
|
2021-05-23 11:43:28 +02:00
|
|
|
BEGIN
|
|
|
|
IF text.modified THEN
|
|
|
|
IF text.fileName # "" THEN
|
2021-09-06 23:06:31 +02:00
|
|
|
IF ~T.save(text, text.fileName) THEN
|
2021-07-11 01:39:41 +02:00
|
|
|
saveError(text.fileName)
|
2021-05-23 11:43:28 +02:00
|
|
|
END
|
|
|
|
ELSE
|
2021-07-11 01:39:41 +02:00
|
|
|
curText := getIdx(text);
|
|
|
|
Switch(text);
|
|
|
|
saveAs(text)
|
2021-12-08 15:02:53 +01:00
|
|
|
END;
|
|
|
|
Tabs.modify(tabs, getIdx(text), text.modified)
|
2021-05-23 11:43:28 +02:00
|
|
|
END
|
|
|
|
END save;
|
|
|
|
|
|
|
|
|
2021-07-11 01:39:41 +02:00
|
|
|
PROCEDURE saveAll;
|
|
|
|
VAR
|
|
|
|
i: INTEGER;
|
2021-12-08 15:02:53 +01:00
|
|
|
txt: T.tText;
|
2021-05-23 11:43:28 +02:00
|
|
|
BEGIN
|
2021-07-11 01:39:41 +02:00
|
|
|
i := textsCount - 1;
|
|
|
|
WHILE i >= 0 DO
|
2021-12-08 15:02:53 +01:00
|
|
|
txt := texts[i];
|
|
|
|
IF txt.modified THEN
|
|
|
|
T.switch(txt);
|
|
|
|
save(txt)
|
2021-07-11 01:39:41 +02:00
|
|
|
END;
|
|
|
|
DEC(i)
|
|
|
|
END;
|
2021-12-08 15:02:53 +01:00
|
|
|
T.switch(text)
|
2021-07-11 01:39:41 +02:00
|
|
|
END saveAll;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
|
2021-07-11 01:39:41 +02:00
|
|
|
PROCEDURE insert (pos: INTEGER; txt: T.tText);
|
2021-05-23 11:43:28 +02:00
|
|
|
VAR
|
2021-07-11 01:39:41 +02:00
|
|
|
i: INTEGER;
|
|
|
|
name: RW.tFileName;
|
2021-05-23 11:43:28 +02:00
|
|
|
BEGIN
|
2021-07-11 01:39:41 +02:00
|
|
|
FOR i := textsCount - 1 TO pos BY -1 DO
|
|
|
|
texts[i + 1] := texts[i]
|
|
|
|
END;
|
|
|
|
texts[pos] := txt;
|
|
|
|
INC(textsCount);
|
|
|
|
curText := pos;
|
|
|
|
IF txt.fileName = "" THEN
|
|
|
|
name := "new"
|
|
|
|
ELSE
|
|
|
|
U.getFileName(txt.fileName, name, U.SLASH)
|
|
|
|
END;
|
|
|
|
Tabs.add(tabs, name);
|
|
|
|
Switch(txt)
|
|
|
|
END insert;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE Confirm;
|
|
|
|
CONST
|
|
|
|
width = btnWidth*2 + 30;
|
|
|
|
height = btnHeight*2 + 20;
|
|
|
|
VAR
|
|
|
|
left, top, right, bottom: INTEGER;
|
|
|
|
BEGIN
|
2021-09-03 01:15:33 +02:00
|
|
|
stopTimer;
|
2021-05-23 11:43:28 +02:00
|
|
|
draw_window;
|
|
|
|
confirm := TRUE;
|
|
|
|
left := (canvas.width - width) DIV 2 + LEFT;
|
|
|
|
top := (canvas.height - height) DIV 2 + TOP;
|
|
|
|
right := left + width - 1;
|
|
|
|
bottom := top + height - 1;
|
2022-01-12 22:15:22 +01:00
|
|
|
K.DrawRect(left, top, width, height, K.colors.work);
|
|
|
|
Rect(left, top, right, bottom, K.colors.line);
|
|
|
|
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.colors.button, "yes");
|
|
|
|
K.CreateButton(btnNo, left + 20 + btnWidth, top + 35, btnWidth, btnHeight, K.colors.button, "no");
|
2021-05-23 11:43:28 +02:00
|
|
|
END Confirm;
|
|
|
|
|
|
|
|
|
2021-07-13 12:30:43 +02:00
|
|
|
PROCEDURE closeFile (conf: BOOLEAN; n: INTEGER);
|
2021-07-11 01:39:41 +02:00
|
|
|
VAR
|
|
|
|
i: INTEGER;
|
|
|
|
BEGIN
|
2021-07-21 18:13:29 +02:00
|
|
|
IF texts[n].modified & conf THEN
|
2021-07-11 01:39:41 +02:00
|
|
|
Confirm
|
|
|
|
ELSE
|
2021-07-13 12:30:43 +02:00
|
|
|
Tabs.delete(tabs, n);
|
2021-12-20 20:09:01 +01:00
|
|
|
T.destroy(texts[n]);
|
2021-07-13 12:30:43 +02:00
|
|
|
FOR i := n + 1 TO textsCount - 1 DO
|
2021-07-11 01:39:41 +02:00
|
|
|
texts[i - 1] := texts[i]
|
|
|
|
END;
|
|
|
|
DEC(textsCount);
|
2021-07-13 12:30:43 +02:00
|
|
|
IF (curText = textsCount) OR (n < curText) THEN
|
2021-07-11 01:39:41 +02:00
|
|
|
DEC(curText)
|
|
|
|
END;
|
|
|
|
IF curText >= 0 THEN
|
|
|
|
Switch(texts[curText])
|
|
|
|
ELSE
|
2021-09-07 22:18:42 +02:00
|
|
|
K.Exit
|
2021-07-11 01:39:41 +02:00
|
|
|
END;
|
|
|
|
draw_window
|
|
|
|
END
|
|
|
|
END closeFile;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE NewFile;
|
|
|
|
VAR
|
|
|
|
nov: T.tText;
|
|
|
|
BEGIN
|
|
|
|
IF textsCount < maxTexts THEN
|
|
|
|
nov := T.New();
|
|
|
|
T.SetPos(nov, 0, 0);
|
|
|
|
insert(textsCount, nov)
|
|
|
|
ELSE
|
2021-12-08 15:02:53 +01:00
|
|
|
error("too many files")
|
2021-07-11 01:39:41 +02:00
|
|
|
END
|
|
|
|
END NewFile;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE getFileNum (fileName: RW.tFileName): INTEGER;
|
|
|
|
VAR
|
|
|
|
i: INTEGER;
|
|
|
|
|
|
|
|
PROCEDURE nameEq (name1, name2: RW.tFileName): BOOLEAN;
|
|
|
|
VAR
|
|
|
|
n1, n2: RW.tFileName;
|
|
|
|
BEGIN
|
|
|
|
n1 := name1;
|
|
|
|
n2 := name2;
|
|
|
|
U.upcase(n1);
|
|
|
|
U.upcase(n2)
|
|
|
|
RETURN n1 = n2
|
|
|
|
END nameEq;
|
|
|
|
|
|
|
|
BEGIN
|
|
|
|
i := 0;
|
|
|
|
WHILE (i < textsCount) & ~nameEq(texts[i].fileName, fileName) DO
|
|
|
|
INC(i)
|
|
|
|
END;
|
|
|
|
IF i = textsCount THEN
|
|
|
|
i := -1
|
|
|
|
END
|
|
|
|
RETURN i
|
|
|
|
END getFileNum;
|
|
|
|
|
|
|
|
|
2021-07-21 18:13:29 +02:00
|
|
|
PROCEDURE SwitchTab (n: INTEGER);
|
|
|
|
BEGIN
|
|
|
|
curText := n;
|
|
|
|
Tabs.switch(tabs, n);
|
|
|
|
Switch(texts[n]);
|
2021-09-03 01:15:33 +02:00
|
|
|
resetTimer;
|
2021-07-21 18:13:29 +02:00
|
|
|
draw_window
|
|
|
|
END SwitchTab;
|
|
|
|
|
|
|
|
|
2022-01-12 22:15:22 +01:00
|
|
|
PROCEDURE open (_fileName: RW.tFileName): BOOLEAN;
|
2021-07-11 01:39:41 +02:00
|
|
|
VAR
|
2022-01-12 22:15:22 +01:00
|
|
|
fileName: RW.tFileName;
|
2021-07-11 01:39:41 +02:00
|
|
|
nov: T.tText;
|
|
|
|
err, n: INTEGER;
|
2022-01-12 22:15:22 +01:00
|
|
|
res: BOOLEAN;
|
2021-07-11 01:39:41 +02:00
|
|
|
BEGIN
|
2022-01-12 22:15:22 +01:00
|
|
|
res := TRUE;
|
2021-07-11 01:39:41 +02:00
|
|
|
IF textsCount < maxTexts THEN
|
2022-01-12 22:15:22 +01:00
|
|
|
fileName := _fileName;
|
|
|
|
IF fileName = "" THEN
|
|
|
|
OD._type := OpenDlg.topen;
|
|
|
|
OpenFile(fileName, EditFilter)
|
|
|
|
END;
|
2021-07-11 01:39:41 +02:00
|
|
|
IF fileName # "" THEN
|
|
|
|
n := getFileNum(fileName);
|
|
|
|
IF n = -1 THEN
|
|
|
|
nov := T.open(fileName, err);
|
|
|
|
IF nov = NIL THEN
|
2022-01-12 22:15:22 +01:00
|
|
|
error("error opening file");
|
|
|
|
SwitchTab(curText);
|
|
|
|
res := FALSE
|
2021-07-11 01:39:41 +02:00
|
|
|
ELSE
|
2021-12-17 07:12:02 +01:00
|
|
|
T.SetPos(nov, 0, 0);
|
2021-07-11 01:39:41 +02:00
|
|
|
insert(textsCount, nov);
|
2021-12-17 07:12:02 +01:00
|
|
|
Scroll.setValue(hScroll, 0);
|
|
|
|
Scroll.setValue(vScroll, 0)
|
2021-07-11 01:39:41 +02:00
|
|
|
END
|
|
|
|
ELSE
|
2021-07-21 18:13:29 +02:00
|
|
|
SwitchTab(n)
|
2021-07-11 01:39:41 +02:00
|
|
|
END
|
|
|
|
END
|
|
|
|
ELSE
|
2022-01-12 22:15:22 +01:00
|
|
|
error("too many files");
|
|
|
|
res := FALSE
|
2021-07-11 01:39:41 +02:00
|
|
|
END
|
2022-01-12 22:15:22 +01:00
|
|
|
RETURN res
|
2021-07-11 01:39:41 +02:00
|
|
|
END open;
|
|
|
|
|
|
|
|
|
2022-01-12 22:15:22 +01:00
|
|
|
PROCEDURE OpenDial;
|
|
|
|
VAR
|
|
|
|
res: BOOLEAN;
|
|
|
|
BEGIN
|
|
|
|
res := open("")
|
|
|
|
END OpenDial;
|
|
|
|
|
|
|
|
|
2021-05-23 11:43:28 +02:00
|
|
|
PROCEDURE createSearchForm;
|
|
|
|
BEGIN
|
2021-12-22 16:56:11 +01:00
|
|
|
EB.create(LEFT_PADDING, TOP + 20, EditBox_Width, EDITBOX_MAXCHARS, FindEdit);
|
|
|
|
EB.create(LEFT_PADDING, TOP + 20 + 55, EditBox_Width, EDITBOX_MAXCHARS, ReplaceEdit);
|
|
|
|
EB.create(LEFT_PADDING, TOP + 20 + 330, EditBox_Width, EDITBOX_MAXCHARS, GotoEdit);
|
2021-09-28 18:15:37 +02:00
|
|
|
INCL(GotoEdit.flags, 15);
|
2021-09-11 22:57:43 +02:00
|
|
|
CheckBox.create("backward", BKW);
|
|
|
|
CheckBox.create("match case", CS);
|
|
|
|
CheckBox.create("whole word", WH);
|
2021-05-23 11:43:28 +02:00
|
|
|
END createSearchForm;
|
|
|
|
|
|
|
|
|
2021-09-11 22:57:43 +02:00
|
|
|
PROCEDURE EditBox_GetValue (edit: EB.tEditBox; VAR s: ARRAY OF WCHAR);
|
2021-05-23 11:43:28 +02:00
|
|
|
VAR
|
|
|
|
str: ARRAY EDITBOX_MAXCHARS + 1 OF CHAR;
|
|
|
|
i: INTEGER;
|
|
|
|
BEGIN
|
2021-09-11 22:57:43 +02:00
|
|
|
EB.getValue(edit, str);
|
2021-05-23 11:43:28 +02:00
|
|
|
i := 0;
|
|
|
|
WHILE str[i] # 0X DO
|
|
|
|
s[i] := WCHR(E.cp866[ORD(str[i])]);
|
|
|
|
INC(i)
|
|
|
|
END;
|
|
|
|
s[i] := 0X
|
|
|
|
END EditBox_GetValue;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE Search;
|
|
|
|
BEGIN
|
|
|
|
search := ~search;
|
2021-12-22 16:56:11 +01:00
|
|
|
LEFT := LEFT_PADDING;
|
2021-05-23 11:43:28 +02:00
|
|
|
IF search THEN
|
2021-07-21 18:13:29 +02:00
|
|
|
searchOpened := TRUE;
|
2021-12-22 16:56:11 +01:00
|
|
|
INC(LEFT, EditBox_Width + SEARCH_PADDING*2 + 4);
|
2021-05-23 11:43:28 +02:00
|
|
|
IF T.search(text, searchText, cs, whole) THEN END
|
|
|
|
ELSE
|
|
|
|
IF T.search(text, "", FALSE, FALSE) THEN END
|
|
|
|
END;
|
2021-07-21 18:13:29 +02:00
|
|
|
SetFocus(FindEdit, search);
|
2021-05-23 11:43:28 +02:00
|
|
|
resize;
|
|
|
|
draw_window
|
|
|
|
END Search;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE click (x, y: INTEGER): INTEGER;
|
|
|
|
VAR
|
|
|
|
scrollX, scrollY: INTEGER;
|
2021-07-21 18:13:29 +02:00
|
|
|
shift, ctrl: BOOLEAN;
|
2021-05-23 11:43:28 +02:00
|
|
|
BEGIN
|
2021-09-11 22:57:43 +02:00
|
|
|
K.getKBState(shift, ctrl);
|
|
|
|
T.getScroll(text, scrollX, scrollY);
|
|
|
|
T.scroll(text, hScroll.value - scrollX, vScroll.value - scrollY);
|
2021-09-28 18:15:37 +02:00
|
|
|
IF U.between(0, x, canvas.width - 1) & U.between(0, y, canvas.height - 1) THEN
|
2021-05-23 11:43:28 +02:00
|
|
|
leftButton := TRUE;
|
2021-07-21 18:13:29 +02:00
|
|
|
SetFocus(FindEdit, FALSE);
|
|
|
|
IF ~shift THEN
|
2021-05-23 11:43:28 +02:00
|
|
|
T.resetSelect(text)
|
|
|
|
END;
|
2021-09-11 22:57:43 +02:00
|
|
|
T.mouse(text, x, y)
|
|
|
|
END;
|
|
|
|
repaint
|
2021-05-23 11:43:28 +02:00
|
|
|
RETURN K.GetTickCount()
|
|
|
|
END click;
|
|
|
|
|
|
|
|
|
2021-07-21 18:13:29 +02:00
|
|
|
PROCEDURE Close;
|
2021-07-11 01:39:41 +02:00
|
|
|
VAR
|
|
|
|
cont: BOOLEAN;
|
2021-05-23 11:43:28 +02:00
|
|
|
BEGIN
|
2021-07-21 18:13:29 +02:00
|
|
|
closing := TRUE;
|
2021-07-11 01:39:41 +02:00
|
|
|
cont := TRUE;
|
|
|
|
WHILE (textsCount > 0) & cont DO
|
|
|
|
IF text.modified THEN
|
|
|
|
Confirm;
|
|
|
|
cont := FALSE
|
|
|
|
ELSE
|
2021-07-13 12:30:43 +02:00
|
|
|
closeFile(FALSE, curText);
|
2021-07-11 01:39:41 +02:00
|
|
|
repaint
|
|
|
|
END
|
2021-05-23 11:43:28 +02:00
|
|
|
END
|
2021-07-21 18:13:29 +02:00
|
|
|
END Close;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
|
2021-09-03 01:15:33 +02:00
|
|
|
PROCEDURE CloseMenu;
|
|
|
|
BEGIN
|
2021-09-14 18:33:15 +02:00
|
|
|
Menu.close(subEOL);
|
|
|
|
Menu.close(subCurLine);
|
|
|
|
Menu.close(subIndent);
|
|
|
|
Menu.close(subCase);
|
|
|
|
Menu.close(subBookmark);
|
2021-09-03 01:15:33 +02:00
|
|
|
Menu.close(menuFile);
|
|
|
|
Menu.close(menuEdit);
|
|
|
|
Menu.close(menuSearch);
|
|
|
|
Menu.close(menuEncoding);
|
|
|
|
Menu.close(menuView);
|
2021-09-14 18:33:15 +02:00
|
|
|
Menu.close(menuLanguage);
|
2021-09-03 01:15:33 +02:00
|
|
|
Menu.close(menuProgram);
|
|
|
|
Menu.close(menuTools);
|
2021-09-11 22:57:43 +02:00
|
|
|
Menu.close(context)
|
2021-09-03 01:15:33 +02:00
|
|
|
END CloseMenu;
|
|
|
|
|
|
|
|
|
2021-05-23 11:43:28 +02:00
|
|
|
PROCEDURE goto;
|
|
|
|
VAR
|
|
|
|
gotoVal: INTEGER;
|
|
|
|
BEGIN
|
|
|
|
EditBox_GetValue(GotoEdit, gotoText);
|
2021-09-03 01:15:33 +02:00
|
|
|
IF U.str2int(gotoText, gotoVal) & T.goto(text, gotoVal) THEN
|
|
|
|
SetFocus(GotoEdit, FALSE)
|
|
|
|
END
|
2021-05-23 11:43:28 +02:00
|
|
|
END goto;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE Script (script: ARRAY OF CHAR);
|
|
|
|
BEGIN
|
|
|
|
IF script # "" THEN
|
2022-01-13 16:13:47 +01:00
|
|
|
U.getPath(script, CurFolder);
|
|
|
|
K.SetCurFolder(CurFolder);
|
2022-01-05 21:32:53 +01:00
|
|
|
K.Run("/sys/@open", script)
|
2021-05-23 11:43:28 +02:00
|
|
|
END
|
|
|
|
END Script;
|
|
|
|
|
|
|
|
|
2021-09-21 20:16:56 +02:00
|
|
|
PROCEDURE ShowSearchPanel (goto: BOOLEAN);
|
|
|
|
VAR
|
|
|
|
i: INTEGER;
|
|
|
|
BEGIN
|
|
|
|
IF T.selected(text) & ~goto THEN
|
|
|
|
T.getSelectedText(text, new_searchText);
|
|
|
|
IF new_searchText # "" THEN
|
|
|
|
i := 0;
|
|
|
|
WHILE (new_searchText[i] # 0X) & (new_searchText[i] # Lines.TAB) DO
|
|
|
|
INC(i)
|
|
|
|
END;
|
|
|
|
IF new_searchText[i] = 0X THEN
|
|
|
|
searchText := new_searchText;
|
|
|
|
EB.setValue(FindEdit, searchText);
|
|
|
|
notFound := ~T.search(text, searchText, cs, whole);
|
|
|
|
END
|
|
|
|
END
|
|
|
|
END;
|
2021-07-21 18:13:29 +02:00
|
|
|
IF ~search THEN
|
|
|
|
Search
|
|
|
|
ELSIF ~searchOpened THEN
|
|
|
|
search := FALSE;
|
|
|
|
Search
|
2021-09-21 20:16:56 +02:00
|
|
|
END;
|
2021-12-08 15:02:53 +01:00
|
|
|
IF goto THEN
|
|
|
|
SetFocus(GotoEdit, TRUE)
|
2021-09-21 20:16:56 +02:00
|
|
|
ELSE
|
2021-12-20 20:09:01 +01:00
|
|
|
SetFocus(FindEdit, TRUE)
|
2021-07-21 18:13:29 +02:00
|
|
|
END
|
|
|
|
END ShowSearchPanel;
|
|
|
|
|
|
|
|
|
2021-09-03 01:15:33 +02:00
|
|
|
PROCEDURE CanvasToScreen (VAR x, y: INTEGER);
|
|
|
|
VAR
|
|
|
|
cliX, cliY,
|
|
|
|
winX, winY: INTEGER;
|
|
|
|
BEGIN
|
|
|
|
K.WinPos(winX, winY);
|
|
|
|
K.ClientPos(cliX, cliY);
|
|
|
|
x := x + winX + cliX + LEFT;
|
|
|
|
y := y + winY + cliY + TOP;
|
|
|
|
END CanvasToScreen;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE ShowMenu (menu: Menu.tMenu);
|
|
|
|
VAR
|
|
|
|
winX, winY, cliX, cliY, x, y, i: INTEGER;
|
|
|
|
selected, enabled: BOOLEAN;
|
|
|
|
BEGIN
|
|
|
|
IF menu = context THEN
|
|
|
|
mouse(x, y);
|
2021-09-28 18:15:37 +02:00
|
|
|
IF ~(U.between(0, x, canvas.width - 1) & U.between(0, y, canvas.height - 1)) THEN
|
2021-09-03 01:15:33 +02:00
|
|
|
menu := NIL
|
|
|
|
END
|
|
|
|
ELSE
|
|
|
|
K.WinPos(winX, winY);
|
|
|
|
K.ClientPos(cliX, cliY);
|
|
|
|
x := winX + cliX;
|
2021-09-11 22:57:43 +02:00
|
|
|
y := Menu.MainMenuHeight + winY + cliY
|
2021-09-03 01:15:33 +02:00
|
|
|
END;
|
|
|
|
selected := T.selected(text);
|
|
|
|
|
|
|
|
IF menu = menuFile THEN
|
|
|
|
Menu.setEnabled(menu, menuSave, text.modified);
|
|
|
|
Menu.setEnabled(menu, menuFolder, text.fileName # "");
|
|
|
|
i := 0;
|
|
|
|
WHILE (i < textsCount) & ~texts[i].modified DO
|
|
|
|
INC(i)
|
|
|
|
END;
|
|
|
|
Menu.setEnabled(menu, menuSaveAll, i < textsCount);
|
|
|
|
INC(x, menuFileX)
|
|
|
|
ELSIF (menu = menuEdit) OR (menu = context) THEN
|
|
|
|
Menu.setEnabled(menu, menuUndo, ~ChangeLog.isFirstGuard(text.edition));
|
|
|
|
Menu.setEnabled(menu, menuRedo, ~ChangeLog.isLastGuard(text.edition));
|
|
|
|
Menu.setEnabled(menu, menuCut, selected);
|
|
|
|
Menu.setEnabled(menu, menuCopy, selected);
|
|
|
|
Menu.setEnabled(menu, menuDelete, selected);
|
|
|
|
Menu.setEnabled(menu, menuPaste, CB.available());
|
|
|
|
IF menu = menuEdit THEN
|
|
|
|
INC(x, menuEditX)
|
|
|
|
ELSE
|
|
|
|
IF y + menu.height >= canvas.height THEN
|
|
|
|
DEC(y, menu.height)
|
|
|
|
END;
|
|
|
|
IF x + menu.width >= canvas.width THEN
|
|
|
|
DEC(x, menu.width)
|
|
|
|
END;
|
|
|
|
CanvasToScreen(x, y)
|
|
|
|
END
|
|
|
|
ELSIF menu = menuEncoding THEN
|
2021-11-27 18:19:15 +01:00
|
|
|
Menu.option(menu, menuUTF8BOM, T.getEnc(text) = E.UTF8BOM);
|
|
|
|
Menu.option(menu, menuUTF8, T.getEnc(text) = E.UTF8);
|
|
|
|
Menu.option(menu, menuCP866, T.getEnc(text) = E.CP866);
|
|
|
|
Menu.option(menu, menuWin1251, T.getEnc(text) = E.W1251);
|
2021-09-03 01:15:33 +02:00
|
|
|
INC(x, menuEncodingX)
|
|
|
|
ELSIF menu = menuView THEN
|
2021-09-08 22:47:14 +02:00
|
|
|
Menu.check(menu, menuNumbers, text.numbers);
|
|
|
|
Menu.check(menu, menuFontSize, font = font2);
|
2021-09-03 01:15:33 +02:00
|
|
|
FOR i := 0 TO Ini.sections.count - 1 DO
|
2021-09-08 22:47:14 +02:00
|
|
|
Menu.option(menu, menuColors + i, Ini.curSectionNum = i)
|
2021-09-03 01:15:33 +02:00
|
|
|
END;
|
|
|
|
INC(x, menuViewX)
|
2021-09-14 18:33:15 +02:00
|
|
|
ELSIF menu = menuLanguage THEN
|
|
|
|
Menu.option(menu, menuText, text.lang = Languages.langText);
|
2021-09-08 22:47:14 +02:00
|
|
|
Menu.option(menu, menuC, text.lang = Languages.langC);
|
|
|
|
Menu.option(menu, menuFasm, text.lang = Languages.langFasm);
|
|
|
|
Menu.option(menu, menuIni, text.lang = Languages.langIni);
|
|
|
|
Menu.option(menu, menuJSON, text.lang = Languages.langJSON);
|
|
|
|
Menu.option(menu, menuLua, text.lang = Languages.langLua);
|
|
|
|
Menu.option(menu, menuOberon, text.lang = Languages.langOberon);
|
|
|
|
Menu.option(menu, menuPascal, text.lang = Languages.langPascal);
|
2021-09-14 18:33:15 +02:00
|
|
|
INC(x, menuLanguageX)
|
2021-09-03 01:15:33 +02:00
|
|
|
ELSIF menu = menuProgram THEN
|
|
|
|
Menu.setEnabled(menu, menuBuild, buildScript # "");
|
|
|
|
Menu.setEnabled(menu, menuDebug, debugScript # "");
|
|
|
|
Menu.setEnabled(menu, menuRun, runScript # "");
|
|
|
|
INC(x, menuProgramX)
|
|
|
|
ELSIF menu = menuTools THEN
|
|
|
|
INC(x, menuToolsX)
|
|
|
|
ELSIF menu = menuSearch THEN
|
|
|
|
INC(x, menuSearchX)
|
|
|
|
END;
|
|
|
|
|
|
|
|
enabled := search & (searchText # "");
|
|
|
|
Menu.setEnabled(menuSearch, menuFindNext, enabled);
|
|
|
|
Menu.setEnabled(menuSearch, menuFindPrev, enabled);
|
|
|
|
|
|
|
|
Menu.setEnabled(subIndent, menuIncInd, selected);
|
|
|
|
Menu.setEnabled(subIndent, menuDecInd, selected);
|
|
|
|
|
|
|
|
Menu.setEnabled(subCase, menuUpper, selected);
|
|
|
|
Menu.setEnabled(subCase, menuLower, selected);
|
|
|
|
|
2021-11-27 18:19:15 +01:00
|
|
|
Menu.option(subEOL, menuCRLF, T.getEol(text) = RW.EOL_CRLF);
|
|
|
|
Menu.option(subEOL, menuLF, T.getEol(text) = RW.EOL_LF);
|
|
|
|
Menu.option(subEOL, menuCR, T.getEol(text) = RW.EOL_CR);
|
2021-09-14 18:33:15 +02:00
|
|
|
|
2021-09-03 01:15:33 +02:00
|
|
|
IF menu # NIL THEN
|
2021-12-20 20:09:01 +01:00
|
|
|
timerEnabled := FALSE;
|
2021-09-03 01:15:33 +02:00
|
|
|
IF Menu.opened(menu) THEN
|
|
|
|
Menu.close(menu)
|
|
|
|
END;
|
2021-09-03 18:20:40 +02:00
|
|
|
Menu.open(menu, x, y);
|
|
|
|
menuActive := TRUE
|
|
|
|
END
|
2021-09-03 01:15:33 +02:00
|
|
|
END ShowMenu;
|
|
|
|
|
|
|
|
|
2021-09-28 18:15:37 +02:00
|
|
|
PROCEDURE setScript (VAR script: RW.tFileName);
|
|
|
|
VAR
|
|
|
|
temp: RW.tFileName;
|
|
|
|
BEGIN
|
|
|
|
OpenFile(temp, ShellFilter);
|
|
|
|
IF temp # "" THEN
|
|
|
|
script := temp
|
|
|
|
END
|
|
|
|
END setScript;
|
|
|
|
|
|
|
|
|
2022-01-18 17:23:19 +01:00
|
|
|
PROCEDURE ClickMenu;
|
2021-09-03 01:15:33 +02:00
|
|
|
VAR
|
2021-09-11 22:57:43 +02:00
|
|
|
item: List.tItem;
|
2021-05-23 11:43:28 +02:00
|
|
|
BEGIN
|
2022-01-18 17:23:19 +01:00
|
|
|
IF Menu.MenuItem < 0 THEN
|
|
|
|
item := List.getItem(mainMenu, (-Menu.MenuItem - mainMenuBtn) MOD mainMenu.count);
|
|
|
|
IF item # NIL THEN
|
|
|
|
ShowMenu(item(Menu.tMainItem).menu)
|
|
|
|
END;
|
|
|
|
Menu.SetItem(0)
|
|
|
|
END;
|
|
|
|
CASE Menu.MenuItem OF
|
|
|
|
|0:
|
|
|
|
|menuCut: T.key(text, ORD("X"), FALSE, TRUE)
|
|
|
|
|menuCopy: T.key(text, ORD("C"), FALSE, TRUE)
|
|
|
|
|menuPaste: T.key(text, ORD("V"), FALSE, TRUE)
|
|
|
|
|menuDelete: T.key(text, 46, FALSE, FALSE)
|
|
|
|
|menuSelectAll: T.key(text, ORD("A"), FALSE, TRUE)
|
|
|
|
|
|
|
|
|menuNew:
|
|
|
|
NewFile
|
|
|
|
|menuOpen:
|
|
|
|
OpenDial
|
|
|
|
|menuSave:
|
|
|
|
save(text);
|
|
|
|
repaint
|
|
|
|
|menuSaveAs:
|
|
|
|
saveAs(text);
|
|
|
|
repaint
|
|
|
|
|menuSaveAll:
|
|
|
|
saveAll;
|
|
|
|
repaint
|
|
|
|
|menuClose:
|
|
|
|
closeFile(TRUE, curText)
|
|
|
|
|menuFolder:
|
|
|
|
K.Run("/sys/File Managers/Eolite", text.fileName)
|
|
|
|
|menuExit:
|
|
|
|
Close
|
|
|
|
|menuUndo:
|
|
|
|
T.undo(text);
|
|
|
|
repaint
|
|
|
|
|menuRedo:
|
|
|
|
T.redo(text);
|
|
|
|
repaint
|
|
|
|
|menuFind:
|
|
|
|
ShowSearchPanel(FALSE)
|
|
|
|
|menuFindNext:
|
|
|
|
notFound := ~T.findNext(text, BKW.value);
|
|
|
|
menuFindClicked := TRUE
|
|
|
|
|menuFindPrev:
|
|
|
|
notFound := ~T.findNext(text, ~BKW.value);
|
|
|
|
menuFindClicked := TRUE
|
|
|
|
|menuGoto:
|
|
|
|
ShowSearchPanel(TRUE)
|
|
|
|
|menuToggleBookmark:
|
|
|
|
T.toggleLabel(text)
|
|
|
|
|menuNextBookmark:
|
|
|
|
T.gotoLabel(text, TRUE)
|
|
|
|
|menuPrevBookmark:
|
|
|
|
T.gotoLabel(text, FALSE)
|
|
|
|
|menuNumbers:
|
|
|
|
T.toggleNumbers(text)
|
|
|
|
|menuFontSize:
|
|
|
|
IF font = font1 THEN
|
|
|
|
font := font2
|
2021-05-23 11:43:28 +02:00
|
|
|
ELSE
|
2022-01-18 17:23:19 +01:00
|
|
|
font := font1
|
|
|
|
END;
|
|
|
|
resize
|
|
|
|
|menuText:
|
|
|
|
T.setLang(text, Languages.langText)
|
|
|
|
|menuC:
|
|
|
|
T.setLang(text, Languages.langC)
|
|
|
|
|menuFasm:
|
|
|
|
T.setLang(text, Languages.langFasm)
|
|
|
|
|menuIni:
|
|
|
|
T.setLang(text, Languages.langIni)
|
|
|
|
|menuJSON:
|
|
|
|
T.setLang(text, Languages.langJSON)
|
|
|
|
|menuLua:
|
|
|
|
T.setLang(text, Languages.langLua)
|
|
|
|
|menuOberon:
|
|
|
|
T.setLang(text, Languages.langOberon)
|
|
|
|
|menuPascal:
|
|
|
|
T.setLang(text, Languages.langPascal)
|
|
|
|
|menuBuild:
|
|
|
|
Script(buildScript)
|
|
|
|
|menuBuildScript:
|
|
|
|
setScript(buildScript)
|
|
|
|
|menuRun:
|
|
|
|
Script(runScript)
|
|
|
|
|menuRunScript:
|
|
|
|
setScript(runScript)
|
|
|
|
|menuDebug:
|
|
|
|
Script(debugScript)
|
|
|
|
|menuDebugScript:
|
|
|
|
setScript(debugScript)
|
|
|
|
|menuUTF8BOM:
|
|
|
|
T.setEnc(text, E.UTF8BOM)
|
|
|
|
|menuUTF8:
|
|
|
|
T.setEnc(text, E.UTF8)
|
|
|
|
|menuCP866:
|
|
|
|
T.setEnc(text, E.CP866)
|
|
|
|
|menuWin1251:
|
|
|
|
T.setEnc(text, E.W1251)
|
|
|
|
|menuLF:
|
|
|
|
T.setEol(text, RW.EOL_LF)
|
|
|
|
|menuCRLF:
|
|
|
|
T.setEol(text, RW.EOL_CRLF)
|
|
|
|
|menuCR:
|
|
|
|
T.setEol(text, RW.EOL_CR)
|
|
|
|
|menuPipet:
|
|
|
|
K.Run("/sys/develop/pipet", "")
|
|
|
|
|menuMagnify:
|
|
|
|
K.Run("/sys/magnify", "")
|
|
|
|
|menuBoard:
|
|
|
|
K.Run("/sys/develop/board", "")
|
|
|
|
|menuSysFunc:
|
|
|
|
K.Run("/sys/docpack", "f")
|
|
|
|
|menuColors..menuMaxColors:
|
|
|
|
Ini.selectSection(Menu.MenuItem - menuColors)
|
|
|
|
|menuMoveUp:
|
|
|
|
T.MoveLines(text, FALSE)
|
|
|
|
|menuMoveDown:
|
|
|
|
T.MoveLines(text, TRUE)
|
|
|
|
|menuDuplicate:
|
|
|
|
T.dupLine(text)
|
|
|
|
|menuRemove:
|
|
|
|
T.delLine(text)
|
|
|
|
|menuIncInd:
|
|
|
|
T.Indent(text, TRUE)
|
|
|
|
|menuDecInd:
|
|
|
|
T.Indent(text, FALSE)
|
|
|
|
|menuUpper:
|
|
|
|
T.chCase(text, TRUE)
|
|
|
|
|menuLower:
|
|
|
|
T.chCase(text, FALSE)
|
2021-05-23 11:43:28 +02:00
|
|
|
END;
|
2022-01-18 17:23:19 +01:00
|
|
|
Menu.SetItem(0)
|
|
|
|
END ClickMenu;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE CreateContextMenu (): Menu.tMenu;
|
|
|
|
VAR
|
|
|
|
menu: List.tList;
|
|
|
|
BEGIN
|
|
|
|
menu := List.create(NIL);
|
|
|
|
Menu.AddMenuItem(menu, menuUndo, "undo ctrl-Z");
|
|
|
|
Menu.AddMenuItem(menu, menuRedo, "redo ctrl-Y");
|
|
|
|
Menu.delimiter(menu);
|
|
|
|
Menu.AddMenuItem(menu, menuCut, "cut ctrl-X");
|
|
|
|
Menu.AddMenuItem(menu, menuCopy, "copy ctrl-C");
|
|
|
|
Menu.AddMenuItem(menu, menuPaste, "paste ctrl-V");
|
|
|
|
Menu.AddMenuItem(menu, menuDelete, "delete");
|
|
|
|
Menu.delimiter(menu);
|
|
|
|
Menu.AddMenuItem(menu, menuSelectAll, "select all ctrl-A");
|
2022-01-18 17:23:19 +01:00
|
|
|
RETURN Menu.create(menu)
|
2021-05-23 11:43:28 +02:00
|
|
|
END CreateContextMenu;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE CreateMenuFile (): Menu.tMenu;
|
|
|
|
VAR
|
|
|
|
menu: List.tList;
|
|
|
|
BEGIN
|
|
|
|
menu := List.create(NIL);
|
2021-07-11 01:39:41 +02:00
|
|
|
Menu.AddMenuItem(menu, menuNew, "new ctrl-N");
|
|
|
|
Menu.AddMenuItem(menu, menuOpen, "open ctrl-O");
|
|
|
|
Menu.AddMenuItem(menu, menuSave, "save ctrl-S");
|
|
|
|
Menu.AddMenuItem(menu, menuSaveAs, "save as");
|
|
|
|
Menu.AddMenuItem(menu, menuSaveAll, "save all");
|
|
|
|
Menu.AddMenuItem(menu, menuFolder, "folder");
|
2021-05-23 11:43:28 +02:00
|
|
|
Menu.delimiter(menu);
|
2021-07-13 12:30:43 +02:00
|
|
|
Menu.AddMenuItem(menu, menuClose, "close ctrl-W");
|
2021-07-11 01:39:41 +02:00
|
|
|
Menu.delimiter(menu);
|
|
|
|
Menu.AddMenuItem(menu, menuExit, "exit");
|
2022-01-18 17:23:19 +01:00
|
|
|
RETURN Menu.create(menu)
|
2021-05-23 11:43:28 +02:00
|
|
|
END CreateMenuFile;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE CreateMenuEdit (): Menu.tMenu;
|
|
|
|
VAR
|
|
|
|
menu: List.tList;
|
|
|
|
BEGIN
|
|
|
|
menu := List.create(NIL);
|
2021-09-03 01:15:33 +02:00
|
|
|
Menu.AddMenuItem(menu, menuUndo, "undo ctrl-Z");
|
|
|
|
Menu.AddMenuItem(menu, menuRedo, "redo ctrl-Y");
|
2021-05-23 11:43:28 +02:00
|
|
|
Menu.delimiter(menu);
|
2021-09-03 01:15:33 +02:00
|
|
|
Menu.AddMenuItem(menu, menuCut, "cut ctrl-X");
|
|
|
|
Menu.AddMenuItem(menu, menuCopy, "copy ctrl-C");
|
|
|
|
Menu.AddMenuItem(menu, menuPaste, "paste ctrl-V");
|
2021-05-23 11:43:28 +02:00
|
|
|
Menu.AddMenuItem(menu, menuDelete, "delete");
|
|
|
|
Menu.delimiter(menu);
|
2021-09-03 01:15:33 +02:00
|
|
|
Menu.AddMenuItem(menu, menuSelectAll, "select all ctrl-A");
|
|
|
|
Menu.delimiter(menu);
|
|
|
|
Menu.AddMenuItem(menu, menuCurLine, "current line");
|
|
|
|
Menu.child(menu, subCurLine);
|
|
|
|
Menu.AddMenuItem(menu, menuIndent, "indent");
|
|
|
|
Menu.child(menu, subIndent);
|
|
|
|
Menu.AddMenuItem(menu, menuCase, "case");
|
|
|
|
Menu.child(menu, subCase);
|
2022-01-18 17:23:19 +01:00
|
|
|
RETURN Menu.create(menu)
|
2021-05-23 11:43:28 +02:00
|
|
|
END CreateMenuEdit;
|
|
|
|
|
|
|
|
|
2021-09-03 01:15:33 +02:00
|
|
|
PROCEDURE CreateMenuSearch (): Menu.tMenu;
|
|
|
|
VAR
|
|
|
|
menu: List.tList;
|
|
|
|
BEGIN
|
|
|
|
menu := List.create(NIL);
|
|
|
|
Menu.AddMenuItem(menu, menuFind, "search ctrl-F");
|
|
|
|
Menu.AddMenuItem(menu, menuFindNext, "find next F3");
|
|
|
|
Menu.AddMenuItem(menu, menuFindPrev, "find previous shift-F3");
|
|
|
|
Menu.AddMenuItem(menu, menuGoto, "go to line ctrl-G");
|
|
|
|
Menu.delimiter(menu);
|
|
|
|
Menu.AddMenuItem(menu, menuBookmark, "bookmark");
|
|
|
|
Menu.child(menu, subBookmark);
|
2022-01-18 17:23:19 +01:00
|
|
|
RETURN Menu.create(menu)
|
2021-09-03 01:15:33 +02:00
|
|
|
END CreateMenuSearch;
|
|
|
|
|
|
|
|
|
2021-05-23 11:43:28 +02:00
|
|
|
PROCEDURE CreateMenuEncoding (): Menu.tMenu;
|
|
|
|
VAR
|
|
|
|
menu: List.tList;
|
|
|
|
BEGIN
|
|
|
|
menu := List.create(NIL);
|
2021-07-21 18:13:29 +02:00
|
|
|
Menu.AddMenuItem(menu, menuUTF8BOM, E.names[E.UTF8BOM]);
|
|
|
|
Menu.AddMenuItem(menu, menuUTF8, E.names[E.UTF8]);
|
|
|
|
Menu.AddMenuItem(menu, menuCP866, E.names[E.CP866]);
|
|
|
|
Menu.AddMenuItem(menu, menuWin1251, E.names[E.W1251]);
|
2021-09-14 18:33:15 +02:00
|
|
|
Menu.delimiter(menu);
|
|
|
|
Menu.AddMenuItem(menu, menuEOL, "EOL");
|
|
|
|
Menu.child(menu, subEOL);
|
2022-01-18 17:23:19 +01:00
|
|
|
RETURN Menu.create(menu)
|
2021-05-23 11:43:28 +02:00
|
|
|
END CreateMenuEncoding;
|
|
|
|
|
|
|
|
|
2021-09-06 23:06:31 +02:00
|
|
|
PROCEDURE CreateMenuEOL (): Menu.tMenu;
|
|
|
|
VAR
|
|
|
|
menu: List.tList;
|
|
|
|
BEGIN
|
|
|
|
menu := List.create(NIL);
|
|
|
|
Menu.AddMenuItem(menu, menuCRLF, RW.eolNames[RW.EOL_CRLF]);
|
|
|
|
Menu.AddMenuItem(menu, menuLF, RW.eolNames[RW.EOL_LF]);
|
|
|
|
Menu.AddMenuItem(menu, menuCR, RW.eolNames[RW.EOL_CR]);
|
2022-01-18 17:23:19 +01:00
|
|
|
RETURN Menu.create(menu)
|
2021-09-06 23:06:31 +02:00
|
|
|
END CreateMenuEOL;
|
|
|
|
|
|
|
|
|
2021-05-23 11:43:28 +02:00
|
|
|
PROCEDURE CreateMenuView (): Menu.tMenu;
|
|
|
|
VAR
|
|
|
|
menu: List.tList;
|
|
|
|
colors: Ini.tSection;
|
|
|
|
idx: INTEGER;
|
|
|
|
BEGIN
|
|
|
|
menu := List.create(NIL);
|
2021-10-03 19:44:42 +02:00
|
|
|
Menu.AddMenuItem(menu, menuNumbers, "line numbers");
|
2021-06-06 12:04:05 +02:00
|
|
|
Menu.AddMenuItem(menu, menuFontSize, "x2");
|
2021-05-23 11:43:28 +02:00
|
|
|
Menu.delimiter(menu);
|
|
|
|
|
|
|
|
colors := Ini.sections.first(Ini.tSection);
|
|
|
|
idx := menuColors;
|
|
|
|
WHILE colors # NIL DO
|
|
|
|
Menu.AddMenuItem(menu, idx, colors.name);
|
|
|
|
INC(idx);
|
|
|
|
colors := colors.next(Ini.tSection)
|
|
|
|
END;
|
|
|
|
|
2022-01-18 17:23:19 +01:00
|
|
|
RETURN Menu.create(menu)
|
2021-05-23 11:43:28 +02:00
|
|
|
END CreateMenuView;
|
|
|
|
|
|
|
|
|
2021-09-14 18:33:15 +02:00
|
|
|
PROCEDURE CreateMenuLanguage (): Menu.tMenu;
|
2021-05-23 11:43:28 +02:00
|
|
|
VAR
|
|
|
|
menu: List.tList;
|
|
|
|
BEGIN
|
|
|
|
menu := List.create(NIL);
|
|
|
|
Menu.AddMenuItem(menu, menuC, "C");
|
|
|
|
Menu.AddMenuItem(menu, menuFasm, "Fasm");
|
|
|
|
Menu.AddMenuItem(menu, menuIni, "Ini");
|
2021-09-03 01:15:33 +02:00
|
|
|
Menu.AddMenuItem(menu, menuJSON, "JSON");
|
2021-05-23 11:43:28 +02:00
|
|
|
Menu.AddMenuItem(menu, menuLua, "Lua");
|
|
|
|
Menu.AddMenuItem(menu, menuOberon, "Oberon");
|
|
|
|
Menu.AddMenuItem(menu, menuPascal, "Pascal");
|
|
|
|
Menu.delimiter(menu);
|
2021-09-14 18:33:15 +02:00
|
|
|
Menu.AddMenuItem(menu, menuText, "Text");
|
2022-01-18 17:23:19 +01:00
|
|
|
RETURN Menu.create(menu)
|
2021-09-14 18:33:15 +02:00
|
|
|
END CreateMenuLanguage;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE CreateMenuProgram (): Menu.tMenu;
|
|
|
|
VAR
|
|
|
|
menu: List.tList;
|
|
|
|
BEGIN
|
|
|
|
menu := List.create(NIL);
|
2021-09-03 01:15:33 +02:00
|
|
|
Menu.AddMenuItem(menu, menuBuild, "build ctrl-F9");
|
2021-05-23 11:43:28 +02:00
|
|
|
Menu.AddMenuItem(menu, menuBuildScript, "script");
|
|
|
|
Menu.delimiter(menu);
|
|
|
|
Menu.AddMenuItem(menu, menuRun, "run F9");
|
|
|
|
Menu.AddMenuItem(menu, menuRunScript, "script");
|
|
|
|
Menu.delimiter(menu);
|
|
|
|
Menu.AddMenuItem(menu, menuDebug, "debug");
|
|
|
|
Menu.AddMenuItem(menu, menuDebugScript, "script");
|
2022-01-18 17:23:19 +01:00
|
|
|
RETURN Menu.create(menu)
|
2021-05-23 11:43:28 +02:00
|
|
|
END CreateMenuProgram;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE CreateMenuTools (): Menu.tMenu;
|
|
|
|
VAR
|
|
|
|
menu: List.tList;
|
|
|
|
BEGIN
|
|
|
|
menu := List.create(NIL);
|
|
|
|
Menu.AddMenuItem(menu, menuPipet, "pipet");
|
2021-12-22 16:56:11 +01:00
|
|
|
Menu.AddMenuItem(menu, menuMagnify, "magnify");
|
2021-07-21 18:13:29 +02:00
|
|
|
Menu.AddMenuItem(menu, menuBoard, "board");
|
2021-05-23 11:43:28 +02:00
|
|
|
Menu.AddMenuItem(menu, menuSysFunc, "system functions");
|
2022-01-18 17:23:19 +01:00
|
|
|
RETURN Menu.create(menu)
|
2021-05-23 11:43:28 +02:00
|
|
|
END CreateMenuTools;
|
|
|
|
|
|
|
|
|
2021-09-03 01:15:33 +02:00
|
|
|
PROCEDURE CreateMenuCurLine(): Menu.tMenu;
|
2021-05-23 11:43:28 +02:00
|
|
|
VAR
|
2021-09-03 01:15:33 +02:00
|
|
|
menu: List.tList;
|
2021-05-23 11:43:28 +02:00
|
|
|
BEGIN
|
2021-09-03 01:15:33 +02:00
|
|
|
menu := List.create(NIL);
|
|
|
|
Menu.AddMenuItem(menu, menuMoveUp, "move up ctrl-Up");
|
|
|
|
Menu.AddMenuItem(menu, menuMoveDown, "move down ctrl-Down");
|
|
|
|
Menu.AddMenuItem(menu, menuDuplicate, "duplicate ctrl-D");
|
|
|
|
Menu.AddMenuItem(menu, menuRemove, "remove ctrl-Del");
|
2022-01-18 17:23:19 +01:00
|
|
|
RETURN Menu.create(menu)
|
2021-09-03 01:15:33 +02:00
|
|
|
END CreateMenuCurLine;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
|
2021-09-03 01:15:33 +02:00
|
|
|
PROCEDURE CreateMenuIndent(): Menu.tMenu;
|
2021-05-23 11:43:28 +02:00
|
|
|
VAR
|
2021-09-03 01:15:33 +02:00
|
|
|
menu: List.tList;
|
2021-05-23 11:43:28 +02:00
|
|
|
BEGIN
|
2021-09-03 01:15:33 +02:00
|
|
|
menu := List.create(NIL);
|
|
|
|
Menu.AddMenuItem(menu, menuIncInd, "increase Tab");
|
|
|
|
Menu.AddMenuItem(menu, menuDecInd, "decrease shift-Bksp");
|
2022-01-18 17:23:19 +01:00
|
|
|
RETURN Menu.create(menu)
|
2021-09-03 01:15:33 +02:00
|
|
|
END CreateMenuIndent;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
|
2021-09-03 01:15:33 +02:00
|
|
|
PROCEDURE CreateMenuCase(): Menu.tMenu;
|
|
|
|
VAR
|
|
|
|
menu: List.tList;
|
|
|
|
BEGIN
|
|
|
|
menu := List.create(NIL);
|
|
|
|
Menu.AddMenuItem(menu, menuUpper, "UPPER ctrl-U");
|
|
|
|
Menu.AddMenuItem(menu, menuLower, "lower ctrl-L");
|
2022-01-18 17:23:19 +01:00
|
|
|
RETURN Menu.create(menu)
|
2021-09-03 01:15:33 +02:00
|
|
|
END CreateMenuCase;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE CreateMenuBookmark(): Menu.tMenu;
|
|
|
|
VAR
|
|
|
|
menu: List.tList;
|
|
|
|
BEGIN
|
|
|
|
menu := List.create(NIL);
|
|
|
|
Menu.AddMenuItem(menu, menuToggleBookmark, "toggle ctrl-F2");
|
|
|
|
Menu.AddMenuItem(menu, menuNextBookmark, "next F2");
|
|
|
|
Menu.AddMenuItem(menu, menuPrevBookmark, "previous shift-F2");
|
2022-01-18 17:23:19 +01:00
|
|
|
RETURN Menu.create(menu)
|
2021-09-03 01:15:33 +02:00
|
|
|
END CreateMenuBookmark;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
|
2022-01-18 17:23:19 +01:00
|
|
|
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;
|
|
|
|
|
|
|
|
|
2021-09-14 18:33:15 +02:00
|
|
|
PROCEDURE HideSearch;
|
|
|
|
BEGIN
|
|
|
|
SetFocus(FindEdit, FALSE);
|
|
|
|
searchOpened := FALSE;
|
2021-12-22 16:56:11 +01:00
|
|
|
LEFT := LEFT_PADDING;
|
2021-09-14 18:33:15 +02:00
|
|
|
resize;
|
|
|
|
draw_window
|
|
|
|
END HideSearch;
|
|
|
|
|
|
|
|
|
2021-07-21 18:13:29 +02:00
|
|
|
PROCEDURE KeyDown (key: INTEGER);
|
|
|
|
VAR
|
|
|
|
keyCode: INTEGER;
|
|
|
|
shift, ctrl: BOOLEAN;
|
|
|
|
BEGIN
|
2021-09-11 22:57:43 +02:00
|
|
|
K.getKBState(shift, ctrl);
|
2021-07-21 18:13:29 +02:00
|
|
|
keyCode := key DIV 65536;
|
|
|
|
IF confirm THEN
|
|
|
|
IF keyCode = 28 THEN (* Enter *)
|
|
|
|
save(text);
|
|
|
|
IF ~text.modified THEN
|
|
|
|
closeFile(FALSE, curText)
|
|
|
|
END
|
|
|
|
END;
|
|
|
|
key := -1
|
|
|
|
ELSE
|
|
|
|
IF keyCode = 61 THEN (* F3 *)
|
|
|
|
key := -1;
|
|
|
|
IF search & (searchText # "") THEN
|
|
|
|
IF shift THEN
|
2021-09-08 22:47:14 +02:00
|
|
|
notFound := ~T.findNext(text, ~BKW.value)
|
2021-07-21 18:13:29 +02:00
|
|
|
ELSE
|
2021-09-08 22:47:14 +02:00
|
|
|
notFound := ~T.findNext(text, BKW.value)
|
2021-07-21 18:13:29 +02:00
|
|
|
END
|
|
|
|
END
|
|
|
|
ELSIF keyCode = 60 THEN (* F2 *)
|
|
|
|
key := -1;
|
|
|
|
IF ctrl THEN
|
|
|
|
T.toggleLabel(text)
|
|
|
|
ELSE
|
|
|
|
T.gotoLabel(text, ~shift)
|
|
|
|
END
|
|
|
|
ELSIF keyCode = 67 THEN (* F9 *)
|
|
|
|
key := -1;
|
|
|
|
IF ctrl THEN
|
|
|
|
Script(buildScript)
|
|
|
|
ELSE
|
|
|
|
Script(runScript)
|
|
|
|
END
|
2021-09-11 22:57:43 +02:00
|
|
|
ELSIF keyCode = 68 THEN (* F10 *)
|
2021-09-14 18:33:15 +02:00
|
|
|
IF shift THEN
|
|
|
|
ShowMenu(context)
|
|
|
|
ELSE
|
|
|
|
ShowMenu(menuFile)
|
|
|
|
END;
|
|
|
|
key := -1
|
2021-07-21 18:13:29 +02:00
|
|
|
ELSIF keyCode = 1 THEN (* Esc *)
|
|
|
|
IF search THEN
|
2021-09-14 18:33:15 +02:00
|
|
|
IF shift THEN
|
|
|
|
HideSearch
|
|
|
|
ELSE
|
|
|
|
Search
|
|
|
|
END
|
|
|
|
END;
|
|
|
|
key := -1
|
2021-07-21 18:13:29 +02:00
|
|
|
ELSIF (keyCode = 55) & (key DIV 256 MOD 256 = 52) THEN (* PrtScn *)
|
|
|
|
key := -1
|
2021-09-03 01:15:33 +02:00
|
|
|
ELSIF (keyCode = 14) & shift THEN (* shift+Backspace *)
|
|
|
|
key := -1;
|
|
|
|
T.input(text, -8)
|
2021-07-21 18:13:29 +02:00
|
|
|
ELSIF (keyCode = 15) & ctrl THEN (* ctrl+Tab *)
|
|
|
|
key := -1;
|
|
|
|
SwitchTab((curText + 1) MOD textsCount)
|
2021-11-27 18:19:15 +01:00
|
|
|
ELSIF ((keyCode = 33) OR (keyCode = 35)) & ctrl THEN (* ctrl+F, ctrl+H*)
|
2021-07-21 18:13:29 +02:00
|
|
|
key := -1;
|
2021-09-21 20:16:56 +02:00
|
|
|
ShowSearchPanel(FALSE)
|
2021-11-27 18:19:15 +01:00
|
|
|
ELSIF (keyCode = 34) & ctrl THEN (* ctrl+G *)
|
2021-07-21 18:13:29 +02:00
|
|
|
key := -1;
|
2021-09-21 20:16:56 +02:00
|
|
|
ShowSearchPanel(TRUE)
|
2021-12-08 15:02:53 +01:00
|
|
|
ELSIF (keyCode = 18) & ctrl THEN (* ctrl+E *)
|
|
|
|
key := -1;
|
|
|
|
T.selectWord(text)
|
2021-07-21 18:13:29 +02:00
|
|
|
ELSE
|
|
|
|
IF EditBox_Focus(FindEdit) THEN
|
2021-11-27 18:19:15 +01:00
|
|
|
IF keyCode = 15 THEN (* Tab *)
|
|
|
|
SetFocus(ReplaceEdit, TRUE)
|
|
|
|
ELSE
|
|
|
|
EB.key(FindEdit, key);
|
|
|
|
EditBox_GetValue(FindEdit, new_searchText);
|
|
|
|
IF new_searchText # searchText THEN
|
|
|
|
searchText := new_searchText;
|
|
|
|
notFound := ~T.search(text, searchText, cs, whole)
|
|
|
|
END
|
2021-07-21 18:13:29 +02:00
|
|
|
END
|
|
|
|
ELSIF EditBox_Focus(ReplaceEdit) THEN
|
2021-11-27 18:19:15 +01:00
|
|
|
IF keyCode = 15 THEN (* Tab *)
|
|
|
|
SetFocus(GotoEdit, TRUE)
|
|
|
|
ELSE
|
|
|
|
EB.key(ReplaceEdit, key);
|
|
|
|
EditBox_GetValue(ReplaceEdit, replaceText)
|
|
|
|
END
|
2021-07-21 18:13:29 +02:00
|
|
|
ELSIF EditBox_Focus(GotoEdit) THEN
|
2021-11-27 18:19:15 +01:00
|
|
|
IF keyCode = 15 THEN (* Tab *)
|
|
|
|
SetFocus(FindEdit, TRUE)
|
|
|
|
ELSE
|
|
|
|
IF (key DIV 256) MOD 256 = 13 THEN
|
|
|
|
goto
|
|
|
|
ELSE
|
|
|
|
EB.key(GotoEdit, key)
|
|
|
|
END
|
2021-07-21 18:13:29 +02:00
|
|
|
END
|
|
|
|
ELSE
|
|
|
|
CASE keyCode OF
|
|
|
|
|73: key := 33
|
|
|
|
|81: key := 34
|
|
|
|
|71: key := 36
|
|
|
|
|79: key := 35
|
|
|
|
|72: key := 38
|
|
|
|
|80: key := 40
|
|
|
|
|75: key := 37
|
|
|
|
|77: key := 39
|
2021-09-03 01:15:33 +02:00
|
|
|
|82, 91, 219, 92, 220: key := -1 (* insert, windows *)
|
|
|
|
|93: ShowMenu(context); key := -1
|
2021-07-21 18:13:29 +02:00
|
|
|
|83: key := 46
|
2021-09-28 18:15:37 +02:00
|
|
|
|59, 62..66, 87, 88: key := -1 (* F1, F4..F8, F11, F12 *)
|
2021-07-21 18:13:29 +02:00
|
|
|
ELSE
|
|
|
|
IF ctrl THEN
|
|
|
|
CASE keyCode OF
|
|
|
|
|17: closeFile(TRUE, curText);
|
|
|
|
key := -2
|
|
|
|
|21: T.redo(text);
|
|
|
|
key := -1
|
|
|
|
|22: key := ORD("U")
|
|
|
|
|24: key := -1;
|
2022-01-12 22:15:22 +01:00
|
|
|
OpenDial
|
2021-07-21 18:13:29 +02:00
|
|
|
|30: key := ORD("A")
|
|
|
|
|31: key := -1;
|
|
|
|
save(text)
|
|
|
|
|32: key := ORD("D")
|
|
|
|
|38: key := ORD("L")
|
|
|
|
|44: T.undo(text);
|
|
|
|
key := -1
|
|
|
|
|45: key := ORD("X")
|
|
|
|
|46: key := ORD("C")
|
|
|
|
|47: key := ORD("V")
|
2021-12-17 07:12:02 +01:00
|
|
|
|49,
|
|
|
|
20: key := -1;
|
2021-07-21 18:13:29 +02:00
|
|
|
NewFile
|
|
|
|
ELSE
|
|
|
|
key := -1
|
|
|
|
END
|
|
|
|
ELSE
|
|
|
|
T.input(text, E.cp866[key DIV 256 MOD 256]);
|
|
|
|
key := -1
|
|
|
|
END
|
|
|
|
END;
|
|
|
|
IF key >= 0 THEN
|
|
|
|
T.key(text, key, shift, ctrl)
|
|
|
|
END
|
|
|
|
END
|
|
|
|
END
|
|
|
|
END;
|
|
|
|
IF key # -2 THEN
|
|
|
|
repaint
|
|
|
|
END
|
|
|
|
END KeyDown;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE BtnClick;
|
|
|
|
VAR
|
|
|
|
btn: INTEGER;
|
|
|
|
middle, exit: BOOLEAN;
|
2021-09-11 22:57:43 +02:00
|
|
|
menu: Menu.tMenu;
|
2021-07-21 18:13:29 +02:00
|
|
|
BEGIN
|
2022-01-18 17:23:19 +01:00
|
|
|
exit := FALSE;
|
2021-07-21 18:13:29 +02:00
|
|
|
btn := K.ButtonCode(middle);
|
2021-09-11 22:57:43 +02:00
|
|
|
IF U.between(Tabs.btnID, btn, Tabs.btnID + maxTexts - 1) THEN
|
2021-07-21 18:13:29 +02:00
|
|
|
DEC(btn, Tabs.btnID);
|
|
|
|
IF middle THEN
|
|
|
|
IF texts[btn].modified THEN
|
|
|
|
SwitchTab(btn)
|
|
|
|
END;
|
|
|
|
closeFile(TRUE, btn)
|
|
|
|
ELSE
|
|
|
|
SwitchTab(btn)
|
|
|
|
END;
|
|
|
|
btn := 0
|
|
|
|
ELSE
|
|
|
|
IF middle THEN
|
|
|
|
btn := 0
|
|
|
|
END
|
|
|
|
END;
|
2021-09-11 22:57:43 +02:00
|
|
|
IF btn # 0 THEN
|
|
|
|
menu := Menu.ClickMain(mainMenu, btn);
|
|
|
|
IF menu # NIL THEN
|
|
|
|
ShowMenu(menu);
|
|
|
|
btn := 0
|
|
|
|
END
|
|
|
|
END;
|
2021-07-21 18:13:29 +02:00
|
|
|
|
2022-01-18 17:23:19 +01:00
|
|
|
CASE btn OF
|
2021-07-21 18:13:29 +02:00
|
|
|
|0:
|
2022-01-18 17:23:19 +01:00
|
|
|
|Tabs.btnLeft, Tabs.btnRight:
|
|
|
|
Tabs.scroll(tabs, btn);
|
|
|
|
switch := TRUE
|
2021-07-21 18:13:29 +02:00
|
|
|
|btnNo:
|
|
|
|
exit := closing;
|
|
|
|
closeFile(FALSE, curText);
|
2022-01-18 17:23:19 +01:00
|
|
|
repaint
|
2021-07-21 18:13:29 +02:00
|
|
|
|btnYes:
|
|
|
|
exit := closing;
|
|
|
|
save(text);
|
|
|
|
IF ~text.modified THEN
|
|
|
|
closeFile(FALSE, curText)
|
|
|
|
END;
|
2022-01-18 17:23:19 +01:00
|
|
|
repaint
|
2021-07-21 18:13:29 +02:00
|
|
|
|btnClose:
|
2022-01-18 17:23:19 +01:00
|
|
|
exit := TRUE
|
2021-07-21 18:13:29 +02:00
|
|
|
|btnNew:
|
2022-01-18 17:23:19 +01:00
|
|
|
NewFile
|
2021-07-21 18:13:29 +02:00
|
|
|
|btnOpen:
|
2022-01-12 22:15:22 +01:00
|
|
|
OpenDial
|
2021-07-21 18:13:29 +02:00
|
|
|
|btnSave:
|
2022-01-18 17:23:19 +01:00
|
|
|
save(text)
|
2021-07-21 18:13:29 +02:00
|
|
|
|btnSearch:
|
2022-01-18 17:23:19 +01:00
|
|
|
ShowSearchPanel(FALSE)
|
2021-09-14 18:33:15 +02:00
|
|
|
|btnCloseSearch:
|
2021-07-21 18:13:29 +02:00
|
|
|
Search
|
2021-09-14 18:33:15 +02:00
|
|
|
|btnHideSearch:
|
|
|
|
HideSearch
|
2021-07-21 18:13:29 +02:00
|
|
|
|btnUndo:
|
2022-01-18 17:23:19 +01:00
|
|
|
T.undo(text)
|
2021-07-21 18:13:29 +02:00
|
|
|
|btnRedo:
|
2022-01-18 17:23:19 +01:00
|
|
|
T.redo(text)
|
2021-07-21 18:13:29 +02:00
|
|
|
|btnUpper:
|
2022-01-18 17:23:19 +01:00
|
|
|
T.chCase(text, TRUE)
|
2021-07-21 18:13:29 +02:00
|
|
|
|btnLower:
|
2022-01-18 17:23:19 +01:00
|
|
|
T.chCase(text, FALSE)
|
2021-07-21 18:13:29 +02:00
|
|
|
|btnBuild:
|
|
|
|
Script(buildScript)
|
|
|
|
|btnRun:
|
|
|
|
Script(runScript)
|
|
|
|
|btnFindNext:
|
|
|
|
IF searchText # "" THEN
|
2021-09-08 22:47:14 +02:00
|
|
|
notFound := ~T.findNext(text, BKW.value);
|
2022-01-18 17:23:19 +01:00
|
|
|
SetFocus(FindEdit, FALSE)
|
2021-07-21 18:13:29 +02:00
|
|
|
END
|
|
|
|
|btnReplace:
|
|
|
|
T.replace(text, replaceText, LENGTH(searchText));
|
2022-01-18 17:23:19 +01:00
|
|
|
SetFocus(FindEdit, FALSE)
|
2021-07-21 18:13:29 +02:00
|
|
|
|btnReplaceAll:
|
|
|
|
notFound := ~T.search(text, searchText, cs, whole);
|
|
|
|
IF ~notFound THEN
|
|
|
|
replaced := T.replaceAll(text, replaceText, LENGTH(searchText));
|
|
|
|
END;
|
2022-01-18 17:23:19 +01:00
|
|
|
SetFocus(FindEdit, FALSE)
|
2021-07-21 18:13:29 +02:00
|
|
|
|btnGoto:
|
2022-01-18 17:23:19 +01:00
|
|
|
goto
|
|
|
|
END;
|
|
|
|
|
|
|
|
IF exit THEN
|
|
|
|
Close
|
|
|
|
ELSE
|
|
|
|
repaint
|
|
|
|
END
|
2021-07-21 18:13:29 +02:00
|
|
|
END BtnClick;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE MouseEvent (VAR resized: BOOLEAN; VAR firstClickX, firstClickY, time: INTEGER);
|
|
|
|
CONST
|
|
|
|
DELAY = 10;
|
2021-05-23 11:43:28 +02:00
|
|
|
VAR
|
|
|
|
msState: SET;
|
2021-07-21 18:13:29 +02:00
|
|
|
scroll, x, y, scrollX, scrollY: INTEGER;
|
2021-10-03 19:44:42 +02:00
|
|
|
pos1, pos2: T.tPoint;
|
2021-07-21 18:13:29 +02:00
|
|
|
|
|
|
|
|
2021-10-03 19:44:42 +02:00
|
|
|
PROCEDURE EditBox (VAR eb: EB.tEditBox);
|
2021-07-21 18:13:29 +02:00
|
|
|
VAR
|
|
|
|
focus: BOOLEAN;
|
|
|
|
BEGIN
|
|
|
|
focus := EditBox_Focus(eb);
|
2021-09-11 22:57:43 +02:00
|
|
|
EB.mouse(eb);
|
2021-07-21 18:13:29 +02:00
|
|
|
IF focus # EditBox_Focus(eb) THEN
|
2021-09-03 01:15:33 +02:00
|
|
|
SetFocus(eb, TRUE);
|
|
|
|
repaint
|
2021-07-21 18:13:29 +02:00
|
|
|
END
|
|
|
|
END EditBox;
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN
|
2021-09-03 01:15:33 +02:00
|
|
|
CloseMenu;
|
2021-07-21 18:13:29 +02:00
|
|
|
IF ~resized THEN
|
|
|
|
msState := K.MouseState();
|
|
|
|
IF ~(0 IN msState) OR (16 IN msState) THEN
|
2021-09-28 18:15:37 +02:00
|
|
|
leftButton := FALSE
|
2021-07-21 18:13:29 +02:00
|
|
|
END;
|
|
|
|
scroll := K.Scroll();
|
|
|
|
IF scroll # 0 THEN
|
|
|
|
T.scroll(text, 0, scroll*3);
|
|
|
|
repaint
|
|
|
|
END;
|
|
|
|
IF leftButton THEN
|
|
|
|
IF K.GetTickCount() - time >= DELAY THEN
|
2021-10-03 19:44:42 +02:00
|
|
|
T.getPos(text, pos1.Y, pos1.X);
|
2021-07-21 18:13:29 +02:00
|
|
|
mouse(x, y);
|
|
|
|
T.mouse(text, x, y);
|
2021-10-03 19:44:42 +02:00
|
|
|
T.getPos(text, pos2.Y, pos2.X);
|
|
|
|
IF (pos1.X # pos2.X) OR (pos1.Y # pos2.Y) THEN
|
|
|
|
repaint
|
|
|
|
END
|
2021-07-21 18:13:29 +02:00
|
|
|
END
|
|
|
|
END;
|
2021-09-28 18:15:37 +02:00
|
|
|
|
|
|
|
Scroll.mouse(hScroll);
|
|
|
|
Scroll.mouse(vScroll);
|
2022-01-18 17:23:19 +01:00
|
|
|
msState := K.MouseState();
|
2021-09-28 18:15:37 +02:00
|
|
|
T.getScroll(text, scrollX, scrollY);
|
|
|
|
IF (hScroll.value # scrollX) OR (vScroll.value # scrollY) THEN
|
|
|
|
T.scroll(text, hScroll.value - scrollX, vScroll.value - scrollY);
|
|
|
|
repaint
|
|
|
|
END;
|
|
|
|
|
2021-07-21 18:13:29 +02:00
|
|
|
IF (8 IN msState) & ~(24 IN msState) THEN
|
|
|
|
mouse(firstClickX, firstClickY);
|
|
|
|
time := click(firstClickX, firstClickY)
|
|
|
|
END;
|
|
|
|
IF 9 IN msState THEN
|
|
|
|
ShowMenu(context)
|
|
|
|
END;
|
|
|
|
IF 24 IN msState THEN
|
|
|
|
mouse(x, y);
|
2021-09-28 18:15:37 +02:00
|
|
|
IF U.between(-4, x - firstClickX, 4) & U.between(-4, y - firstClickY, 4) THEN
|
|
|
|
IF U.between(0, x, canvas.width - 1) & U.between(0, y, canvas.height - 1) THEN
|
2021-07-21 18:13:29 +02:00
|
|
|
leftButton := FALSE;
|
|
|
|
T.selectWord(text);
|
|
|
|
repaint
|
2021-12-17 07:12:02 +01:00
|
|
|
ELSIF Tabs.DblClicked(tabs, x + LEFT, y + TOP) THEN
|
|
|
|
leftButton := FALSE;
|
|
|
|
NewFile;
|
|
|
|
repaint
|
2021-07-21 18:13:29 +02:00
|
|
|
END
|
|
|
|
ELSE
|
|
|
|
firstClickX := x;
|
|
|
|
firstClickY := y;
|
|
|
|
time := click(firstClickX, firstClickY)
|
|
|
|
END
|
|
|
|
END
|
|
|
|
END;
|
|
|
|
IF search & searchOpened THEN
|
2021-09-28 18:15:37 +02:00
|
|
|
CheckBox.mouse(BKW);
|
|
|
|
CheckBox.mouse(CS);
|
|
|
|
CheckBox.mouse(WH);
|
2021-07-21 18:13:29 +02:00
|
|
|
EditBox(FindEdit);
|
|
|
|
EditBox(ReplaceEdit);
|
|
|
|
EditBox(GotoEdit);
|
2021-09-28 18:15:37 +02:00
|
|
|
IF (CS.value # cs) OR (WH.value # whole) THEN
|
|
|
|
cs := CS.value;
|
|
|
|
whole := WH.value;
|
2021-07-21 18:13:29 +02:00
|
|
|
notFound := ~T.search(text, searchText, cs, whole);
|
|
|
|
repaint
|
|
|
|
END
|
|
|
|
END;
|
|
|
|
resized := FALSE
|
|
|
|
END MouseEvent;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE Redraw (VAR resized: BOOLEAN; VAR width, height, cliWidth, cliHeight: INTEGER);
|
2022-01-18 17:23:19 +01:00
|
|
|
VAR
|
|
|
|
onClose: BOOLEAN;
|
2021-07-21 18:13:29 +02:00
|
|
|
BEGIN
|
2022-01-18 17:23:19 +01:00
|
|
|
onClose := (Menu.MenuItem = menuClose) OR (Menu.MenuItem = menuExit);
|
|
|
|
IF ~onClose THEN
|
|
|
|
ClickMenu
|
|
|
|
END;
|
2022-01-12 22:15:22 +01:00
|
|
|
K.GetSystemColors;
|
|
|
|
IF ~K.RolledUp() THEN
|
|
|
|
K.ClientSize(width, height);
|
|
|
|
IF (width # cliWidth) OR (height # cliHeight) THEN
|
|
|
|
cliWidth := width;
|
|
|
|
cliHeight := height;
|
|
|
|
resize;
|
|
|
|
resized := TRUE
|
|
|
|
END;
|
2022-01-18 17:23:19 +01:00
|
|
|
K.SetEventsMask({0, 1, 2, 5, 31})
|
2022-01-12 22:15:22 +01:00
|
|
|
ELSE
|
|
|
|
SetCaption(text.fileName);
|
|
|
|
K.SetEventsMask({0, 30, 31})
|
|
|
|
END;
|
|
|
|
draw_window;
|
|
|
|
IF SkinHeight # K.SkinHeight() THEN
|
|
|
|
SkinHeight := K.SkinHeight();
|
|
|
|
Redraw(resized, width, height, cliWidth, cliHeight)
|
2022-01-18 17:23:19 +01:00
|
|
|
END;
|
|
|
|
IF onClose THEN
|
|
|
|
ClickMenu
|
2022-01-12 22:15:22 +01:00
|
|
|
END
|
2021-07-21 18:13:29 +02:00
|
|
|
END Redraw;
|
|
|
|
|
|
|
|
|
2021-09-28 18:15:37 +02:00
|
|
|
PROCEDURE ScrollChange;
|
|
|
|
BEGIN
|
2022-01-18 17:23:19 +01:00
|
|
|
T.scroll(text, hScroll.btn, vScroll.btn);
|
2021-09-28 18:15:37 +02:00
|
|
|
IF menuActive THEN
|
|
|
|
draw_window;
|
|
|
|
menuActive := FALSE
|
|
|
|
ELSE
|
|
|
|
repaint
|
|
|
|
END
|
|
|
|
END ScrollChange;
|
|
|
|
|
|
|
|
|
2021-07-21 18:13:29 +02:00
|
|
|
PROCEDURE main;
|
|
|
|
VAR
|
2021-05-23 11:43:28 +02:00
|
|
|
fileName, filePath: RW.tFileName;
|
2021-07-21 18:13:29 +02:00
|
|
|
width, height, cliWidth, cliHeight: INTEGER;
|
|
|
|
resized: BOOLEAN;
|
2022-01-12 22:15:22 +01:00
|
|
|
firstClickX, firstClickY, time, blink, i: INTEGER;
|
2021-05-23 11:43:28 +02:00
|
|
|
BEGIN
|
2021-12-30 12:11:45 +01:00
|
|
|
header := "";
|
2021-06-05 17:18:11 +02:00
|
|
|
K.GetSystemColors;
|
2021-07-11 01:39:41 +02:00
|
|
|
switch := FALSE;
|
2021-07-21 18:13:29 +02:00
|
|
|
closing := FALSE;
|
2021-07-11 01:39:41 +02:00
|
|
|
textsCount := 0;
|
|
|
|
curText := 0;
|
2022-01-12 22:15:22 +01:00
|
|
|
Args.GetArg(0, AppPath);
|
2021-05-23 11:43:28 +02:00
|
|
|
Ini.load(AppPath);
|
2021-09-28 18:15:37 +02:00
|
|
|
leftButton := FALSE;
|
2021-05-23 11:43:28 +02:00
|
|
|
resized := FALSE;
|
2021-06-06 12:04:05 +02:00
|
|
|
K.ScreenSize(winWidth, winHeight);
|
2021-07-11 01:39:41 +02:00
|
|
|
winWidth := (winWidth*80) DIV 100 - (128 + 30);
|
2021-06-06 12:04:05 +02:00
|
|
|
winHeight := winHeight - (128 + 30);
|
|
|
|
winWidth := MAX(winWidth, minWinWidth);
|
|
|
|
winHeight := MAX(winHeight, minWinHeight);
|
2021-06-05 17:18:11 +02:00
|
|
|
cliWidth := winWidth;
|
|
|
|
cliHeight := winHeight;
|
2021-12-22 16:56:11 +01:00
|
|
|
LEFT := LEFT_PADDING;
|
2022-01-12 22:15:22 +01:00
|
|
|
SkinHeight := K.SkinHeight();
|
|
|
|
canvas := G.CreateCanvas(winWidth - (LEFT + RIGHT + 11 + RIGHT_PADDING), winHeight - (TOP + BOTTOM + 5) - SkinHeight);
|
2021-07-11 01:39:41 +02:00
|
|
|
tabs := Tabs.create();
|
|
|
|
Tabs.setArea(tabs, LEFT, TOP - Tabs.tabHeight, canvas.width, Tabs.tabHeight);
|
2021-06-06 12:04:05 +02:00
|
|
|
font1 := G.CreateFont(1, "", {});
|
|
|
|
font2 := G.CreateFont(2, "", {});
|
|
|
|
font := font1;
|
2021-05-23 11:43:28 +02:00
|
|
|
G.SetFont(canvas, font);
|
2021-09-03 01:15:33 +02:00
|
|
|
T.init(resetTimer);
|
2021-05-23 11:43:28 +02:00
|
|
|
T.setCanvas(canvas);
|
2021-09-06 23:06:31 +02:00
|
|
|
|
2022-01-18 17:23:19 +01:00
|
|
|
Menu.init(resetTimer);
|
2021-05-23 11:43:28 +02:00
|
|
|
context := CreateContextMenu();
|
|
|
|
menuFile := CreateMenuFile();
|
2021-09-03 01:15:33 +02:00
|
|
|
subCurLine := CreateMenuCurLine();
|
|
|
|
subIndent := CreateMenuIndent();
|
|
|
|
subCase := CreateMenuCase();
|
2021-05-23 11:43:28 +02:00
|
|
|
menuEdit := CreateMenuEdit();
|
2021-09-03 01:15:33 +02:00
|
|
|
subCurLine.parent := menuEdit;
|
|
|
|
subIndent.parent := menuEdit;
|
|
|
|
subCase.parent := menuEdit;
|
|
|
|
subBookmark := CreateMenuBookmark();
|
|
|
|
menuSearch := CreateMenuSearch();
|
|
|
|
subBookmark.parent := menuSearch;
|
2021-09-14 18:33:15 +02:00
|
|
|
subEOL := CreateMenuEOL();
|
2021-05-23 11:43:28 +02:00
|
|
|
menuEncoding := CreateMenuEncoding();
|
2021-09-14 18:33:15 +02:00
|
|
|
subEOL.parent := menuEncoding;
|
2021-05-23 11:43:28 +02:00
|
|
|
menuView := CreateMenuView();
|
2021-09-14 18:33:15 +02:00
|
|
|
menuLanguage := CreateMenuLanguage();
|
2021-05-23 11:43:28 +02:00
|
|
|
menuProgram := CreateMenuProgram();
|
|
|
|
menuTools := CreateMenuTools();
|
2021-09-03 01:15:33 +02:00
|
|
|
|
2021-09-11 22:57:43 +02:00
|
|
|
mainMenu := Menu.CreateMain(mainMenuBtn);
|
|
|
|
Menu.AddMainItem(mainMenu, "file", menuFile);
|
|
|
|
Menu.AddMainItem(mainMenu, "edit", menuEdit);
|
|
|
|
Menu.AddMainItem(mainMenu, "search", menuSearch);
|
|
|
|
Menu.AddMainItem(mainMenu, "encoding", menuEncoding);
|
|
|
|
Menu.AddMainItem(mainMenu, "view", menuView);
|
2021-09-14 18:33:15 +02:00
|
|
|
Menu.AddMainItem(mainMenu, "language", menuLanguage);
|
2021-09-11 22:57:43 +02:00
|
|
|
Menu.AddMainItem(mainMenu, "program", menuProgram);
|
|
|
|
Menu.AddMainItem(mainMenu, "tools", menuTools);
|
2022-01-18 17:23:19 +01:00
|
|
|
Shortcuts;
|
2021-09-11 22:57:43 +02:00
|
|
|
|
2021-12-29 16:38:29 +01:00
|
|
|
Toolbar.create(toolbar, LEFT_PADDING + 5, toolbarTop);
|
2021-12-20 20:09:01 +01:00
|
|
|
Toolbar.add(toolbar, btnNew, 2, "");
|
|
|
|
Toolbar.add(toolbar, btnOpen, 0, "");
|
|
|
|
Toolbar.add(toolbar, btnSave, 5, "");
|
|
|
|
Toolbar.delimiter(toolbar);
|
|
|
|
Toolbar.add(toolbar, btnSearch, 49, "");
|
|
|
|
Toolbar.delimiter(toolbar);
|
|
|
|
Toolbar.add(toolbar, btnUndo, 37, "");
|
|
|
|
Toolbar.add(toolbar, btnRedo, 36, "");
|
|
|
|
Toolbar.delimiter(toolbar);
|
|
|
|
Toolbar.add(toolbar, btnUpper, -1, "AB");
|
|
|
|
Toolbar.add(toolbar, btnLower, -1, "ab");
|
|
|
|
Toolbar.delimiter(toolbar);
|
|
|
|
Toolbar.add(toolbar, btnBuild, 54, "");
|
|
|
|
Toolbar.add(toolbar, btnRun, 53, "");
|
|
|
|
|
2021-09-03 01:15:33 +02:00
|
|
|
Ini.getSettings(buildScript, runScript, debugScript);
|
2022-01-12 22:15:22 +01:00
|
|
|
|
|
|
|
filePath := "/sys";
|
|
|
|
IF Args.argc = 1 THEN
|
2021-05-23 11:43:28 +02:00
|
|
|
text := T.New();
|
2022-01-12 22:15:22 +01:00
|
|
|
insert(0, text);
|
|
|
|
T.SetPos(text, 0, 0)
|
2021-05-23 11:43:28 +02:00
|
|
|
END;
|
2022-01-12 22:15:22 +01:00
|
|
|
FOR i := 1 TO Args.argc - 1 DO
|
|
|
|
Args.GetArg(i, fileName);
|
|
|
|
IF open(fileName) THEN
|
|
|
|
U.getPath(fileName, filePath)
|
|
|
|
END
|
|
|
|
END;
|
|
|
|
IF textsCount = 0 THEN
|
|
|
|
K.Exit
|
|
|
|
END;
|
|
|
|
SwitchTab(textsCount - 1);
|
|
|
|
|
2022-01-18 17:23:19 +01:00
|
|
|
Scroll.create(FALSE, canvas.width + 1, scrollWidth, scrollWidth, scrollWidth*3 DIV 2, ScrollChange, hScroll);
|
|
|
|
Scroll.create(TRUE, scrollWidth, canvas.height + 2, scrollWidth, scrollWidth*3 DIV 2, ScrollChange, vScroll);
|
2021-05-23 11:43:28 +02:00
|
|
|
T.resize(canvas.width, canvas.height);
|
|
|
|
confirm := FALSE;
|
|
|
|
notFound := FALSE;
|
2021-09-03 18:20:40 +02:00
|
|
|
menuFindClicked := FALSE;
|
|
|
|
menuActive := FALSE;
|
2021-05-23 11:43:28 +02:00
|
|
|
search := FALSE;
|
2021-07-21 18:13:29 +02:00
|
|
|
searchOpened := FALSE;
|
2021-05-23 11:43:28 +02:00
|
|
|
createSearchForm;
|
|
|
|
new_searchText := "";
|
|
|
|
searchText := "";
|
|
|
|
cs := FALSE;
|
|
|
|
whole := FALSE;
|
|
|
|
replaced := 0;
|
2022-01-12 22:15:22 +01:00
|
|
|
|
|
|
|
OD := OpenDlg.Create(draw_window, OpenDlg.topen, filePath, "");
|
|
|
|
|
2022-01-18 17:23:19 +01:00
|
|
|
K.SetEventsMask({0, 1, 2, 5, 31});
|
2021-05-23 11:43:28 +02:00
|
|
|
draw_window;
|
2022-01-08 22:10:10 +01:00
|
|
|
blink := Ini.blink;
|
|
|
|
IF blink <= 0 THEN
|
|
|
|
blink := 0
|
|
|
|
ELSIF blink < 30 THEN
|
|
|
|
blink := 30
|
|
|
|
END;
|
2021-12-20 20:09:01 +01:00
|
|
|
timerEnabled := TRUE;
|
|
|
|
CursorTime := K.GetTickCount();
|
2021-05-23 11:43:28 +02:00
|
|
|
WHILE TRUE DO
|
2021-12-20 20:09:01 +01:00
|
|
|
CurrentTime := K.GetTickCount();
|
2022-01-08 22:10:10 +01:00
|
|
|
IF (CurrentTime - CursorTime > blink) & (blink > 0) & timerEnabled THEN
|
2021-12-20 20:09:01 +01:00
|
|
|
CursorTime := CurrentTime;
|
|
|
|
T.toggleCursor;
|
|
|
|
repaint
|
|
|
|
END;
|
2022-01-18 17:23:19 +01:00
|
|
|
|
2021-12-20 20:09:01 +01:00
|
|
|
CASE K.EventTimeout(10) OF
|
|
|
|
|0:
|
2021-09-14 18:33:15 +02:00
|
|
|
|1: Redraw(resized, width, height, cliWidth, cliHeight)
|
2021-07-21 18:13:29 +02:00
|
|
|
|2: KeyDown(K.GetKey())
|
|
|
|
|3: BtnClick
|
|
|
|
|6: MouseEvent(resized, firstClickX, firstClickY, time)
|
2021-05-23 11:43:28 +02:00
|
|
|
END
|
|
|
|
END
|
|
|
|
END main;
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN
|
|
|
|
main
|
|
|
|
END CEdit.
|