Fix statusline and tabbar offsets

This commit is contained in:
Zachary Yedidia
2016-08-11 13:50:59 -04:00
parent bd55c5f834
commit 61536326ca
6 changed files with 53 additions and 17 deletions

View File

@@ -782,6 +782,7 @@ func (v *View) Quit() bool {
}
if curTab == 0 {
// CurView().Resize(screen.Size())
CurView().ToggleTabbar()
CurView().matches = Match(CurView())
}
}
@@ -799,13 +800,13 @@ func (v *View) AddTab() bool {
tab.SetNum(len(tabs))
tabs = append(tabs, tab)
curTab++
// if len(tabs) == 2 {
// for _, t := range tabs {
// for _, v := range t.views {
// v.Resize(screen.Size())
// }
// }
// }
if len(tabs) == 2 {
for _, t := range tabs {
for _, v := range t.views {
v.ToggleTabbar()
}
}
}
return true
}

View File

@@ -126,13 +126,13 @@ func NewTab(args []string) {
tab.SetNum(len(tabs))
tabs = append(tabs, tab)
curTab++
// if len(tabs) == 2 {
// for _, t := range tabs {
// for _, v := range t.views {
// v.Resize(screen.Size())
// }
// }
// }
if len(tabs) == 2 {
for _, t := range tabs {
for _, v := range t.views {
v.ToggleTabbar()
}
}
}
}
}

View File

@@ -126,7 +126,7 @@ func SetOption(view *View, args []string) {
}
if option == "statusline" {
// view.Resize(screen.Size())
view.ToggleStatusLine()
}
err := WriteSettings(filename)

View File

@@ -142,6 +142,13 @@ func (s *SplitTree) ResizeSplits() {
n.view.y = s.y + n.view.height*i
n.view.x = s.x
}
// n.view.ToggleStatusLine()
_, screenH := screen.Size()
if settings["statusline"].(bool) || (n.view.y+n.view.height) != screenH-1 {
n.view.height--
}
n.view.ToggleTabbar()
n.view.matches = Match(n.view)
} else if n, ok := node.(*SplitTree); ok {
if s.kind == VerticalSplit {

View File

@@ -31,7 +31,7 @@ func NewTabFromView(v *View) *Tab {
w, h := screen.Size()
t.tree.width = w
t.tree.height = h
t.tree.height = h - 1
return t
}
@@ -47,6 +47,9 @@ func (t *Tab) Cleanup() {
}
func (t *Tab) Resize() {
w, h := screen.Size()
t.tree.width = w
t.tree.height = h - 1
t.tree.ResizeSplits()
}

View File

@@ -102,6 +102,8 @@ func NewViewWidthHeight(buf *Buffer, w, h int) *View {
v.width = w
v.height = h
v.ToggleTabbar()
v.OpenBuffer(buf)
v.messages = make(map[string][]GutterMessage)
@@ -117,6 +119,29 @@ func NewViewWidthHeight(buf *Buffer, w, h int) *View {
return v
}
func (v *View) ToggleStatusLine() {
if settings["statusline"].(bool) {
v.height--
} else {
v.height++
}
}
func (v *View) ToggleTabbar() {
if len(tabs) > 1 {
if v.y == 0 {
// Include one line for the tab bar at the top
v.height--
v.y = 1
}
} else {
if v.y == 1 {
v.y = 0
v.height++
}
}
}
// ScrollUp scrolls the view up n lines (if possible)
func (v *View) ScrollUp(n int) {
// Try to scroll by n but if it would overflow, scroll by 1
@@ -280,7 +305,7 @@ func (v *View) HandleEvent(event tcell.Event) {
switch e := event.(type) {
case *tcell.EventResize:
// Window resized
// v.Resize(e.Size())
tabs[v.TabNum].Resize()
case *tcell.EventKey:
if e.Key() == tcell.KeyRune && (e.Modifiers() == 0 || e.Modifiers() == tcell.ModShift) {
// Insert a character