okami.mom/albedo
git clone https://git.nkp.pet/okami.mom/albedo
8499f48
main
1package tui 2 3import "slices" 4 5type Notice struct { 6Message string 7Error bool 8} 9 10type Notices []Notice 11 12func (ns * Notices )Add (msg string ,isErr bool )bool { 13if msg == "" || slices .Contains (* ns ,Notice {msg ,isErr }) { 14return false 15 } 16* ns = append (* ns ,Notice {Message :msg ,Error :isErr }) 17return true 18} 19 20func (ns * Notices )AddNotice (msg string )bool {return ns .Add (msg ,false ) } 21func (ns * Notices )AddError (msg string )bool {return ns .Add (msg ,true ) } 22func (ns * Notices )Clear () {* ns = nil } 23 24func (ns Notices )HasError ()bool { 25return slices .ContainsFunc (ns ,func (n Notice )bool {return n .Error }) 26} 27 28func (ns Notices )ChromeRows ()int { 29if len (ns )== 0 { 30return 0 31 } 32return len (ns )+ 1 33}