X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=cmd%2Fmicro%2Fshell%2Fterminal.go;h=bfb7fa87f209b03e13ea74e9a651300fd72cfb53;hb=212b0f8c71edd37a8ca7ed76958b195c46186f84;hp=b4e5da31e813381f25687252f5dee6dff7b465d6;hpb=4146730aafdaaf7f70a0261b3f3679c2b98acae9;p=micro.git diff --git a/cmd/micro/shell/terminal.go b/cmd/micro/shell/terminal.go index b4e5da31..bfb7fa87 100644 --- a/cmd/micro/shell/terminal.go +++ b/cmd/micro/shell/terminal.go @@ -15,7 +15,7 @@ import ( type TermType int const ( - TTIdle = iota // Waiting for a new command + TTClose = iota // Should be closed TTRunning // Currently running a command TTDone // Finished running a command ) @@ -38,6 +38,10 @@ func (t *Terminal) HasSelection() bool { return t.Selection[0] != t.Selection[1] } +func (t *Terminal) Name() string { + return t.title +} + // GetSelection returns the selected text func (t *Terminal) GetSelection(width int) string { start := t.Selection[0] @@ -60,7 +64,7 @@ func (t *Terminal) GetSelection(width int) string { } // Start begins a new command in this terminal with a given view -func (t *Terminal) Start(execCmd []string, getOutput bool) error { +func (t *Terminal) Start(execCmd []string, getOutput bool, wait bool) error { if len(execCmd) <= 0 { return nil } @@ -78,6 +82,7 @@ func (t *Terminal) Start(execCmd []string, getOutput bool) error { t.getOutput = getOutput t.Status = TTRunning t.title = execCmd[0] + ":" + strconv.Itoa(cmd.Process.Pid) + t.wait = wait go func() { for { @@ -88,8 +93,7 @@ func (t *Terminal) Start(execCmd []string, getOutput bool) error { } screen.Redraw() } - // TODO: close Term - // closeterm <- view.Num + t.Stop() }() return nil @@ -107,10 +111,10 @@ func (t *Terminal) Stop() { } } -// Close sets the Status to TTIdle indicating that the terminal -// is ready for a new command to execute +// Close sets the Status to TTClose indicating that the terminal +// is done and should be closed func (t *Terminal) Close() { - t.Status = TTIdle + t.Status = TTClose // call the lua function that the user has given as a callback if t.getOutput { // TODO: plugin callback on Term emulator