6 "github.com/zyedidia/micro/internal/buffer"
7 "github.com/zyedidia/micro/internal/config"
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 TermWindow struct {
21 func NewTermWindow(x, y, w, h int, term *shell.Terminal) *TermWindow {
30 // Resize informs the terminal of a resize event
31 func (w *TermWindow) Resize(width, height int) {
32 if config.GetGlobalOption("statusline").(bool) {
35 w.Term.Resize(width, height)
36 w.Width, w.Height = width, height
39 func (w *TermWindow) SetActive(b bool) {
43 func (w *TermWindow) GetMouseLoc(vloc buffer.Loc) buffer.Loc {
47 func (w *TermWindow) Clear() {
48 for y := 0; y < w.Height; y++ {
49 for x := 0; x < w.Width; x++ {
50 screen.Screen.SetContent(w.X+x, w.Y+y, ' ', nil, config.DefStyle)
55 func (w *TermWindow) Relocate() bool { return true }
56 func (w *TermWindow) GetView() *View {
59 func (w *TermWindow) SetView(v *View) {
63 // Display displays this terminal in a view
64 func (w *TermWindow) Display() {
66 defer w.State.Unlock()
69 for y := 0; y < w.Height; y++ {
70 for x := 0; x < w.Width; x++ {
72 c, f, b := w.State.Cell(x, y)
74 fg, bg := int(f), int(b)
75 if f == terminal.DefaultFG {
76 fg = int(tcell.ColorDefault)
78 if b == terminal.DefaultBG {
79 bg = int(tcell.ColorDefault)
81 st := tcell.StyleDefault.Foreground(config.GetColor256(int(fg))).Background(config.GetColor256(int(bg)))
83 if l.LessThan(w.Selection[1]) && l.GreaterEqual(w.Selection[0]) || l.LessThan(w.Selection[0]) && l.GreaterEqual(w.Selection[1]) {
87 screen.Screen.SetContent(w.X+x, w.Y+y, c, nil, st)
90 if config.GetGlobalOption("statusline").(bool) {
91 statusLineStyle := config.DefStyle.Reverse(true)
92 if style, ok := config.Colorscheme["statusline"]; ok {
93 statusLineStyle = style
96 text := []byte(w.Name())
97 textLen := utf8.RuneCount(text)
98 for x := 0; x < w.Width; x++ {
100 r, size := utf8.DecodeRune(text)
102 screen.Screen.SetContent(w.X+x, w.Y+w.Height, r, nil, statusLineStyle)
104 screen.Screen.SetContent(w.X+x, w.Y+w.Height, ' ', nil, statusLineStyle)
108 if w.State.CursorVisible() && w.active {
109 curx, cury := w.State.Cursor()
110 screen.Screen.ShowCursor(curx+w.X, cury+w.Y)