@@ -120,37 +120,44 @@ namespace dp { namespace undo { namespace bugs {
120120}}} // namespace dp::undo::bugs
121121
122122void test_undo_sys () {
123- using namespace dp ::undo::test;
124- using namespace dp ::undo::bugs;
125-
126- using State = std::string;
127- using M = undo_cxx::undoable_cmd_system_t <State>;
128- using UndoCmdT = UndoCmd<State>;
129- using RedoCmdT = RedoCmd<State>;
130- using FontStyleCmdT = FontStyleCmd<State>;
131-
132- M undoable_cmd_system;
133-
134- // do some stuffs
135-
136- undoable_cmd_system.invoke <FontStyleCmdT>(" italic state1" );
137- undoable_cmd_system.invoke <FontStyleCmdT>(" italic-bold state2" );
138- undoable_cmd_system.invoke <FontStyleCmdT>(" underline state3" );
139- undoable_cmd_system.invoke <FontStyleCmdT>(" italic state4" );
140-
141- // and try to undo or redo
142-
143- undoable_cmd_system.invoke <UndoCmdT>(" undo 1" );
144- undoable_cmd_system.invoke <UndoCmdT>(" undo 2" );
145- undoable_cmd_system.invoke <RedoCmdT>(" redo 1" );
146- undoable_cmd_system.invoke <UndoCmdT>(" undo 3" );
147- undoable_cmd_system.invoke <UndoCmdT>(" undo 4" );
123+ using namespace dp ::undo::test;
124+ using namespace dp ::undo::bugs;
125+
126+ using State = std::string;
127+ using M = undo_cxx::undoable_cmd_system_t <State>;
128+ using UndoCmdT = UndoCmd<State>;
129+ using RedoCmdT = RedoCmd<State>;
130+ using FontStyleCmdT = FontStyleCmd<State>;
131+
132+ M undoable_cmd_system;
133+
134+ // do some stuffs
135+
136+ undoable_cmd_system.invoke <FontStyleCmdT>(" italic state1" );
137+ std::cout << " > newest item: " << *undoable_cmd_system.newest_item () << ' \n ' ;
138+ undoable_cmd_system.invoke <FontStyleCmdT>(" italic-bold state2" );
139+ undoable_cmd_system.invoke <FontStyleCmdT>(" underline state3" );
140+ undoable_cmd_system.invoke <FontStyleCmdT>(" italic state4" );
141+ std::cout << " > newest item: " << *undoable_cmd_system.newest_item () << ' \n ' ;
142+
143+ // and try to undo or redo
144+
145+ undoable_cmd_system.invoke <UndoCmdT>(" undo 1" );
146+ std::cout << " > focused item: " << *undoable_cmd_system.focused_item () << " , newest item: " << *undoable_cmd_system.newest_item () << ' \n ' ;
147+ undoable_cmd_system.invoke <UndoCmdT>(" undo 2" );
148+ std::cout << " > focused item: " << *undoable_cmd_system.focused_item () << " , newest item: " << *undoable_cmd_system.newest_item () << ' \n ' ;
149+ undoable_cmd_system.invoke <RedoCmdT>(" redo 1" );
150+ std::cout << " > focused item: " << *undoable_cmd_system.focused_item () << " , newest item: " << *undoable_cmd_system.newest_item () << ' \n ' ;
151+ undoable_cmd_system.invoke <UndoCmdT>(" undo 3" );
152+ std::cout << " > focused item: " << *undoable_cmd_system.focused_item () << " , newest item: " << *undoable_cmd_system.newest_item () << ' \n ' ;
153+ undoable_cmd_system.invoke <UndoCmdT>(" undo 4" );
154+ std::cout << " > focused item: " << *undoable_cmd_system.focused_item () << " , newest item: " << *undoable_cmd_system.newest_item () << ' \n ' ;
148155}
149156
150157int main () {
151158
152- // test_undo_basic();
153- test_undo_sys ();
159+ // test_undo_basic();
160+ test_undo_sys ();
154161
155- return 0 ;
162+ return 0 ;
156163}
0 commit comments