Undo the first event in the undo stack. Returns false if the stack is empty.
()
| 255 | |
| 256 | // Undo the first event in the undo stack. Returns false if the stack is empty. |
| 257 | func (eh *EventHandler) Undo() bool { |
| 258 | t := eh.UndoStack.Peek() |
| 259 | if t == nil { |
| 260 | return false |
| 261 | } |
| 262 | |
| 263 | startTime := t.Time.UnixNano() / int64(time.Millisecond) |
| 264 | endTime := startTime - (startTime % undoThreshold) |
| 265 | |
| 266 | for { |
| 267 | t = eh.UndoStack.Peek() |
| 268 | if t == nil { |
| 269 | break |
| 270 | } |
| 271 | |
| 272 | if t.Time.UnixNano()/int64(time.Millisecond) < endTime { |
| 273 | break |
| 274 | } |
| 275 | |
| 276 | eh.UndoOneEvent() |
| 277 | } |
| 278 | return true |
| 279 | } |
| 280 | |
| 281 | // UndoOneEvent undoes one event |
| 282 | func (eh *EventHandler) UndoOneEvent() { |
nothing calls this directly
no test coverage detected