From 7d5620b2da5bf35160dfa35647a5ccb70d0bfafe Mon Sep 17 00:00:00 2001 From: skalogryz Date: Fri, 30 Jan 2015 23:55:14 +0000 Subject: [PATCH] richmemo: gtk2 removing timer dependent code for getting selection length git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3916 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/richmemo/gtk2/gtk2richmemo.pas | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/components/richmemo/gtk2/gtk2richmemo.pas b/components/richmemo/gtk2/gtk2richmemo.pas index b5d21904e..18723dc95 100644 --- a/components/richmemo/gtk2/gtk2richmemo.pas +++ b/components/richmemo/gtk2/gtk2richmemo.pas @@ -55,6 +55,7 @@ type class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override; class procedure DestroyHandle(const AWinControl: TWinControl); override; + class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override; class function GetStrings(const ACustomMemo: TCustomMemo): TStrings; override; class function GetStyleRange(const AWinControl: TWinControl; TextStart: Integer; @@ -621,6 +622,25 @@ begin inherited DestroyHandle(AWinControl); end; +class function TGtk2WSCustomRichMemo.GetSelLength(const ACustomEdit: TCustomEdit + ): integer; +var + w : PGtkWidget; + b : PGtkTextBuffer; + istart : TGtkTextIter; + iend : TGtkTextIter; +begin + GetWidgetBuffer(ACustomEdit, w, b); + if not Assigned(b) then begin + Result:=-1; + Exit; + end; + Result := 0; + if not gtk_text_buffer_get_selection_bounds(b, @istart, @iend) then Exit; + + Result := Abs(gtk_text_iter_get_offset(@iend) - gtk_text_iter_get_offset(@istart)); +end; + class function TGtk2WSCustomRichMemo.GetStrings(const ACustomMemo: TCustomMemo ): TStrings; var