mirror of
https://github.com/felixangell/phi.git
synced 2024-09-11 07:45:30 +03:00
remove dialog stuff for now; updated phi to support new strife changes
This commit is contained in:
parent
a634897283
commit
c1b51df9dd
@ -4,8 +4,6 @@ import (
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/sqweek/dialog"
|
||||
)
|
||||
|
||||
type BufferAction struct {
|
||||
@ -23,10 +21,13 @@ func NewBufferAction(name string, proc func(*View, []string) bool) BufferAction
|
||||
}
|
||||
|
||||
func OpenFile(v *View, commands []string) bool {
|
||||
path, err := dialog.File().Title("Open file").Load()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return false
|
||||
path := ""
|
||||
if path == "" {
|
||||
panic("unimplemented")
|
||||
// ive removed this since the cross platform
|
||||
// thing causes too much hassle on diff. platforms
|
||||
// going to wriet my own file open viewer thing built
|
||||
// into the editor instead.
|
||||
}
|
||||
|
||||
buff := v.AddBuffer()
|
||||
|
@ -17,7 +17,6 @@ import (
|
||||
"github.com/felixangell/phi/lex"
|
||||
"github.com/felixangell/phi/piecetable"
|
||||
"github.com/felixangell/strife"
|
||||
"github.com/sqweek/dialog"
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
)
|
||||
|
||||
@ -101,7 +100,7 @@ func (a *AutoCompleteBox) renderAt(x, y int, ctx *strife.Renderer) {
|
||||
|
||||
ctx.SetColor(strife.HexRGB(0xffffff))
|
||||
for idx, sugg := range a.suggestions {
|
||||
ctx.String(sugg, x, y+(idx*height))
|
||||
ctx.Text(sugg, x, y+(idx*height))
|
||||
}
|
||||
}
|
||||
|
||||
@ -232,10 +231,8 @@ func (b *Buffer) reload() {
|
||||
// ask if the user wants to reload the file or not
|
||||
// otherwise re-load it anyway.
|
||||
if b.modified {
|
||||
ok := dialog.Message("This file has been modified, would you like to reload?").YesNo()
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
// ok := dialog.Message("This file has been modified, would you like to reload?").YesNo()
|
||||
panic("this should show a file modified thing but this has been removed for now!")
|
||||
}
|
||||
|
||||
contents, err := ioutil.ReadFile(b.filePath)
|
||||
@ -1335,7 +1332,7 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) {
|
||||
// so we can calculate the size of characters
|
||||
{
|
||||
if int(last_h) == 0 || int(last_w) == 0 {
|
||||
last_w, last_h = ctx.String("_", -50, -50)
|
||||
last_w, last_h = ctx.Text("_", -50, -50)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1455,7 +1452,7 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) {
|
||||
// todo render background
|
||||
|
||||
ctx.SetColor(strife.HexRGB(characterColor.fg))
|
||||
last_w, last_h = ctx.String(string(char), xPos, yPos)
|
||||
last_w, last_h = ctx.Text(string(char), xPos, yPos)
|
||||
|
||||
if DEBUG_MODE {
|
||||
ctx.SetColor(strife.HexRGB(0xff00ff))
|
||||
@ -1484,7 +1481,7 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) {
|
||||
}
|
||||
|
||||
ctx.SetColor(strife.HexRGB(b.buffOpts.lineNumForeground))
|
||||
ctx.String(fmt.Sprintf("%*d", numLinesCharWidth, (start+lineNum)+1), rx+gutterPadPx, yPos)
|
||||
ctx.Text(fmt.Sprintf("%*d", numLinesCharWidth, (start+lineNum)+1), rx+gutterPadPx, yPos)
|
||||
|
||||
b.ex = gutterWidth
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ func (b *BufferPane) renderMetaPanel(ctx *strife.Renderer) {
|
||||
ctx.SetColor(strife.HexRGB(conf.Suggestion.Foreground))
|
||||
|
||||
ctx.SetFont(b.font)
|
||||
lastWidth, _ = ctx.String(infoLine, ((b.x + b.w) - (lastWidth + (pad))), mpY+(pad/2))
|
||||
lastWidth, _ = ctx.Text(infoLine, ((b.x + b.w) - (lastWidth + (pad))), mpY+(pad/2))
|
||||
}
|
||||
|
||||
{
|
||||
@ -89,7 +89,7 @@ func (b *BufferPane) renderMetaPanel(ctx *strife.Renderer) {
|
||||
ctx.SetColor(strife.HexRGB(conf.Suggestion.Foreground))
|
||||
|
||||
ctx.SetFont(b.font)
|
||||
_, strHeight := ctx.String(infoLine, b.x+pad, mpY+(pad/2)+1)
|
||||
_, strHeight := ctx.Text(infoLine, b.x+pad, mpY+(pad/2)+1)
|
||||
metaPanelHeight = strHeight + pad
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,6 @@ package gui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/sqweek/dialog"
|
||||
)
|
||||
|
||||
func CloseBuffer(v *View, commands []string) bool {
|
||||
@ -18,10 +16,13 @@ func CloseBuffer(v *View, commands []string) bool {
|
||||
// TODO basename?
|
||||
text := fmt.Sprintf("Do you want to save the changes you made to %s?", b.filePath)
|
||||
|
||||
dontSave := dialog.Message("%s", text).YesNo()
|
||||
if !dontSave {
|
||||
return false
|
||||
}
|
||||
// TODO
|
||||
panic(text)
|
||||
|
||||
// dontSave := dialog.Message("%s", text).YesNo()
|
||||
// if !dontSave {
|
||||
// return false
|
||||
// }
|
||||
|
||||
// save the buffer!
|
||||
Save(v, []string{})
|
||||
|
@ -61,10 +61,10 @@ func (s *suggestion) renderHighlighted(x, y int, ctx *strife.Renderer) {
|
||||
|
||||
// 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)
|
||||
_, h := ctx.Text("foo", -500000, -50000)
|
||||
|
||||
yOffs := (suggestionBoxHeight / 2) - (h / 2)
|
||||
ctx.String(s.name, x+border, y+yOffs)
|
||||
ctx.Text(s.name, x+border, y+yOffs)
|
||||
}
|
||||
|
||||
func (s *suggestion) render(x, y int, ctx *strife.Renderer) {
|
||||
@ -82,10 +82,10 @@ func (s *suggestion) render(x, y int, ctx *strife.Renderer) {
|
||||
|
||||
// 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)
|
||||
_, h := ctx.Text("foo", -500000, -50000)
|
||||
|
||||
yOffs := (suggestionBoxHeight / 2) - (h / 2)
|
||||
ctx.String(s.name, x+border, y+yOffs)
|
||||
ctx.Text(s.name, x+border, y+yOffs)
|
||||
}
|
||||
|
||||
func NewCommandPalette(conf cfg.TomlConfig, view *View) *CommandPalette {
|
||||
@ -342,7 +342,7 @@ func (b *CommandPalette) OnRender(ctx *strife.Renderer) {
|
||||
ctx.SetColor(strife.HexRGB(conf.Outline))
|
||||
ctx.Rect(xPos, yPos, paletteWidth, paletteHeight, strife.Fill)
|
||||
|
||||
_, charHeight := ctx.String("foo", -5000, -5000)
|
||||
_, charHeight := ctx.Text("foo", -5000, -5000)
|
||||
b.buff.ey = (suggestionBoxHeight / 2) - (charHeight / 2)
|
||||
|
||||
b.buff.OnRender(ctx)
|
||||
|
Loading…
Reference in New Issue
Block a user