RedoTo returns the action, action data, and state at the given index, returning nil if already at end of saved records.
(idx int)
| 266 | // RedoTo returns the action, action data, and state at the given index, |
| 267 | // returning nil if already at end of saved records. |
| 268 | func (us *Stack) RedoTo(idx int) (action, data string, state []string) { |
| 269 | us.Mu.Lock() |
| 270 | if idx >= len(us.Records)-1 || idx <= 0 { |
| 271 | us.Mu.Unlock() |
| 272 | return |
| 273 | } |
| 274 | us.Index = idx |
| 275 | rec := us.Records[idx] |
| 276 | action = rec.Action |
| 277 | data = rec.Data |
| 278 | state = us.RecState(idx + 1) |
| 279 | us.Mu.Unlock() |
| 280 | return |
| 281 | } |
| 282 | |
| 283 | // Reset resets the undo state |
| 284 | func (us *Stack) Reset() { |