diff --git a/programs/develop/cedit/CEDIT b/programs/develop/cedit/CEDIT index 69e82803cb..27aa7445cd 100644 Binary files a/programs/develop/cedit/CEDIT and b/programs/develop/cedit/CEDIT differ diff --git a/programs/develop/cedit/SRC/CEdit.ob07 b/programs/develop/cedit/SRC/CEdit.ob07 index ea8979add9..4533357641 100644 --- a/programs/develop/cedit/SRC/CEdit.ob07 +++ b/programs/develop/cedit/SRC/CEdit.ob07 @@ -28,7 +28,7 @@ IMPORT RW, Ini, EB := EditBox, Tabs, Toolbar, SB := StatusBar; CONST - HEADER = "CEdit (09-feb-2022)"; + HEADER = "CEdit (25-feb-2022)"; ShellFilter = ""; EditFilter = "SH|INC|TXT|ASM|OB07|C|CPP|H|PAS|PP|LUA|INI|JSON"; @@ -212,6 +212,8 @@ VAR CursorTime, CurrentTime: INTEGER; timerEnabled: BOOLEAN; + IPC: ARRAY 64 OF INTEGER; mainTID: INTEGER; + PROCEDURE EditBox_Focus (edit: EB.tEditBox): BOOLEAN; RETURN 1 IN edit.flags @@ -463,7 +465,7 @@ BEGIN bottom := top + 395 + btnHeight + SEARCH_PADDING; Rect(left, top, right, bottom, K.colors.line); - K.CreateButton(btnCloseSearch, right - 20, top, 20, 20, 0EF999FH, ""); + K.CreateButton(btnCloseSearch, right - 20, top, 20, 20, Tabs.btnCloseColor, ""); 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); @@ -1341,7 +1343,7 @@ BEGIN Menu.AddMenuItem(menu, menuDelete, "delete"); Menu.delimiter(menu); Menu.AddMenuItem(menu, menuSelectAll, "select all ctrl-A"); - RETURN Menu.create(menu) + RETURN Menu.create(menu, mainTID) END CreateContextMenu; @@ -1360,7 +1362,7 @@ BEGIN Menu.AddMenuItem(menu, menuClose, "close ctrl-W"); Menu.delimiter(menu); Menu.AddMenuItem(menu, menuExit, "exit"); - RETURN Menu.create(menu) + RETURN Menu.create(menu, mainTID) END CreateMenuFile; @@ -1385,7 +1387,7 @@ BEGIN Menu.child(menu, subIndent); Menu.AddMenuItem(menu, menuCase, "case"); Menu.child(menu, subCase); - RETURN Menu.create(menu) + RETURN Menu.create(menu, mainTID) END CreateMenuEdit; @@ -1401,7 +1403,7 @@ BEGIN Menu.delimiter(menu); Menu.AddMenuItem(menu, menuBookmark, "bookmark"); Menu.child(menu, subBookmark); - RETURN Menu.create(menu) + RETURN Menu.create(menu, mainTID) END CreateMenuSearch; @@ -1415,12 +1417,12 @@ BEGIN Menu.AddMenuItem(menu, menuCP866, E.names[E.CP866]); Menu.AddMenuItem(menu, menuCP1251, E.names[E.CP1251]); Menu.delimiter(menu); - Menu.AddMenuItem(menu, menuEOL, "EOL"); - Menu.child(menu, subEOL); - Menu.delimiter(menu); Menu.AddMenuItem(menu, menuConv1251_866, "convert 1251 >> 866"); Menu.AddMenuItem(menu, menuConv866_1251, "convert 866 >> 1251"); - RETURN Menu.create(menu) + Menu.delimiter(menu); + Menu.AddMenuItem(menu, menuEOL, "EOL"); + Menu.child(menu, subEOL); + RETURN Menu.create(menu, mainTID) END CreateMenuEncoding; @@ -1432,7 +1434,7 @@ BEGIN Menu.AddMenuItem(menu, menuCRLF, E.eolNames[E.EOL_CRLF]); Menu.AddMenuItem(menu, menuLF, E.eolNames[E.EOL_LF]); Menu.AddMenuItem(menu, menuCR, E.eolNames[E.EOL_CR]); - RETURN Menu.create(menu) + RETURN Menu.create(menu, mainTID) END CreateMenuEOL; @@ -1456,7 +1458,7 @@ BEGIN colors := colors.next(Ini.tSection) END; - RETURN Menu.create(menu) + RETURN Menu.create(menu, mainTID) END CreateMenuView; @@ -1474,7 +1476,7 @@ BEGIN Menu.AddMenuItem(menu, menuPascal, "Pascal"); Menu.delimiter(menu); Menu.AddMenuItem(menu, menuText, "Text"); - RETURN Menu.create(menu) + RETURN Menu.create(menu, mainTID) END CreateMenuLanguage; @@ -1493,7 +1495,7 @@ BEGIN Menu.AddMenuItem(menu, menuDebugScript, "script"); Menu.delimiter(menu); Menu.AddMenuItem(menu, menuFASM, "Fasm"); - RETURN Menu.create(menu) + RETURN Menu.create(menu, mainTID) END CreateMenuProgram; @@ -1506,7 +1508,7 @@ BEGIN Menu.AddMenuItem(menu, menuMagnify, "magnify"); Menu.AddMenuItem(menu, menuBoard, "board"); Menu.AddMenuItem(menu, menuSysFunc, "system functions"); - RETURN Menu.create(menu) + RETURN Menu.create(menu, mainTID) END CreateMenuTools; @@ -1519,7 +1521,7 @@ BEGIN Menu.AddMenuItem(menu, menuAutoIndents, "automatic indents"); Menu.AddMenuItem(menu, menuAutoBrackets, "automatic brackets"); Menu.AddMenuItem(menu, menuTrimSpace, "trim trailing space"); - RETURN Menu.create(menu) + RETURN Menu.create(menu, mainTID) END CreateMenuOptions; @@ -1532,7 +1534,7 @@ BEGIN Menu.AddMenuItem(menu, menuMoveDown, "move down ctrl-Down"); Menu.AddMenuItem(menu, menuDuplicate, "duplicate ctrl-D"); Menu.AddMenuItem(menu, menuRemove, "remove ctrl-Del"); - RETURN Menu.create(menu) + RETURN Menu.create(menu, mainTID) END CreateMenuCurLine; @@ -1543,7 +1545,7 @@ BEGIN menu := List.create(NIL); Menu.AddMenuItem(menu, menuIncInd, "increase Tab"); Menu.AddMenuItem(menu, menuDecInd, "decrease shift-Bksp"); - RETURN Menu.create(menu) + RETURN Menu.create(menu, mainTID) END CreateMenuIndent; @@ -1554,7 +1556,7 @@ BEGIN menu := List.create(NIL); Menu.AddMenuItem(menu, menuUpper, "UPPER ctrl-U"); Menu.AddMenuItem(menu, menuLower, "lower ctrl-L"); - RETURN Menu.create(menu) + RETURN Menu.create(menu, mainTID) END CreateMenuCase; @@ -1566,7 +1568,7 @@ BEGIN Menu.AddMenuItem(menu, menuToggleBookmark, "toggle ctrl-F2"); Menu.AddMenuItem(menu, menuNextBookmark, "next F2"); Menu.AddMenuItem(menu, menuPrevBookmark, "previous shift-F2"); - RETURN Menu.create(menu) + RETURN Menu.create(menu, mainTID) END CreateMenuBookmark; @@ -1797,6 +1799,16 @@ BEGIN SwitchTab(btn) END; btn := 0 + ELSIF U.between(Tabs.btnClose, btn, Tabs.btnClose + maxTexts - 1) THEN + DEC(btn, Tabs.btnClose); + IF ~middle THEN + IF texts[btn].modified THEN + SwitchTab(btn) + END; + closeFile(TRUE, btn); + middle := TRUE + END; + btn := 0 ELSE IF middle THEN btn := 0 @@ -1959,6 +1971,10 @@ BEGIN firstClickY := y; time := click(firstClickX, firstClickY) END + END; + IF msState = {} THEN + mouse(x, y); + Menu.MouseMove(mainMenu, x + LEFT, y + TOP) END END; IF search & searchOpened THEN @@ -2022,6 +2038,20 @@ BEGIN END ScrollChange; +PROCEDURE receiveIPC; +VAR + x, y, cliX, cliY, winX, winY: INTEGER; +BEGIN + K.ClientPos(cliX, cliY); + K.WinPos(winX, winY); + x := IPC[2] DIV 65536 - cliX - winX; + y := IPC[2] MOD 65536 - cliY - winY; + Menu.MouseMove(mainMenu, x, y); + IPC[1] := 0; + IPC[0] := 0 +END receiveIPC; + + PROCEDURE main; VAR fileName, filePath: RW.tFileName; @@ -2031,6 +2061,7 @@ VAR key, scr: INTEGER; text_ptr, text_size, errno: INTEGER; BEGIN + mainTID := K.ThreadID(); header := ""; K.GetSystemColors; switch := FALSE; @@ -2067,6 +2098,8 @@ BEGIN Ini.selectSection(Ini.theme); T.setCanvas(canvas); + mainMenu := Menu.CreateMain(mainMenuBtn); + Menu.init(resetTimer); context := CreateContextMenu(); menuFile := CreateMenuFile(); @@ -2089,7 +2122,7 @@ BEGIN menuTools := CreateMenuTools(); menuOptions := CreateMenuOptions(); - mainMenu := Menu.CreateMain(mainMenuBtn); + Menu.AddMainItem(mainMenu, "file", menuFile); Menu.AddMainItem(mainMenu, "edit", menuEdit); Menu.AddMainItem(mainMenu, "search", menuSearch); @@ -2163,7 +2196,10 @@ BEGIN OD := OpenDlg.Create(draw_window, OpenDlg.topen, filePath, ""); - K.SetEventsMask({0, 1, 2, 5, 31}); + IPC[1] := 0; + IPC[0] := 0; + K.SetIPC(IPC); + K.SetEventsMask({0, 1, 2, 5, 6, 31}); draw_window; blink := Ini.blink; IF blink <= 0 THEN @@ -2197,6 +2233,7 @@ BEGIN ELSE scr := K.Scroll() END + |7: receiveIPC END END END main; diff --git a/programs/develop/cedit/SRC/KolibriOS.ob07 b/programs/develop/cedit/SRC/KolibriOS.ob07 index f02d6ccf2c..58cf561bff 100644 --- a/programs/develop/cedit/SRC/KolibriOS.ob07 +++ b/programs/develop/cedit/SRC/KolibriOS.ob07 @@ -393,6 +393,18 @@ BEGIN END PutPixel; +PROCEDURE SetIPC* (buffer: ARRAY OF INTEGER); +BEGIN + KOSAPI.sysfunc4(60, 1, SYSTEM.ADR(buffer[0]), LEN(buffer)*SYSTEM.SIZE(INTEGER)) +END SetIPC; + + +PROCEDURE SendIPC* (pid, ptr, size: INTEGER); +BEGIN + KOSAPI.sysfunc5(60, 2, pid, ptr, size) +END SendIPC; + + PROCEDURE docpack* (VAR param: ARRAY OF CHAR; VAR text_ptr, text_size: INTEGER); VAR i, size, ptr, ptr2: INTEGER; diff --git a/programs/develop/cedit/SRC/Menu.ob07 b/programs/develop/cedit/SRC/Menu.ob07 index e6fb57db7f..5199f69def 100644 --- a/programs/develop/cedit/SRC/Menu.ob07 +++ b/programs/develop/cedit/SRC/Menu.ob07 @@ -20,7 +20,7 @@ MODULE Menu; IMPORT - SYSTEM, G := Graph, List, K := KolibriOS; + SYSTEM, G := Graph, List, K := KolibriOS, U := Utils; CONST itemHeight = 22; @@ -53,13 +53,15 @@ TYPE tMainItem* = POINTER TO descMainItem; tMain* = POINTER TO RECORD (List.tList) - id: INTEGER + id: INTEGER; + canvas: G.tCanvas END; tMenu* = POINTER TO RECORD tid*: INTEGER; active*, keyboard: BOOLEAN; parent*, child: tMenu; + mainTID: INTEGER; mainID: INTEGER; x*, winX, winY, width*, height*: INTEGER; selItem, cliItem: INTEGER; @@ -81,7 +83,8 @@ TYPE id*, x: INTEGER; text: ARRAY 32 OF WCHAR; menu*: tMenu; - main: tMain + main: tMain; + selected: BOOLEAN END; tShortcut = POINTER TO RECORD (List.tItem) @@ -111,6 +114,7 @@ BEGIN COPY(text, item.text); item.menu := menu; item.main := main; + item.selected := FALSE; menu.mainID := item.id; List.append(main, item); prev := item.prev(tMainItem); @@ -119,7 +123,10 @@ BEGIN ELSE item.x := MainMenuX END; - menu.x := item.x + menu.x := item.x; + G.destroy(main.canvas); + main.canvas := G.CreateCanvas(item.x + LENGTH(item.text)*fontWidth + 9, MainMenuHeight); + G.SetFont(main.canvas, G.fonts[1]) END AddMainItem; @@ -130,6 +137,7 @@ VAR BEGIN NEW(res); res.id := id; + res.canvas := NIL; list := List.create(res) RETURN res END CreateMain; @@ -138,33 +146,62 @@ END CreateMain; PROCEDURE drawMainItem (item: tMainItem); VAR menuColor, textColor, n: INTEGER; + canvas: G.tCanvas; BEGIN IF item.menu.tid # 0 THEN menuColor := K.colors.work_text; textColor := K.colors.work ELSE - menuColor := K.colors.work; - textColor := K.colors.work_text + IF item.selected THEN + menuColor := K.colors.button; + textColor := K.colors.button_text + ELSE + menuColor := K.colors.work; + textColor := K.colors.work_text + END END; n := LENGTH(item.text); - K.DrawRect(item.x, 0, n*fontWidth + 2, MainMenuHeight, menuColor); - K.CreateButton(item.id + ORD({30}), item.x, 0, n*fontWidth + 2, MainMenuHeight, K.colors.button, ""); - K.DrawText(item.x + 1, (MainMenuHeight - K.fontHeight) DIV 2 + 1, textColor, item.text) + canvas := item.main.canvas; + G.SetColor(canvas, menuColor); + G.FillRect(canvas, item.x, 0, item.x + n*fontWidth + 2, MainMenuHeight - 1); + G.SetTextColor(canvas, textColor); + G.SetBkColor(canvas, menuColor); + G.TextOut2(canvas, item.x + 1, (MainMenuHeight - K.fontHeight) DIV 2 + 1, item.text, n); END drawMainItem; PROCEDURE DrawMain* (main: tMain); VAR - item: List.tItem; + item: tMainItem; BEGIN - item := main.first; + G.SetColor(main.canvas, K.colors.work); + G.clear(main.canvas); + item := main.first(tMainItem); WHILE item # NIL DO - drawMainItem(item(tMainItem)); - item := item.next - END + drawMainItem(item); + K.CreateButton(item.id + ORD({30}), item.x, 0, LENGTH(item.text)*fontWidth + 2, MainMenuHeight, 0, ""); + item := item.next(tMainItem) + END; + G.DrawCanvas(main.canvas, 0, 0) END DrawMain; +PROCEDURE MouseMove* (main: tMain; x, y: INTEGER); +VAR + item: tMainItem; +BEGIN + item := main.first(tMainItem); + WHILE item # NIL DO + item.selected := + U.between(item.x, x, item.x + LENGTH(item.text)*fontWidth - 1) & + U.between(0, y, MainMenuHeight - 1); + drawMainItem(item); + item := item.next(tMainItem) + END; + G.DrawCanvas(main.canvas, 0, 0) +END MouseMove; + + PROCEDURE getMainID (m: tMenu): INTEGER; BEGIN WHILE m.parent # NIL DO @@ -485,6 +522,8 @@ BEGIN repaint(m) |6: K.mouse(msState, x, y); + temp := (x + m.winX)*65536 + (y + m.winY); + K.SendIPC(m.mainTID, SYSTEM.ADR(temp), SYSTEM.SIZE(INTEGER)); IF (0 <= x) & (x < m.width) & (0 <= y) & (y < m.height) THEN m.active := TRUE; m.selItem := (y - TOP) DIV itemHeight; @@ -621,7 +660,7 @@ BEGIN END isEnabled; -PROCEDURE create* (items: List.tList): tMenu; +PROCEDURE create* (items: List.tList; mainTID: INTEGER): tMenu; VAR m: tMenu; maxLength: INTEGER; @@ -633,6 +672,7 @@ BEGIN m.parent := NIL; m.child := NIL; m.mainID := 0; + m.mainTID := mainTID; m.items := items; maxLength := 0; item := items.first(tItem); diff --git a/programs/develop/cedit/SRC/Tabs.ob07 b/programs/develop/cedit/SRC/Tabs.ob07 index dd24b771f3..313bbe6f0a 100644 --- a/programs/develop/cedit/SRC/Tabs.ob07 +++ b/programs/develop/cedit/SRC/Tabs.ob07 @@ -24,11 +24,13 @@ IMPORT List, K := KolibriOS, RW, U := Utils; CONST btnID* = 100; + btnClose* = btnID + 100; btnLeft* = btnID - 1; btnRight* = btnID - 2; tabHeight* = 22; curTabHeight = 26; scrWidth = 15; + btnCloseColor* = 0EF999FH; TYPE @@ -55,8 +57,11 @@ END DblClicked; PROCEDURE drawTab (t: tTabs; id, x, y, width, height: INTEGER; s: ARRAY OF CHAR; modified: BOOLEAN); +CONST + btnCloseSize = 14; VAR x2, y2, color: INTEGER; + left, top: INTEGER; BEGIN IF id = t.current THEN INC(height, curTabHeight - tabHeight); @@ -72,8 +77,12 @@ BEGIN K.DrawRect(x, y, width, height, color); K.DrawLine(x, y, x2, y, K.colors.line); K.DrawLine(x2, y, x2, y2, K.colors.line); + + top := y + 3; IF id # t.current THEN - K.DrawLine(x2 - 1, y2, x, y2, K.colors.line); + K.DrawLine(x2 - 1, y2, x, y2, K.colors.line) + ELSE + INC(top, (curTabHeight - tabHeight) DIV 2) END; K.DrawLine(x, y2, x, y, K.colors.line); @@ -81,12 +90,20 @@ BEGIN IF modified THEN K.DrawText866bk(x + K.fontWidth DIV 2, y + (height - K.fontHeight) DIV 2, K.colors.work_text, color, "*") END; - K.CreateButton(id + ORD({30}) + btnID, x + 1, y - 1, width - 1, height - 1, color, ""); + K.CreateButton(id + ORD({30}) + btnID, x + 1, y - 1, width - 1, height - 1, 0, ""); + left := x + width - btnCloseSize - 5; + K.CreateButton(id + btnClose, left, top, btnCloseSize, btnCloseSize, btnCloseColor, ""); + K.DrawLine(left + 5, top + 4, left + btnCloseSize - 4, top + btnCloseSize - 5, 0FFFFFFH); + K.DrawLine(left + 4, top + 4, left + btnCloseSize - 4, top + btnCloseSize - 4, 0FFFFFFH); + K.DrawLine(left + 4, top + 5, left + btnCloseSize - 5, top + btnCloseSize - 4, 0FFFFFFH); + K.DrawLine(left + 4, top + btnCloseSize - 4, left + btnCloseSize - 4, top + 4, 0FFFFFFH); + K.DrawLine(left + 4, top + btnCloseSize - 5, left + btnCloseSize - 5, top + 4, 0FFFFFFH); + K.DrawLine(left + 5, top + btnCloseSize - 4, left + btnCloseSize - 4, top + 5, 0FFFFFFH); END drawTab; PROCEDURE tabWidth (tab: tItem): INTEGER; - RETURN (LENGTH(tab.val) + 3)*K.fontWidth + RETURN (LENGTH(tab.val) + 5)*K.fontWidth END tabWidth;