mirror of
https://github.com/felixangell/phi.git
synced 2024-08-16 19:20:21 +03:00
commit
abcb12f1c6
@ -2,7 +2,7 @@
|
||||
|
||||
<h1>phi-editor</h1>
|
||||
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.
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
8
main.go
8
main.go
@ -5,7 +5,7 @@ import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
@ -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)
|
||||
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user