2016-11-14 10:24:19 +03:00
|
|
|
package cfg
|
|
|
|
|
2016-11-27 21:06:17 +03:00
|
|
|
import "strconv"
|
|
|
|
|
2016-11-14 11:14:53 +03:00
|
|
|
type TomlConfig struct {
|
2016-11-27 20:21:03 +03:00
|
|
|
Editor EditorConfig
|
|
|
|
Cursor CursorConfig
|
|
|
|
Render RenderConfig
|
|
|
|
Theme ThemeConfig
|
2016-11-27 19:58:12 +03:00
|
|
|
}
|
|
|
|
|
2016-11-27 20:21:03 +03:00
|
|
|
var DEFUALT_TOML_CONFIG string = `[editor]
|
|
|
|
tab_size = 2
|
|
|
|
hungry_backspace = true
|
|
|
|
tabs_are_spaces = true
|
|
|
|
match_braces = false
|
2016-11-27 21:06:17 +03:00
|
|
|
maintain_indentation = true
|
2016-11-27 20:21:03 +03:00
|
|
|
|
|
|
|
[render]
|
|
|
|
aliased = true
|
|
|
|
|
|
|
|
[theme]
|
|
|
|
background = "0xfdf6e3"
|
|
|
|
foreground = "0x7a7a7a"
|
|
|
|
cursor = "0x657B83"
|
|
|
|
cursor_invert = "0xffffff"
|
|
|
|
|
|
|
|
[cursor]
|
|
|
|
flash_rate = 400
|
|
|
|
reset_delay = 400
|
|
|
|
draw = true
|
|
|
|
flash = true
|
|
|
|
`
|
|
|
|
|
2016-11-27 19:58:12 +03:00
|
|
|
type CursorConfig struct {
|
|
|
|
Flash_Rate uint32
|
|
|
|
Reset_Delay uint32
|
|
|
|
Draw bool
|
|
|
|
Flash bool
|
2016-11-27 21:06:17 +03:00
|
|
|
Block_Width string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c CursorConfig) GetCaretWidth() int {
|
|
|
|
if c.Block_Width == "block" {
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
value, err := strconv.ParseInt(c.Block_Width, 10, 32)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return int(value)
|
2016-11-27 19:58:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type RenderConfig struct {
|
|
|
|
Aliased bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// todo make this more extendable...
|
|
|
|
// e.g. .nate-editor/themes with TOML
|
|
|
|
// themes in them and we can select
|
|
|
|
// the default theme in the EditorConfig
|
|
|
|
// instead.
|
|
|
|
type ThemeConfig struct {
|
|
|
|
Background string
|
|
|
|
Foreground string
|
|
|
|
Cursor string
|
|
|
|
Cursor_Invert string
|
2016-11-14 11:14:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type EditorConfig struct {
|
2016-11-27 21:06:17 +03:00
|
|
|
Tab_Size int32
|
|
|
|
Hungry_Backspace bool
|
|
|
|
Tabs_Are_Spaces bool
|
|
|
|
Match_Braces bool
|
|
|
|
Maintain_Indentation bool
|
2016-11-14 10:24:19 +03:00
|
|
|
}
|
|
|
|
|
2016-11-14 11:14:53 +03:00
|
|
|
func NewDefaultConfig() *TomlConfig {
|
|
|
|
return &TomlConfig{
|
2016-11-27 17:07:05 +03:00
|
|
|
Editor: EditorConfig{},
|
2016-11-27 19:58:12 +03:00
|
|
|
Theme: ThemeConfig{
|
|
|
|
Background: "0xfdf6e3",
|
|
|
|
Foreground: "0x7a7a7a",
|
|
|
|
Cursor: "0x657B83",
|
|
|
|
Cursor_Invert: "0xffffff",
|
|
|
|
},
|
2016-11-14 10:24:19 +03:00
|
|
|
}
|
|
|
|
}
|