mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-21 16:27:12 +09:00
Fix edit bar cursor
This commit is contained in:
@@ -153,14 +153,14 @@ func (m *Messenger) HandleEvent(event tcell.Event) {
|
||||
}
|
||||
case tcell.KeyBackspace2:
|
||||
if m.cursorx > 0 {
|
||||
m.response = string([]rune(m.response)[:Count(m.response)-1])
|
||||
m.response = string([]rune(m.response)[:m.cursorx-1]) + string(m.response[m.cursorx:])
|
||||
}
|
||||
m.cursorx--
|
||||
case tcell.KeySpace:
|
||||
m.response += " "
|
||||
m.cursorx++
|
||||
case tcell.KeyRune:
|
||||
m.response += string(e.Rune())
|
||||
m.response = Insert(m.response, m.cursorx, string(e.Rune()))
|
||||
m.cursorx++
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,3 +70,8 @@ func Contains(list []string, a string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Insert makes a simple insert into a string at the given position
|
||||
func Insert(str string, pos int, value string) string {
|
||||
return string([]rune(str)[:pos]) + value + string([]rune(str)[pos:])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user