mirror of
https://github.com/felixangell/phi.git
synced 2024-09-11 15:55:25 +03:00
editor can now "escape" brackets
This commit is contained in:
parent
ade7bde768
commit
388153daca
@ -137,6 +137,28 @@ func (b *Buffer) processTextInput(r rune) bool {
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: we have to do this AFTER we map the
|
||||
// shift combo for the value!
|
||||
// this will not insert a ), }, or ] if there
|
||||
// is one to the right of us... basically
|
||||
// this escapes out of a closing bracket
|
||||
// rather than inserting a new one IF we are inside
|
||||
// brackets.
|
||||
if b.cfg.Editor.Match_Braces {
|
||||
if r == ')' || r == '}' || r == ']' {
|
||||
currLine := b.contents[b.curs.y]
|
||||
if b.curs.x < currLine.Len() {
|
||||
curr := currLine.Index(b.curs.x + 1)
|
||||
if curr == r {
|
||||
b.curs.move(1, 0)
|
||||
return true
|
||||
} else {
|
||||
log.Print("no it's ", curr)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
b.contents[b.curs.y] = b.contents[b.curs.y].Insert(b.curs.x, string(r))
|
||||
b.curs.move(1, 0)
|
||||
|
||||
@ -146,6 +168,8 @@ func (b *Buffer) processTextInput(r rune) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// TODO: shall we match single quotes and double quotes too?1
|
||||
|
||||
matchingPair := int(r)
|
||||
|
||||
// the offset in the ASCII Table is +2 for { and for [
|
||||
|
Loading…
Reference in New Issue
Block a user