From c1b51df9dd286ee62062c3762c4ceddd4615f6d1 Mon Sep 17 00:00:00 2001 From: Felix Angell Date: Fri, 22 Jun 2018 09:40:01 +0100 Subject: [PATCH] remove dialog stuff for now; updated phi to support new strife changes --- gui/action.go | 13 +++++++------ gui/buffer.go | 15 ++++++--------- gui/buffer_pane.go | 4 ++-- gui/close_buffer.go | 13 +++++++------ gui/palette.go | 10 +++++----- main.go | 2 +- 6 files changed, 28 insertions(+), 29 deletions(-) diff --git a/gui/action.go b/gui/action.go index 36191d5..12c36a7 100644 --- a/gui/action.go +++ b/gui/action.go @@ -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() diff --git a/gui/buffer.go b/gui/buffer.go index d00f822..908a5fd 100644 --- a/gui/buffer.go +++ b/gui/buffer.go @@ -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 } diff --git a/gui/buffer_pane.go b/gui/buffer_pane.go index e7b294d..9b1c520 100644 --- a/gui/buffer_pane.go +++ b/gui/buffer_pane.go @@ -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 } diff --git a/gui/close_buffer.go b/gui/close_buffer.go index 56b6e0b..007fe74 100644 --- a/gui/close_buffer.go +++ b/gui/close_buffer.go @@ -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{}) diff --git a/gui/palette.go b/gui/palette.go index 5d354dd..4872dcf 100644 --- a/gui/palette.go +++ b/gui/palette.go @@ -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) diff --git a/main.go b/main.go index 5a467a0..5f53766 100644 --- a/main.go +++ b/main.go @@ -150,7 +150,7 @@ func main() { // this is only printed on each // render... ctx.SetColor(strife.White) - ctx.String(fmt.Sprintf("fps: %d, ups %d", fps, ups), ww-256, wh-128) + ctx.Text(fmt.Sprintf("fps: %d, ups %d", fps, ups), ww-256, wh-128) ctx.Display() frames += 1