Delphi select a paragraph in richedit
Ho开发者_JS百科w to select a paragraph on several lines. Paragraphs are limited by number and not by #10 + *#13? Selection fear to be by clicking or by mouse flying over the paragraph.
Basically if you use SelStart and SelLength public properties of your TRichEdit, you can select whatever text you want in your richedit control.
So, you can break your text apart as you want, paragraphs or not, and then just select programmatically a slice of it.
{********************************************************************}
// Nombre de la funcion: TI2FStrings.GetCursorSQL
// Explicación: Obtiene el párrafo donde está situado el cursor.
//
// Usuario Fecha Modificación
// ------------ ---------- ------------------------------------------
// drodriguez 11/08/2005 Creación
{********************************************************************}
class function TI2FStrings.GetCursorSQL(Text: string; CursorPos: Integer): string;
var
LastPos, iPos: Integer;
IniPos, FinPos: Integer;
Begin
iPos:= 1;
Repeat
LastPos:= iPos;
iPos:= PosEx(#13#10#13#10, Text, iPos);
if (iPos <> 0) then Inc(iPos, 2);
until (iPos = 0) or (CursorPos < iPos - 1);
if (iPos = 0) then iPos:= Length(Text)
else Dec(iPos, 2);
FinPos:= iPos;
IniPos:= LastPos;
Result:= Trim(Copy(Text, IniPos, FinPos - IniPos + 1));
end;
This is to get an SQL from an TMemo where every SQL is separated by an empty line. Just replace #13#10#13#10
by #13#10
.
精彩评论