fixed buffer overflow from colour change focus thing; added highlight

line col
This commit is contained in:
Felix Angell 2018-05-24 02:22:26 +01:00
parent 5da67dbe41
commit 172344ad3f
8 changed files with 23 additions and 12 deletions

View File

@ -85,13 +85,14 @@ type RenderConfig struct {
// the default theme in the EditorConfig // the default theme in the EditorConfig
// instead. // instead.
type ThemeConfig struct { type ThemeConfig struct {
Background uint32 Background uint32
Foreground uint32 Foreground uint32
Cursor uint32 Cursor uint32
Cursor_Invert uint32 Cursor_Invert uint32
Palette PaletteConfig Palette PaletteConfig
Gutter_Background uint32 Gutter_Background uint32
Gutter_Foreground uint32 Gutter_Foreground uint32
Highlight_Line_Background uint32
} }
type PaletteConfig struct { type PaletteConfig struct {

View File

@ -41,6 +41,7 @@ cursor = 0xf2f4f6
cursor_invert = 0x000000 cursor_invert = 0x000000
gutter_background = 0x002649 gutter_background = 0x002649
gutter_foreground = 0xf2f4f6 gutter_foreground = 0xf2f4f6
highlight_line_background = 0x000000
[theme.palette] [theme.palette]
outline = 0xebedef outline = 0xebedef

View File

@ -41,6 +41,7 @@ cursor = 0xf2f4f6
cursor_invert = 0x000000 cursor_invert = 0x000000
gutter_background = 0x002649 gutter_background = 0x002649
gutter_foreground = 0xf2f4f6 gutter_foreground = 0xf2f4f6
highlight_line_background = 0x000000
[theme.palette] [theme.palette]
outline = 0xebedef outline = 0xebedef

View File

@ -41,6 +41,7 @@ cursor = 0xf2f4f6
cursor_invert = 0x000000 cursor_invert = 0x000000
gutter_background = 0x002649 gutter_background = 0x002649
gutter_foreground = 0xf2f4f6 gutter_foreground = 0xf2f4f6
highlight_line_background = 0x000000
[theme.palette] [theme.palette]
outline = 0xebedef outline = 0xebedef

View File

@ -29,7 +29,7 @@ var (
) )
const ( const (
DEFAULT_SCROLL_AMOUNT = 50 DEFAULT_SCROLL_AMOUNT = 10
) )
// TODO move into config // TODO move into config
@ -119,6 +119,7 @@ type BufferConfig struct {
foreground uint32 foreground uint32
cursor uint32 cursor uint32
cursorInvert uint32 cursorInvert uint32
highlightLine uint32
lineNumBackground uint32 lineNumBackground uint32
lineNumForeground uint32 lineNumForeground uint32
font *strife.Font font *strife.Font
@ -1249,7 +1250,7 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) {
ctx.Rect(b.x, b.y, b.w, b.h, strife.Fill) ctx.Rect(b.x, b.y, b.w, b.h, strife.Fill)
if b.cfg.Editor.Highlight_Line && b.HasFocus() { if b.cfg.Editor.Highlight_Line && b.HasFocus() {
ctx.SetColor(strife.Black) // highlight_line_col? ctx.SetColor(strife.HexRGB(b.buffOpts.highlightLine)) // highlight_line_col?
highlightLinePosY := b.ey + (ry + b.curs.ry*(last_h+pad)) - (b.cam.y * (last_h + pad)) highlightLinePosY := b.ey + (ry + b.curs.ry*(last_h+pad)) - (b.cam.y * (last_h + pad))
highlightLinePosX := b.ex + rx highlightLinePosX := b.ex + rx

View File

@ -48,10 +48,12 @@ func (b *BufferPane) renderMetaPanel(ctx *strife.Renderer) {
focused := b.Buff.index == b.Buff.parent.focusedBuff focused := b.Buff.index == b.Buff.parent.focusedBuff
colour := strife.HexRGB(conf.Suggestion.Background) colour := strife.HexRGB(conf.Suggestion.Background)
if focused { if focused {
colour.R *= 2 nr := int(colour.R) + 10
colour.G *= 2 ng := int(colour.G) + 10
colour.B *= 2 nb := int(colour.B) + 10
colour = strife.RGB(nr, ng, nb)
} }
// panel backdrop // panel backdrop

View File

@ -102,9 +102,12 @@ func NewCommandPalette(conf cfg.TomlConfig, view *View) *CommandPalette {
conf.Theme.Palette.Cursor, conf.Theme.Palette.Cursor,
conf.Theme.Palette.Cursor, // TODO invert conf.Theme.Palette.Cursor, // TODO invert
conf.Theme.Highlight_Line_Background,
// we dont show line numbers // we dont show line numbers
// so these aren't necessary // so these aren't necessary
0x0, 0x0, 0x0, 0x0,
conf.Editor.Loaded_Font, conf.Editor.Loaded_Font,
}, nil, 0), }, nil, 0),
parentBuff: nil, parentBuff: nil,

View File

@ -334,6 +334,7 @@ func (n *View) AddBuffer() *Buffer {
cfg.Theme.Foreground, cfg.Theme.Foreground,
cfg.Theme.Cursor, cfg.Theme.Cursor,
cfg.Theme.Cursor_Invert, cfg.Theme.Cursor_Invert,
cfg.Theme.Highlight_Line_Background,
cfg.Theme.Gutter_Background, cfg.Theme.Gutter_Background,
cfg.Theme.Gutter_Foreground, cfg.Theme.Gutter_Foreground,
cfg.Editor.Loaded_Font, cfg.Editor.Loaded_Font,