From a3e84c168e7963946a76f11618f9bda71db162dd Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Wed, 6 May 2020 17:43:37 +0100 Subject: [PATCH] Fix broken git hook and the formatting it missed And tidy up logic for exit adding docs --- cmd/fyneterm/main.go | 6 +++--- output.go | 4 ++-- term.go | 12 +++++++++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/cmd/fyneterm/main.go b/cmd/fyneterm/main.go index 28c65781..85693ac1 100644 --- a/cmd/fyneterm/main.go +++ b/cmd/fyneterm/main.go @@ -54,10 +54,10 @@ func main() { setupListener(t, w) w.SetContent(fyne.NewContainerWithLayout(layout.NewMaxLayout(), bg, img, t)) w.Canvas().AddShortcut(&desktop.CustomShortcut{ - KeyName: fyne.KeyD, + KeyName: fyne.KeyD, Modifier: desktop.ControlModifier, - }, func (_ fyne.Shortcut) { - t.Close() + }, func(_ fyne.Shortcut) { + t.Exit() }) cellSize := guessCellSize() diff --git a/output.go b/output.go index bb822086..ef6e82b8 100644 --- a/output.go +++ b/output.go @@ -104,7 +104,7 @@ func (t *Terminal) handleOutput(buf []byte) { if r == '\t' { // TODO handle tab r = ' ' } - + cellStyle := &widget.CustomTextGridStyle{FGColor: currentFG, BGColor: currentBG} for len(t.content.Rows[t.cursorRow].Cells)-1 < t.cursorCol { @@ -123,7 +123,7 @@ func (t *Terminal) handleOutput(buf []byte) { // record progress for next chunk of buffer if state.esc != noEscape { - state.esc = -1-(len(state.code)) + state.esc = -1 - (len(state.code)) previous = state } } diff --git a/term.go b/term.go index db1f47fb..60a937e4 100644 --- a/term.go +++ b/term.go @@ -107,8 +107,14 @@ func (t *Terminal) open() error { return nil } -func (t *Terminal) Close() { - t.pty.Write([]byte("exit\n")) +// Exit requests that this terminal exits. +// If there are embedded shells it will exit the child one only. +func (t *Terminal) Exit() { + _, _ = t.pty.Write([]byte("exit\n")) +} + +func (t *Terminal) close() error { + return t.pty.Close() } // don't call often - should we cache? @@ -151,7 +157,7 @@ func (t *Terminal) Run() error { t.run() - return t.pty.Close() + return t.close() } // NewTerminal sets up a new terminal instance with the bash shell