From 580f8b2e1e9de5ded34649fbcd4e3c7b285f599c Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Tue, 31 Mar 2020 16:48:05 +0200 Subject: [PATCH] fix #11 - terminal scrollbar lacks of accuracy --- etc/terminal/terminalctrls.pas | 14 ++++++++------ src/u_term.pas | 5 +++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/etc/terminal/terminalctrls.pas b/etc/terminal/terminalctrls.pas index 22a7208d..fd74d24f 100644 --- a/etc/terminal/terminalctrls.pas +++ b/etc/terminal/terminalctrls.pas @@ -18,7 +18,7 @@ uses type TTerminalScrollInfo = record - min, max, value: integer; + min, max, value, pageSize: integer; end; TTerminalTextScrolled = procedure(sender: TObject; delta: integer) of Object; @@ -634,16 +634,18 @@ end; function TTerminal.getVScrollInfo: TTerminalScrollInfo; {$ifdef hasgtk2term} var - a: PGtkAdjustment = nil; + a: PGtkAdjustment; {$endif} begin + FillChar(result, sizeOf(result), 0); {$ifdef hasgtk2term} if assigned(fTerminalHanlde) then begin - a := vte_terminal_get_adjustment(fTerminalHanlde); - result.max := round(a^.upper); - result.min := round(a^.lower); - result.value := round(a^.value); + a := vte_terminal_get_adjustment(fTerminalHanlde); + result.max := round(a^.upper); + result.min := round(a^.lower); + result.value := round(a^.value); + result.pageSize := round(a^.page_size); end; {$endif} end; diff --git a/src/u_term.pas b/src/u_term.pas index 78331e1c..b93a2636 100644 --- a/src/u_term.pas +++ b/src/u_term.pas @@ -329,9 +329,10 @@ var begin if fDisableScrollBarSync or not visible or fTerm.isNil then exit; - i := fTerm.getVScrollInfo(); - ScrollBar1.Max := i.max; + i := fTerm.getVScrollInfo(); + ScrollBar1.Max := i.max; ScrollBar1.Position := i.value; + ScrollBar1.PageSize := i.pageSize; end; procedure TTermWidget.FormShortCut(var Msg: TLMKey; var Handled: Boolean);