diff options
| author | Nikolaus Gotsche <n@softwarefools.com> | 2019-01-28 04:07:50 +0100 |
|---|---|---|
| committer | Nikolaus Gotsche <n@softwarefools.com> | 2019-01-28 04:07:50 +0100 |
| commit | d02a8cb49104817621555545ee31ac5069ead0b4 (patch) | |
| tree | ef31e25edb719adf5590f53457c0dd93801dc531 | |
| parent | dc2a043f75de7fbdb9b04f88269c699acf06e8c7 (diff) | |
Timer, Parameters and nice example0.4
| -rw-r--r-- | example.cheat | 31 | ||||
| -rw-r--r-- | example.txt | 64 | ||||
| -rw-r--r-- | main.go | 80 | ||||
| -rw-r--r-- | nucuwin.go | 4 |
4 files changed, 81 insertions, 98 deletions
diff --git a/example.cheat b/example.cheat new file mode 100644 index 0000000..420874c --- /dev/null +++ b/example.cheat @@ -0,0 +1,31 @@ +***Title + +***Additional Titles will override the first + +Some Text that is not part of a Category +All Texts without any seperators will be shown centered. Wrapping is not yet implemented. +The User should edit newlines +If he wishes everything to be displayed without scrolling. + +##Category Title 1 +Again some Leading Text that describes the category. +Some Info -- Description +Some Command -- And its desricption + Tabs are -- Filtered out + Info -- And description always alligned to center + +##Category Title 2 +Lists -- + -- Can Be + -- Made with + -- empty Infos +As long as no Seperators are present text will be displayed in one Row + +##Some Unix Commands +An example of what Fenestra is intended to show + +mkdir <name> -- Make a Directory called <name> +rm -r <name> -- Remove a directory <name> recursivly +touch <filename> -- Create an empty file named <filename> + +//Comments and Empty Lines are Ignored diff --git a/example.txt b/example.txt deleted file mode 100644 index 80f0b3a..0000000 --- a/example.txt +++ /dev/null @@ -1,64 +0,0 @@ -***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 -<Win> - F -- Launch Nautilus -<Win><Shift> - <Enter> -- Launch Terminal -<Win><Shift> - C -- Kill Focused Window - -##Layout -<Win> - <Space> -- Rotate through Layouts -<Win><Shift> - <Space> -- Reset Layout of Current Workspace -<Win> - N -- Resize Window to Correct size -<Win> - B -- Toggle Strouts (Fullestscreen) -<Win><Ctrl> - B -- Toggle StatBar -<Win> - H -- Shrink Master Area -<Win> - L -- Expand Master Area -<Win> - T -- Push Floater back to Tiling -<Win> - <Left Mouse> -- Make Window Float and Move -<Win> - <Right Mouse> -- Make Window Float and Resize -<Win> - , -- Increase Windows in Master Area -<Win> - . -- Decrease Windows in Master Area -<Win> - A -- Mirror Shrink -<Win> - Y -- Mirror Expand - -##Focus and Order -<Win> - <Tab> -- Focus on Next Window -<Win><Shift> - <Tab> -- Focus on Previous Window -<Win> - J -- Focus on Next Window -<Win> - K -- Focus on Previous Window -<Win> - M -- Focus on Master Window -<Win><Shift> - J -- Swap Focused Window with Next -<Win><Shift> - K -- Swap Focused Window with Previous -<Win><Return> -- Swap Focused with Master -<Win> - U -- Focus on Urgent Window - -##Workspaces & Screens -<Win> [1-0,-,+] -- Switch to Workspace N -<Win><Shift> [1-0,-,+] -- Move Window to Workspace N -<Win> [w,e,r] -- Switch to Screen 1,2 or 3 -<Win><Shift> [w,e,r] -- Move Window to Screen 1,2 or 3 -<Win> [Arrow Keys] -- Move on Workspace Pattern -<Win> - D -- Toggle Single and Multiscreen - -##Login -<Win> - Q -- Reload Xmonad -<Win> - Ö -- Lock Screen -<Win><Shift> - Q -- Quit Xmonad and Logout User - -##System -<Print> -- Screenshot of current Workspace -<Win> - <Print> -- Screenshot of All Workspaces -<Win><Ctrl> - <Print> -- Screenshot of current Window -<Win> - Ä -- Display this Help - -//Comments and Empty Lines are Ignored @@ -20,12 +20,13 @@ var ( Wnd nucular.MasterWindow theme nstyle.Theme = nstyle.DarkTheme dat []data - interArgs []string + interArgs,empty []string hea,filename,themestr,exitbut string help, border, resize, move, scroll, menubar bool countd int = 0 version string compdate string + //timer time.Timer ) type data struct { @@ -35,7 +36,7 @@ type data struct { } func init() { - filename = "example.txt" + filename = "example.cheat" exitbut = "QUIT" getopt.FlagLong(&border, "no-border", 'b', "Remove Borders") getopt.FlagLong(&resize, "no-resize", 'r', "Prohibit resizing") @@ -52,6 +53,17 @@ func init() { } func main() { + + //timer := time.NewTimer(time.Second*time.Duration(countd*1000)) + //defer timer.Stop() + go func() { + //<-timer.C + time.Sleep(time.Duration(countd)*time.Second) + if countd>0 { + fmt.Println("Timer of",countd,"s has Ended") + os.Exit(0) + } + }() info, err := os.Stdin.Stat() if err != nil { panic(err) @@ -59,50 +71,43 @@ func main() { getopt.Parse() interArgs = getopt.Args() + additions := false border = !border resize = !resize move = !move scroll = !scroll menubar = !menubar - fmt.Println(info) - - if info.Mode()&os.ModeCharDevice == os.ModeCharDevice { // || info.Size() <= 0 { - fmt.Println("No Piped Content detected.") - hea,dat = parseFile(loadFile(filename)) - }else{ - hea,dat = parseFile(bufio.NewScanner(os.Stdin)) + //fmt.Println(info) - /*reader := bufio.NewReader(os.Stdin) - var output []rune - - for { - input, _, err := reader.ReadRune() - if err != nil && err == io.EOF { - break - } - output = append(output, input) - } - for _,out := range(output) { - fmt.Printf("%c\n", out) - }*/ - } if len(interArgs) > 0 { - fmt.Println("Args:",interArgs) + //fmt.Println("Unknown Arguments:",interArgs) + additions = true } else { - fmt.Println("No Args") + /*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) + fmt.Println("magn",scaling)*/ + } + if info.Mode()&os.ModeCharDevice == os.ModeCharDevice { + //fmt.Println("No Piped Content detected.") + if additions && filename=="example.cheat"{ + empty = append(empty,"") + var one []string + txt := strings.TrimPrefix(fmt.Sprintln(interArgs),"[") + one = append(one,txt[:len(txt)-2]) + dat = append(dat,data{"",one,empty}) + }else{ + hea,dat = parseFile(loadFile(filename)) + } + }else{ + hea,dat = parseFile(bufio.NewScanner(os.Stdin)) } 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) + showHelp() } //hea,dat = loadfile(filename) @@ -114,12 +119,23 @@ func main() { Wnd.Main() } +func showHelp() { + fmt.Printf("Usage of %s Version %s:\n A simple and Customizable Cheatsheet viewer.\n When No Text is piped and no File specified the Parameters\n will be shown as Text.\n\n", os.Args[0], version) + + getopt.Usage() + os.Exit(0) +} func loadFile(filename string) (out *bufio.Scanner) { f, err := os.Open(filename) if err != nil { + if filename=="example.cheat" { + fmt.Println("Example File cannot be Found") + showHelp() + }else{ //fmt.Println("Filename",filename,"was not found!") - fmt.Println(err) - os.Exit(1) + fmt.Println(err) + os.Exit(1) + } } out = bufio.NewScanner(f) return @@ -111,9 +111,9 @@ func (nw *fenestraWindow) masterWindow(w *nucular.Window) { w.TreePop() } } - w.Row(30).Static(300, 100, 100) + w.RowScaled(30).Dynamic(3) //.Static(300, 100, 100) w.Label("", "LC") - if w.ButtonText("Exit") { + if w.ButtonText(exitbut) { os.Exit(0) } } |
