fix #11 - terminal scrollbar lacks of accuracy

This commit is contained in:
Basile Burg 2020-03-31 16:48:05 +02:00
parent a4a9a50a09
commit 580f8b2e1e
2 changed files with 11 additions and 8 deletions

View File

@ -18,7 +18,7 @@ uses
type type
TTerminalScrollInfo = record TTerminalScrollInfo = record
min, max, value: integer; min, max, value, pageSize: integer;
end; end;
TTerminalTextScrolled = procedure(sender: TObject; delta: integer) of Object; TTerminalTextScrolled = procedure(sender: TObject; delta: integer) of Object;
@ -634,16 +634,18 @@ end;
function TTerminal.getVScrollInfo: TTerminalScrollInfo; function TTerminal.getVScrollInfo: TTerminalScrollInfo;
{$ifdef hasgtk2term} {$ifdef hasgtk2term}
var var
a: PGtkAdjustment = nil; a: PGtkAdjustment;
{$endif} {$endif}
begin begin
FillChar(result, sizeOf(result), 0);
{$ifdef hasgtk2term} {$ifdef hasgtk2term}
if assigned(fTerminalHanlde) then if assigned(fTerminalHanlde) then
begin begin
a := vte_terminal_get_adjustment(fTerminalHanlde); a := vte_terminal_get_adjustment(fTerminalHanlde);
result.max := round(a^.upper); result.max := round(a^.upper);
result.min := round(a^.lower); result.min := round(a^.lower);
result.value := round(a^.value); result.value := round(a^.value);
result.pageSize := round(a^.page_size);
end; end;
{$endif} {$endif}
end; end;

View File

@ -329,9 +329,10 @@ var
begin begin
if fDisableScrollBarSync or not visible or fTerm.isNil then if fDisableScrollBarSync or not visible or fTerm.isNil then
exit; exit;
i := fTerm.getVScrollInfo(); i := fTerm.getVScrollInfo();
ScrollBar1.Max := i.max; ScrollBar1.Max := i.max;
ScrollBar1.Position := i.value; ScrollBar1.Position := i.value;
ScrollBar1.PageSize := i.pageSize;
end; end;
procedure TTermWidget.FormShortCut(var Msg: TLMKey; var Handled: Boolean); procedure TTermWidget.FormShortCut(var Msg: TLMKey; var Handled: Boolean);