Ejemplo n.º 1
0
void
BootPromptWindow::_ActivateKeymap(const BMessage* message) const
{
	entry_ref ref;
	if (message == NULL || message->FindRef("ref", &ref) != B_OK)
		return;

	// Load and use the new keymap
	Keymap keymap;
	if (keymap.Load(ref) != B_OK) {
		fprintf(stderr, "Failed to load new keymap file (%s).\n", ref.name);
		return;
	}

	// Get entry_ref to the Key_map file in the user settings.
	entry_ref currentRef;
	if (_GetCurrentKeymapRef(currentRef) != B_OK) {
		fprintf(stderr, "Failed to get ref to user keymap file.\n");
		return;
	}

	if (keymap.Save(currentRef) != B_OK) {
		fprintf(stderr, "Failed to save new keymap file (%s).\n", ref.name);
		return;
	}

	keymap.Use();
}
Ejemplo n.º 2
0
void
BootPromptWindow::_StoreKeymap() const
{
	KeymapListItem* item = dynamic_cast<KeymapListItem*>(
		fKeymapsListView->ItemAt(fKeymapsListView->CurrentSelection(0)));
	if (item == NULL)
		return;

	// Load and use the new keymap
	Keymap keymap;
	if (keymap.Load(item->EntryRef()) != B_OK) {
		fprintf(stderr, "Failed to load new keymap file (%s).\n",
			item->EntryRef().name);
		return;
	}

	// Get entry_ref to the Key_map file in the user settings.
	entry_ref ref;
	if (_GetCurrentKeymapRef(ref) != B_OK) {
		fprintf(stderr, "Failed to get ref to user keymap file.\n");
		return;
	}

	if (keymap.Save(ref) != B_OK) {
		fprintf(stderr, "Failed to save new keymap file (%s).\n",
			item->EntryRef().name);
		return;
	}

	keymap.Use();
}
Ejemplo n.º 3
0
static void
load_keymap(Keymap& keymap, const char* name, bool source)
{
	status_t status;
	if (source) {
		if (name != NULL)
			status = keymap.LoadSource(name);
		else
			status = keymap.LoadSource(stdin);
	} else {
		if (name != NULL)
			status = keymap.Load(name);
		else
			status = keymap.Load(stdin);
	}

	if (status != B_OK) {
		fprintf(stderr, "%s: error when loading the keymap: %s\n", sProgramName,
			keymap_error(status));
		exit(1);
	}
}