diff --git a/etc/terminal/terminalctrls.pas b/etc/terminal/terminalctrls.pas index 23e5dd63..52124a88 100644 --- a/etc/terminal/terminalctrls.pas +++ b/etc/terminal/terminalctrls.pas @@ -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} diff --git a/src/u_term.pas b/src/u_term.pas index eb960000..b4cae053 100644 --- a/src/u_term.pas +++ b/src/u_term.pas @@ -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;