From 32ed5a2d05b8266b2dd00844dc7b52b3cb91114d Mon Sep 17 00:00:00 2001 From: Nikolaus Gotsche Date: Sun, 27 Jan 2019 00:55:41 +0100 Subject: Fenestra 0.1 --- main.go | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 main.go (limited to 'main.go') diff --git a/main.go b/main.go new file mode 100644 index 0000000..a1a2eb8 --- /dev/null +++ b/main.go @@ -0,0 +1,77 @@ +package main + +import ( + //"fmt" + "os" + "bufio" + "strings" + + "github.com/aarzilli/nucular" + _"github.com/aarzilli/nucular/label" + nstyle "github.com/aarzilli/nucular/style" +) + +var ( + scaling = 1.1 + Wnd nucular.MasterWindow + theme nstyle.Theme = nstyle.DarkTheme + dat []data + hea string +) + +type data struct { + title string + textl []string + textr []string +} + + +func main() { + + hea,dat = loadfile("data.txt") + + nw := newNucularWindow() + nw.Theme = theme + + Wnd = nucular.NewMasterWindow(0,hea, nw.nucularWindow) + Wnd.SetStyle(nstyle.FromTheme(theme, scaling)) + Wnd.Main() + +} +func loadfile(filename string) (head string,out []data){ + f, _ := os.Open(filename) + scanner := bufio.NewScanner(f) + title := "" + keys := []string{} + info := []string{} + for scanner.Scan() { + li := scanner.Text() + line := strings.Replace(li,"\t","",-1) + + if strings.HasPrefix(line,"//") { + continue + } + if strings.HasPrefix(line,"***") { + head = line[3:] + continue + } + if strings.HasPrefix(line,"##") { + if title != "" { + out = append(out,data{title,keys,info}) + } + title = line[2:] + keys = nil + info = nil + }else{ + if line != "" { + da := strings.Split(line,"--") + keys = append(keys,da[0]) + info = append(info,da[1]) + } + } + } + + out = append(out,data{title,keys,info}) + return +} + -- cgit v1.2.3