Testing a scroll frame
This commit is contained in:
parent
031e6645c1
commit
c0494c8d3a
@ -30,6 +30,7 @@ type mainScreen struct {
|
||||
battStat *termboxUtil.ProgressBar
|
||||
notepad *termboxUtil.InputField
|
||||
db *boltrest.DB
|
||||
scrollFrame *termboxUtil.ScrollFrame
|
||||
}
|
||||
|
||||
func (screen *mainScreen) handleKeyPress(event termbox.Event) int {
|
||||
@ -48,6 +49,14 @@ func (screen *mainScreen) handleKeyPress(event termbox.Event) int {
|
||||
screen.refreshData()
|
||||
} else if event.Ch == 'q' {
|
||||
return exitScreenIndex
|
||||
} else if event.Key == termbox.KeyArrowUp {
|
||||
screen.scrollFrame.ScrollUp()
|
||||
} else if event.Key == termbox.KeyArrowRight {
|
||||
screen.scrollFrame.ScrollRight()
|
||||
} else if event.Key == termbox.KeyArrowDown {
|
||||
screen.scrollFrame.ScrollDown()
|
||||
} else if event.Key == termbox.KeyArrowLeft {
|
||||
screen.scrollFrame.ScrollLeft()
|
||||
}
|
||||
case tabNotepad:
|
||||
// Notepad key handling
|
||||
@ -91,6 +100,31 @@ func (screen *mainScreen) performLayout(style style) {
|
||||
screen.notepad.SetMultiline(true)
|
||||
// TODO: Load saved notepad data
|
||||
|
||||
screen.scrollFrame = termboxUtil.CreateScrollFrame((w / 2), 4, 5, 5, style.defaultFg, style.defaultBg)
|
||||
//screen.scrollFrame = termboxUtil.CreateScrollFrame((w / 2), 4, (w / 2), (h / 2), style.defaultFg, style.defaultBg)
|
||||
var aa []string
|
||||
aa = append(aa, "1234567890123456789012345678901234567890")
|
||||
aa = append(aa, "2345678901234567890123456789012345678901")
|
||||
aa = append(aa, "3456789012345678901234567890123456789012")
|
||||
aa = append(aa, "4567890123456789012345678901234567890123")
|
||||
aa = append(aa, "5678901234567890123456789012345678901234")
|
||||
aa = append(aa, "6789012345678901234567890123456789012345")
|
||||
aa = append(aa, "7890123456789012345678901234567890123456")
|
||||
aa = append(aa, "8901234567890123456789012345678901234567")
|
||||
aa = append(aa, "9012345678901234567890123456789012345678")
|
||||
aa = append(aa, "0123456789012345678901234567890123456789")
|
||||
aa = append(aa, "1234567890123456789012345678901234567890")
|
||||
aa = append(aa, "2345678901234567890123456789012345678901")
|
||||
aa = append(aa, "3456789012345678901234567890123456789012")
|
||||
aa = append(aa, "4567890123456789012345678901234567890123")
|
||||
aa = append(aa, "5678901234567890123456789012345678901234")
|
||||
aa = append(aa, "6789012345678901234567890123456789012345")
|
||||
aa = append(aa, "7890123456789012345678901234567890123456")
|
||||
aa = append(aa, "8901234567890123456789012345678901234567")
|
||||
aa = append(aa, "9012345678901234567890123456789012345678")
|
||||
aa = append(aa, "0123456789012345678901234567890123456789")
|
||||
screen.scrollFrame.AddControl(termboxUtil.CreateASCIIArt(aa, 1, 1, style.defaultFg, style.defaultBg))
|
||||
|
||||
screen.refreshData()
|
||||
}
|
||||
if time.Since(time.Now()) <= time.Minute {
|
||||
@ -136,6 +170,7 @@ func (screen *mainScreen) drawScreen(style style) {
|
||||
termboxUtil.DrawStringAtPoint("Notes", screen.notepad.GetX(), screen.notepad.GetY()-1, fg, bg)
|
||||
fg, bg = style.defaultFg, style.defaultBg
|
||||
screen.notepad.Draw()
|
||||
screen.scrollFrame.Draw()
|
||||
}
|
||||
|
||||
func getBatteryPct() int {
|
||||
|
Loading…
Reference in New Issue
Block a user