summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data.txt8
-rw-r--r--main.go68
-rw-r--r--makefile24
-rw-r--r--nucuwin.go85
4 files changed, 147 insertions, 38 deletions
diff --git a/data.txt b/data.txt
index 9754f16..80f0b3a 100644
--- a/data.txt
+++ b/data.txt
@@ -1,5 +1,13 @@
***XMonad Cheatsheet
+This Text is not to be seen???
+Und Nochmehr TExt der immer Zentriert wird. Schuamamal wie lange es klappt es sollte vll ein Wrap LAbel sein.
+##NAAASUPER
+Schaumamal ob jetzt der text erkannt wird
+--some list
+ --or some other ideas
+ WTF--naschau
+
##Launching and Killing
<Win> - P -- Launch Dmenu
<Win> - S -- Launch Synergy
diff --git a/main.go b/main.go
index a1a2eb8..bfca0df 100644
--- a/main.go
+++ b/main.go
@@ -1,11 +1,13 @@
package main
import (
- //"fmt"
+ "fmt"
"os"
"bufio"
"strings"
+ "github.com/pborman/getopt/v2"
+
"github.com/aarzilli/nucular"
_"github.com/aarzilli/nucular/label"
nstyle "github.com/aarzilli/nucular/style"
@@ -16,7 +18,12 @@ var (
Wnd nucular.MasterWindow
theme nstyle.Theme = nstyle.DarkTheme
dat []data
- hea string
+ interArgs []string
+ hea,filename,themestr string
+ help, border, resize, move, scroll, menubar bool
+
+ version string
+ compdate string
)
type data struct {
@@ -25,15 +32,53 @@ type data struct {
textr []string
}
+func init() {
+ filename = "none"
+ getopt.FlagLong(&border, "no-border", 'b', "Remove Borders")
+ getopt.FlagLong(&resize, "no-resize", 'r', "Prohibit resizing")
+ getopt.FlagLong(&move, "no-translate", 't', "Prohibit window moving")
+ getopt.FlagLong(&scroll, "no-scroll", 's', "Prohibit scrollibars")
+ getopt.FlagLong(&menubar, "no-menu", 'm', "Dont Show Menu")
+ getopt.FlagLong(&scaling, "magnify", 'g', "Magnification level")
+ getopt.FlagLong(&themestr, "color-theme", 'c', "Specify Theme")
+ getopt.FlagLong(&help, "help", 'h', "Show Program Usage")
+ getopt.FlagLong(&filename, "file", 'f', "The textfile to be parsed and displayed")
+
+}
func main() {
+ getopt.Parse()
+ interArgs = getopt.Args()
+
+ border = !border
+ resize = !resize
+ move = !move
+ scroll = !scroll
+ menubar = !menubar
+ if len(interArgs) > 0 {
+ fmt.Println("Args:",interArgs)
+ } else {
+ fmt.Println("No Args")
+ fmt.Println("Border",border)
+ fmt.Println("Resize",resize)
+ fmt.Println("Translate",move)
+ fmt.Println("Scroll",scroll)
+ fmt.Println("Menubar",menubar)
+ fmt.Println("magn",scaling)
+ }
+ if help {
+ fmt.Printf("Usage of %s Version %s:\n A simple and Customizable Cheatsheet viewer.\n\n", os.Args[0], version)
+
+ getopt.Usage()
+ os.Exit(0)
+ }
hea,dat = loadfile("data.txt")
- nw := newNucularWindow()
+ nw := newFenestraWindow()
nw.Theme = theme
- Wnd = nucular.NewMasterWindow(0,hea, nw.nucularWindow)
+ Wnd = nucular.NewMasterWindow(0,hea, nw.masterWindow)
Wnd.SetStyle(nstyle.FromTheme(theme, scaling))
Wnd.Main()
@@ -56,17 +101,22 @@ func loadfile(filename string) (head string,out []data){
continue
}
if strings.HasPrefix(line,"##") {
- if title != "" {
+ //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])
+ if strings.Contains(line, "--"){
+ da := strings.Split(line,"--")
+ keys = append(keys,da[0])
+ info = append(info,da[1])
+ }else{
+ keys = append(keys,line)
+ info = append(info,"")
+ }
}
}
}
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..d3e2e3c
--- /dev/null
+++ b/makefile
@@ -0,0 +1,24 @@
+version=$(shell git tag --points-at HEAD)
+date=$(shell date "+%b %Y")
+name=fenestra
+.PHONY: all
+
+all:
+ @echo " make <cmd>"
+ @echo ""
+ @echo "Commands:"
+ @echo " build - runs go build with ldflags version=${version} & date=${date}"
+ @echo " fetch_stuff - installs all needed libaries"
+ @echo ""
+
+
+build: clean
+ @go build -v -ldflags '-X "main.version=${version}" -X "main.compdate=${date}"' -o ${name}
+
+clean:
+ @rm -f ${name}
+
+fetch_stuff:
+ @go get -u github.com/aarzilli/nucular
+ @go get -u github.com/pborman/getopt/v2
+ @echo "All nessecary libaries installed"
diff --git a/nucuwin.go b/nucuwin.go
index 3cde330..7802910 100644
--- a/nucuwin.go
+++ b/nucuwin.go
@@ -16,49 +16,49 @@ import (
)
-type nucularWindow struct {
+type fenestraWindow struct {
ShowMenu bool
Titlebar bool
Border bool
Resize bool
Movable bool
NoScrollbar bool
- Minimizable bool
+ //Minimizable bool
Close bool
HeaderAlign nstyle.HeaderAlign
// Menu status
- Mprog int
- Mslider int
- Mcheck bool
- Prog int
- Slider int
- Check bool
+ //Mprog int
+ //Mslider int
+ //Mcheck bool
+ //Prog int
+ //Slider int
+ //Check bool
Theme nstyle.Theme
}
-func newNucularWindow() (nw *nucularWindow) {
- nw = &nucularWindow{}
- nw.ShowMenu = true
+func newFenestraWindow() (nw *fenestraWindow) {
+ nw = &fenestraWindow{}
+ nw.ShowMenu = menubar
nw.Titlebar = true
- nw.Border = true
- nw.Resize = true
- nw.Movable = true
- nw.NoScrollbar = false
+ nw.Border = border
+ nw.Resize = resize
+ nw.Movable = move
+ nw.NoScrollbar = scroll
nw.Close = true
nw.HeaderAlign = nstyle.HeaderRight
- nw.Mprog = 60
- nw.Mslider = 8
- nw.Mcheck = true
+ //nw.Mprog = 60
+ //nw.Mslider = 8
+ //nw.Mcheck = true
return nw
}
// Master Window
-func (nw *nucularWindow) nucularWindow(w *nucular.Window) {
+func (nw *fenestraWindow) masterWindow(w *nucular.Window) {
//keybindings(w)
mw := w.Master()
@@ -71,14 +71,41 @@ func (nw *nucularWindow) nucularWindow(w *nucular.Window) {
w.Label(hea,"CC")
//w.Spacing(2)
for _,d := range(dat) {
- if w.TreePush(nucular.TreeTab, d.title, true) {
- w.Row(20).Dynamic(2)
+ if d.title == "" {
+ for i,_ := range(d.textl){
+ if d.textr[i]==""{
+ w.RowScaled(25).Dynamic(1)
+ w.Label(d.textl[i],"CC")
+ }else if d.textl[i]==""{
+ w.RowScaled(20).Dynamic(2)
+ w.Label("*)", "RC")
+ w.Label(d.textr[i], "LC")
+ }else{
+ w.RowScaled(20).Dynamic(2)
+ w.Label(d.textl[i], "RC")
+ w.Label(d.textr[i], "LC")
+ }
+ }
+ }else if w.TreePush(nucular.TreeTab, d.title, true) {
+ //w.RowScaled(20).Dynamic(2)
//w.Row(20).Dynamic(3)
//w.Row(20).Static(100)
for i,_ := range(d.textl){
- w.Label(d.textl[i], "RC")
- w.Label(d.textr[i], "LC")
+ // w.Label(d.textl[i], "RC")
+ // w.Label(d.textr[i], "LC")
//w.Label("", "LC")
+ if d.textr[i]==""{
+ w.RowScaled(25).Dynamic(1)
+ w.Label(d.textl[i],"CC")
+ }else if d.textl[i]==""{
+ w.RowScaled(20).Dynamic(2)
+ w.Label("*)", "RC")
+ w.Label(d.textr[i], "LC")
+ }else{
+ w.RowScaled(20).Dynamic(2)
+ w.Label(d.textl[i], "RC")
+ w.Label(d.textr[i], "LC")
+ }
}
w.TreePop()
@@ -92,7 +119,7 @@ func (nw *nucularWindow) nucularWindow(w *nucular.Window) {
}
-func (nw *nucularWindow) nucularMenubar(w *nucular.Window) {
+func (nw *fenestraWindow) nucularMenubar(w *nucular.Window) {
w.MenubarBegin()
w.Row(25).Static(45, 70, 45, 70, 70)
if w := w.Menu(label.TA("Menu", "CC"), 120, nil); w != nil {
@@ -134,7 +161,7 @@ func (nw *nucularWindow) nucularMenubar(w *nucular.Window) {
w.MenubarEnd()
}
-func (nw *nucularWindow) errorPopup(w *nucular.Window) {
+func (nw *fenestraWindow) errorPopup(w *nucular.Window) {
w.Row(25).Dynamic(1)
w.Label("A terrible error has occured", "LC")
w.Row(25).Dynamic(2)
@@ -146,7 +173,7 @@ func (nw *nucularWindow) errorPopup(w *nucular.Window) {
}
}
-func (nw *nucularWindow) questionPopup(w *nucular.Window) {
+func (nw *fenestraWindow) questionPopup(w *nucular.Window) {
w.Row(25).Dynamic(1)
w.Label("Are You Sure?", "LC")
w.Row(25).Dynamic(2)
@@ -158,7 +185,7 @@ func (nw *nucularWindow) questionPopup(w *nucular.Window) {
}
}
-func (nw *nucularWindow) aboutPopup(w *nucular.Window) {
+func (nw *fenestraWindow) aboutPopup(w *nucular.Window) {
w.Row(20).Dynamic(1)
w.Label("Fenestra", "LC")
w.Row(40).Dynamic(1)
@@ -172,7 +199,7 @@ func (nw *nucularWindow) aboutPopup(w *nucular.Window) {
}
}
-func (nw *nucularWindow) showAppAbout(mw nucular.MasterWindow) {
+func (nw *fenestraWindow) showAppAbout(mw nucular.MasterWindow) {
var wf nucular.WindowFlags
if nw.Border {
@@ -196,7 +223,7 @@ func (nw *nucularWindow) showAppAbout(mw nucular.MasterWindow) {
mw.PopupOpen("About", wf, rect.Rect{20, 100, 300, 190}, true, nw.aboutPopup)
}
-func (nw *nucularWindow) showQuestion(mw nucular.MasterWindow) {
+func (nw *fenestraWindow) showQuestion(mw nucular.MasterWindow) {
var wf nucular.WindowFlags
if nw.Border {