mirror of
https://github.com/felixangell/phi.git
synced 2024-07-14 19:00:33 +03:00
change default font to Arial Unicode for mac; small cleanups
This commit is contained in:
parent
fad16bdcaf
commit
6ffcff9600
@ -19,7 +19,7 @@ type BufferPane struct {
|
||||
}
|
||||
|
||||
func NewBufferPane(buff *Buffer) *BufferPane {
|
||||
fontPath := filepath.Join(cfg.FONT_FOLDER, buff.cfg.Editor.Font_Face+".ttf")
|
||||
fontPath := filepath.Join(cfg.FontFolder, buff.cfg.Editor.Font_Face+".ttf")
|
||||
// FIXME DPI
|
||||
metaPanelFont, err := strife.LoadFont(fontPath, int(14.0*cfg.ScaleFactor))
|
||||
if err != nil {
|
||||
|
@ -9,7 +9,7 @@ tabs_are_spaces = true
|
||||
match_braces = false
|
||||
maintain_indentation = true
|
||||
highlight_line = true
|
||||
font_face = "Courier New"
|
||||
font_face = "Arial Unicode"
|
||||
font_size = 20
|
||||
show_line_numbers = true
|
||||
|
||||
|
@ -23,21 +23,21 @@ import (
|
||||
//
|
||||
|
||||
const (
|
||||
CONFIG_DIR_PATH = "/.phi-editor/"
|
||||
CONFIG_TOML_FILE = "config.toml"
|
||||
ConfigDirPath = "/.phi-editor/"
|
||||
ConfigTomlFile = "config.toml"
|
||||
)
|
||||
|
||||
var FONT_FOLDER string = ""
|
||||
var FontFolder = ""
|
||||
|
||||
// this is the absolute path to the
|
||||
// config.toml file. todo rename/refactor
|
||||
var CONFIG_FULL_PATH string = ""
|
||||
var ConfigFullPath = ""
|
||||
|
||||
// the absolute path to the config directory
|
||||
// rename/refactor due here too!
|
||||
var configDirAbsPath string = ""
|
||||
var configDirAbsPath = ""
|
||||
|
||||
var ICON_DIR_PATH string = ""
|
||||
var IconDirPath = ""
|
||||
|
||||
// TODO we only had double key combos
|
||||
// e.g. cmd+s. we want to handle things
|
||||
@ -85,14 +85,14 @@ func configureAndValidate(conf *TomlConfig) {
|
||||
if len(conf.Editor.Font_Path) == 0 {
|
||||
switch runtime.GOOS {
|
||||
case "windows":
|
||||
FONT_FOLDER = filepath.Join(os.Getenv("WINDIR"), "fonts")
|
||||
FontFolder = filepath.Join(os.Getenv("WINDIR"), "fonts")
|
||||
case "darwin":
|
||||
FONT_FOLDER = "/Library/Fonts/"
|
||||
FontFolder = "/Library/Fonts/"
|
||||
case "linux":
|
||||
FONT_FOLDER = findFontFolder()
|
||||
FontFolder = findFontFolder()
|
||||
}
|
||||
// and set it accordingly.
|
||||
conf.Editor.Font_Path = FONT_FOLDER
|
||||
conf.Editor.Font_Path = FontFolder
|
||||
}
|
||||
|
||||
// we only support ttf at the moment.
|
||||
@ -190,15 +190,15 @@ func Setup() TomlConfig {
|
||||
home = os.Getenv("USERPROFILE")
|
||||
}
|
||||
|
||||
CONFIG_DIR := filepath.Join(home, CONFIG_DIR_PATH)
|
||||
CONFIG_DIR := filepath.Join(home, ConfigDirPath)
|
||||
configDirAbsPath = CONFIG_DIR
|
||||
|
||||
CONFIG_PATH := filepath.Join(CONFIG_DIR, CONFIG_TOML_FILE)
|
||||
CONFIG_PATH := filepath.Join(CONFIG_DIR, ConfigTomlFile)
|
||||
|
||||
// this folder is where we store all of the language syntax
|
||||
SYNTAX_CONFIG_DIR := filepath.Join(CONFIG_DIR, "syntax")
|
||||
|
||||
CONFIG_FULL_PATH = CONFIG_PATH
|
||||
ConfigFullPath = CONFIG_PATH
|
||||
|
||||
// if the user doesn't have a /.phi-editor
|
||||
// directory we create it for them.
|
||||
@ -211,9 +211,9 @@ func Setup() TomlConfig {
|
||||
// ----
|
||||
// downloads the icon from github
|
||||
// and puts it into the phi-editor config folder.
|
||||
ICON_DIR_PATH = filepath.Join(CONFIG_DIR, "icons")
|
||||
if _, err := os.Stat(ICON_DIR_PATH); os.IsNotExist(err) {
|
||||
if err := os.Mkdir(ICON_DIR_PATH, 0775); err != nil {
|
||||
IconDirPath = filepath.Join(CONFIG_DIR, "icons")
|
||||
if _, err := os.Stat(IconDirPath); os.IsNotExist(err) {
|
||||
if err := os.Mkdir(IconDirPath, 0775); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ func Setup() TomlConfig {
|
||||
downloadIcon := func(iconSize int) {
|
||||
log.Println("downloading the phi icon ", iconSize, "x", iconSize, " png image.")
|
||||
|
||||
file, err := os.Create(filepath.Join(ICON_DIR_PATH, fmt.Sprintf("icon%d.png", iconSize)))
|
||||
file, err := os.Create(filepath.Join(IconDirPath, fmt.Sprintf("icon%d.png", iconSize)))
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
log.Println(err.Error())
|
||||
|
@ -1,67 +0,0 @@
|
||||
package gui
|
||||
|
||||
import (
|
||||
"github.com/felixangell/strife"
|
||||
)
|
||||
|
||||
type debugPane struct {
|
||||
fpsGraph *lineGraph
|
||||
}
|
||||
|
||||
type lineGraph struct {
|
||||
yAxisLabel string
|
||||
xAxisLabel string
|
||||
|
||||
xValues []float64
|
||||
yValues []float64
|
||||
}
|
||||
|
||||
func newLineGraph(xAxis, yAxis string) *lineGraph {
|
||||
return &lineGraph{
|
||||
xAxis,
|
||||
yAxis,
|
||||
[]float64{},
|
||||
[]float64{1, 2, 3, 4, 5, 6, 7},
|
||||
}
|
||||
}
|
||||
|
||||
func (l *lineGraph) plot(x, y float64) {
|
||||
l.xValues = append(l.xValues, x)
|
||||
l.yValues = append(l.yValues, y)
|
||||
}
|
||||
|
||||
func max(a, b int) int {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (l *lineGraph) render(ctx *strife.Renderer, x, y int) {
|
||||
graphWidth, graphHeight := 256, 256
|
||||
|
||||
ctx.SetColor(strife.RGBA(0, 0, 0, 255))
|
||||
ctx.Rect(x, y, graphWidth, graphHeight, strife.Fill)
|
||||
|
||||
// render last ten values
|
||||
// xSnip := l.xValues[len(l.xValues)-10:]
|
||||
ySnip := l.yValues[max(len(l.yValues)-256, 0):]
|
||||
|
||||
size := graphHeight / len(ySnip)
|
||||
|
||||
for idx, yItem := range ySnip {
|
||||
ctx.SetColor(strife.RGB(255, 0, 255))
|
||||
ctx.Rect(x+(idx*size), y+(graphHeight-(int(yItem)*size)), 5, 5, strife.Fill)
|
||||
}
|
||||
}
|
||||
|
||||
var pane = &debugPane{
|
||||
newLineGraph("time", "framerate"),
|
||||
}
|
||||
|
||||
func renderDebugPane(ctx *strife.Renderer, x, y int) {
|
||||
ctx.SetColor(strife.HexRGB(0xff00ff))
|
||||
{
|
||||
pane.fpsGraph.render(ctx, x, y)
|
||||
}
|
||||
}
|
6
main.go
6
main.go
@ -106,7 +106,9 @@ func main() {
|
||||
}
|
||||
})
|
||||
|
||||
window.Create()
|
||||
if err := window.Create(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
{
|
||||
size := 16
|
||||
@ -122,7 +124,7 @@ func main() {
|
||||
}
|
||||
|
||||
iconFile := fmt.Sprintf("icon%d.png", size)
|
||||
icon, err := strife.LoadImage(filepath.Join(cfg.ICON_DIR_PATH, iconFile))
|
||||
icon, err := strife.LoadImage(filepath.Join(cfg.IconDirPath, iconFile))
|
||||
if err != nil {
|
||||
log.Println("Failed to load icon ", err.Error())
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user