removed res folder; closes #32
@ -1,8 +1,11 @@
|
||||
package cfg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
@ -34,6 +37,8 @@ var CONFIG_FULL_PATH string = ""
|
||||
// rename/refactor due here too!
|
||||
var configDirAbsPath string = ""
|
||||
|
||||
var ICON_DIR_PATH string = ""
|
||||
|
||||
// TODO we only had double key combos
|
||||
// e.g. cmd+s. we want to handle things
|
||||
// like cmd+alt+s
|
||||
@ -198,6 +203,57 @@ 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 {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
log.Println("setting up the icons folder")
|
||||
|
||||
// https://raw.githubusercontent.com/felixangell/phi/gh-pages/images/icon128.png
|
||||
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)))
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
log.Println(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// Generated by curl-to-Go: https://mholt.github.io/curl-to-go
|
||||
resp, err := http.Get(fmt.Sprintf("https://raw.githubusercontent.com/felixangell/phi/gh-pages/images/icon%d.png", iconSize))
|
||||
if err != nil {
|
||||
log.Println("Failed to download icon", iconSize, "!", err.Error())
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
_, err = io.Copy(file, resp.Body)
|
||||
if err != nil {
|
||||
log.Println(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
size := 16
|
||||
switch runtime.GOOS {
|
||||
case "windows":
|
||||
size = 64
|
||||
case "darwin":
|
||||
size = 512
|
||||
case "linux":
|
||||
size = 96
|
||||
}
|
||||
|
||||
// download the icon and
|
||||
// write it to the phi-editor folder.
|
||||
downloadIcon(size)
|
||||
}
|
||||
|
||||
// try make the syntax config folder.
|
||||
if _, err := os.Stat(SYNTAX_CONFIG_DIR); os.IsNotExist(err) {
|
||||
if err := os.Mkdir(SYNTAX_CONFIG_DIR, 0775); err != nil {
|
||||
|
12
main.go
@ -5,6 +5,7 @@ import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
@ -86,19 +87,20 @@ func main() {
|
||||
window.Create()
|
||||
|
||||
{
|
||||
size := "16"
|
||||
size := 16
|
||||
switch runtime.GOOS {
|
||||
case "windows":
|
||||
size = "64"
|
||||
size = 64
|
||||
case "darwin":
|
||||
size = "512"
|
||||
size = 512
|
||||
case "linux":
|
||||
size = "96"
|
||||
size = 96
|
||||
default:
|
||||
log.Println("unrecognized runtime ", runtime.GOOS)
|
||||
}
|
||||
|
||||
icon, err := strife.LoadImage("./res/icons/icon" + size + ".png")
|
||||
iconFile := fmt.Sprintf("icon%d.png", size)
|
||||
icon, err := strife.LoadImage(filepath.Join(cfg.ICON_DIR_PATH, iconFile))
|
||||
if err != nil {
|
||||
log.Println("Failed to load icon ", err.Error())
|
||||
} else {
|
||||
|
BIN
res/firacode.ttf
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 5.0 KiB |