]> git.lizzy.rs Git - micro.git/blobdiff - internal/action/termpane.go
better top
[micro.git] / internal / action / termpane.go
index 6928856fc49b0ee4c6a6507c3811c24e5920d7a8..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 {
@@ -90,6 +95,10 @@ func (t *TermPane) HandleEvent(event tcell.Event) {
                } else if t.Status != shell.TTDone {
                        t.WriteString(event.EscSeq())
                }
+       } else if _, ok := event.(*tcell.EventPaste); ok {
+               if t.Status != shell.TTDone {
+                       t.WriteString(event.EscSeq())
+               }
        } else if e, ok := event.(*tcell.EventMouse); e != nil && (!ok || t.State.Mode(terminal.ModeMouseMask)) {
                // t.WriteString(event.EscSeq())
        } else if e != nil {