Minor code cleanup
Some checks failed
timw4mail/gilo/pipeline/head There was a failure building this commit

This commit is contained in:
Timothy Warren 2021-04-09 13:48:39 -04:00
parent 07c37910d7
commit e6513cf3c2
3 changed files with 10 additions and 13 deletions

View File

@ -31,14 +31,10 @@ type editor struct {
}
func NewEditor() *editor {
screen := terminal.Size()
// Subtract rows for status bar and message bar/prompt
screen := terminal.Size()
screen.Rows -= 2
cursor := gilo.DefaultPoint()
offset := gilo.DefaultPoint()
d := document.NewDocument()
status := &statusMsg{
"",
time.Now(),
@ -46,9 +42,9 @@ func NewEditor() *editor {
return &editor{
screen,
cursor,
offset,
d,
gilo.DefaultPoint(),
gilo.DefaultPoint(),
document.NewDocument(),
status,
newSearch(),
gilo.QuitTimes,

View File

@ -190,7 +190,7 @@ func parseEscapeSequence() string {
for i := 0; i < 2; i++ {
ch, size := terminal.ReadKey()
if size == 0 {
return string(rune(key.Esc))
return string(key.Esc)
}
runes[i] = ch
@ -204,7 +204,7 @@ func parseEscapeSequence() string {
}
}
return string(rune(key.Esc))
return string(key.Esc)
}
func escSeqToKey(seq []rune) string {
@ -255,5 +255,5 @@ func escSeqToKey(seq []rune) string {
}
}
return string(rune(key.Esc))
return string(key.Esc)
}

View File

@ -13,7 +13,7 @@ type moveCursor struct {
}
var cursorTests = []moveCursor{
{[]string{string(rune(key.Esc))}, false, gilo.DefaultPoint()},
{[]string{string(key.Esc)}, false, gilo.DefaultPoint()},
{[]string{keyRight}, true, gilo.NewPoint(1, 0)},
{[]string{keyDown, keyEnd}, true, gilo.NewPoint(14, 1)},
{[]string{keyEnd, keyHome}, true, gilo.DefaultPoint()},
@ -63,7 +63,8 @@ var seqTests = []seqTest{
{"[6~", keyPageDown},
{"[7~", keyHome},
{"[8~", keyEnd},
{"OQ", string(rune(key.Esc))},
{"OQ", string(key.Esc)},
{"XZ", string(key.Esc)},
}
func TestEscToKey(t *testing.T) {