Archive/Unarchive
Several other improvements
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/br0xen/termbox-util"
|
||||
@@ -9,13 +10,48 @@ import (
|
||||
|
||||
// AboutScreen holds all that's going on
|
||||
type AboutScreen struct {
|
||||
viewPort *ViewPort
|
||||
viewPort ViewPort
|
||||
message string
|
||||
messageTimeout time.Duration
|
||||
messageTime time.Time
|
||||
|
||||
titleTemplate []string
|
||||
commandsCol1 []Command
|
||||
commandsCol2 []Command
|
||||
}
|
||||
|
||||
type Command struct {
|
||||
key string
|
||||
description string
|
||||
}
|
||||
|
||||
func (screen *AboutScreen) initialize(bundle Bundle) error {
|
||||
screen.titleTemplate = []string{
|
||||
" __ ",
|
||||
" _________ _____| | __",
|
||||
" / ___\\__ \\ / ___/ |/ /",
|
||||
" / /_/ > __ \\_\\___ \\| < ",
|
||||
" \\___ (____ /____ >__|_ \\",
|
||||
"/_____/ \\/ \\/ \\/",
|
||||
}
|
||||
|
||||
screen.commandsCol1 = []Command{
|
||||
Command{"j,↓", "down"},
|
||||
Command{"k,↑", "up"},
|
||||
Command{"l,→", "open task"},
|
||||
Command{"g", "goto top"},
|
||||
Command{"G", "goto bottom"},
|
||||
Command{"ctrl+f", "jump down"},
|
||||
Command{"ctrl+b", "jump up"},
|
||||
}
|
||||
screen.commandsCol2 = []Command{
|
||||
Command{"r", "rename pair/bucket"},
|
||||
Command{"D", "move task to done.txt"},
|
||||
Command{"x,X", "export as string/json to file"},
|
||||
Command{"?", "this screen"},
|
||||
Command{"q", "quit program"},
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -25,6 +61,36 @@ func (screen *AboutScreen) handleKeyEvent(event termbox.Event) int {
|
||||
|
||||
func (screen *AboutScreen) drawScreen() {
|
||||
width, height := termbox.Size()
|
||||
exitTxt := "Press any key to return to tasks"
|
||||
xPos := (width - len(screen.titleTemplate[0])) / 2
|
||||
yPos := 1
|
||||
for _, line := range screen.titleTemplate {
|
||||
termboxUtil.DrawStringAtPoint(line, xPos, yPos, DefaultFg, DefaultBg)
|
||||
yPos++
|
||||
}
|
||||
|
||||
numCols := 2
|
||||
if width < 80 {
|
||||
numCols = 1
|
||||
}
|
||||
col1XPos := (width - (width * 3 / 4))
|
||||
col2XPos := (width - (width * 2 / 4))
|
||||
if numCols == 1 {
|
||||
col2XPos = col1XPos
|
||||
}
|
||||
screen.drawCommandsAtPoint(screen.commandsCol1, col1XPos, yPos)
|
||||
screen.drawCommandsAtPoint(screen.commandsCol2, col2XPos, yPos)
|
||||
exitTxt := "Press any key to return to tasks " + fmt.Sprintf("%d", width)
|
||||
termboxUtil.DrawStringAtPoint(exitTxt, (width-len(exitTxt))/2, height-1, TitleFg, TitleBg)
|
||||
}
|
||||
|
||||
func (screen *AboutScreen) drawCommandsAtPoint(commands []Command, x, y int) {
|
||||
xPos, yPos := x, y
|
||||
for index, cmd := range commands {
|
||||
termboxUtil.DrawStringAtPoint(fmt.Sprintf("%6s", cmd.key), xPos, yPos, DefaultFg, DefaultBg)
|
||||
termboxUtil.DrawStringAtPoint(cmd.description, xPos+8, yPos, DefaultFg, DefaultBg)
|
||||
yPos++
|
||||
if index > 2 && index%2 == 1 {
|
||||
yPos++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user