mirror of
https://github.com/felixangell/phi.git
synced 2024-08-16 19:20:21 +03:00
command palette is styled
This commit is contained in:
parent
e80e33b577
commit
0497504406
@ -42,17 +42,18 @@ gutter_background = 0x000000
|
||||
gutter_foreground = 0xf2f4f6
|
||||
|
||||
[theme.palette]
|
||||
background = 0x002649
|
||||
foreground = 0xf2f4f6
|
||||
outline = 0xebedef
|
||||
background = 0xffffff
|
||||
foreground = 0x000000
|
||||
cursor = 0xf2f4f6
|
||||
render_shadow = true
|
||||
shadow_color = 0x000000
|
||||
|
||||
[theme.palette.suggestion]
|
||||
background = 0xff00ff
|
||||
foreground = 0xffffff
|
||||
selected_background = 0xff0000
|
||||
selected_foreground = 0x0000ff
|
||||
background = 0xebedef
|
||||
foreground = 0x3a3839
|
||||
selected_background = 0xc7cbd1
|
||||
selected_foreground = 0x3a3839
|
||||
|
||||
[cursor]
|
||||
flash_rate = 400
|
||||
|
@ -42,17 +42,18 @@ gutter_background = 0x000000
|
||||
gutter_foreground = 0xf2f4f6
|
||||
|
||||
[theme.palette]
|
||||
background = 0x002649
|
||||
foreground = 0xf2f4f6
|
||||
outline = 0xebedef
|
||||
background = 0xffffff
|
||||
foreground = 0x000000
|
||||
cursor = 0xf2f4f6
|
||||
render_shadow = true
|
||||
shadow_color = 0x000000
|
||||
|
||||
[theme.palette.suggestion]
|
||||
background = 0xff00ff
|
||||
foreground = 0xffffff
|
||||
selected_background = 0xff0000
|
||||
selected_foreground = 0x0000ff
|
||||
background = 0xebedef
|
||||
foreground = 0x3a3839
|
||||
selected_background = 0xc7cbd1
|
||||
selected_foreground = 0x3a3839
|
||||
|
||||
[cursor]
|
||||
flash_rate = 400
|
||||
|
@ -42,17 +42,18 @@ gutter_background = 0x000000
|
||||
gutter_foreground = 0xf2f4f6
|
||||
|
||||
[theme.palette]
|
||||
background = 0x002649
|
||||
foreground = 0xf2f4f6
|
||||
outline = 0xebedef
|
||||
background = 0xffffff
|
||||
foreground = 0x000000
|
||||
cursor = 0xf2f4f6
|
||||
render_shadow = true
|
||||
shadow_color = 0x000000
|
||||
|
||||
[theme.palette.suggestion]
|
||||
background = 0xff00ff
|
||||
foreground = 0xffffff
|
||||
selected_background = 0xff0000
|
||||
selected_foreground = 0x0000ff
|
||||
background = 0xebedef
|
||||
foreground = 0x3a3839
|
||||
selected_background = 0xc7cbd1
|
||||
selected_foreground = 0x3a3839
|
||||
|
||||
[cursor]
|
||||
flash_rate = 400
|
||||
|
@ -53,6 +53,7 @@ type Buffer struct {
|
||||
cam *camera
|
||||
filePath string
|
||||
languageInfo *cfg.LanguageSyntaxConfig
|
||||
ex, ey int
|
||||
}
|
||||
|
||||
func NewBuffer(conf *cfg.TomlConfig, buffOpts BufferConfig, parent *View, index int) *Buffer {
|
||||
@ -135,13 +136,6 @@ func (b *Buffer) OpenFile(filePath string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Buffer) OnDispose() {
|
||||
// hm!
|
||||
// os.Remove(b.fileHandle)
|
||||
}
|
||||
|
||||
func (b *Buffer) OnInit() {}
|
||||
|
||||
func (b *Buffer) setLine(idx int, val string) {
|
||||
b.contents[idx] = rope.New(val)
|
||||
if b.curs.y == idx {
|
||||
@ -883,9 +877,6 @@ type syntaxRuneInfo struct {
|
||||
// dimensions of the last character we rendered
|
||||
var last_w, last_h int
|
||||
|
||||
// editor x and y offsets
|
||||
var ex, ey = 0, 0
|
||||
|
||||
// runs up a lexer instance
|
||||
func lexFindMatches(matches *map[int]syntaxRuneInfo, currLine string, toMatch map[string]bool, bg int, fg int) {
|
||||
// start up a lexer instance and
|
||||
@ -948,10 +939,10 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) {
|
||||
if b.cfg.Editor.Highlight_Line && b.HasFocus() {
|
||||
ctx.SetColor(strife.Black) // highlight_line_col?
|
||||
|
||||
highlightLinePosY := ey + (ry + b.curs.ry*last_h) - (b.cam.y * last_h)
|
||||
highlightLinePosX := ex + rx
|
||||
highlightLinePosY := b.ey + (ry + b.curs.ry*last_h) - (b.cam.y * last_h)
|
||||
highlightLinePosX := b.ex + rx
|
||||
|
||||
ctx.Rect(highlightLinePosX, highlightLinePosY, b.w-ex, last_h, strife.Fill)
|
||||
ctx.Rect(highlightLinePosX, highlightLinePosY, b.w-b.ex, last_h-b.ey, strife.Fill)
|
||||
}
|
||||
|
||||
var visibleLines, visibleChars int = 50, -1
|
||||
@ -971,13 +962,13 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) {
|
||||
// render an extra three lines just
|
||||
// so we dont cut anything off if its
|
||||
// not evenly divisible
|
||||
visibleLines = (int(b.h) / int(last_h)) + 3
|
||||
visibleLines = (int(b.h-b.ey) / int(last_h)) + 3
|
||||
}
|
||||
|
||||
// calculate how many chars we can fit
|
||||
// on the screen.
|
||||
if int(last_w) > 0 && int(b.w) != 0 {
|
||||
visibleChars = (int(b.w-ex) / int(last_w)) - 3
|
||||
visibleChars = (int(b.w-b.ex) / int(last_w)) - 3
|
||||
}
|
||||
|
||||
start := b.cam.y
|
||||
@ -991,7 +982,7 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) {
|
||||
|
||||
// render the selection if any
|
||||
if lastSelection != nil {
|
||||
lastSelection.renderAt(ctx, b.x+ex, b.y+ey)
|
||||
lastSelection.renderAt(ctx, b.x+b.ex, b.y+b.ey)
|
||||
}
|
||||
|
||||
numLines := len(b.contents)
|
||||
@ -1045,7 +1036,7 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) {
|
||||
a, colorStack = int32(colorStack[len(colorStack)-1]), colorStack[:len(colorStack)-1]
|
||||
ctx.SetColor(strife.HexRGB(a))
|
||||
}
|
||||
last_w, last_h = ctx.String(string(char), ex+(rx+((x_col-1)*last_w)), (ry + (y_col * last_h)))
|
||||
last_w, last_h = ctx.String(string(char), b.ex+(rx+((x_col-1)*last_w)), b.ey+(ry+(y_col*last_h)))
|
||||
}
|
||||
|
||||
if b.cfg.Editor.Show_Line_Numbers {
|
||||
@ -1060,7 +1051,7 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) {
|
||||
ctx.SetColor(strife.HexRGB(b.buffOpts.lineNumForeground))
|
||||
ctx.String(fmt.Sprintf("%*d", numLinesWidth, start+lineNum), rx+gutterPadPx, (ry + (y_col * last_h)))
|
||||
|
||||
ex = gutterWidth
|
||||
b.ex = gutterWidth
|
||||
}
|
||||
|
||||
y_col += 1
|
||||
@ -1074,7 +1065,7 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) {
|
||||
}
|
||||
|
||||
ctx.SetColor(strife.HexRGB(b.buffOpts.cursor)) // caret colour
|
||||
ctx.Rect(ex+(rx+b.curs.rx*last_w)-(b.cam.x*last_w), (ry+b.curs.ry*last_h)-(b.cam.y*last_h), cursorWidth, last_h, strife.Fill)
|
||||
ctx.Rect(b.ex+(rx+b.curs.rx*last_w)-(b.cam.x*last_w), b.ey+(ry+b.curs.ry*last_h)-(b.cam.y*last_h), cursorWidth, last_h, strife.Fill)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,13 @@ func (s *suggestion) renderHighlighted(x, y int, ctx *strife.Renderer) {
|
||||
ctx.Rect(x, y, suggestionBoxWidth, suggestionBoxHeight, strife.Fill)
|
||||
|
||||
ctx.SetColor(strife.HexRGB(conf.Suggestion.Selected_Foreground))
|
||||
ctx.String(s.name, x, y)
|
||||
|
||||
// FIXME strife library needs something to get
|
||||
// text width and heights... for now we render offscreen to measure... lol
|
||||
_, h := ctx.String("foo", -500000, -50000)
|
||||
|
||||
yOffs := (suggestionBoxHeight / 2) - (h / 2)
|
||||
ctx.String(s.name, x+border, y+yOffs)
|
||||
}
|
||||
|
||||
func (s *suggestion) render(x, y int, ctx *strife.Renderer) {
|
||||
@ -62,7 +68,13 @@ func (s *suggestion) render(x, y int, ctx *strife.Renderer) {
|
||||
ctx.Rect(x, y, suggestionBoxWidth, suggestionBoxHeight, strife.Fill)
|
||||
|
||||
ctx.SetColor(strife.HexRGB(conf.Suggestion.Foreground))
|
||||
ctx.String(s.name, x, y)
|
||||
|
||||
// FIXME strife library needs something to get
|
||||
// text width and heights... for now we render offscreen to measure... lol
|
||||
_, h := ctx.String("foo", -500000, -50000)
|
||||
|
||||
yOffs := (suggestionBoxHeight / 2) - (h / 2)
|
||||
ctx.String(s.name, x+border, y+yOffs)
|
||||
}
|
||||
|
||||
func NewCommandPalette(conf cfg.TomlConfig, view *View) *CommandPalette {
|
||||
@ -88,19 +100,23 @@ func NewCommandPalette(conf cfg.TomlConfig, view *View) *CommandPalette {
|
||||
|
||||
palette.Resize(view.w/3, 48)
|
||||
palette.Translate((view.w/2)-(palette.w/2), 10)
|
||||
|
||||
// the buffer is not rendered
|
||||
// relative to the palette so we have to set its position
|
||||
palette.buff.Resize(palette.w, palette.h)
|
||||
palette.buff.Translate((view.w/2)-(palette.w/2), 10)
|
||||
|
||||
// this is technically a hack. this ex is an xoffset
|
||||
// for the line numbers but we're going to use it for
|
||||
// general border offsets. this is a real easy fixme
|
||||
// for general code clean but maybe another day!
|
||||
palette.buff.ex = 5
|
||||
|
||||
suggestionBoxWidth = palette.w
|
||||
|
||||
return palette
|
||||
}
|
||||
|
||||
func (b *CommandPalette) OnInit() {
|
||||
b.buff.Translate(b.x, b.y)
|
||||
b.buff.Resize(b.w, b.h)
|
||||
}
|
||||
|
||||
func (b *CommandPalette) processCommand() {
|
||||
tokenizedLine := strings.Split(b.buff.contents[0].String(), " ")
|
||||
command := tokenizedLine[0]
|
||||
@ -222,6 +238,9 @@ func (b *CommandPalette) OnRender(ctx *strife.Renderer) {
|
||||
ctx.SetColor(strife.HexRGB(conf.Outline))
|
||||
ctx.Rect(b.x-border, b.y-border, b.w+(border*2), b.h+(border*2), strife.Fill)
|
||||
|
||||
_, charHeight := ctx.String("foo", -5000, -5000)
|
||||
b.buff.ey = (suggestionBoxHeight / 2) - (charHeight / 2)
|
||||
|
||||
b.buff.OnRender(ctx)
|
||||
|
||||
if b.recentSuggestions != nil {
|
||||
@ -234,7 +253,3 @@ func (b *CommandPalette) OnRender(ctx *strife.Renderer) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (b *CommandPalette) OnDispose() {
|
||||
log.Println("poop diddity scoop")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user