]> git.lizzy.rs Git - micro.git/commitdiff
Clicking tabbar arrow scrolls and fix multicursor
authorZachary Yedidia <zyedidia@gmail.com>
Wed, 12 Feb 2020 18:05:15 +0000 (13:05 -0500)
committerZachary Yedidia <zyedidia@gmail.com>
Wed, 12 Feb 2020 18:05:15 +0000 (13:05 -0500)
Closes #1503

internal/action/bufpane.go
internal/action/tab.go
internal/buffer/buffer.go
internal/config/rtfiles.go
internal/display/tabwindow.go

index 2cbbbab5c07b3a82c292a03f2df23f3511697f3f..9c95c5c750f0bc64be0042f4710989c1e97c376c 100644 (file)
@@ -113,6 +113,9 @@ func BufMapKey(k Event, action string) {
                success := true
                for i, a := range actionfns {
                        for j, c := range cursors {
+                               if c == nil {
+                                       continue
+                               }
                                h.Buf.SetCurCursor(c.Num)
                                h.Cursor = c
                                if i == 0 || (success && types[i-1] == '&') || (!success && types[i-1] == '|') || (types[i-1] == ',') {
index ac49edb957e43885e4842accc7a9da7a5465b2f2..d6766655fecb0d645d005ffb613653b4f16c7aa4 100644 (file)
@@ -104,6 +104,13 @@ func (t *TabList) HandleEvent(event tcell.Event) {
                mx, my := e.Position()
                switch e.Buttons() {
                case tcell.Button1:
+                       if my == t.Y && mx == 0 {
+                               t.Scroll(-4)
+                               return
+                       } else if my == t.Y && mx == t.Width-1 {
+                               t.Scroll(4)
+                               return
+                       }
                        if len(t.List) > 1 {
                                ind := t.LocFromVisual(buffer.Loc{mx, my})
                                if ind != -1 {
index e97cf24b08340ebb149451d716cfad47f0b6dbc8..1f761e975646c88dc38fdb0eac6113d53698b0f9 100644 (file)
@@ -763,6 +763,7 @@ func (b *Buffer) ClearCursors() {
        b.UpdateCursors()
        b.curCursor = 0
        b.GetActiveCursor().ResetSelection()
+       log.Println("Cleared cursors:", len(b.cursors))
 }
 
 // MoveLinesUp moves the range of lines up one row
index 09e9176883cbabc712d3ce3f5dca33cf18aaa4ff..1c31cbc15744b3f2e7cebb3024a014c6ce501cef 100644 (file)
@@ -199,7 +199,6 @@ func InitRuntimeFiles() {
                                        }
                                        p.Info, err = NewPluginInfo(data)
                                        if err != nil {
-                                               log.Println(err)
                                                continue
                                        }
                                        p.Name = p.Info.Name
@@ -232,7 +231,6 @@ func InitRuntimeFiles() {
                                                }
                                                p.Info, err = NewPluginInfo(data)
                                                if err != nil {
-                                                       log.Println(err)
                                                        continue
                                                }
                                                p.Name = p.Info.Name
index 182e675d1400fa287ca0378f308dc363229a6494..0b26fd7b49288dad8fc8ab96a7f3309df8d1c4a3 100644 (file)
@@ -14,19 +14,19 @@ type TabWindow struct {
        Names   []string
        active  int
        Y       int
-       width   int
+       Width   int
        hscroll int
 }
 
 func NewTabWindow(w int, y int) *TabWindow {
        tw := new(TabWindow)
-       tw.width = w
+       tw.Width = w
        tw.Y = y
        return tw
 }
 
 func (w *TabWindow) Resize(width, height int) {
-       w.width = width
+       w.Width = width
 }
 
 func (w *TabWindow) LocFromVisual(vloc buffer.Loc) int {
@@ -40,7 +40,7 @@ func (w *TabWindow) LocFromVisual(vloc buffer.Loc) int {
                }
                x += s
                x += 3
-               if x >= w.width {
+               if x >= w.Width {
                        break
                }
        }
@@ -50,9 +50,9 @@ func (w *TabWindow) LocFromVisual(vloc buffer.Loc) int {
 func (w *TabWindow) Scroll(amt int) {
        w.hscroll += amt
        s := w.TotalSize()
-       w.hscroll = util.Clamp(w.hscroll, 0, s-w.width)
+       w.hscroll = util.Clamp(w.hscroll, 0, s-w.Width)
 
-       if s-w.width <= 0 {
+       if s-w.Width <= 0 {
                w.hscroll = 0
        }
 }
@@ -77,17 +77,17 @@ func (w *TabWindow) SetActive(a int) {
        for i, n := range w.Names {
                c := utf8.RuneCountInString(n)
                if i == a {
-                       if x+c >= w.hscroll+w.width {
-                               w.hscroll = util.Clamp(x+c+1-w.width, 0, s-w.width)
+                       if x+c >= w.hscroll+w.Width {
+                               w.hscroll = util.Clamp(x+c+1-w.Width, 0, s-w.Width)
                        } else if x < w.hscroll {
-                               w.hscroll = util.Clamp(x-4, 0, s-w.width)
+                               w.hscroll = util.Clamp(x-4, 0, s-w.Width)
                        }
                        break
                }
                x += c + 4
        }
 
-       if s-w.width <= 0 {
+       if s-w.Width <= 0 {
                w.hscroll = 0
        }
 }
@@ -104,13 +104,13 @@ func (w *TabWindow) Display() {
                                if j > 0 {
                                        c = ' '
                                }
-                               if x == w.width-1 && !done {
-                                       screen.SetContent(w.width-1, w.Y, '>', nil, config.DefStyle.Reverse(true))
+                               if x == w.Width-1 && !done {
+                                       screen.SetContent(w.Width-1, w.Y, '>', nil, config.DefStyle.Reverse(true))
                                        x++
                                        break
                                } else if x == 0 && w.hscroll > 0 {
                                        screen.SetContent(0, w.Y, '<', nil, config.DefStyle.Reverse(true))
-                               } else if x >= 0 && x < w.width {
+                               } else if x >= 0 && x < w.Width {
                                        screen.SetContent(x, w.Y, c, nil, config.DefStyle.Reverse(true))
                                }
                                x++
@@ -136,12 +136,12 @@ func (w *TabWindow) Display() {
                } else {
                        draw(' ', 3)
                }
-               if x >= w.width {
+               if x >= w.Width {
                        break
                }
        }
 
-       if x < w.width {
-               draw(' ', w.width-x)
+       if x < w.Width {
+               draw(' ', w.Width-x)
        }
 }