Extract method for drawing placeholder rows
All checks were successful
timw4mail/gilo/pipeline/head This commit looks good
All checks were successful
timw4mail/gilo/pipeline/head This commit looks good
This commit is contained in:
parent
c0d5436c35
commit
2203e30b18
@ -28,27 +28,7 @@ func (e *editor) RefreshScreen() {
|
||||
func (e *editor) drawRows(ab *buffer) {
|
||||
for y :=0; y < e.screen.Rows; y++ {
|
||||
if y >= len(e.rows) {
|
||||
if len(e.rows) == 0 && y == e.screen.Rows / 3 {
|
||||
welcome := fmt.Sprintf("Gilo editor -- version %s", KiloVersion)
|
||||
if len(welcome) > e.screen.Cols {
|
||||
welcome = truncateString(welcome, e.screen.Cols)
|
||||
}
|
||||
|
||||
padding := (e.screen.Cols - len(welcome)) / 2
|
||||
if padding > 0 {
|
||||
ab.appendRune('~')
|
||||
padding--
|
||||
}
|
||||
|
||||
for padding > 0 {
|
||||
padding--
|
||||
ab.appendRune(' ')
|
||||
}
|
||||
|
||||
ab.append(welcome)
|
||||
} else {
|
||||
ab.appendRune('~')
|
||||
}
|
||||
e.drawPlaceholderRow(y, ab)
|
||||
} else {
|
||||
row := truncateString(string(e.rows[y].chars), e.screen.Cols)
|
||||
ab.append(row)
|
||||
@ -62,6 +42,30 @@ func (e *editor) drawRows(ab *buffer) {
|
||||
}
|
||||
}
|
||||
|
||||
func (e *editor) drawPlaceholderRow(y int, ab *buffer) {
|
||||
if len(e.rows) == 0 && y == e.screen.Rows / 3 {
|
||||
welcome := fmt.Sprintf("Gilo editor -- version %s", KiloVersion)
|
||||
if len(welcome) > e.screen.Cols {
|
||||
welcome = truncateString(welcome, e.screen.Cols)
|
||||
}
|
||||
|
||||
padding := (e.screen.Cols - len(welcome)) / 2
|
||||
if padding > 0 {
|
||||
ab.appendRune('~')
|
||||
padding--
|
||||
}
|
||||
|
||||
for padding > 0 {
|
||||
padding--
|
||||
ab.appendRune(' ')
|
||||
}
|
||||
|
||||
ab.append(welcome)
|
||||
} else {
|
||||
ab.appendRune('~')
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// !Output Buffer
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user