diff --git a/programs/develop/cedit/CEDIT b/programs/develop/cedit/CEDIT index 27aa7445cd..27081e58b5 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 4533357641..26b306a39a 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 (25-feb-2022)"; + HEADER = "CEdit (26-feb-2022)"; ShellFilter = ""; EditFilter = "SH|INC|TXT|ASM|OB07|C|CPP|H|PAS|PP|LUA|INI|JSON"; @@ -732,20 +732,6 @@ BEGIN 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 - error("too many files") - END -END NewFile; - - PROCEDURE getFileNum (fileName: RW.tFileName): INTEGER; VAR i: INTEGER; @@ -783,12 +769,27 @@ BEGIN END SwitchTab; +PROCEDURE NewFile; +VAR + nov: T.tText; +BEGIN + IF textsCount < maxTexts THEN + nov := T.New(); + T.SetPos(nov, 0, 0); + insert(textsCount, nov); + SwitchTab(curText) + ELSE + error("too many files") + END +END NewFile; + + PROCEDURE open (_fileName: RW.tFileName): BOOLEAN; VAR fileName: RW.tFileName; nov: T.tText; err, n: INTEGER; - res: BOOLEAN; + res, empty: BOOLEAN; BEGIN res := TRUE; IF textsCount < maxTexts THEN @@ -806,8 +807,15 @@ BEGIN SwitchTab(curText); res := FALSE ELSE + T.switch(text); + empty := (textsCount = 1) & (text.fileName = "") & T.empty(text) & + ChangeLog.isFirstGuard(text.edition) & ChangeLog.isLastGuard(text.edition); + T.switch(nov); T.SetPos(nov, 0, 0); insert(textsCount, nov); + IF empty THEN + closeFile(FALSE, 0) + END; Scroll.setValue(hScroll, 0); Scroll.setValue(vScroll, 0) END @@ -1801,13 +1809,11 @@ BEGIN 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 + IF texts[btn].modified THEN + SwitchTab(btn) END; + closeFile(TRUE, btn); + middle := TRUE; btn := 0 ELSE IF middle THEN diff --git a/programs/develop/cedit/SRC/Menu.ob07 b/programs/develop/cedit/SRC/Menu.ob07 index 5199f69def..21bf887994 100644 --- a/programs/develop/cedit/SRC/Menu.ob07 +++ b/programs/develop/cedit/SRC/Menu.ob07 @@ -145,28 +145,23 @@ END CreateMain; PROCEDURE drawMainItem (item: tMainItem); VAR - menuColor, textColor, n: INTEGER; - canvas: G.tCanvas; + menuColor, textColor, n: INTEGER; + canvas: G.tCanvas; BEGIN - IF item.menu.tid # 0 THEN - menuColor := K.colors.work_text; - textColor := K.colors.work - ELSE - 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); - 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); + IF item.selected OR (item.menu.tid # 0) THEN + menuColor := K.colors.button; + textColor := K.colors.button_text + ELSE + menuColor := K.colors.work; + textColor := K.colors.work_text + END; + n := LENGTH(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; @@ -193,7 +188,7 @@ 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(item.x, x, item.x + LENGTH(item.text)*fontWidth + 1) & U.between(0, y, MainMenuHeight - 1); drawMainItem(item); item := item.next(tMainItem) diff --git a/programs/develop/cedit/SRC/Tabs.ob07 b/programs/develop/cedit/SRC/Tabs.ob07 index 313bbe6f0a..dc634cb342 100644 --- a/programs/develop/cedit/SRC/Tabs.ob07 +++ b/programs/develop/cedit/SRC/Tabs.ob07 @@ -60,16 +60,15 @@ PROCEDURE drawTab (t: tTabs; id, x, y, width, height: INTEGER; s: ARRAY OF CHAR; CONST btnCloseSize = 14; VAR - x2, y2, color: INTEGER; + x2, y2, color, closeColor, closeForeColor, textColor: INTEGER; left, top: INTEGER; BEGIN IF id = t.current THEN INC(height, curTabHeight - tabHeight); - DEC(y, curTabHeight - tabHeight); - color := K.colors.light - ELSE - color := K.colors.work + DEC(y, curTabHeight - tabHeight) END; + color := K.colors.work; + textColor := K.colors.work_text; DEC(x); INC(width); x2 := x + width - 1; y2 := y + height - 1; @@ -80,25 +79,29 @@ BEGIN 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); + closeColor := K.colors.button; + closeForeColor := K.colors.button_text ELSE - INC(top, (curTabHeight - tabHeight) DIV 2) + INC(top, (curTabHeight - tabHeight) DIV 2); + closeColor := btnCloseColor; + closeForeColor := 0FFFFFFH END; K.DrawLine(x, y2, x, y, K.colors.line); - K.DrawText866bk(x + K.fontWidth + K.fontWidth DIV 2, y + (height - K.fontHeight) DIV 2, K.colors.work_text, color, s); + K.DrawText866bk(x + K.fontWidth + K.fontWidth DIV 2, y + (height - K.fontHeight) DIV 2, textColor, color, s); IF modified THEN - K.DrawText866bk(x + K.fontWidth DIV 2, y + (height - K.fontHeight) DIV 2, K.colors.work_text, color, "*") + K.DrawText866bk(x + K.fontWidth DIV 2, y + (height - K.fontHeight) DIV 2, textColor, color, "*") END; 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); + K.CreateButton(id + btnClose, left, top, btnCloseSize, btnCloseSize, closeColor, ""); + K.DrawLine(left + 5, top + 4, left + btnCloseSize - 4, top + btnCloseSize - 5, closeForeColor); + K.DrawLine(left + 4, top + 4, left + btnCloseSize - 4, top + btnCloseSize - 4, closeForeColor); + K.DrawLine(left + 4, top + 5, left + btnCloseSize - 5, top + btnCloseSize - 4, closeForeColor); + K.DrawLine(left + 4, top + btnCloseSize - 4, left + btnCloseSize - 4, top + 4, closeForeColor); + K.DrawLine(left + 4, top + btnCloseSize - 5, left + btnCloseSize - 5, top + 4, closeForeColor); + K.DrawLine(left + 5, top + btnCloseSize - 4, left + btnCloseSize - 4, top + 5, closeForeColor); END drawTab; diff --git a/programs/develop/cedit/SRC/Text.ob07 b/programs/develop/cedit/SRC/Text.ob07 index e220304d32..7e75f9080b 100644 --- a/programs/develop/cedit/SRC/Text.ob07 +++ b/programs/develop/cedit/SRC/Text.ob07 @@ -2799,6 +2799,11 @@ BEGIN END New; +PROCEDURE empty* (text: tText): BOOLEAN; + RETURN (text.count = 1) & (text.curLine.length = 0) +END empty; + + PROCEDURE init* (pShowCursor: tProcedure; _lineNumbers, _autoIndents, _autoBrackets, _trimSpace: BOOLEAN); BEGIN ShowCursor := pShowCursor;