我知道有很多关于撤消/重做文本类型编辑器的信息,我已经阅读了相当多的信息,但仍然缺乏对如何将其应用到我的代码的理解。
我使用链表来保存句子的第一部分,输入第一部分后的每个单词都可以添加、删除、撤消或重做到链表中。
在我理解的添加过程中推送命令和单词,我理解的撤消和重做操作。
当我执行添加或删除命令时,重做堆栈为空。
我不明白的是如何将要从列表中删除的命令和数据推送到撤消堆栈上。
我正在使用的代码片段如下:
case "delete"://removes linked list node with the string specified on undo stack.
if(!undo.isEmpty()){
undo.topAndPop();//removes the previous command/choice off the undo stack.
temp = undo.top();//reads the data on the next stack segment after the command is gone.
readme.listRemove(temp);//removes the data from the linked list.
undo.pop();//removes the tos data
redo.makeEmpty();//empties redo stack.
}else break;
break;