z_mirror/pesticide
git clone https://git.raiguard.me/z_mirror/pesticide
8be16be
trunk
1package ui 2 3type CommandHistory struct { 4history []string 5pos int 6} 7 8func NewCommandHistory ()CommandHistory { 9return CommandHistory { 10history : []string {}, 11pos :0 , 12 } 13} 14 15func (c * CommandHistory )Append (item string ) { 16c .history = append (c .history ,item ) 17c .pos = len (c .history ) 18} 19 20func (c * CommandHistory )Up () { 21if c .pos == 0 { 22return 23 } 24c .pos -- 25} 26 27func (c * CommandHistory )Down () { 28if c .pos > len (c .history )- 1 { 29return 30 } 31c .pos ++ 32} 33 34func (c * CommandHistory )Get ()string { 35if c .pos > len (c .history )- 1 { 36return "" 37 } 38return c .history [c .pos ] 39}