Page 1 of 1
find first character
Posted: Sat Oct 12, 2019 1:57 pm
by adamrich
Hello,
Is there a way to find first character in TRichViewEdit?
I'm trying to find if the whole document is started with character @
I can't get the text of TRichViewEdit to see if copy(RichViewEdit1.Text, 1,1)='@'
Thank you
Re: find first character
Posted: Sat Oct 12, 2019 3:32 pm
by Sergey Tkachenko
You can use the function GetAllText from RVGetTextW.
But it is not efficient, you just need the first character, not the whole string that can be several megabytes.
I can write a function, but some details must be clarified:
1) What if the document is started from non-text object (such as picture or horizontal line)?
2) What if the document is started from several empty lines? Space characters? Tabs?
3) What if the document is started from a table, and '@' starts the first cell?
Re: find first character
Posted: Sat Oct 12, 2019 6:25 pm
by adamrich
Thanks for your time,
All I need to know if the document's first character @ or whatever I look for ,
if picture or anything else other than @ or table etc, that means the first character not @ (excluding the space and empty lines)
example
@ abc, <table> hello world (first character is @ on the first paragraph )
@ (excluding the space, the first character is @)
even with more than one line, here the first line or paragraph empty or filled with space
@ (excluding the space, the first character is @)
abcd @ (@ not first character)
<table> @ </Table> (@ not first character)
<Picture> @ (@ not first character)
Hope I could explained clearly
Thank you
Re: find first character
Posted: Sat Oct 12, 2019 8:07 pm
by Sergey Tkachenko
This function returns the first non-space character (or #0, if the document is empty or started from non-text).
Empty lines, spaces and tab characters are ignored.
Code: Select all
uses
RVUni;
function GetNonSpaceFirstChar(rv: TCustomRichView): TRVUnicodeChar;
var
i: Integer;
s: TRVUnicodeString;
begin
Result := #0;
for i := 0 to rv.ItemCount - 1 do
begin
if (rv.GetItemStyle(i) < 0) and (rv.GetItemStyle(i) <> rvsTab) then
break
else if rv.GetItemStyle(i) >= 0 then
begin
s := Trim(rv.GetItemTextW(i));
if s <> '' then
begin
Result := s[1];
break;
end;
end;
end;
end;
Re: find first character
Posted: Sun Oct 13, 2019 12:37 pm
by adamrich
Thank you,
As always I appreciate your superb support, you never let your user down, best support ever.
Thanks again