From a4f032f4e42359b1c9021f9092438d71580dbe63 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Tue, 17 Apr 2018 09:54:12 +0900 Subject: [PATCH 1/5] fix config directory in README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8a89d92..8d0a153 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@

phi-editor

Phi is a minimal text editor designed to look pretty, run fast, and be easy -to configure and use. It's primary function is for editing code. +to configure and use. It's primary function is for editing code. Note that this is a work in progress and is very buggy! The editor is written as if it's a game, so it will probably **eat up your battery**, as well as **run possibly quite slow** - especially @@ -22,7 +22,7 @@ The editor must: * run fast; * load and edit large files with ease; * look pretty; and finally -* be easy to use +* be easy to use # building You'll need Go with the GOPATH, GOBIN, etc. setup, as well as SDL2, SDL2\_image, and SDL2\_ttf. Here's @@ -49,7 +49,7 @@ $ ./phi-editor If you're on windows, you have my condolences. ## configuration -Configuration files are stored in `$HOME/.phi-editor-editor/config.toml`. Note that +Configuration files are stored in `$HOME/.phi-editor/config.toml`. Note that this directory is created on first startup by the editor, as well as the configuration files in the 'cfg/' directory are pre-loaded dependening on platform: see 'cfg/linuxconfig.go', for example. From 374ea255ecd8046cf302c62eb3a70e050908cbd9 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Tue, 17 Apr 2018 09:57:44 +0900 Subject: [PATCH 2/5] use path/filepath instead of path --- main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 8bc8369..0bb0362 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,7 @@ import ( "io/ioutil" "log" "os" - "path" + "path/filepath" "runtime" "time" @@ -65,14 +65,14 @@ func (n *PhiEditor) init(cfg *cfg.TomlConfig) { switch runtime.GOOS { case "windows": - fontFolder = path.Join(os.Getenv("%WINDIR%"), "fonts") + fontFolder = filepath.Join(os.Getenv("WINDIR"), "fonts") case "darwin": fontFolder = "/Library/Fonts/" case "linux": fontFolder = "/usr/share/fonts/" } - fontPath := path.Join(fontFolder, cfg.Editor.Font_Face) + ".ttf" + fontPath := filepath.Join(fontFolder, cfg.Editor.Font_Face) + ".ttf" font, err := strife.LoadFont(fontPath, cfg.Editor.Font_Size) if err != nil { From 88b798517d1f87fb0dd9c5f74257a8d7e1b804f9 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Tue, 17 Apr 2018 09:59:31 +0900 Subject: [PATCH 3/5] pass empty string into ioutil.TempDir TempDir uses the default directory for temporary files if dir is empty --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 0bb0362..78a0e77 100644 --- a/main.go +++ b/main.go @@ -42,7 +42,7 @@ func (n *PhiEditor) init(cfg *cfg.TomlConfig) { } } else { // we have no args, open up a scratch file - tempFile, err := ioutil.TempFile("/var/tmp/", "phi-editor-") + tempFile, err := ioutil.TempFile("", "phi-editor-") if err != nil { log.Println("Failed to create temp file", err.Error()) os.Exit(1) From c93373804dd5f990493768368f356e031940e70b Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Tue, 17 Apr 2018 09:59:46 +0900 Subject: [PATCH 4/5] use USERPROFILE instead of HOME for Windows --- cfg/loader.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cfg/loader.go b/cfg/loader.go index 3735cfc..c68cd28 100644 --- a/cfg/loader.go +++ b/cfg/loader.go @@ -4,6 +4,8 @@ import ( "io/ioutil" "log" "os" + "path/filepath" + "runtime" "strings" // fork of BurntSushi with hexadecimal support. @@ -81,8 +83,12 @@ func configureAndValidate(conf *TomlConfig) { func Setup() TomlConfig { log.Println("Setting up Phi Editor") - CONFIG_DIR := os.Getenv("HOME") + CONFIG_DIR_PATH - CONFIG_PATH := CONFIG_DIR + CONFIG_TOML_FILE + home := os.Getenv("HOME") + if runtime.GOOS == "windows" { + home = os.Getenv("USERPROFILE") + } + CONFIG_DIR := filepath.Join(home, CONFIG_DIR_PATH) + CONFIG_PATH := filepath.Join(CONFIG_DIR, CONFIG_TOML_FILE) CONFIG_FULL_PATH = CONFIG_PATH // if the user doesn't have a /.phi-editor From db1e92033a15838a889d14eb496664f065c88cf0 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Tue, 17 Apr 2018 10:00:05 +0900 Subject: [PATCH 5/5] start possibly be large than b.contents --- gui/buffer.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gui/buffer.go b/gui/buffer.go index 5cb2918..75d8e68 100644 --- a/gui/buffer.go +++ b/gui/buffer.go @@ -799,6 +799,9 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) { start := b.cam.y upper := b.cam.y + visibleLines + if start > len(b.contents) { + start = len(b.contents) + } if upper > len(b.contents) { upper = len(b.contents) }