diff --git a/programs/develop/cedit/CEDIT b/programs/develop/cedit/CEDIT index 70cbbe306c..6b0474e70a 100644 Binary files a/programs/develop/cedit/CEDIT and b/programs/develop/cedit/CEDIT differ diff --git a/programs/develop/cedit/README.TXT b/programs/develop/cedit/README.TXT index d31b70aedd..5713bd9128 100644 --- a/programs/develop/cedit/README.TXT +++ b/programs/develop/cedit/README.TXT @@ -7,7 +7,7 @@ ctrl+L преобразовать буквы A..Z слева от курсора в a..z ctrl+U преобразовать буквы a..z слева от курсора в A..Z ctrl+F показать панель поиска - Esc скрыть панель поиска + Esc закрыть панель поиска F3 найти следующий shift+F3 найти предыдущий ctrl+Z отменить diff --git a/programs/develop/cedit/SRC/CEdit.ob07 b/programs/develop/cedit/SRC/CEdit.ob07 index ffa99399b4..2e18bccdc0 100644 --- a/programs/develop/cedit/SRC/CEdit.ob07 +++ b/programs/develop/cedit/SRC/CEdit.ob07 @@ -28,7 +28,7 @@ IMPORT RW, Ini, box_lib, Icons, Tabs; CONST - header = "CEdit (12-jul-2021)"; + header = "CEdit (17-jul-2021)"; ShellFilter = ""; EditFilter = "SH|ASM|TXT|INC|OB07|C|CPP|H|PAS|PP|LUA|INI"; @@ -54,14 +54,12 @@ CONST btnRight = 33; btnYes = 40; btnNo = 41; - btnFindEdit = 50; - btnReplaceEdit = 51; - btnGotoEdit = 52; btnFindNext = 60; btnReplace = 61; btnReplaceAll = 62; btnGoto = 63; btnCloseFind = 64; + btnHideFind = 65; btnFile = 70; btnEdit = 71; @@ -84,7 +82,7 @@ CONST RIGHT = scrollWidth - 2; BOTTOM = scrollWidth + 18; - minWinWidth = 635; minWinHeight = 542; + minWinWidth = 635; minWinHeight = 538; SEARCH_PADDING = 10; searchLeft = 0; @@ -146,7 +144,8 @@ CONST menuWin1251 = 63; menuPipet = 70; - menuSysFunc = 71; + menuBoard = 71; + menuSysFunc = 72; maxTexts = 32; @@ -161,12 +160,11 @@ VAR textsCount, curText: INTEGER; winWidth, winHeight: INTEGER; - shift: SET; AppPath, runScript, buildScript, debugScript: RW.tFileName; OD: OpenDlg.Dialog; - confirm, notFound, search, modified: BOOLEAN; + confirm, notFound, search, searchOpened, modified: BOOLEAN; - switch: BOOLEAN; + switch, closing: BOOLEAN; leftButton, VScroll, HScroll: BOOLEAN; vScroll, hScroll: Scroll.tScroll; LEFT: INTEGER; @@ -215,12 +213,21 @@ BEGIN ELSE edit.flags := ORD(BITS(edit.flags) - {1}) END; - IF search THEN + IF search & searchOpened THEN box_lib.edit_box_draw(edit) END END EditBox_SetFocus; +PROCEDURE SetFocus (edit: box_lib.edit_box; value: BOOLEAN); +BEGIN + EditBox_SetFocus(FindEdit, FALSE); + EditBox_SetFocus(ReplaceEdit, FALSE); + EditBox_SetFocus(GotoEdit, FALSE); + EditBox_SetFocus(edit, value) +END SetFocus; + + PROCEDURE Rect (left, top, right, bottom, color: INTEGER); BEGIN K.DrawLine(left, top, right, top, color); @@ -256,9 +263,7 @@ BEGIN IF notFound THEN Message("not found"); notFound := FALSE; - EditBox_SetFocus(FindEdit, TRUE); - EditBox_SetFocus(ReplaceEdit, FALSE); - EditBox_SetFocus(GotoEdit, FALSE) + SetFocus(FindEdit, TRUE) END END NotFound; @@ -273,9 +278,7 @@ BEGIN U.append(s, s1); Message(s); replaced := 0; - EditBox_SetFocus(FindEdit, TRUE); - EditBox_SetFocus(ReplaceEdit, FALSE); - EditBox_SetFocus(GotoEdit, FALSE) + SetFocus(FindEdit, TRUE) END END Replaced; @@ -350,14 +353,8 @@ VAR y: INTEGER; BEGIN y := (btnHeight - fontHeight) DIV 2 + btnTop; - K.DrawRect(width - 12*fontWidth, y, 12*fontWidth, fontHeight, K.winColor); - CASE text.enc OF - |E.UTF8: K.DrawText866(width - 5*fontWidth, y, K.textColor, "UTF-8") - |E.UTF8BOM: K.DrawText866(width - 9*fontWidth, y, K.textColor, "UTF-8-BOM") - |E.CP866: K.DrawText866(width - 5*fontWidth, y, K.textColor, "CP866") - |E.W1251: K.DrawText866(width - 12*fontWidth, y, K.textColor, "Windows-1251") - END; - + K.DrawRect(width - 16*fontWidth, y, 16*fontWidth, fontHeight, K.winColor); + K.DrawText(width - LENGTH(E.names[text.enc])*fontWidth, y, K.textColor, E.names[text.enc]); y := height - (BOTTOM - scrollWidth) + (BOTTOM - scrollWidth - 16) DIV 2; K.DrawRect(LEFT + 16*fontWidth, TOP + canvas.height + scrollWidth - 1, width - LEFT - 24*fontWidth, BOTTOM - scrollWidth + 1, K.winColor); K.DrawText866(LEFT + 16*fontWidth, y, K.textColor, text.fileName); @@ -373,9 +370,10 @@ BEGIN IF confirm THEN K.DeleteButton(btnYes); K.DeleteButton(btnNo); - confirm := FALSE + confirm := FALSE; + closing := FALSE END; - IF ~search THEN + IF ~search OR (searchText = "") THEN T.wordSel(text) END; K.ClientSize(width, height); @@ -450,14 +448,15 @@ BEGIN K.DrawLine(right - 15, top + 15, right - 5, top + 5, 0FFFFFFH); K.DrawLine(right - 14, top + 15, right - 5, top + 6, 0FFFFFFH); + K.CreateButton(btnHideFind, right - 40, top, 20, 20, K.btnColor, ""); + K.DrawLine(right - 34, top + 14, right - 26, top + 14, K.btnTextColor); + K.DrawLine(right - 34, top + 15, right - 26, top + 15, K.btnTextColor); + INC(top, 15); INC(left, SEARCH_PADDING); K.DrawText866(left, top, K.textColor, "find"); K.DrawText866(left, top + 55, K.textColor, "replace with"); - K.CreateButton(btnFindEdit + ORD({30}), left, top + 20, EditBox_Width, fontHeight + 5, 0, ""); - K.CreateButton(btnReplaceEdit + ORD({30}), left, top + 75, EditBox_Width, fontHeight + 5, 0, ""); K.DrawText866(left, top + 330, K.textColor, "go to line"); - K.CreateButton(btnGotoEdit + ORD({30}), left, top + 350, EditBox_Width, fontHeight + 5, 0, ""); BKW.top_s := BKW.top_s MOD 65536 + (top + 110) * 65536; CS.top_s := CS.top_s MOD 65536 + (top + 140) * 65536; WH.top_s := WH.top_s MOD 65536 + (top + 170) * 65536; @@ -586,7 +585,7 @@ BEGIN K.PutPixel(LEFT, TOP + canvas.height + scrollWidth - 2, K.winColor); DrawState(text, width, height); - IF search THEN + IF search & searchOpened THEN SearchPanel(searchLeft, TOP) END; Tabs.draw(tabs); @@ -610,22 +609,13 @@ BEGIN END mouse; -PROCEDURE getKBState; +PROCEDURE getKBState (VAR shift, ctrl: BOOLEAN); VAR kbState: SET; BEGIN kbState := K.GetControlKeys(); - IF {0, 1} * kbState # {} THEN - INCL(shift, T.SHIFT) - ELSE - EXCL(shift, T.SHIFT) - END; - - IF {2, 3} * kbState # {} THEN - INCL(shift, T.CTRL) - ELSE - EXCL(shift, T.CTRL) - END + shift := {0, 1} * kbState # {}; + ctrl := {2, 3} * kbState # {}; END getKBState; @@ -792,7 +782,7 @@ PROCEDURE closeFile (conf: BOOLEAN; n: INTEGER); VAR i: INTEGER; BEGIN - IF text.modified & conf THEN + IF texts[n].modified & conf THEN Confirm ELSE Tabs.delete(tabs, n); @@ -854,6 +844,15 @@ BEGIN END getFileNum; +PROCEDURE SwitchTab (n: INTEGER); +BEGIN + curText := n; + Tabs.switch(tabs, n); + Switch(texts[n]); + draw_window +END SwitchTab; + + PROCEDURE open; VAR fileName: RW.tFileName; @@ -874,10 +873,7 @@ BEGIN T.SetPos(nov, 0, 0) END ELSE - curText := n; - Tabs.switch(tabs, n); - Switch(texts[n]); - draw_window + SwitchTab(n) END END ELSE @@ -931,16 +927,15 @@ END EditBox_GetValue; PROCEDURE Search; BEGIN search := ~search; + LEFT := searchLeft; IF search THEN - LEFT := searchLeft + EditBox_Width + SEARCH_PADDING*2 + 5; + searchOpened := TRUE; + INC(LEFT, EditBox_Width + SEARCH_PADDING*2 + 5); IF T.search(text, searchText, cs, whole) THEN END ELSE - LEFT := searchLeft; IF T.search(text, "", FALSE, FALSE) THEN END END; - EditBox_SetFocus(FindEdit, search); - EditBox_SetFocus(ReplaceEdit, FALSE); - EditBox_SetFocus(GotoEdit, FALSE); + SetFocus(FindEdit, search); resize; draw_window END Search; @@ -949,30 +944,26 @@ END Search; PROCEDURE click (x, y: INTEGER): INTEGER; VAR scrollX, scrollY: INTEGER; + shift, ctrl: BOOLEAN; BEGIN + getKBState(shift, ctrl); IF (0 <= x) & (x < canvas.width) & (0 <= y) & (y < canvas.height) THEN leftButton := TRUE; - EditBox_SetFocus(FindEdit, FALSE); - EditBox_SetFocus(ReplaceEdit, FALSE); - EditBox_SetFocus(GotoEdit, FALSE); - IF ~(T.SHIFT IN shift) THEN + SetFocus(FindEdit, FALSE); + IF ~shift THEN T.resetSelect(text) END; T.mouse(text, x, y); repaint ELSIF (canvas.width < x) & (x < canvas.width + scrollWidth) & (scrollWidth < y) & (y < canvas.height - scrollWidth) THEN VScroll := TRUE; - DEC(x, canvas.width); - DEC(y, scrollWidth); - Scroll.mouse(vScroll, x, y); + Scroll.mouse(vScroll, x - canvas.width, y - scrollWidth); T.getScroll(text, scrollX, scrollY); T.scroll(text, 0, vScroll.value - scrollY); repaint ELSIF (scrollWidth < x) & (x < canvas.width - scrollWidth) & (canvas.height < y) & (y < canvas.height + scrollWidth) THEN HScroll := TRUE; - DEC(x, scrollWidth); - DEC(y, canvas.height); - Scroll.mouse(hScroll, x, y); + Scroll.mouse(hScroll, x - scrollWidth, y - canvas.height); T.getScroll(text, scrollX, scrollY); T.scroll(text, hScroll.value - scrollX, 0); repaint @@ -991,10 +982,11 @@ BEGIN END LeftButtonUp; -PROCEDURE close; +PROCEDURE Close; VAR cont: BOOLEAN; BEGIN + closing := TRUE; cont := TRUE; WHILE (textsCount > 0) & cont DO IF text.modified THEN @@ -1005,7 +997,7 @@ BEGIN repaint END END -END close; +END Close; PROCEDURE MenuItemClick (menu: Menu.tMenu; id: INTEGER); @@ -1031,6 +1023,17 @@ BEGIN END Script; +PROCEDURE ShowSearchPanel; +BEGIN + IF ~search THEN + Search + ELSIF ~searchOpened THEN + search := FALSE; + Search + END +END ShowSearchPanel; + + PROCEDURE receiveIPC; BEGIN IF IPC[0] # Menu.lastTID THEN @@ -1038,11 +1041,11 @@ BEGIN END; CASE IPC[2] OF |0: - |menuCut: T.key(text, ORD("X"), {T.CTRL}) - |menuCopy: T.key(text, ORD("C"), {T.CTRL}) - |menuPaste: T.key(text, ORD("V"), {T.CTRL}) - |menuDelete: T.key(text, 46, {}) - |menuSelectAll: T.key(text, ORD("A"), {T.CTRL}) + |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 @@ -1062,7 +1065,7 @@ BEGIN |menuFolder: K.Run("/rd/1/File Managers/Eolite", text.fileName) |menuExit: - close + Close |menuUndo: T.undo(text); repaint @@ -1070,19 +1073,11 @@ BEGIN T.redo(text); repaint |menuSearch: - IF ~search THEN - Search - END; - EditBox_SetFocus(FindEdit, TRUE); - EditBox_SetFocus(ReplaceEdit, FALSE); - EditBox_SetFocus(GotoEdit, FALSE) + ShowSearchPanel; + SetFocus(FindEdit, TRUE) |menuGoto: - IF ~search THEN - Search - END; - EditBox_SetFocus(GotoEdit, TRUE); - EditBox_SetFocus(FindEdit, FALSE); - EditBox_SetFocus(ReplaceEdit, FALSE) + ShowSearchPanel; + SetFocus(GotoEdit, TRUE) |menuNumbers: T.toggleNumbers(text) |menuFontSize: @@ -1128,6 +1123,8 @@ BEGIN text.enc := E.W1251 |menuPipet: K.Run("/rd/1/develop/pipet", "") + |menuBoard: + K.Run("/rd/1/develop/board", "") |menuSysFunc: K.Run("/rd/1/docpack", "f") |menuColors..menuMaxColors: @@ -1141,10 +1138,11 @@ END receiveIPC; PROCEDURE MenuKeyDown (menu: Menu.tMenu; key: INTEGER): BOOLEAN; VAR menuItem: INTEGER; + shift, ctrl: BOOLEAN; BEGIN menuItem := -1; - getKBState; - IF (T.CTRL IN shift) THEN + getKBState(shift, ctrl); + IF ctrl THEN CASE key DIV 65536 OF |17: menuItem := menuClose |21: menuItem := menuRedo @@ -1242,10 +1240,10 @@ VAR menu: List.tList; BEGIN menu := List.create(NIL); - Menu.AddMenuItem(menu, menuUTF8BOM, "UTF-8-BOM"); - Menu.AddMenuItem(menu, menuUTF8, "UTF-8"); - Menu.AddMenuItem(menu, menuCP866, "CP866"); - Menu.AddMenuItem(menu, menuWin1251, "Windows-1251"); + 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]); RETURN Menu.create(menu, MenuItemClick, MenuKeyDown) END CreateMenuEncoding; @@ -1313,6 +1311,7 @@ VAR BEGIN menu := List.create(NIL); Menu.AddMenuItem(menu, menuPipet, "pipet"); + Menu.AddMenuItem(menu, menuBoard, "board"); Menu.AddMenuItem(menu, menuSysFunc, "system functions"); RETURN Menu.create(menu, MenuItemClick, MenuKeyDown) END CreateMenuTools; @@ -1415,32 +1414,413 @@ BEGIN END ShowMenu; +PROCEDURE KeyDown (key: INTEGER); +VAR + keyCode: INTEGER; + shift, ctrl: BOOLEAN; +BEGIN + keyCode := key DIV 65536; + getKBState(shift, ctrl); + 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 + notFound := ~T.findNext(text, ~box_lib.check_box_get_value(BKW)) + ELSE + notFound := ~T.findNext(text, box_lib.check_box_get_value(BKW)) + 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 + ELSIF keyCode = 1 THEN (* Esc *) + key := -1; + IF search THEN + Search + END + ELSIF (keyCode = 55) & (key DIV 256 MOD 256 = 52) THEN (* PrtScn *) + key := -1 + ELSIF (keyCode = 15) & ctrl THEN (* ctrl+Tab *) + key := -1; + SwitchTab((curText + 1) MOD textsCount) + ELSIF (keyCode = 33) & ctrl THEN + key := -1; + ShowSearchPanel; + SetFocus(FindEdit, TRUE) + ELSIF (keyCode = 34) & ctrl THEN + key := -1; + ShowSearchPanel; + SetFocus(GotoEdit, TRUE) + ELSE + IF EditBox_Focus(FindEdit) THEN + box_lib.edit_box_key(FindEdit, key); + EditBox_GetValue(FindEdit, new_searchText); + IF new_searchText # searchText THEN + searchText := new_searchText; + notFound := ~T.search(text, searchText, cs, whole) + END + ELSIF EditBox_Focus(ReplaceEdit) THEN + box_lib.edit_box_key(ReplaceEdit, key); + EditBox_GetValue(ReplaceEdit, replaceText) + ELSIF EditBox_Focus(GotoEdit) THEN + IF (key DIV 256) MOD 256 = 13 THEN + goto + ELSE + box_lib.edit_box_key(GotoEdit, key) + 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 + |82: key := -1 (* insert *) + |83: key := 46 + |59, 62..66, 68, 87, 88: key := -1 (* F1, F4..F8, F10, F11, F12 *) + 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; + open + |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") + |49: key := -1; + 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; +BEGIN + btn := K.ButtonCode(middle); + IF (Tabs.btnID <= btn) & (btn <= Tabs.btnID + maxTexts - 1) THEN + 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; + CASE btn OF + |Tabs.btnID - 1: Tabs.scroll(tabs, -1); switch := TRUE; repaint + |Tabs.btnID - 2: Tabs.scroll(tabs, +1); switch := TRUE; repaint + + |0: + + |btnFile: + ShowMenu(menuFile) + |btnEdit: + ShowMenu(menuEdit) + |btnEncoding: + ShowMenu(menuEncoding) + |btnView: + ShowMenu(menuView) + |btnSyntax: + ShowMenu(menuSyntax) + |btnProgram: + ShowMenu(menuProgram) + |btnTools: + ShowMenu(menuTools) + |btnNo: + exit := closing; + closeFile(FALSE, curText); + repaint; + IF exit THEN + Close + END + |btnYes: + exit := closing; + save(text); + IF ~text.modified THEN + closeFile(FALSE, curText) + END; + repaint; + IF exit THEN + Close + END + |btnClose: + Close + |btnNew: + NewFile; + repaint + |btnOpen: + open + |btnSave: + save(text); + repaint + |btnSearch: + ShowSearchPanel + |btnCloseFind: + Search + |btnHideFind: + SetFocus(FindEdit, FALSE); + searchOpened := FALSE; + LEFT := searchLeft; + resize; + draw_window + |btnUndo: + T.undo(text); + repaint + |btnRedo: + T.redo(text); + repaint + |btnUpper: + T.chCase(text, TRUE); + repaint + |btnLower: + T.chCase(text, FALSE); + repaint + |btnBuild: + Script(buildScript) + |btnRun: + Script(runScript) + |btnUp: + T.scroll(text, 0, -1); + repaint + |btnDown: + T.scroll(text, 0, 1); + repaint + |btnLeft: + T.scroll(text, -1, 0); + repaint + |btnRight: + T.scroll(text, 1, 0); + repaint + |btnFindNext: + IF searchText # "" THEN + notFound := ~T.findNext(text, box_lib.check_box_get_value(BKW)); + repaint + END + |btnReplace: + T.replace(text, replaceText, LENGTH(searchText)); + repaint + |btnReplaceAll: + notFound := ~T.search(text, searchText, cs, whole); + IF ~notFound THEN + replaced := T.replaceAll(text, replaceText, LENGTH(searchText)); + END; + repaint + |btnGoto: + goto; + repaint + END +END BtnClick; + + +PROCEDURE MouseEvent (VAR resized: BOOLEAN; VAR firstClickX, firstClickY, time: INTEGER); +CONST + DELAY = 10; +VAR + msState: SET; + scroll, x, y, scrollX, scrollY: INTEGER; + + + PROCEDURE EditBox (eb: box_lib.edit_box); + VAR + focus: BOOLEAN; + BEGIN + focus := EditBox_Focus(eb); + box_lib.edit_box_mouse(eb); + IF focus # EditBox_Focus(eb) THEN + SetFocus(eb, TRUE) + END + END EditBox; + + +BEGIN + Menu.close(menuFile); + Menu.close(menuEdit); + Menu.close(menuEncoding); + Menu.close(menuView); + Menu.close(menuSyntax); + Menu.close(menuProgram); + Menu.close(menuTools); + Menu.close(context); + IF ~resized THEN + msState := K.MouseState(); + IF ~(0 IN msState) OR (16 IN msState) THEN + LeftButtonUp + 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 + mouse(x, y); + T.mouse(text, x, y); + repaint + END + END; + IF VScroll THEN + mouse(x, y); + Scroll.mouse(vScroll, x, y - scrollWidth); + T.getScroll(text, scrollX, scrollY); + T.scroll(text, 0, vScroll.value - scrollY); + repaint + END; + IF HScroll THEN + mouse(x, y); + Scroll.mouse(hScroll, x - scrollWidth, y); + T.getScroll(text, scrollX, scrollY); + T.scroll(text, hScroll.value - scrollX, 0); + repaint + END; + 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); + IF (ABS(x - firstClickX) < 5) & (ABS(y - firstClickY) < 5) THEN + VScroll := FALSE; + HScroll := FALSE; + IF (0 <= x) & (x < canvas.width) & (0 <= y) & (y < canvas.height) THEN + leftButton := FALSE; + T.selectWord(text); + repaint + END + ELSE + firstClickX := x; + firstClickY := y; + time := click(firstClickX, firstClickY) + END + END + END; + IF search & searchOpened THEN + EditBox(FindEdit); + EditBox(ReplaceEdit); + EditBox(GotoEdit); + box_lib.check_box_mouse2(CS); + box_lib.check_box_mouse2(WH); + box_lib.check_box_mouse2(BKW); + IF box_lib.check_box_get_value(CS) # cs THEN + cs := ~cs; + notFound := ~T.search(text, searchText, cs, whole); + repaint + END; + IF box_lib.check_box_get_value(WH) # whole THEN + whole := ~whole; + 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); +VAR + i: INTEGER; +BEGIN + K.GetSystemColors; + FOR i := 0 TO 1 DO + IF ~K.RolledUp() THEN + K.ClientSize(width, height); + IF (width # cliWidth) OR (height # cliHeight) THEN + cliWidth := width; + cliHeight := height; + resize; + resized := TRUE + END; + K.SetEventsMask({0, 1, 2, 5, 6, 31}) + ELSE + K.SetEventsMask({0, 30, 31}) + END; + draw_window + END +END Redraw; + + PROCEDURE main; VAR - width, height, x, y, scrollX, scrollY, i: INTEGER; - key, btn: INTEGER; - msState: SET; - scroll: INTEGER; err: INTEGER; fileName, filePath: RW.tFileName; - cliWidth, cliHeight: INTEGER; - resized, middle: BOOLEAN; + width, height, cliWidth, cliHeight: INTEGER; + resized: BOOLEAN; firstClickX, firstClickY, time: INTEGER; BEGIN K.GetSystemColors; Icons.get(icons, grayIcons); modified := FALSE; switch := FALSE; + closing := FALSE; textsCount := 0; curText := 0; mainTID := K.ThreadID(); K.SetIPC(IPC); U.ptr2str(K.GetName(), AppPath); Ini.load(AppPath); - K.SetEventsMask({0, 1, 2, 5, 6, 31}); LeftButtonUp; resized := FALSE; - shift := {}; K.ScreenSize(winWidth, winHeight); winWidth := (winWidth*80) DIV 100 - (128 + 30); winHeight := winHeight - (128 + 30); @@ -1489,6 +1869,7 @@ BEGIN confirm := FALSE; notFound := FALSE; search := FALSE; + searchOpened := FALSE; createSearchForm; new_searchText := ""; searchText := ""; @@ -1498,378 +1879,14 @@ BEGIN Ini.getStr("paths", "build", buildScript); Ini.getStr("paths", "run", runScript); Ini.getStr("paths", "debug", debugScript); + K.SetEventsMask({0, 1, 2, 5, 6, 31}); draw_window; - repaint; WHILE TRUE DO CASE K.WaitForEvent() OF - |1: - FOR i := 0 TO 1 DO - K.GetSystemColors; - Icons.get(icons, grayIcons); - IF ~K.RolledUp() THEN - K.ClientSize(width, height); - IF (width # cliWidth) OR (height # cliHeight) THEN - cliWidth := width; - cliHeight := height; - resize; - resized := TRUE; - END; - K.SetEventsMask({0, 1, 2, 5, 6, 31}) - ELSE - K.SetEventsMask({0, 30, 31}) - END; - draw_window - END - - |2: - key := K.GetKey(); - getKBState; - IF confirm THEN - IF key DIV 65536 = 28 THEN (* Enter *) - save(text); - IF ~text.modified THEN - closeFile(FALSE, curText) - END; - repaint - END; - key := -1 - END; - IF key DIV 65536 = 61 THEN (* F3 *) - key := -1; - IF search & (searchText # "") THEN - IF T.SHIFT IN shift THEN - notFound := ~T.findNext(text, ~box_lib.check_box_get_value(BKW)) - ELSE - notFound := ~T.findNext(text, box_lib.check_box_get_value(BKW)) - END - END - ELSIF key DIV 65536 = 60 THEN (* F2 *) - key := -1; - IF T.CTRL IN shift THEN - T.toggleLabel(text) - ELSE - T.gotoLabel(text, ~(T.SHIFT IN shift)) - END - ELSIF key DIV 65536 = 67 THEN (* F9 *) - key := -1; - IF T.CTRL IN shift THEN - Script(buildScript) - ELSE - Script(runScript) - END - ELSIF key DIV 65536 = 1 THEN (* Esc *) - key := -1; - IF search THEN - Search - END - ELSIF (key DIV 65536 = 55) & (key DIV 256 MOD 256 = 52) THEN - key := -1 (* PrtScn *) - ELSIF (T.CTRL IN shift) & (key DIV 65536 = 15) THEN (* ctrl+Tab *) - key := -1; - curText := (curText + 1) MOD textsCount; - Tabs.switch(tabs, curText); - Switch(texts[curText]); - draw_window - ELSIF (T.CTRL IN shift) & (key DIV 65536 = 33) THEN - key := -1; - IF ~search THEN - Search - END; - EditBox_SetFocus(FindEdit, TRUE); - EditBox_SetFocus(ReplaceEdit, FALSE); - EditBox_SetFocus(GotoEdit, FALSE) - ELSIF (T.CTRL IN shift) & (key DIV 65536 = 34) THEN - key := -1; - IF ~search THEN - Search - END; - EditBox_SetFocus(GotoEdit, TRUE); - EditBox_SetFocus(FindEdit, FALSE); - EditBox_SetFocus(ReplaceEdit, FALSE) - END; - IF (key # -1) & EditBox_Focus(FindEdit) THEN - box_lib.edit_box_key(FindEdit, key); - EditBox_GetValue(FindEdit, new_searchText); - IF new_searchText # searchText THEN - searchText := new_searchText; - notFound := ~T.search(text, searchText, cs, whole) - END - ELSIF (key # -1) & EditBox_Focus(ReplaceEdit) THEN - box_lib.edit_box_key(ReplaceEdit, key); - EditBox_GetValue(ReplaceEdit, replaceText) - ELSIF (key # -1) & EditBox_Focus(GotoEdit) THEN - IF (key DIV 256) MOD 256 = 13 THEN - goto - ELSE - box_lib.edit_box_key(GotoEdit, key) - END - ELSIF key # -1 THEN - CASE key DIV 65536 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 - |82: key := -1 (* insert *) - |83: key := 46 - |59, 60, 62..66, 68, 87, 88: key := -1 (* F1, F2, F4..F8, F10, F11, F12 *) - ELSE - IF (T.CTRL IN shift) THEN - CASE key DIV 65536 OF - |17: closeFile(TRUE, curText); - key := -2 - |21: T.redo(text); - key := -1 - |22: key := ORD("U") - |24: key := -1; - open - |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") - |49: key := -1; - 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) - END - END; - IF key # -2 THEN - repaint - END - |3: - btn := K.ButtonCode(middle); - IF (Tabs.btnID <= btn) & (btn <= Tabs.btnID + maxTexts - 1) THEN - DEC(btn, Tabs.btnID); - IF middle THEN - IF texts[btn].modified THEN - curText := btn; - Tabs.switch(tabs, btn); - Switch(texts[btn]); - draw_window; - END; - closeFile(TRUE, btn) - ELSE - curText := btn; - Tabs.switch(tabs, btn); - Switch(texts[btn]); - draw_window - END; - btn := 0 - ELSE - IF middle THEN - btn := 0 - END - END; - CASE btn OF - |Tabs.btnID - 1: Tabs.scroll(tabs, -1); switch := TRUE; repaint - |Tabs.btnID - 2: Tabs.scroll(tabs, +1); switch := TRUE; repaint - - |0: - - |btnFile: - ShowMenu(menuFile) - |btnEdit: - ShowMenu(menuEdit) - |btnEncoding: - ShowMenu(menuEncoding) - |btnView: - ShowMenu(menuView) - |btnSyntax: - ShowMenu(menuSyntax) - |btnProgram: - ShowMenu(menuProgram) - |btnTools: - ShowMenu(menuTools) - |btnNo: - closeFile(FALSE, curText); - repaint - |btnYes: - save(text); - IF ~text.modified THEN - closeFile(FALSE, curText) - END; - repaint - |btnClose: - close - |btnNew: - NewFile; - repaint - |btnOpen: - open - |btnSave: - save(text); - repaint - |btnSearch: - IF ~search THEN - Search - END - |btnCloseFind: - Search - |btnUndo: - T.undo(text); - repaint - |btnRedo: - T.redo(text); - repaint - |btnUpper: - T.chCase(text, TRUE); - repaint - |btnLower: - T.chCase(text, FALSE); - repaint - |btnBuild: - Script(buildScript) - |btnRun: - Script(runScript) - |btnUp: - T.scroll(text, 0, -1); - repaint - |btnDown: - T.scroll(text, 0, 1); - repaint - |btnLeft: - T.scroll(text, -1, 0); - repaint - |btnRight: - T.scroll(text, 1, 0); - repaint - |btnFindEdit: - EditBox_SetFocus(FindEdit, TRUE); - EditBox_SetFocus(ReplaceEdit, FALSE); - EditBox_SetFocus(GotoEdit, FALSE) - |btnReplaceEdit: - EditBox_SetFocus(ReplaceEdit, TRUE); - EditBox_SetFocus(FindEdit, FALSE); - EditBox_SetFocus(GotoEdit, FALSE) - |btnGotoEdit: - EditBox_SetFocus(GotoEdit, TRUE); - EditBox_SetFocus(FindEdit, FALSE); - EditBox_SetFocus(ReplaceEdit, FALSE) - |btnFindNext: - IF searchText # "" THEN - notFound := ~T.findNext(text, box_lib.check_box_get_value(BKW)); - repaint - END - |btnReplace: - T.replace(text, replaceText, LENGTH(searchText)); - repaint - |btnReplaceAll: - notFound := ~T.search(text, searchText, cs, whole); - IF ~notFound THEN - replaced := T.replaceAll(text, replaceText, LENGTH(searchText)); - END; - repaint - |btnGoto: - goto; - repaint - END - |6: - Menu.close(menuFile); - Menu.close(menuEdit); - Menu.close(menuEncoding); - Menu.close(menuView); - Menu.close(menuSyntax); - Menu.close(menuProgram); - Menu.close(menuTools); - Menu.close(context); - IF ~resized THEN - getKBState; - msState := K.MouseState(); - IF ~(0 IN msState) OR (16 IN msState) THEN - LeftButtonUp - END; - scroll := K.Scroll(); - IF scroll # 0 THEN - T.scroll(text, 0, scroll*3); - repaint - END; - IF leftButton THEN - IF K.GetTickCount() - time > 9 THEN - mouse(x, y); - T.mouse(text, x, y); - repaint - END - END; - IF VScroll THEN - mouse(x, y); - Scroll.mouse(vScroll, x, y - scrollWidth); - T.getScroll(text, scrollX, scrollY); - T.scroll(text, 0, vScroll.value - scrollY); - repaint - END; - IF HScroll THEN - mouse(x, y); - Scroll.mouse(hScroll, x - scrollWidth, y); - T.getScroll(text, scrollX, scrollY); - T.scroll(text, hScroll.value - scrollX, 0); - repaint - END; - 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); - IF (ABS(x - firstClickX) < 5) & (ABS(y - firstClickY) < 5) THEN - VScroll := FALSE; - HScroll := FALSE; - IF (0 <= x) & (x < canvas.width) & (0 <= y) & (y < canvas.height) THEN - leftButton := FALSE; - T.selectWord(text); - repaint - END - ELSE - firstClickX := x; - firstClickY := y; - time := click(firstClickX, firstClickY) - END - END - END; - IF search THEN - IF EditBox_Focus(FindEdit) THEN - box_lib.edit_box_mouse(FindEdit) - END; - IF EditBox_Focus(ReplaceEdit) THEN - box_lib.edit_box_mouse(ReplaceEdit) - END; - IF EditBox_Focus(GotoEdit) THEN - box_lib.edit_box_mouse(GotoEdit) - END; - box_lib.check_box_mouse2(CS); - box_lib.check_box_mouse2(WH); - box_lib.check_box_mouse2(BKW); - IF box_lib.check_box_get_value(CS) # cs THEN - cs := ~cs; - notFound := ~T.search(text, searchText, cs, whole); - repaint - END; - IF box_lib.check_box_get_value(WH) # whole THEN - whole := ~whole; - notFound := ~T.search(text, searchText, cs, whole); - repaint - END - END; - resized := FALSE + |1: Redraw(resized, width, height, cliWidth, cliHeight) + |2: KeyDown(K.GetKey()) + |3: BtnClick + |6: MouseEvent(resized, firstClickX, firstClickY, time) |7: receiveIPC ELSE END diff --git a/programs/develop/cedit/SRC/ChangeLog.ob07 b/programs/develop/cedit/SRC/ChangeLog.ob07 index c3e4be22e5..e05b365699 100644 --- a/programs/develop/cedit/SRC/ChangeLog.ob07 +++ b/programs/develop/cedit/SRC/ChangeLog.ob07 @@ -27,7 +27,7 @@ TYPE END; tBoolItem = POINTER TO RECORD (List.tItem) - adr: INTEGER; val: BOOLEAN + adr: INTEGER; val: BOOLEAN; save: BOOLEAN END; (* tUntypedPtr = POINTER TO RECORD (List.tItem) @@ -39,7 +39,7 @@ TYPE END; *) tGuard* = POINTER TO RECORD (List.tItem) - + saved*: BOOLEAN END; tLog* = POINTER TO RECORD @@ -123,6 +123,21 @@ BEGIN END clear; +PROCEDURE save* (guard: tGuard); +VAR + item: List.tItem; +BEGIN + item := CL.Log.first; + WHILE item # NIL DO + IF item IS tGuard THEN + item(tGuard).saved := FALSE + END; + item := item.next + END; + guard.saved := TRUE +END save; + + PROCEDURE changeWord (adrV, adrX: INTEGER); VAR item: tIntItem; @@ -144,6 +159,7 @@ BEGIN NEW(item); item.adr := SYSTEM.ADR(v); item.val := x; + item.save := FALSE; IF ~CL.isLast THEN clear(CL.guard) END; @@ -151,6 +167,81 @@ BEGIN END changeBool; +PROCEDURE delSaved*; +VAR + boolItem: tBoolItem; + cur: List.tItem; + del: BOOLEAN; +BEGIN + cur := CL.guard.next; + WHILE cur # NIL DO + IF cur IS tBoolItem THEN + boolItem := cur(tBoolItem); + del := boolItem.save + ELSE + del := FALSE + END; + cur := cur.next; + IF del THEN + List.delete(CL.Log, boolItem); + DISPOSE(boolItem) + END + END +END delSaved; + + +PROCEDURE delCurSaved*; +VAR + boolItem: tBoolItem; + cur: List.tItem; + del: BOOLEAN; +BEGIN + cur := CL.guard.prev; + WHILE (cur # NIL) & ~(cur IS tGuard) DO + IF cur IS tBoolItem THEN + boolItem := cur(tBoolItem); + del := boolItem.save + ELSE + del := FALSE + END; + cur := cur.prev; + IF del THEN + SYSTEM.PUT(boolItem.adr, ~boolItem.val); + List.delete(CL.Log, boolItem); + DISPOSE(boolItem) + END + END +END delCurSaved; + + +PROCEDURE changeBool2 (VAR v: BOOLEAN; x: BOOLEAN); +VAR + item, boolItem: tBoolItem; + cur: List.tItem; + del: BOOLEAN; +BEGIN + NEW(item); + item.adr := SYSTEM.ADR(v); + item.val := x; + item.save := TRUE; + cur := CL.guard.prev; + WHILE cur # NIL DO + IF cur IS tBoolItem THEN + boolItem := cur(tBoolItem); + del := boolItem.save & (boolItem.adr = SYSTEM.ADR(v)) & (boolItem.val = x) + ELSE + del := FALSE + END; + cur := cur.prev; + IF del THEN + List.delete(CL.Log, boolItem); + DISPOSE(boolItem) + END + END; + List.insert(CL.Log, CL.guard.prev, item) +END changeBool2; + + PROCEDURE changeInt (VAR v: INTEGER; x: INTEGER); BEGIN changeWord(SYSTEM.ADR(v), SYSTEM.ADR(x)) @@ -205,5 +296,5 @@ END create; BEGIN List.init(changeInt, changePtr); - Lines.init(changeInt, changePtr, changeBool(*, typedPtr, untypedPtr*)) + Lines.init(changeInt, changePtr, changeBool, changeBool2(*, typedPtr, untypedPtr*)) END ChangeLog. \ No newline at end of file diff --git a/programs/develop/cedit/SRC/Clipboard.ob07 b/programs/develop/cedit/SRC/Clipboard.ob07 index bd615c6ed6..11953327e8 100644 --- a/programs/develop/cedit/SRC/Clipboard.ob07 +++ b/programs/develop/cedit/SRC/Clipboard.ob07 @@ -118,11 +118,8 @@ END appends; PROCEDURE eol* (buffer: tBuffer); -VAR - s: ARRAY 2 OF WCHAR; BEGIN - s[0] := 0DX; s[1] := 0AX; - appends(buffer, s, 0, 1) + appends(buffer, 0DX + 0AX, 0, 1) END eol; diff --git a/programs/develop/cedit/SRC/Encodings.ob07 b/programs/develop/cedit/SRC/Encodings.ob07 index 0007b452c7..6146293207 100644 --- a/programs/develop/cedit/SRC/Encodings.ob07 +++ b/programs/develop/cedit/SRC/Encodings.ob07 @@ -29,6 +29,7 @@ TYPE VAR cpW1251*, cp866*: CP; + names*: ARRAY 4, 16 OF WCHAR; UNI*: ARRAY 65536, 2 OF INTEGER; @@ -121,6 +122,10 @@ END setUNI; BEGIN + names[CP866] := "CP866"; + names[W1251] := "Windows-1251"; + names[UTF8] := "UTF-8"; + names[UTF8BOM] := "UTF-8-BOM"; InitW1251(cpW1251); InitCP866(cp866); setUNI diff --git a/programs/develop/cedit/SRC/File.ob07 b/programs/develop/cedit/SRC/File.ob07 index dc99a0c680..e49cdd3d5d 100644 --- a/programs/develop/cedit/SRC/File.ob07 +++ b/programs/develop/cedit/SRC/File.ob07 @@ -265,6 +265,36 @@ BEGIN END Create; +PROCEDURE Copy* (From, To: ARRAY OF CHAR): BOOLEAN; +VAR + buf, size: INTEGER; + outFile: FS; + res: BOOLEAN; +BEGIN + res := FALSE; + size := FileSize(From); + IF size > 0 THEN + buf := Load(From, size) + ELSE + buf := -1; + size := 0 + END; + IF buf # 0 THEN + outFile := Create(To); + IF outFile # NIL THEN + IF size # 0 THEN + res := Write(outFile, buf, size) = size + END; + Close(outFile) + END; + IF size # 0 THEN + buf := KOSAPI.free(buf) + END + END + RETURN res +END Copy; + + PROCEDURE DirExists* (FName: ARRAY OF CHAR): BOOLEAN; VAR fd: rFD; diff --git a/programs/develop/cedit/SRC/Languages.ob07 b/programs/develop/cedit/SRC/Languages.ob07 index f747da3e23..ffafb951a6 100644 --- a/programs/develop/cedit/SRC/Languages.ob07 +++ b/programs/develop/cedit/SRC/Languages.ob07 @@ -27,7 +27,7 @@ CONST langNone* = 0; langC* = 1; langOberon* = 2; langPascal* = 3; langFasm* = 4; langLua* = 5; langIni* = 6; - csLang = {langNone, langC, langOberon, langLua, langIni}; + csLang = {langC, langOberon, langLua, langIni}; TYPE diff --git a/programs/develop/cedit/SRC/Lines.ob07 b/programs/develop/cedit/SRC/Lines.ob07 index 1a758855df..adba577979 100644 --- a/programs/develop/cedit/SRC/Lines.ob07 +++ b/programs/develop/cedit/SRC/Lines.ob07 @@ -46,7 +46,7 @@ TYPE VAR _movInt: PmovInt; - _movBool: PmovBool; + _movBool, _movBool2: PmovBool; _movPtr: PmovPtr; (* _typedPtr: PTypedPtr; _untypedPtr: PUntypedPtr;*) @@ -66,6 +66,12 @@ BEGIN END movBool; +PROCEDURE movBool2 (VAR v: BOOLEAN; x: BOOLEAN); +BEGIN + _movBool2(v, x) +END movBool2; + + PROCEDURE movPtr (VAR v: List.tItem; x: List.tItem); BEGIN _movPtr(v, x) @@ -174,8 +180,8 @@ END modify; PROCEDURE save* (line: tLine); BEGIN IF ~line.temp THEN - movBool(line.saved, TRUE); - movBool(line.modified, FALSE) + movBool2(line.saved, TRUE); + movBool2(line.modified, FALSE) END; line.modified := FALSE; line.saved := TRUE @@ -416,11 +422,12 @@ BEGIN END chCase; -PROCEDURE init* (movInt: PmovInt; movPtr: PmovPtr; movBool: PmovBool(*; typedPtr: PTypedPtr; untypedPtr: PUntypedPtr*)); +PROCEDURE init* (movInt: PmovInt; movPtr: PmovPtr; movBool, movBool2: PmovBool(*; typedPtr: PTypedPtr; untypedPtr: PUntypedPtr*)); BEGIN _movInt := movInt; _movPtr := movPtr; _movBool := movBool; + _movBool2 := movBool2; (* _typedPtr := typedPtr; _untypedPtr := untypedPtr;*) END init; diff --git a/programs/develop/cedit/SRC/Tabs.ob07 b/programs/develop/cedit/SRC/Tabs.ob07 index 6e7aadb525..72142e2793 100644 --- a/programs/develop/cedit/SRC/Tabs.ob07 +++ b/programs/develop/cedit/SRC/Tabs.ob07 @@ -71,7 +71,7 @@ BEGIN END; K.DrawLine(x, y2, x, y, K.borderColor); K.DrawText866bk(x + K.fontWidth, y + (height - K.fontHeight) DIV 2, K.textColor, color, s); - K.CreateButton(id + ORD({30}) + btnID, x, y - 1, width, height - 1, color, ""); + K.CreateButton(id + ORD({30}) + btnID, x + 1, y - 1, width - 1, height - 1, color, ""); END drawTab; diff --git a/programs/develop/cedit/SRC/Text.ob07 b/programs/develop/cedit/SRC/Text.ob07 index 52297e09f7..13acc2387a 100644 --- a/programs/develop/cedit/SRC/Text.ob07 +++ b/programs/develop/cedit/SRC/Text.ob07 @@ -27,7 +27,7 @@ IMPORT E := Encodings, CB := Clipboard, K := KolibriOS, - ChangeLog, + ChangeLog, File, Lang := Languages; @@ -37,8 +37,6 @@ CONST TAB = RW.TAB_SIZE; lenEOL = CB.lenEOL; - SHIFT* = 0; CTRL* = 1; - mark_width = 2; pad_left = mark_width + 3; pad_top = 0; @@ -1187,20 +1185,19 @@ END scroll; PROCEDURE save* (text: tText; name: RW.tFileName; enc, nl: INTEGER): BOOLEAN; +CONST + tempFile = "/tmp0/1/cedit~.tmp"; VAR line: tLine; file: RW.tOutput; res: BOOLEAN; Len: INTEGER; -(* item: List.tItem;*) BEGIN + ChangeLog.setGuard(text.edition); res := TRUE; - file := RW.create(name, enc, nl); + file := RW.create(tempFile, enc, nl); IF file # NIL THEN -(* IF ChangeLog.Log.last IS ChangeLog.tGuard THEN - item := List.pop(ChangeLog.Log); - DISPOSE(item) - END;*) + ChangeLog.delSaved; line := text.first(tLine); WHILE (line # NIL) & res DO Len := Lines.trimLength(line); @@ -1219,14 +1216,21 @@ BEGIN END; IF ~RW.close(file) THEN res := FALSE - END; - IF res THEN - text.modified := FALSE END ELSE res := FALSE END; - text.guard := TRUE + IF res THEN + res := File.Copy(tempFile, name); + IF res THEN + text.modified := FALSE; + ChangeLog.save(text.edition); + IF File.Delete(tempFile) THEN END + END + END; + IF ~res THEN + ChangeLog.delCurSaved + END RETURN res END save; @@ -1262,8 +1266,7 @@ BEGIN IF item # NIL THEN guard := item(tGuard); - text.edition := guard; - text.modified := TRUE + text.edition := guard END; item := ChangeLog.CL.Log.first; @@ -1272,7 +1275,8 @@ BEGIN item := item.next END; redoGuard(text, guard); - ChangeLog.setGuard(guard) + ChangeLog.setGuard(guard); + text.modified := ~guard.saved END undo; @@ -1291,7 +1295,8 @@ BEGIN guard := item(tGuard); redoGuard(text, guard) END; - ChangeLog.setGuard(guard) + ChangeLog.setGuard(guard); + text.modified := ~guard.saved END redo; @@ -1432,19 +1437,42 @@ PROCEDURE gotoLabel* (text: tText; frw: BOOLEAN); VAR line: tLine; n: INTEGER; + + PROCEDURE search (VAR line: tLine; VAR n: INTEGER; frw: BOOLEAN); + BEGIN + IF frw THEN + WHILE (line # NIL) & ~line.label DO + NextLine(line); + INC(n) + END + ELSE + WHILE (line # NIL) & ~line.label DO + PrevLine(line); + DEC(n) + END + END + END search; + BEGIN n := text.cursor.Y; line := text.curLine; IF frw THEN - REPEAT - line := line.next(tLine); - INC(n) - UNTIL (line = NIL) OR line.label + NextLine(line); + INC(n) ELSE - REPEAT - line := line.prev(tLine); - DEC(n) - UNTIL (line = NIL) OR line.label + PrevLine(line); + DEC(n) + END; + search(line, n, frw); + IF line = NIL THEN + IF frw THEN + n := 0; + line := text.first(tLine) + ELSE + n := text.count - 1; + line := text.last(tLine) + END; + search(line, n, frw) END; IF line # NIL THEN IF goto(text, n + 1) THEN END @@ -1615,9 +1643,9 @@ BEGIN END wordSel; -PROCEDURE key* (text: tText; code: INTEGER; shift: SET); +PROCEDURE key* (text: tText; code: INTEGER; shift, ctrl: BOOLEAN); BEGIN - IF SHIFT IN shift THEN + IF shift THEN setSelect(text) ELSE IF (33 <= code) & (code <= 40) THEN @@ -1627,27 +1655,27 @@ BEGIN CASE code OF |33: - IF CTRL IN shift THEN + IF ctrl THEN UpDown(text, text.scroll.Y - text.cursor.Y) ELSE text.scroll.Y := MAX(text.scroll.Y - textsize.Y, 0); UpDown(text, -textsize.Y) END |34: - IF CTRL IN shift THEN + IF ctrl THEN UpDown(text, MIN(text.scroll.Y + textsize.Y - 1, text.count - 1) - text.cursor.Y) ELSE text.scroll.Y := MIN(text.scroll.Y + textsize.Y, text.count - 1); UpDown(text, textsize.Y) END |35: - IF CTRL IN shift THEN + IF ctrl THEN SetPos(text, text.last(tLine).length, text.count - 1) ELSE SetPos(text, text.curLine.length, text.cursor.Y) END |36: - IF CTRL IN shift THEN + IF ctrl THEN SetPos(text, 0, 0) ELSE SetPos(text, 0, text.cursor.Y) @@ -1659,7 +1687,7 @@ BEGIN SetPos(text, text.cursor.X - 1, text.cursor.Y) END |38: - IF CTRL IN shift THEN + IF ctrl THEN upLine(text) ELSE UpDown(text, -1) @@ -1671,49 +1699,49 @@ BEGIN SetPos(text, text.cursor.X + 1, text.cursor.Y) END |40: - IF CTRL IN shift THEN + IF ctrl THEN downLine(text) ELSE UpDown(text, 1) END |46: - IF CTRL IN shift THEN + IF ctrl THEN delLine(text) ELSE delete(text); ShowCursor; drawCursor := TRUE END |ORD("C"): - IF CTRL IN shift THEN + IF ctrl THEN IF selected(text) THEN copy(text) END END |ORD("X"): - IF CTRL IN shift THEN + IF ctrl THEN IF selected(text) THEN copy(text); delSelect(text) END END |ORD("V"): - IF CTRL IN shift THEN + IF ctrl THEN IF CB.available() THEN paste(text) END END |ORD("A"): - IF CTRL IN shift THEN + IF ctrl THEN text.select2.X := 0; text.select2.Y := 0; text.select := text.select2; SetPos(text, text.last(tLine).length, text.count - 1) END |ORD("L"), ORD("U"): - IF CTRL IN shift THEN + IF ctrl THEN changeCase(text, code = ORD("U")) END |ORD("D"): - IF CTRL IN shift THEN + IF ctrl THEN dupLine(text) END ELSE @@ -1842,8 +1870,9 @@ BEGIN IF text.guard THEN NEW(guard); List.append(ChangeLog.CL.Log, guard); + guard.saved := ChangeLog.isFirstGuard(guard); text.edition := guard; - text.guard := FALSE; + text.guard := FALSE ELSE guard := text.edition END;