]> git.lizzy.rs Git - micro.git/commitdiff
Term should return error on unsupported systems
authorZachary Yedidia <zyedidia@gmail.com>
Tue, 11 Feb 2020 00:09:03 +0000 (19:09 -0500)
committerZachary Yedidia <zyedidia@gmail.com>
Tue, 11 Feb 2020 00:09:03 +0000 (19:09 -0500)
Fixes #1494

internal/action/command.go
internal/action/terminal_supported.go
internal/action/termpane.go

index 724a8d69edd77045e1121fe1e0c2c1a12e889166..3a445caa0a64e0aa76dadb118834147e2a838f18 100644 (file)
@@ -807,6 +807,11 @@ func (h *BufPane) ReplaceAllCmd(args []string) {
 func (h *BufPane) TermCmd(args []string) {
        ps := h.tab.Panes
 
+       if !TermEmuSupported {
+               InfoBar.Error("Terminal emulator not supported on this system")
+               return
+       }
+
        if len(args) == 0 {
                sh := os.Getenv("SHELL")
                if sh == "" {
@@ -830,7 +835,12 @@ func (h *BufPane) TermCmd(args []string) {
                }
 
                v := h.GetView()
-               MainTab().Panes[i] = NewTermPane(v.X, v.Y, v.Width, v.Height, t, id, MainTab())
+               tp, err := NewTermPane(v.X, v.Y, v.Width, v.Height, t, id, MainTab())
+               if err != nil {
+                       InfoBar.Error(err)
+                       return
+               }
+               MainTab().Panes[i] = tp
                MainTab().SetActive(i)
        }
 
index 4df8611543016de66d5a09b2bcbaa8e8caf5462c..cb5cc3dcd910a223146be7e84f8ce5a5d34da8b8 100644 (file)
@@ -30,7 +30,12 @@ func RunTermEmulator(h *BufPane, input string, wait bool, getOutput bool, callba
        id := MainTab().Panes[0].ID()
 
        v := h.GetView()
-       MainTab().Panes[0] = NewTermPane(v.X, v.Y, v.Width, v.Height, t, id, MainTab())
+
+       tp, err := NewTermPane(v.X, v.Y, v.Width, v.Height, t, id, MainTab())
+       if err != nil {
+               return err
+       }
+       MainTab().Panes[0] = tp
        MainTab().SetActive(0)
 
        return nil
index 540b23150f5cb26596d119a2c55a58a6e5bd40f7..7fc0b8d1c2f386f3bc2699d13acd26855e6b1e4a 100644 (file)
@@ -1,6 +1,7 @@
 package action
 
 import (
+       "errors"
        "runtime"
 
        "github.com/zyedidia/clipboard"
@@ -20,14 +21,18 @@ type TermPane struct {
        tab           *Tab
 }
 
-func NewTermPane(x, y, w, h int, t *shell.Terminal, id uint64, tab *Tab) *TermPane {
+func NewTermPane(x, y, w, h int, t *shell.Terminal, id uint64, tab *Tab) (*TermPane, error) {
+       if !TermEmuSupported {
+               return nil, errors.New("Terminal emulator is not supported on this system")
+       }
+
        th := new(TermPane)
        th.Terminal = t
        th.id = id
        th.mouseReleased = true
        th.Window = display.NewTermWindow(x, y, w, h, t)
        th.tab = tab
-       return th
+       return th, nil
 }
 
 func (t *TermPane) ID() uint64 {