2015-05-18 14:47:08 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2015-09-17 16:49:57 +00:00
|
|
|
|
2015-10-21 16:47:34 +00:00
|
|
|
"github.com/br0xen/termbox-util"
|
2015-05-18 14:47:08 +00:00
|
|
|
"github.com/nsf/termbox-go"
|
|
|
|
)
|
|
|
|
|
2015-09-17 16:49:57 +00:00
|
|
|
/*
|
|
|
|
Command is a struct for associating descriptions to keys
|
|
|
|
*/
|
2015-05-18 14:47:08 +00:00
|
|
|
type Command struct {
|
|
|
|
key string
|
|
|
|
description string
|
|
|
|
}
|
|
|
|
|
2015-09-17 16:49:57 +00:00
|
|
|
/*
|
|
|
|
AboutScreen is just a basic 'int' type that we can extend to make this screen
|
|
|
|
*/
|
2015-05-18 14:47:08 +00:00
|
|
|
type AboutScreen int
|
|
|
|
|
|
|
|
func drawCommandsAtPoint(commands []Command, x int, y int, style Style) {
|
2015-09-17 16:49:57 +00:00
|
|
|
xPos, yPos := x, y
|
2015-05-18 14:47:08 +00:00
|
|
|
for index, cmd := range commands {
|
2015-10-21 16:47:34 +00:00
|
|
|
termboxUtil.DrawStringAtPoint(fmt.Sprintf("%6s", cmd.key), xPos, yPos, style.defaultFg, style.defaultBg)
|
|
|
|
termboxUtil.DrawStringAtPoint(cmd.description, xPos+8, yPos, style.defaultFg, style.defaultBg)
|
2015-09-17 16:49:57 +00:00
|
|
|
yPos++
|
2015-05-18 14:47:08 +00:00
|
|
|
if index > 2 && index%2 == 1 {
|
2015-09-17 16:49:57 +00:00
|
|
|
yPos++
|
2015-05-18 14:47:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (screen *AboutScreen) handleKeyEvent(event termbox.Event) int {
|
2015-09-17 16:49:57 +00:00
|
|
|
return BrowserScreenIndex
|
2015-05-18 14:47:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (screen *AboutScreen) performLayout() {}
|
|
|
|
|
|
|
|
func (screen *AboutScreen) drawScreen(style Style) {
|
2015-09-17 16:49:57 +00:00
|
|
|
defaultFg := style.defaultFg
|
|
|
|
defaultBg := style.defaultBg
|
2015-05-18 14:47:08 +00:00
|
|
|
width, height := termbox.Size()
|
|
|
|
template := [...]string{
|
|
|
|
" _______ _______ ___ _______ _______ ______ _______ _ _ _______ _______ ______ ",
|
|
|
|
"| _ || || | | || _ || _ | | || | _ | || || || _ | ",
|
|
|
|
"| |_| || _ || | |_ _|| |_| || | || | _ || || || || _____|| ___|| | || ",
|
|
|
|
"| || | | || | | | | || |_||_ | | | || || |_____ | |___ | |_||_ ",
|
|
|
|
"| _ | | |_| || |___ | | | _ | | __ || |_| || ||_____ || ___|| __ |",
|
|
|
|
"| |_| || || || | | |_| || | | || || _ | _____| || |___ | | | |",
|
|
|
|
"|_______||_______||_______||___| |_______||___| |_||_______||__| |__||_______||_______||___| |_|",
|
|
|
|
}
|
2015-09-17 16:49:57 +00:00
|
|
|
if width < 100 {
|
|
|
|
template = [...]string{
|
|
|
|
" ____ ____ _ _____ ____ ____ ____ _ _ ____ ___ ____ ",
|
|
|
|
"| _ || || | | || _ || _ | | || | _ | || || || _ | ",
|
|
|
|
"| |_||| _ || | |_ _|| |_||| | || | _ || || || || ___|| _|| | || ",
|
|
|
|
"| ||| | || | | | | || |_|| || | || |||___ | |_ | |_||_ ",
|
|
|
|
"| _ |||_| || |___| | | _ || _ |||_| || ||__ || _|| __ |",
|
|
|
|
"| |_||| || | | | |_||| | | || || _ | __| || |_ | | | |",
|
|
|
|
"|____||____||_____|_| |____||_| |_||____||__| |__||____||___||_| |_|",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
firstLine := template[0]
|
|
|
|
startX := (width - len(firstLine)) / 2
|
|
|
|
//startX := (width - len(firstLine)) / 2
|
|
|
|
startY := ((height - 2*len(template)) / 2) - 2
|
|
|
|
xPos := startX
|
|
|
|
yPos := startY
|
2015-05-18 14:47:08 +00:00
|
|
|
if height <= 20 {
|
|
|
|
title := "BoltBrowser"
|
2015-09-17 16:49:57 +00:00
|
|
|
startY = 0
|
|
|
|
yPos = 0
|
2015-10-21 16:47:34 +00:00
|
|
|
termboxUtil.DrawStringAtPoint(title, (width-len(title))/2, startY, style.titleFg, style.titleBg)
|
2015-05-18 14:47:08 +00:00
|
|
|
} else {
|
|
|
|
if height < 25 {
|
2015-09-17 16:49:57 +00:00
|
|
|
startY = 0
|
|
|
|
yPos = 0
|
2015-05-18 14:47:08 +00:00
|
|
|
}
|
|
|
|
for _, line := range template {
|
2015-09-17 16:49:57 +00:00
|
|
|
xPos = startX
|
2015-05-18 14:47:08 +00:00
|
|
|
for _, runeValue := range line {
|
2015-09-17 16:49:57 +00:00
|
|
|
bg := defaultBg
|
2015-05-18 14:47:08 +00:00
|
|
|
displayRune := ' '
|
|
|
|
if runeValue != ' ' {
|
|
|
|
//bg = termbox.Attribute(125)
|
|
|
|
displayRune = runeValue
|
2015-09-17 16:49:57 +00:00
|
|
|
termbox.SetCell(xPos, yPos, displayRune, defaultFg, bg)
|
2015-05-18 14:47:08 +00:00
|
|
|
}
|
2015-09-17 16:49:57 +00:00
|
|
|
xPos++
|
2015-05-18 14:47:08 +00:00
|
|
|
}
|
2015-09-17 16:49:57 +00:00
|
|
|
yPos++
|
2015-05-18 14:47:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
commands1 := [...]Command{
|
|
|
|
{"h,←", "close parent"},
|
|
|
|
{"j,↓", "down"},
|
|
|
|
{"k,↑", "up"},
|
|
|
|
{"l,→", "open item"},
|
|
|
|
|
|
|
|
{"g", "goto top"},
|
|
|
|
{"G", "goto bottom"},
|
|
|
|
{"ctrl+f", "jump down"},
|
|
|
|
{"ctrl+b", "jump up"},
|
|
|
|
}
|
|
|
|
|
|
|
|
commands2 := [...]Command{
|
|
|
|
{"p,P", "create pair/at parent"},
|
|
|
|
{"b,B", "create bucket/at parent"},
|
|
|
|
{"e", "edit value of pair"},
|
|
|
|
{"r", "rename pair/bucket"},
|
|
|
|
{"d", "delete item"},
|
|
|
|
|
|
|
|
{"?", "this screen"},
|
|
|
|
{"q", "quit program"},
|
|
|
|
}
|
2015-09-17 16:49:57 +00:00
|
|
|
xPos = startX // + 20
|
|
|
|
yPos++
|
2015-05-18 14:47:08 +00:00
|
|
|
|
2015-09-17 16:49:57 +00:00
|
|
|
drawCommandsAtPoint(commands1[:], xPos, yPos+1, style)
|
|
|
|
drawCommandsAtPoint(commands2[:], xPos+20, yPos+1, style)
|
|
|
|
exitTxt := "Press any key to return to browser"
|
2015-10-21 16:47:34 +00:00
|
|
|
termboxUtil.DrawStringAtPoint(exitTxt, (width-len(exitTxt))/2, height-1, style.titleFg, style.titleBg)
|
2015-05-18 14:47:08 +00:00
|
|
|
}
|