mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-11 14:18:13 +02:00
gtk1: replaced idle function with begin/endupdate, bug #1477
git-svn-id: trunk@15759 -
This commit is contained in:
parent
50c3731145
commit
cadf49eda8
@ -16,22 +16,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////// Callbacks //////
|
//////// Callbacks //////
|
||||||
type
|
|
||||||
PFreezeRec = ^TFreezeRec;
|
|
||||||
TFreezeRec = record
|
|
||||||
GtkText: PGtkText;
|
|
||||||
NewCursorPos: Integer;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function GtkWS_GtkTextUnFreeze(Freeze: PFreezeRec): guint; cdecl;
|
|
||||||
begin
|
|
||||||
gtk_text_thaw(Freeze^.GtkText);
|
|
||||||
if Freeze^.NewCursorPos <> -1 then
|
|
||||||
gtk_editable_set_position(PGtkEditable(Freeze^.GtkText), Freeze^.NewCursorPos);
|
|
||||||
Dispose(Freeze);
|
|
||||||
Result := 0;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure GtkWS_GtkTextInserting(GtkEditable: PGtkEditable; NewText: pgchar;
|
procedure GtkWS_GtkTextInserting(GtkEditable: PGtkEditable; NewText: pgchar;
|
||||||
NewTextLength: gint; position: pgint; TextInserted:
|
NewTextLength: gint; position: pgint; TextInserted:
|
||||||
PGtkTextInsertEvent); cdecl;
|
PGtkTextInsertEvent); cdecl;
|
||||||
@ -213,6 +197,21 @@ begin
|
|||||||
Result := X;
|
Result := X;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TGtkMemoStrings.SetUpdateState(Updating: Boolean);
|
||||||
|
begin
|
||||||
|
inherited SetUpdateState(Updating);
|
||||||
|
//DebugLn(['TGtkMemoStrings.SetUpdateState Updating=',Updating,' ',FGtkText<>nil,' FFreezed=',FFreezed]);
|
||||||
|
if Updating and (FGtkText<>nil) and (not FFreezed) then begin
|
||||||
|
gtk_text_freeze(FGtkText);
|
||||||
|
FFreezed:=true;
|
||||||
|
end;
|
||||||
|
if (not Updating) and (FFreezed) then begin
|
||||||
|
if FGtkText<>nil then
|
||||||
|
gtk_text_thaw(FGtkText);
|
||||||
|
FFreezed:=false;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TGtkMemoStrings.Create(GtkText: PGtkText; TheOwner: TWinControl);
|
constructor TGtkMemoStrings.Create(GtkText: PGtkText; TheOwner: TWinControl);
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
@ -279,16 +278,11 @@ var
|
|||||||
LineStart: Integer;
|
LineStart: Integer;
|
||||||
NewLine: String;
|
NewLine: String;
|
||||||
NeedMoveCursor: Boolean;
|
NeedMoveCursor: Boolean;
|
||||||
Freeze: PFreezeRec;
|
LocalFreeze: Boolean;
|
||||||
begin
|
begin
|
||||||
Freeze := nil;
|
LocalFreeze:=FGtkText^.freeze_count = 0;
|
||||||
if FGtkText^.freeze_count = 0 then begin
|
if LocalFreeze then
|
||||||
gtk_text_freeze(FGtkText);
|
gtk_text_freeze(FGtkText);
|
||||||
New(Freeze);
|
|
||||||
Freeze^.GtkText := FGtkText;
|
|
||||||
Freeze^.NewCursorPos := -1;
|
|
||||||
gtk_idle_add(TGtkfunction(@GtkWS_GtkTextUnFreeze), Freeze);
|
|
||||||
end;
|
|
||||||
|
|
||||||
LockOnChange(PGtkObject(FGtkText),+1);
|
LockOnChange(PGtkObject(FGtkText),+1);
|
||||||
|
|
||||||
@ -313,8 +307,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// when we are thawed out we will move the cursor
|
// when we are thawed out we will move the cursor
|
||||||
if NeedMoveCursor and (Freeze <> nil) then
|
if LocalFreeze then begin
|
||||||
Freeze^.NewCursorPos := LineStart;
|
gtk_text_thaw(FGtkText);
|
||||||
|
if NeedMoveCursor and (LineStart <> -1) then
|
||||||
|
gtk_editable_set_position(PGtkEditable(FGtkText), LineStart);
|
||||||
|
end;
|
||||||
|
|
||||||
LockOnChange(PGtkObject(FGtkText),-1);
|
LockOnChange(PGtkObject(FGtkText),-1);
|
||||||
end;
|
end;
|
||||||
|
@ -27,6 +27,7 @@ type
|
|||||||
TGtkMemoStrings = class(TStrings)
|
TGtkMemoStrings = class(TStrings)
|
||||||
private
|
private
|
||||||
FGtkText : PGtkText;
|
FGtkText : PGtkText;
|
||||||
|
FFreezed: boolean;
|
||||||
FOwner: TWinControl;
|
FOwner: TWinControl;
|
||||||
fTextInsertEvent: TGtkTextInsertEvent;
|
fTextInsertEvent: TGtkTextInsertEvent;
|
||||||
fTextDeleteEvent: TGtkTextDeleteEvent;
|
fTextDeleteEvent: TGtkTextDeleteEvent;
|
||||||
@ -46,6 +47,7 @@ type
|
|||||||
procedure TextInserted(NewText: pgchar; NewTextLength: gint; position: pgint);
|
procedure TextInserted(NewText: pgchar; NewTextLength: gint; position: pgint);
|
||||||
procedure TextDeleted(StartPos, EndPos: gint);
|
procedure TextDeleted(StartPos, EndPos: gint);
|
||||||
function PositionToLine(Position: Integer; StartLine: Integer = 0): Integer;
|
function PositionToLine(Position: Integer; StartLine: Integer = 0): Integer;
|
||||||
|
procedure SetUpdateState(Updating: Boolean); override;
|
||||||
//procedure SetSorted(Val : boolean); virtual;
|
//procedure SetSorted(Val : boolean); virtual;
|
||||||
public
|
public
|
||||||
constructor Create(GtkText : PGtkText; TheOwner: TWinControl);
|
constructor Create(GtkText : PGtkText; TheOwner: TWinControl);
|
||||||
|
Loading…
Reference in New Issue
Block a user