6 "github.com/zyedidia/clipboard"
7 "github.com/zyedidia/micro/internal/display"
8 "github.com/zyedidia/micro/internal/screen"
9 "github.com/zyedidia/micro/internal/shell"
10 "github.com/zyedidia/tcell"
11 "github.com/zyedidia/terminal"
14 type TermPane struct {
22 func NewTermPane(x, y, w, h int, t *shell.Terminal, id uint64) *TermPane {
26 th.mouseReleased = true
27 th.Window = display.NewTermWindow(x, y, w, h, t)
31 func (t *TermPane) ID() uint64 {
35 func (t *TermPane) SetID(i uint64) {
39 func (t *TermPane) Close() {}
41 func (t *TermPane) Quit() {
43 if len(MainTab().Panes) > 1 {
45 } else if len(Tabs.List) > 1 {
54 func (t *TermPane) Unsplit() {
55 n := MainTab().GetNode(t.id)
58 MainTab().RemovePane(MainTab().GetPane(t.id))
60 MainTab().SetActive(len(MainTab().Panes) - 1)
63 // HandleEvent handles a tcell event by forwarding it to the terminal emulator
64 // If the event is a mouse event and the program running in the emulator
65 // does not have mouse support, the emulator will support selections and
67 func (t *TermPane) HandleEvent(event tcell.Event) {
68 if e, ok := event.(*tcell.EventKey); ok {
69 if t.Status == shell.TTDone {
71 case tcell.KeyEscape, tcell.KeyCtrlQ, tcell.KeyEnter:
77 if e.Key() == tcell.KeyCtrlC && t.HasSelection() {
78 clipboard.WriteAll(t.GetSelection(t.GetView().Width), "clipboard")
79 InfoBar.Message("Copied selection to clipboard")
80 } else if t.Status != shell.TTDone {
81 t.WriteString(event.EscSeq())
83 } else if e, ok := event.(*tcell.EventMouse); e != nil && (!ok || t.State.Mode(terminal.ModeMouseMask)) {
84 t.WriteString(event.EscSeq())
91 if e.Buttons() == tcell.Button1 {
103 t.mouseReleased = false
104 } else if e.Buttons() == tcell.ButtonNone {
105 if !t.mouseReleased {
109 t.mouseReleased = true
113 if t.Status == shell.TTClose {
118 func (t *TermPane) HandleCommand(input string) {
119 InfoBar.Error("Commands are unsupported in term for now")