terminal, fix bad scrollbar sync after auto checkdir

This commit is contained in:
Basile Burg 2020-03-07 16:12:56 +01:00
parent 3b358c9a48
commit e335409c8f
2 changed files with 17 additions and 7 deletions

View File

@ -262,7 +262,8 @@ begin
g_signal_connect(Info.ClientWidget, 'child-exited', G_CALLBACK(@TerminalExit), nil);
g_signal_connect(Info.ClientWidget, 'contents-changed',G_CALLBACK(@TerminalRefresh), nil);
g_signal_connect(Info.ClientWidget, 'scroll-event', G_CALLBACK(@TerminalTextScrolled), nil);
g_signal_connect(Info.ClientWidget, 'commit', G_CALLBACK(@TerminalCommit), nil);
//g_signal_connect(Info.ClientWidget, 'commit', G_CALLBACK(@TerminalCommit), nil);
g_signal_connect(Info.ClientWidget, 'cursor-moved', G_CALLBACK(@TerminalCommit), nil);
SetCallbacks(Info.CoreWidget, Info);
Result := {%H-}TLCLIntfHandle(Info.CoreWidget);
end;
@ -333,8 +334,11 @@ begin
gtk_container_add(GTK_CONTAINER(Info.CoreWidget), Info.ClientWidget);
g_object_set_data(PGObject(Info.ClientWidget), 'widgetinfo', Info);
gtk_widget_show_all(Info.CoreWidget);
g_signal_connect(Info.ClientWidget, 'child-exited', G_CALLBACK(@TerminalExit), nil);
g_signal_connect(Info.ClientWidget, 'contents-changed', G_CALLBACK(@TerminalRefresh), nil);
g_signal_connect(Info.ClientWidget, 'child-exited', G_CALLBACK(@TerminalExit), nil);
g_signal_connect(Info.ClientWidget, 'contents-changed',G_CALLBACK(@TerminalRefresh), nil);
g_signal_connect(Info.ClientWidget, 'scroll-event', G_CALLBACK(@TerminalTextScrolled), nil);
//g_signal_connect(Info.ClientWidget, 'commit', G_CALLBACK(@TerminalCommit), nil);
g_signal_connect(Info.ClientWidget, 'cursor-moved', G_CALLBACK(@TerminalCommit), nil);
{$endif}
{$ifdef Windows}

View File

@ -81,6 +81,7 @@ type
fTerm: TTerminal;
fOpts: TTerminalOptions;
fLastCheckedDirectory: string;
fDisableScrollBarSync: boolean;
fNeedApplyChanges: boolean;
procedure checkDirectory(const dir: string);
procedure updateScrollBar();
@ -286,15 +287,20 @@ begin
end;
procedure TTermWidget.checkDirectory(const dir: string);
var
i: TTerminalScrollInfo;
begin
fDisableScrollBarSync := true;
fLastCheckedDirectory := dir;
fTerm.SendControlChar(TASCIIControlCharacter.HOME);
fTerm.SendControlChar(TASCIIControlCharacter.VT);
fTerm.SendControlChar(TASCIIControlCharacter.LF);
fNeedApplyChanges := true;
fOpts.applyChanges;
fTerm.Command('cd ' + dir);
updateScrollBar();
i := fTerm.getVScrollInfo();
ScrollBar1.Max := i.max;
ScrollBar1.Position := ScrollBar1.Max;
fTerm.setVScrollPosition(ScrollBar1.Max);
fDisableScrollBarSync := false;
end;
procedure TTermWidget.SetVisible(Value: boolean);
@ -321,7 +327,7 @@ procedure TTermWidget.updateScrollBar();
var
i: TTerminalScrollInfo;
begin
if not visible or fTerm.isNil then
if fDisableScrollBarSync or not visible or fTerm.isNil then
exit;
i := fTerm.getVScrollInfo();
ScrollBar1.Max := i.max;