Beispiel #1
0
// Undo and redo commands
void UndoBuffer::undo()
{
    if (locked)
	return;

    if (history_position == 0)
    {
	set_status("Nothing to undo");
	return;
    }

    StatusDelay delay("Undoing " + undo_action());
   
    // Undo most recent command
    bool have_command = history[history_position - 1].has_command();

    bool ok = process_command(history_position - 1);
    if (ok && history_position > 1)
    {
	if (!have_command)
	    process_frame(history_position - 2);
	process_pos(history_position - 2);
	process_state(history_position - 2);
    }

    if (!ok)
	delay.outcome = "failed";

    history_position--;

    done(&delay);
}
Beispiel #2
0
void UndoBuffer::log()
{
#if LOG_UNDO_BUFFER
    std::clog << "Undo buffer:\n";
    for (int i = 0; i < history.size(); i++)
    {
#if 0
	// Only log the first 2 items around the current position
	if (abs(i - (history_position - 1)) > 2)
	    continue;
#endif

	const UndoBufferEntry& entry = history[i];

	if (i == history_position)
	    std::clog << ">-------------\n";

	std::clog << i << '\t';

	bool first_line = true;
	for (StringStringAssocIter iter(entry); iter.ok(); iter++)
	{
	    if (!first_line)
		std::clog << "\n\t";
	    std::clog << iter.key() << " = " << quote(iter.value());
	    first_line = false;
	}
	std::clog << "\n";
    }

#if 0
    std::clog << "Collector:";
    for (StringStringAssocIter iter(collector); iter.ok(); iter++)
	std::clog << "\n\t" << iter.key() << " = " << quote(iter.value());
    std::clog << "\n";
#endif

    if (undo_action() != NO_GDB_ANSWER)
	std::clog << "Undo " << undo_action() << "\n";
    if (redo_action() != NO_GDB_ANSWER)
	std::clog << "Redo " << redo_action() << "\n";

    std::clog << "Allocated " << allocation() << " bytes\n";

    std::clog << "\n";
#endif
}
Beispiel #3
0
int main()
{
  goods_t *myShelf = create_shelf(100);
  goods_t *previousshelf = create_shelf(100);
  int loop = 1; 
 
 
  while (loop)
    {
      menu();
      char option = read_char();
      switch(option)
	{

	case 'A':
	  {
	    get_old_shelf(previousshelf, myShelf);
	    add_to_shelf_IO(myShelf);
	    break;
	  }

	case 'R':
	  {
	    get_old_shelf(previousshelf, myShelf);
	    char remove = 'r';
	    show_page_IO(myShelf, remove);
	    break;
	  }

	case 'E':
	  {
	    char edit = 'e';
	    show_page_IO(myShelf, edit);
	    break;
	  }
	case 'U':
	  undo_action(previousshelf, myShelf);
	  printf("\n\tYou have undone your latest action");
	  break;
	  
	case 'L':
	  {
	    char list = 'l';
	    show_page_IO(myShelf, list);  
	    break;
	  }  
	case 'x':
	  exit_program();
	  break;
	default:
	  printf("\n\nInvalid input _");
	  break;
	}
    }
  return 0;
}
Beispiel #4
0
void FadeStrength::cancel_action()
{
	finish_hold();
	undo_action();
}
Beispiel #5
0
void FadeBend::cancel_action()
{
	finish_hold();
	undo_action();
}
Beispiel #6
0
void FadeRange::cancel_action()
{
	finish_hold();
	undo_action();
}
void MoveMarker::cancel_action()
{
	finish_hold();
	undo_action();
}