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 {
23 func NewTermPane(x, y, w, h int, t *shell.Terminal, id uint64, tab *Tab) *TermPane {
27 th.mouseReleased = true
28 th.Window = display.NewTermWindow(x, y, w, h, t)
33 func (t *TermPane) ID() uint64 {
37 func (t *TermPane) SetID(i uint64) {
41 func (t *TermPane) SetTab(tab *Tab) {
45 func (t *TermPane) Tab() *Tab {
49 func (t *TermPane) Close() {}
51 func (t *TermPane) Quit() {
53 if len(MainTab().Panes) > 1 {
55 } else if len(Tabs.List) > 1 {
64 func (t *TermPane) Unsplit() {
65 n := MainTab().GetNode(t.id)
68 MainTab().RemovePane(MainTab().GetPane(t.id))
70 MainTab().SetActive(len(MainTab().Panes) - 1)
73 // HandleEvent handles a tcell event by forwarding it to the terminal emulator
74 // If the event is a mouse event and the program running in the emulator
75 // does not have mouse support, the emulator will support selections and
77 func (t *TermPane) HandleEvent(event tcell.Event) {
78 if e, ok := event.(*tcell.EventKey); ok {
79 if t.Status == shell.TTDone {
81 case tcell.KeyEscape, tcell.KeyCtrlQ, tcell.KeyEnter:
87 if e.Key() == tcell.KeyCtrlC && t.HasSelection() {
88 clipboard.WriteAll(t.GetSelection(t.GetView().Width), "clipboard")
89 InfoBar.Message("Copied selection to clipboard")
90 } else if t.Status != shell.TTDone {
91 t.WriteString(event.EscSeq())
93 } else if _, ok := event.(*tcell.EventPaste); ok {
94 if t.Status != shell.TTDone {
95 t.WriteString(event.EscSeq())
97 } else if e, ok := event.(*tcell.EventMouse); e != nil && (!ok || t.State.Mode(terminal.ModeMouseMask)) {
98 // t.WriteString(event.EscSeq())
105 if e.Buttons() == tcell.Button1 {
106 if !t.mouseReleased {
117 t.mouseReleased = false
118 } else if e.Buttons() == tcell.ButtonNone {
119 if !t.mouseReleased {
123 t.mouseReleased = true
127 if t.Status == shell.TTClose {
132 func (t *TermPane) HandleCommand(input string) {
133 InfoBar.Error("Commands are unsupported in term for now")