Actually rename width, height, lockWidth, lockHeight

This commit is contained in:
Zachary Yedidia
2016-11-28 20:28:40 -05:00
parent e53229ec00
commit 5481a834bf
6 changed files with 68 additions and 68 deletions

View File

@@ -57,9 +57,9 @@ func (v *View) Center(usePlugin bool) bool {
return false
}
v.Topline = v.Cursor.Y - v.height/2
if v.Topline+v.height > v.Buf.NumLines {
v.Topline = v.Buf.NumLines - v.height
v.Topline = v.Cursor.Y - v.Height/2
if v.Topline+v.Height > v.Buf.NumLines {
v.Topline = v.Buf.NumLines - v.Height
}
if v.Topline < 0 {
v.Topline = 0
@@ -1124,10 +1124,10 @@ func (v *View) End(usePlugin bool) bool {
return false
}
if v.height > v.Buf.NumLines {
if v.Height > v.Buf.NumLines {
v.Topline = 0
} else {
v.Topline = v.Buf.NumLines - v.height
v.Topline = v.Buf.NumLines - v.Height
}
if usePlugin {
@@ -1142,8 +1142,8 @@ func (v *View) PageUp(usePlugin bool) bool {
return false
}
if v.Topline > v.height {
v.ScrollUp(v.height)
if v.Topline > v.Height {
v.ScrollUp(v.Height)
} else {
v.Topline = 0
}
@@ -1160,10 +1160,10 @@ func (v *View) PageDown(usePlugin bool) bool {
return false
}
if v.Buf.NumLines-(v.Topline+v.height) > v.height {
v.ScrollDown(v.height)
} else if v.Buf.NumLines >= v.height {
v.Topline = v.Buf.NumLines - v.height
if v.Buf.NumLines-(v.Topline+v.Height) > v.Height {
v.ScrollDown(v.Height)
} else if v.Buf.NumLines >= v.Height {
v.Topline = v.Buf.NumLines - v.Height
}
if usePlugin {
@@ -1184,7 +1184,7 @@ func (v *View) CursorPageUp(usePlugin bool) bool {
v.Cursor.Loc = v.Cursor.CurSelection[0]
v.Cursor.ResetSelection()
}
v.Cursor.UpN(v.height)
v.Cursor.UpN(v.Height)
if usePlugin {
return PostActionCall("CursorPageUp", v)
@@ -1204,7 +1204,7 @@ func (v *View) CursorPageDown(usePlugin bool) bool {
v.Cursor.Loc = v.Cursor.CurSelection[1]
v.Cursor.ResetSelection()
}
v.Cursor.DownN(v.height)
v.Cursor.DownN(v.Height)
if usePlugin {
return PostActionCall("CursorPageDown", v)
@@ -1218,8 +1218,8 @@ func (v *View) HalfPageUp(usePlugin bool) bool {
return false
}
if v.Topline > v.height/2 {
v.ScrollUp(v.height / 2)
if v.Topline > v.Height/2 {
v.ScrollUp(v.Height / 2)
} else {
v.Topline = 0
}
@@ -1236,11 +1236,11 @@ func (v *View) HalfPageDown(usePlugin bool) bool {
return false
}
if v.Buf.NumLines-(v.Topline+v.height) > v.height/2 {
v.ScrollDown(v.height / 2)
if v.Buf.NumLines-(v.Topline+v.Height) > v.Height/2 {
v.ScrollDown(v.Height / 2)
} else {
if v.Buf.NumLines >= v.height {
v.Topline = v.Buf.NumLines - v.height
if v.Buf.NumLines >= v.Height {
v.Topline = v.Buf.NumLines - v.Height
}
}

View File

@@ -298,7 +298,7 @@ func Match(v *View) SyntaxMatches {
rules := v.Buf.rules
viewStart := v.Topline
viewEnd := v.Topline + v.height
viewEnd := v.Topline + v.Height
if viewEnd > buf.NumLines {
viewEnd = buf.NumLines
}
@@ -315,7 +315,7 @@ func Match(v *View) SyntaxMatches {
// We don't actually check the entire buffer, just from synLinesUp to synLinesDown
totalStart := v.Topline - synLinesUp
totalEnd := v.Topline + v.height + synLinesDown
totalEnd := v.Topline + v.Height + synLinesDown
if totalStart < 0 {
totalStart = 0
}
@@ -343,7 +343,7 @@ func Match(v *View) SyntaxMatches {
continue
}
lineNum -= viewStart
if lineNum >= 0 && lineNum < v.height {
if lineNum >= 0 && lineNum < v.Height {
matches[lineNum][colNum] = rule.style
}
}

View File

@@ -439,7 +439,7 @@ func main() {
// We loop through each view in the current tab and make sure the current view
// is the one being clicked in
for _, v := range tabs[curTab].views {
if x >= v.x && x < v.x+v.width && y >= v.y && y < v.y+v.height {
if x >= v.x && x < v.x+v.Width && y >= v.y && y < v.y+v.Height {
tabs[curTab].curView = v.Num
}
}

View File

@@ -204,13 +204,13 @@ func (s *SplitTree) ResizeSplits() {
for _, node := range s.children {
if n, ok := node.(*LeafNode); ok {
if s.kind == VerticalSplit {
if n.view.lockWidth {
lockedWidth += n.view.width
if n.view.LockWidth {
lockedWidth += n.view.Width
lockedChildren++
}
} else {
if n.view.lockHeight {
lockedHeight += n.view.height
if n.view.LockHeight {
lockedHeight += n.view.Height
lockedChildren++
}
}
@@ -232,26 +232,26 @@ func (s *SplitTree) ResizeSplits() {
for _, node := range s.children {
if n, ok := node.(*LeafNode); ok {
if s.kind == VerticalSplit {
if !n.view.lockWidth {
n.view.width = (s.width - lockedWidth) / (len(s.children) - lockedChildren)
if !n.view.LockWidth {
n.view.Width = (s.width - lockedWidth) / (len(s.children) - lockedChildren)
}
n.view.height = s.height
n.view.Height = s.height
n.view.x = s.x + x
n.view.y = s.y
x += n.view.width
x += n.view.Width
} else {
if !n.view.lockHeight {
n.view.height = (s.height - lockedHeight) / (len(s.children) - lockedChildren)
if !n.view.LockHeight {
n.view.Height = (s.height - lockedHeight) / (len(s.children) - lockedChildren)
}
n.view.width = s.width
n.view.Width = s.width
n.view.y = s.y + y
n.view.x = s.x
y += n.view.height
y += n.view.Height
}
if n.view.Buf.Settings["statusline"].(bool) {
n.view.height--
n.view.Height--
}
n.view.ToggleTabbar()

View File

@@ -15,7 +15,7 @@ type Statusline struct {
// Display draws the statusline to the screen
func (sline *Statusline) Display() {
// We'll draw the line at the lowest line in the view
y := sline.view.height + sline.view.y
y := sline.view.Height + sline.view.y
file := sline.view.Buf.GetName()
if file == "" {
@@ -56,11 +56,11 @@ func (sline *Statusline) Display() {
screen.SetContent(viewX, y, ' ', nil, statusLineStyle)
viewX++
}
for x := 0; x < sline.view.width; x++ {
for x := 0; x < sline.view.Width; x++ {
if x < len(fileRunes) {
screen.SetContent(viewX+x, y, fileRunes[x], nil, statusLineStyle)
} else if x >= sline.view.width-len(rightText) && x < len(rightText)+sline.view.width-len(rightText) {
screen.SetContent(viewX+x, y, []rune(rightText)[x-sline.view.width+len(rightText)], nil, statusLineStyle)
} else if x >= sline.view.Width-len(rightText) && x < len(rightText)+sline.view.Width-len(rightText) {
screen.SetContent(viewX+x, y, []rune(rightText)[x-sline.view.Width+len(rightText)], nil, statusLineStyle)
} else {
screen.SetContent(viewX+x, y, ' ', nil, statusLineStyle)
}

View File

@@ -103,8 +103,8 @@ func NewViewWidthHeight(buf *Buffer, w, h int) *View {
v.x, v.y = 0, 0
v.width = w
v.height = h
v.Width = w
v.Height = h
v.ToggleTabbar()
@@ -117,7 +117,7 @@ func NewViewWidthHeight(buf *Buffer, w, h int) *View {
}
if v.Buf.Settings["statusline"].(bool) {
v.height--
v.Height--
}
for _, pl := range loadedPlugins {
@@ -134,9 +134,9 @@ func NewViewWidthHeight(buf *Buffer, w, h int) *View {
// ToggleStatusLine creates an extra row for the statusline if necessary
func (v *View) ToggleStatusLine() {
if v.Buf.Settings["statusline"].(bool) {
v.height--
v.Height--
} else {
v.height++
v.Height++
}
}
@@ -145,13 +145,13 @@ 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.Height--
v.y = 1
}
} else {
if v.y == 1 {
v.y = 0
v.height++
v.Height++
}
}
}
@@ -183,9 +183,9 @@ func (v *View) ScrollUp(n int) {
// ScrollDown scrolls the view down n lines (if possible)
func (v *View) ScrollDown(n int) {
// Try to scroll by n but if it would overflow, scroll by 1
if v.Topline+n <= v.Buf.NumLines-v.height {
if v.Topline+n <= v.Buf.NumLines-v.Height {
v.Topline += n
} else if v.Topline < v.Buf.NumLines-v.height {
} else if v.Topline < v.Buf.NumLines-v.Height {
v.Topline++
}
}
@@ -313,7 +313,7 @@ func (v *View) GetSoftWrapLocation(vx, vy int) (int, int) {
colN := 0
for _, ch := range line {
if screenX >= v.width-v.lineNumOffset {
if screenX >= v.Width-v.lineNumOffset {
screenX = 0
screenY++
}
@@ -341,17 +341,17 @@ func (v *View) GetSoftWrapLocation(vx, vy int) (int, int) {
func (v *View) Bottomline() int {
if !v.Buf.Settings["softwrap"].(bool) {
return v.Topline + v.height
return v.Topline + v.Height
}
screenX, screenY := 0, 0
numLines := 0
for lineN := v.Topline; lineN < v.Topline+v.height; lineN++ {
for lineN := v.Topline; lineN < v.Topline+v.Height; lineN++ {
line := v.Buf.Line(lineN)
colN := 0
for _, ch := range line {
if screenX >= v.width-v.lineNumOffset {
if screenX >= v.Width-v.lineNumOffset {
screenX = 0
screenY++
}
@@ -367,7 +367,7 @@ func (v *View) Bottomline() int {
screenY++
numLines++
if screenY >= v.height {
if screenY >= v.Height {
break
}
}
@@ -402,8 +402,8 @@ func (v *View) Relocate() bool {
v.leftCol = cx
ret = true
}
if cx+v.lineNumOffset+1 > v.leftCol+v.width {
v.leftCol = cx - v.width + v.lineNumOffset + 1
if cx+v.lineNumOffset+1 > v.leftCol+v.Width {
v.leftCol = cx - v.Width + v.lineNumOffset + 1
ret = true
}
}
@@ -413,9 +413,9 @@ func (v *View) Relocate() bool {
// MoveToMouseClick moves the cursor to location x, y assuming x, y were given
// by a mouse click
func (v *View) MoveToMouseClick(x, y int) {
if y-v.Topline > v.height-1 {
if y-v.Topline > v.Height-1 {
v.ScrollDown(1)
y = v.height + v.Topline - 1
y = v.Height + v.Topline - 1
}
if y >= v.Buf.NumLines {
y = v.Buf.NumLines - 1
@@ -643,7 +643,7 @@ func (v *View) openHelp(helpPage string) {
}
func (v *View) drawCell(x, y int, ch rune, combc []rune, style tcell.Style) {
if x >= v.x && x < v.x+v.width && y >= v.y && y < v.y+v.height {
if x >= v.x && x < v.x+v.Width && y >= v.y && y < v.y+v.Height {
screen.SetContent(x, y, ch, combc, style)
}
}
@@ -697,14 +697,14 @@ func (v *View) DisplayView() {
curLineN := 0
// ViewLine is the current line from the top of the viewport
for viewLine := 0; viewLine < v.height; viewLine++ {
for viewLine := 0; viewLine < v.Height; viewLine++ {
screenY++
screenX = v.x
// This is the current line number of the buffer that we are drawing
curLineN = viewLine + v.Topline
if screenY-v.y >= v.height {
if screenY-v.y >= v.Height {
break
}
@@ -716,7 +716,7 @@ func (v *View) DisplayView() {
// If the buffer is smaller than the view height we have to clear all this space
if curLineN >= v.Buf.NumLines {
for i := screenX; i < v.x+v.width; i++ {
for i := screenX; i < v.x+v.Width; i++ {
v.drawCell(i, screenY, ' ', nil, defStyle)
}
@@ -807,7 +807,7 @@ func (v *View) DisplayView() {
tabSize := int(v.Buf.Settings["tabsize"].(float64))
for _, ch := range line {
if v.Buf.Settings["softwrap"].(bool) {
if screenX-v.x >= v.width {
if screenX-v.x >= v.Width {
screenY++
for i := 0; i < v.lineNumOffset; i++ {
screen.SetContent(v.x+i, screenY, ' ', nil, lineNumStyle)
@@ -931,7 +931,7 @@ func (v *View) DisplayView() {
charNum = charNum.Move(1, v.Buf)
for i := 0; i < v.width; i++ {
for i := 0; i < v.Width; i++ {
lineStyle := defStyle
if v.Buf.Settings["cursorline"].(bool) && tabs[curTab].curView == v.Num && !v.Cursor.HasSelection() && v.Cursor.Y == curLineN {
if style, ok := colorscheme["cursor-line"]; ok {
@@ -963,15 +963,15 @@ func (v *View) DisplayCursor(x, y int) {
func (v *View) Display() {
v.DisplayView()
// Don't draw the cursor if it is out of the viewport or if it has a selection
if (v.Cursor.Y-v.Topline < 0 || v.Cursor.Y-v.Topline > v.height-1) || v.Cursor.HasSelection() {
if (v.Cursor.Y-v.Topline < 0 || v.Cursor.Y-v.Topline > v.Height-1) || v.Cursor.HasSelection() {
screen.HideCursor()
}
_, screenH := screen.Size()
if v.Buf.Settings["statusline"].(bool) {
v.sline.Display()
} else if (v.y + v.height) != screenH-1 {
for x := 0; x < v.width; x++ {
screen.SetContent(v.x+x, v.y+v.height, '-', nil, defStyle.Reverse(true))
} else if (v.y + v.Height) != screenH-1 {
for x := 0; x < v.Width; x++ {
screen.SetContent(v.x+x, v.y+v.Height, '-', nil, defStyle.Reverse(true))
}
}
}