func Database(w *draw.Window, root *database.Folder, statusCh chan string) Screen { return &DatabaseScreen{ Title: fmt.Sprintf("Password Database"), Window: w, Root: root, StatusChannel: statusCh, ParentColumn: w.NewWindow(0, 0, 18, w.Height), CurrentColumn: w.NewWindow(19, 0, 32, w.Height), NextColumn: w.NewWindow(52, 0, 32, w.Height), } }
func (scr *DatabaseScreen) renderFolder(w *draw.Window, folder *database.Folder, highlight int) { w.Clear() y := 0 items := folder.Items() // TODO: Paginate for i := range items { fg := termbox.ColorDefault bg := termbox.ColorDefault if items[i].Type() == database.Entry_Folder { fg = termbox.ColorCyan } if highlight != -1 && y == highlight { fg = fg | termbox.AttrReverse bg = bg | termbox.AttrReverse w.Fill(0, y, w.Width, 1, termbox.Cell{Bg: bg, Fg: fg}) } else { w.Fill(0, y, w.Width, 1, termbox.Cell{Bg: bg, Fg: fg}) } w.Print(0, y, fg, bg, items[i].GetName()) y = y + 1 } }
func (scr *DatabaseScreen) renderAccount(w *draw.Window, account *database.Account) { w.Print(0, 0, termbox.ColorDefault, termbox.ColorDefault, fmt.Sprintf("Username: %s", account.AccountName)) w.Print(0, 1, termbox.ColorDefault, termbox.ColorDefault, fmt.Sprintf("URL: %s", account.URL)) w.Print(0, 2, termbox.ColorDefault, termbox.ColorDefault, "Password: ••••••••") }