mirror of
https://github.com/felixangell/phi.git
synced 2024-09-11 15:55:25 +03:00
Match pairs setting
This will match {, (, and [. But not angle brackets!
This commit is contained in:
parent
556e027011
commit
02da76691e
@ -13,6 +13,7 @@ type EditorConfig struct {
|
||||
Flash_Cursor bool `toml:"flash_cursor"`
|
||||
Cursor_Flash_Rate uint32 `toml:"cursor_flash_rate"`
|
||||
Cursor_Reset_Delay uint32 `toml:"cursor_reset_delay"`
|
||||
Match_Braces bool `toml:"match_braces"`
|
||||
}
|
||||
|
||||
func NewDefaultConfig() *TomlConfig {
|
||||
|
@ -71,8 +71,26 @@ func (b *Buffer) processTextInput(t *sdl.TextInputEvent) {
|
||||
|
||||
b.contents[b.curs.y] = b.contents[b.curs.y].Insert(b.curs.x, string(rawVal))
|
||||
b.curs.move(1, 0)
|
||||
|
||||
matchingPair := int(rawVal)
|
||||
|
||||
// the offset in the ASCII Table is +2 for { and for [
|
||||
// but its +1 for parenthesis (
|
||||
offset := 2
|
||||
|
||||
switch rawVal {
|
||||
case '(':
|
||||
offset = 1
|
||||
fallthrough
|
||||
case '{':
|
||||
fallthrough
|
||||
case '[':
|
||||
matchingPair += offset
|
||||
b.contents[b.curs.y] = b.contents[b.curs.y].Insert(b.curs.x, string(rune(matchingPair)))
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(Felix): refactor me!)
|
||||
func (b *Buffer) processActionKey(t *sdl.KeyDownEvent) {
|
||||
switch t.Keysym.Scancode {
|
||||
case sdl.SCANCODE_RETURN:
|
||||
|
Loading…
Reference in New Issue
Block a user