diff --git a/data/common/fb2read b/data/common/fb2read index d03348a67f..a7c728cd6e 100644 Binary files a/data/common/fb2read and b/data/common/fb2read differ diff --git a/programs/develop/cedit/CEDIT b/programs/develop/cedit/CEDIT index bbed588b43..315c88e522 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 3e07e0b044..940d869e6c 100644 --- a/programs/develop/cedit/SRC/CEdit.ob07 +++ b/programs/develop/cedit/SRC/CEdit.ob07 @@ -28,7 +28,7 @@ IMPORT RW, Ini, EB := EditBox, Icons, Tabs, Timer; CONST - header = "CEdit (17-sep-2021)"; + header = "CEdit (21-sep-2021)"; ShellFilter = ""; EditFilter = "SH|ASM|TXT|INC|OB07|C|CPP|H|PAS|PP|LUA|INI|JSON"; @@ -1087,13 +1087,39 @@ BEGIN END Script; -PROCEDURE ShowSearchPanel; +PROCEDURE ShowSearchPanel (goto: BOOLEAN); +VAR + i: INTEGER; + flag: BOOLEAN; BEGIN + flag := FALSE; + 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); + flag := TRUE + END + END + END; IF ~search THEN Search ELSIF ~searchOpened THEN search := FALSE; Search + END; + IF flag THEN + SetFocus(FindEdit, FALSE) + ELSIF goto THEN + SetFocus(GotoEdit, TRUE) + ELSE + SetFocus(FindEdit, TRUE) END END ShowSearchPanel; @@ -1305,8 +1331,7 @@ BEGIN T.redo(text); repaint |menuFind: - ShowSearchPanel; - SetFocus(FindEdit, TRUE) + ShowSearchPanel(FALSE) |menuFindNext: notFound := ~T.findNext(text, BKW.value); menuFindClicked := TRUE @@ -1314,8 +1339,7 @@ BEGIN notFound := ~T.findNext(text, ~BKW.value); menuFindClicked := TRUE |menuGoto: - ShowSearchPanel; - SetFocus(GotoEdit, TRUE) + ShowSearchPanel(TRUE) |menuToggleBookmark: T.toggleLabel(text) |menuNextBookmark: @@ -1762,12 +1786,10 @@ BEGIN SwitchTab((curText + 1) MOD textsCount) ELSIF (keyCode = 33) & ctrl THEN key := -1; - ShowSearchPanel; - SetFocus(FindEdit, TRUE) + ShowSearchPanel(FALSE) ELSIF (keyCode = 34) & ctrl THEN key := -1; - ShowSearchPanel; - SetFocus(GotoEdit, TRUE) + ShowSearchPanel(TRUE) ELSE IF EditBox_Focus(FindEdit) THEN EB.key(FindEdit, key); @@ -1905,7 +1927,8 @@ BEGIN save(text); repaint |btnSearch: - ShowSearchPanel + ShowSearchPanel(FALSE); + repaint |btnCloseSearch: Search |btnHideSearch: diff --git a/programs/develop/cedit/SRC/EditBox.ob07 b/programs/develop/cedit/SRC/EditBox.ob07 index 1d639d25ce..01800fcaf6 100644 --- a/programs/develop/cedit/SRC/EditBox.ob07 +++ b/programs/develop/cedit/SRC/EditBox.ob07 @@ -19,7 +19,11 @@ MODULE EditBox; -IMPORT sys := SYSTEM, KOSAPI; +IMPORT SYSTEM, KOSAPI, Encodings; + +CONST + + MAX_LENGTH = 1024; TYPE @@ -50,14 +54,14 @@ TYPE VAR key_proc: EditBoxKey; - paint *: PROCEDURE (eb: tEditBox); - mouse *: PROCEDURE (eb: tEditBox); - setValue *: PROCEDURE (eb: tEditBox; text: INTEGER); + paint *: PROCEDURE (eb: tEditBox); + mouse *: PROCEDURE (eb: tEditBox); + _setValue : PROCEDURE (eb: tEditBox; text: INTEGER); PROCEDURE _key (key: INTEGER; key_proc: EditBoxKey; text: tEditBox); BEGIN - sys.CODE( + SYSTEM.CODE( 08BH, 045H, 008H, (* mov eax, dword [ebp + 8] *) 08BH, 055H, 00CH, (* mov edx, dword [ebp + 12] *) 08BH, 04DH, 010H, (* mov ecx, dword [ebp + 16] *) @@ -83,7 +87,7 @@ BEGIN ASSERT(max < LEN(str)); i := 0; REPEAT - sys.GET(ptr, str[i]); + SYSTEM.GET(ptr, str[i]); INC(i); INC(ptr) UNTIL (str[i - 1] = 0X) OR (i = max); @@ -91,6 +95,21 @@ BEGIN END getValue; +PROCEDURE setValue* (text: tEditBox; str: ARRAY OF WCHAR); +VAR + i: INTEGER; + temp: ARRAY MAX_LENGTH OF CHAR; +BEGIN + ASSERT(LENGTH(str) < LEN(temp)); + i := 0; + REPEAT + temp[i] := CHR(Encodings.UNI[ORD(str[i]), Encodings.CP866] MOD 256); + INC(i) + UNTIL str[i - 1] = 0X; + _setValue(text, SYSTEM.ADR(temp[0])) +END setValue; + + PROCEDURE create* (tlx, tly, width, max_chars: INTEGER; editbox_interlock: tEditBox): tEditBox; VAR new_textbox: tEditBox; @@ -122,7 +141,7 @@ VAR BEGIN a := KOSAPI.GetProcAdr(name, Lib); ASSERT(a # 0); - sys.PUT(v, a) + SYSTEM.PUT(v, a) END GetProc; @@ -132,10 +151,10 @@ VAR BEGIN Lib := KOSAPI.LoadLib("/rd/1/lib/box_lib.obj"); ASSERT(Lib # 0); - GetProc(Lib, sys.ADR(paint), "edit_box"); - GetProc(Lib, sys.ADR(key_proc), "edit_box_key"); - GetProc(Lib, sys.ADR(mouse), "edit_box_mouse"); - GetProc(Lib, sys.ADR(setValue), "edit_box_set_text"); + GetProc(Lib, SYSTEM.ADR(paint), "edit_box"); + GetProc(Lib, SYSTEM.ADR(key_proc), "edit_box_key"); + GetProc(Lib, SYSTEM.ADR(mouse), "edit_box_mouse"); + GetProc(Lib, SYSTEM.ADR(_setValue), "edit_box_set_text"); END main; diff --git a/programs/develop/cedit/SRC/Text.ob07 b/programs/develop/cedit/SRC/Text.ob07 index 029f90e465..6851fb5bda 100644 --- a/programs/develop/cedit/SRC/Text.ob07 +++ b/programs/develop/cedit/SRC/Text.ob07 @@ -1776,6 +1776,19 @@ PROCEDURE isWordChar (c: WCHAR): BOOLEAN; END isWordChar; +PROCEDURE getSelectedText* (text: tText; VAR s: ARRAY OF WCHAR); +VAR + n: INTEGER; + selBeg, selEnd: tPoint; +BEGIN + s[0] := 0X; + IF selected(text) & (text.cursor.Y = text.select.Y) THEN + getSelect(text, selBeg, selEnd); + n := getString(text.curLine, selBeg.X, selEnd.X - selBeg.X, s) + END +END getSelectedText; + + PROCEDURE wordSel* (text: tText); VAR n, i, x1, x2: INTEGER;