mirror of
https://github.com/felixangell/phi.git
synced 2024-09-11 15:55:25 +03:00
commit
abcb12f1c6
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<h1>phi-editor</h1>
|
<h1>phi-editor</h1>
|
||||||
Phi is a minimal text editor designed to look pretty, run fast, and be easy
|
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,
|
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
|
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;
|
* run fast;
|
||||||
* load and edit large files with ease;
|
* load and edit large files with ease;
|
||||||
* look pretty; and finally
|
* look pretty; and finally
|
||||||
* be easy to use
|
* be easy to use
|
||||||
|
|
||||||
# building
|
# building
|
||||||
You'll need Go with the GOPATH, GOBIN, etc. setup, as well as SDL2, SDL2\_image, and SDL2\_ttf. Here's
|
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.
|
If you're on windows, you have my condolences.
|
||||||
|
|
||||||
## configuration
|
## 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
|
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.
|
files in the 'cfg/' directory are pre-loaded dependening on platform: see 'cfg/linuxconfig.go', for example.
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
// fork of BurntSushi with hexadecimal support.
|
// fork of BurntSushi with hexadecimal support.
|
||||||
@ -81,8 +83,12 @@ func configureAndValidate(conf *TomlConfig) {
|
|||||||
func Setup() TomlConfig {
|
func Setup() TomlConfig {
|
||||||
log.Println("Setting up Phi Editor")
|
log.Println("Setting up Phi Editor")
|
||||||
|
|
||||||
CONFIG_DIR := os.Getenv("HOME") + CONFIG_DIR_PATH
|
home := os.Getenv("HOME")
|
||||||
CONFIG_PATH := CONFIG_DIR + CONFIG_TOML_FILE
|
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
|
CONFIG_FULL_PATH = CONFIG_PATH
|
||||||
|
|
||||||
// if the user doesn't have a /.phi-editor
|
// 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
|
start := b.cam.y
|
||||||
upper := b.cam.y + visibleLines
|
upper := b.cam.y + visibleLines
|
||||||
|
if start > len(b.contents) {
|
||||||
|
start = len(b.contents)
|
||||||
|
}
|
||||||
if upper > len(b.contents) {
|
if upper > len(b.contents) {
|
||||||
upper = len(b.contents)
|
upper = len(b.contents)
|
||||||
}
|
}
|
||||||
|
8
main.go
8
main.go
@ -5,7 +5,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ func (n *PhiEditor) init(cfg *cfg.TomlConfig) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// we have no args, open up a scratch file
|
// 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 {
|
if err != nil {
|
||||||
log.Println("Failed to create temp file", err.Error())
|
log.Println("Failed to create temp file", err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@ -65,14 +65,14 @@ func (n *PhiEditor) init(cfg *cfg.TomlConfig) {
|
|||||||
|
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "windows":
|
case "windows":
|
||||||
fontFolder = path.Join(os.Getenv("%WINDIR%"), "fonts")
|
fontFolder = filepath.Join(os.Getenv("WINDIR"), "fonts")
|
||||||
case "darwin":
|
case "darwin":
|
||||||
fontFolder = "/Library/Fonts/"
|
fontFolder = "/Library/Fonts/"
|
||||||
case "linux":
|
case "linux":
|
||||||
fontFolder = "/usr/share/fonts/"
|
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)
|
font, err := strife.LoadFont(fontPath, cfg.Editor.Font_Size)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user