mirror of
https://github.com/felixangell/phi.git
synced 2024-08-16 19:20:21 +03:00
uploaded new screenshot
This commit is contained in:
parent
41851db6b7
commit
ffa751e13c
28
README.md
28
README.md
@ -18,7 +18,7 @@ editing the config file for the editor itself.
|
||||
# goals
|
||||
The editor must:
|
||||
|
||||
* run at 60 fps;
|
||||
* run fast;
|
||||
* load and edit large files with ease;
|
||||
* look pretty; and finally
|
||||
* be easy to use
|
||||
@ -38,30 +38,42 @@ $ ./phi-editor
|
||||
If you're on macOS, you can get these dependencies via. homebrew. If you're on windows; you have my condolences.
|
||||
|
||||
## configuration
|
||||
Configuration files are stored in `$HOME/.phi-editor-editor/config.toml`, here's
|
||||
an example, which just so happens to be the defualt configuration:
|
||||
Configuration files are stored in `$HOME/.phi-editor-editor/config.toml`. Note that
|
||||
this directory is created on first startup by the editor, as well as the configuration
|
||||
file below is pre-loaded:
|
||||
|
||||
```toml
|
||||
[editor]
|
||||
tab_size = 2
|
||||
tab_size = 4
|
||||
hungry_backspace = true
|
||||
tabs_are_spaces = true
|
||||
match_braces = false
|
||||
maintain_indentation = true
|
||||
highlight_line = true
|
||||
|
||||
[render]
|
||||
aliased = true
|
||||
accelerated = true
|
||||
throttle_cpu_usage = true
|
||||
|
||||
[theme]
|
||||
background = "0xfdf6e3"
|
||||
foreground = "0x7a7a7a"
|
||||
cursor = "0x657B83"
|
||||
cursor_invert = "0xffffff"
|
||||
background = 0x002649
|
||||
foreground = 0xf2f4f6
|
||||
cursor = 0xf2f4f6
|
||||
cursor_invert = 0x000000
|
||||
|
||||
[cursor]
|
||||
flash_rate = 400
|
||||
reset_delay = 400
|
||||
draw = true
|
||||
flash = true
|
||||
|
||||
[commands]
|
||||
[commands.save]
|
||||
shortcut = "super+s"
|
||||
|
||||
[commands.delete_line]
|
||||
shortcut = "super+d"
|
||||
```
|
||||
|
||||
# license
|
||||
|
@ -12,7 +12,7 @@ type TomlConfig struct {
|
||||
}
|
||||
|
||||
var DEFUALT_TOML_CONFIG string = `[editor]
|
||||
tab_size = 2
|
||||
tab_size = 4
|
||||
hungry_backspace = true
|
||||
tabs_are_spaces = true
|
||||
match_braces = false
|
||||
@ -22,12 +22,13 @@ highlight_line = true
|
||||
[render]
|
||||
aliased = true
|
||||
accelerated = true
|
||||
throttle_cpu_usage = true
|
||||
|
||||
[theme]
|
||||
background = 0x002649
|
||||
foreground = 0xf2f4f6
|
||||
cursor = 0xf2f4f6
|
||||
cursor_invert = 0xffffff
|
||||
cursor_invert = 0x000000
|
||||
|
||||
[cursor]
|
||||
flash_rate = 400
|
||||
@ -71,8 +72,9 @@ func (c CursorConfig) GetCaretWidth() int {
|
||||
}
|
||||
|
||||
type RenderConfig struct {
|
||||
Aliased bool
|
||||
Accelerated bool
|
||||
Aliased bool
|
||||
Accelerated bool
|
||||
Throttle_Cpu_Usage bool
|
||||
}
|
||||
|
||||
// todo make this more extendable...
|
||||
|
@ -101,7 +101,7 @@ var shiftAlternative = map[rune]rune{
|
||||
'[': '{',
|
||||
']': '}',
|
||||
';': ':',
|
||||
'"': '\'',
|
||||
'\'': '"',
|
||||
'\\': '|',
|
||||
'§': '±',
|
||||
}
|
||||
|
37
main.go
37
main.go
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/felixangell/phi-editor/cfg"
|
||||
"github.com/felixangell/phi-editor/gui"
|
||||
@ -21,7 +22,8 @@ type PhiEditor struct {
|
||||
}
|
||||
|
||||
func (n *PhiEditor) init(cfg *cfg.TomlConfig) {
|
||||
n.AddComponent(gui.NewView(1280, 720, cfg))
|
||||
n.AddComponent(gui.NewView(1280/2, 720, cfg))
|
||||
n.AddComponent(gui.NewView(1280/2, 720, cfg))
|
||||
|
||||
font, err := strife.LoadFont("./res/firacode.ttf", 14)
|
||||
if err != nil {
|
||||
@ -48,14 +50,11 @@ func (n *PhiEditor) update() bool {
|
||||
}
|
||||
|
||||
func (n *PhiEditor) render(ctx *strife.Renderer) {
|
||||
ctx.Clear()
|
||||
ctx.SetFont(n.defaultFont)
|
||||
|
||||
for _, child := range n.GetComponents() {
|
||||
gui.Render(child, ctx)
|
||||
}
|
||||
|
||||
ctx.Display()
|
||||
}
|
||||
|
||||
func main() {
|
||||
@ -100,11 +99,15 @@ func main() {
|
||||
editor.init(&config)
|
||||
|
||||
timer := strife.CurrentTimeMillis()
|
||||
num_frames := 0
|
||||
frames, updates := 0, 0
|
||||
fps, ups := frames, updates
|
||||
|
||||
ctx := window.GetRenderContext()
|
||||
|
||||
ctx.Clear()
|
||||
editor.render(ctx)
|
||||
ctx.Display()
|
||||
|
||||
for {
|
||||
window.PollEvents()
|
||||
if window.CloseRequested() {
|
||||
@ -112,17 +115,29 @@ func main() {
|
||||
}
|
||||
|
||||
if editor.update() {
|
||||
ctx.Clear()
|
||||
editor.render(ctx)
|
||||
}
|
||||
|
||||
num_frames += 1
|
||||
// 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.Display()
|
||||
frames += 1
|
||||
}
|
||||
updates += 1
|
||||
|
||||
if strife.CurrentTimeMillis()-timer > 1000 {
|
||||
timer = strife.CurrentTimeMillis()
|
||||
if PRINT_FPS {
|
||||
fmt.Println("frames: ", num_frames)
|
||||
}
|
||||
num_frames = 0
|
||||
fps, ups = frames, updates
|
||||
frames, updates = 0, 0
|
||||
}
|
||||
|
||||
if config.Render.Throttle_Cpu_Usage {
|
||||
// todo put in the config how long
|
||||
// we sleep for!
|
||||
time.Sleep(16)
|
||||
}
|
||||
}
|
||||
|
||||
|
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
Before Width: | Height: | Size: 188 KiB After Width: | Height: | Size: 85 KiB |
Loading…
Reference in New Issue
Block a user