Permalink
Browse files

gtk2: use queued SelLength if available (issue #0014065)

git-svn-id: http://svn2.freepascal.org/svn/lazarus/trunk@20768 4005530d-fff6-0310-9dd1-cebe43e6787f
  • Loading branch information...
1 parent 3681a01 commit e7e9bbfa6215a229028bba16c58615de6daabce1 paul committed Jun 30, 2009
Showing with 14 additions and 5 deletions.
  1. +1 −1 lcl/include/customedit.inc
  2. +1 −0 lcl/interfaces/gtk2/gtk2memostrings.inc
  3. +12 −4 lcl/interfaces/gtk2/gtk2wscustommemo.inc
@@ -161,7 +161,7 @@ function TCustomEdit.GetSelLength : integer;
begin
if HandleAllocated then
FSelLength := TWSCustomEditClass(WidgetSetClass).GetSelLength(Self);
- Result:= FSelLength;
+ Result := FSelLength;
end;
{------------------------------------------------------------------------------
@@ -33,6 +33,7 @@ type
public
//property Sorted: boolean read FSorted write SetSorted;
property Owner: TWinControl read FOwner;
+ property QueueSelLength: Integer read FQueueSelLength;
end;
{$ELSE}
{
@@ -326,6 +326,7 @@ end;
class function TGtk2WSCustomMemo.GetSelLength(const ACustomEdit: TCustomEdit): integer;
var
+ MemoStrings: TGtk2MemoStrings;
TextView: PGtkTextView;
TextBuffer: PGtkTextBuffer;
StartIter, EndIter: TGtkTextIter;
@@ -334,11 +335,18 @@ begin
if not WSCheckHandleAllocated(ACustomEdit, 'GetSelLength') then
Exit;
- TextView := PGtkTextView(GetWidgetInfo(Pointer(ACustomEdit.Handle), False)^.CoreWidget);
- TextBuffer := gtk_text_view_get_buffer(TextView);
- if not gtk_text_buffer_get_selection_bounds(TextBuffer, @StartIter, @EndIter) then Exit;
+ MemoStrings := TCustomMemo(ACustomEdit).Lines as TGtk2MemoStrings;
+ Result := MemoStrings.QueueSelLength;
+
+ if Result = -1 then
+ begin
+ Result := 0;
+ TextView := PGtkTextView(GetWidgetInfo(Pointer(ACustomEdit.Handle), False)^.CoreWidget);
+ TextBuffer := gtk_text_view_get_buffer(TextView);
+ if not gtk_text_buffer_get_selection_bounds(TextBuffer, @StartIter, @EndIter) then Exit;
- Result := Abs(gtk_text_iter_get_offset(@EndIter) - gtk_text_iter_get_offset(@StartIter));
+ Result := Abs(gtk_text_iter_get_offset(@EndIter) - gtk_text_iter_get_offset(@StartIter));
+ end;
end;
class function TGtk2WSCustomMemo.GetCaretPos(const ACustomEdit: TCustomEdit): TPoint;

0 comments on commit e7e9bbf

Please sign in to comment.