cedit: search selected text

FB2 Reader: minor fix

git-svn-id: svn://kolibrios.org@9197 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Anton Krotov 2021-09-21 18:16:56 +00:00
parent 7763a294f3
commit f3105b9785
5 changed files with 77 additions and 22 deletions

Binary file not shown.

Binary file not shown.

View File

@ -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:

View File

@ -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;

View File

@ -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;