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, 'child-exited', G_CALLBACK(@TerminalExit), nil);
g_signal_connect(Info.ClientWidget, 'contents-changed',G_CALLBACK(@TerminalRefresh), 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, '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); SetCallbacks(Info.CoreWidget, Info);
Result := {%H-}TLCLIntfHandle(Info.CoreWidget); Result := {%H-}TLCLIntfHandle(Info.CoreWidget);
end; end;
@ -333,8 +334,11 @@ begin
gtk_container_add(GTK_CONTAINER(Info.CoreWidget), Info.ClientWidget); gtk_container_add(GTK_CONTAINER(Info.CoreWidget), Info.ClientWidget);
g_object_set_data(PGObject(Info.ClientWidget), 'widgetinfo', Info); g_object_set_data(PGObject(Info.ClientWidget), 'widgetinfo', Info);
gtk_widget_show_all(Info.CoreWidget); gtk_widget_show_all(Info.CoreWidget);
g_signal_connect(Info.ClientWidget, 'child-exited', G_CALLBACK(@TerminalExit), 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, '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} {$endif}
{$ifdef Windows} {$ifdef Windows}

View File

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