mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-29 22:27:13 +09:00
Calculate line number offset
This commit is contained in:
@@ -96,6 +96,11 @@ func (c *CellView) Draw(buf *Buffer, top, height, left, width int) {
|
|||||||
if wrap && viewCol >= width {
|
if wrap && viewCol >= width {
|
||||||
viewLine++
|
viewLine++
|
||||||
|
|
||||||
|
// If we go too far soft wrapping we have to cut off
|
||||||
|
if viewLine >= height {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
nextLine := line[colN:]
|
nextLine := line[colN:]
|
||||||
lineLength := min(StringWidth(string(nextLine), tabsize), width)
|
lineLength := min(StringWidth(string(nextLine), tabsize), width)
|
||||||
if len(c.lines[viewLine]) != lineLength {
|
if len(c.lines[viewLine]) != lineLength {
|
||||||
@@ -104,10 +109,6 @@ func (c *CellView) Draw(buf *Buffer, top, height, left, width int) {
|
|||||||
|
|
||||||
viewCol = 0
|
viewCol = 0
|
||||||
|
|
||||||
// If we go too far soft wrapping we have to cut off
|
|
||||||
if viewLine >= height {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,24 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
|
import "strconv"
|
||||||
|
|
||||||
func (v *View) DisplayView() {
|
func (v *View) DisplayView() {
|
||||||
if v.Type == vtLog {
|
if v.Type == vtLog {
|
||||||
// Log views should always follow the cursor...
|
// Log views should always follow the cursor...
|
||||||
v.Relocate()
|
v.Relocate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We need to know the string length of the largest line number
|
||||||
|
// so we can pad appropriately when displaying line numbers
|
||||||
|
maxLineNumLength := len(strconv.Itoa(v.Buf.NumLines))
|
||||||
|
|
||||||
|
if v.Buf.Settings["ruler"] == true {
|
||||||
|
// + 1 for the little space after the line number
|
||||||
|
v.lineNumOffset = maxLineNumLength + 1
|
||||||
|
} else {
|
||||||
|
v.lineNumOffset = 0
|
||||||
|
}
|
||||||
|
|
||||||
height := v.Height
|
height := v.Height
|
||||||
width := v.Width
|
width := v.Width
|
||||||
left := v.leftCol
|
left := v.leftCol
|
||||||
|
|||||||
Reference in New Issue
Block a user