Пример #1
0
// Save history into history file
void save_history(const string& file, Widget origin)
{
    if (!file.empty())
    {
	StatusDelay delay("Saving history in " + quote(file));
	std::ofstream os(file.chars());
	if (os.bad())
	{
	    post_error("Cannot save history in " + quote(file),
		       "history_save_error", origin);
	    delay.outcome = "failed";
	    return;
	}

	// Save the 10 most recently opened files
	int i;
	StringArray recent;
	get_recent(recent);
	for (i = recent.size() - 1; i >= 0 && i >= recent.size() - 10; i--)
	    os << gdb->debug_command(recent[i]) << "\n";

	// Now save the command history itself
	int start = gdb_history.size() - gdb_history_size;
	if (start < 0)
	    start = 0;

	for (i = start; i < gdb_history.size(); i++)
	    os << gdb_history[i] << "\n";
    }
}
Пример #2
0
static void update_recent_menu(const MMDesc *items)
{
    StringArray recent_files;
    {
	StringArray r;
	get_recent(r);
	for (int i = 0; i < r.size() && items[i].widget != 0; i++)
	    recent_files += r[i];
    }

    // Uniquify labels
    char sep = '/';
    if (gdb->type() == JDB)
	sep = '.';

    StringArray labels;
    uniquify(recent_files, labels, sep);

    // Set labels
    int i;
    for (i = 0; i < labels.size(); i++)
    {
	MString label(itostring(i + 1) + " ");
	label += tt(labels[i]);

	Widget w = items[i].widget;
	set_label(w, label);

	const string& file = recent_files[i];

	bool sens = true;
	if (!remote_gdb())
	{
	    if (gdb->has_exec_files() && !is_debuggee_file(file))
		sens = false;	// File not accessible
	    else if (!gdb->has_classes() && !is_regular_file(file))
		sens = false;	// File not accessible
	}

	set_sensitive(w, sens);
	XtManageChild(w);
    }

    // Unmanage remaining items
    for (; items[i].widget != 0; i++)
	XtUnmanageChild(items[i].widget);
}
Пример #3
0
void gdbOpenRecentCB(Widget, XtPointer client_data, XtPointer)
{
    int index = ((int)(long)client_data) - 1;

    StringArray recent_files;
    get_recent(recent_files);

    if (index >= 0 && index < recent_files.size())
    {
	string file = recent_files[index];
	open_file(file);
	// This is a kludge as I don't [yet] understand how to force the
	// reading of the source file automatically, as is done when an
	// compiled executable is opened.
	if (gdb->type() == PYDB)
	    source_view->read_file(file);
    }
}