Esempio n. 1
0
static void goto_tag(gboolean definition)
{
	GeanyDocument *doc = document_get_current();

	g_return_if_fail(doc != NULL);

	/* update cursor pos for navigating back afterwards */
	if (!sci_has_selection(doc->editor->sci))
		sci_set_current_position(doc->editor->sci, editor_info.click_pos, FALSE);

	/* use the keybinding callback as it checks for selections as well as current word */
	if (definition)
		keybindings_send_command(GEANY_KEY_GROUP_GOTO, GEANY_KEYS_GOTO_TAGDEFINITION);
	else
		keybindings_send_command(GEANY_KEY_GROUP_GOTO, GEANY_KEYS_GOTO_TAGDECLARATION);
}
Esempio n. 2
0
static PyObject *kb_manager_send_command(PyObject *module, PyObject *args,
	PyObject *kwargs)
{
	gchar *key;
	static gchar *kwlist[] = { "key", NULL };

	if (PyArg_ParseTupleAndKeywords(args, kwargs, "s", kwlist, &key)) {
		if (key) {
			KeyCmdHashEntry*he = NULL;
			gchar cmdbuf[64];
			gchar *cmdname;
			gint i;
			memset(cmdbuf, '\0', sizeof(cmdbuf));
			strncpy(cmdbuf, key, sizeof(cmdbuf) - 1);
			for (i = 0; cmdbuf[i]; i++) {
				cmdbuf[i] = g_ascii_toupper(cmdbuf[i]);
			}
			cmdname = cmdbuf;
			if (strncmp(cmdname, "GEANY_", 6) == 0) {
				cmdname += 6;
				if (strncmp(cmdname, "KEYS_", 5) == 0) {
					cmdname += 5;
				}
			}
			he = lookup_key_cmd_str(cmdname)
			;
			keybindings_send_command(he->group, he->key_id);
		}
	}

	Py_RETURN_NONE;
}
Esempio n. 3
0
void on_toggle_case1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
	GeanyDocument *doc = document_get_current();
	ScintillaObject *sci;
	gchar *text;
	gboolean keep_sel = TRUE;

	g_return_if_fail(doc != NULL);

	sci = doc->editor->sci;
	if (! sci_has_selection(sci))
	{
		keybindings_send_command(GEANY_KEY_GROUP_SELECT, GEANY_KEYS_SELECT_WORD);
		keep_sel = FALSE;
	}

	/* either we already had a selection or we created one for current word */
	if (sci_has_selection(sci))
	{
		gchar *result = NULL;
		gint cmd = SCI_LOWERCASE;
		gboolean rectsel = (gboolean) scintilla_send_message(sci, SCI_SELECTIONISRECTANGLE, 0, 0);

		text = sci_get_selection_contents(sci);

		if (utils_str_has_upper(text))
		{
			if (rectsel)
				cmd = SCI_LOWERCASE;
			else
				result = g_utf8_strdown(text, -1);
		}
		else
		{
			if (rectsel)
				cmd = SCI_UPPERCASE;
			else
				result = g_utf8_strup(text, -1);
		}

		if (result != NULL)
		{
			sci_replace_sel(sci, result);
			g_free(result);
			if (keep_sel)
				sci_set_selection_start(sci, sci_get_current_position(sci) - strlen(text));
		}
		else
			sci_send_command(sci, cmd);

		g_free(text);

	}
}
Esempio n. 4
0
void msgwin_show_hide(gboolean show)
{
	ui_prefs.msgwindow_visible = show;
	ignore_callback = TRUE;
	gtk_check_menu_item_set_active(
		GTK_CHECK_MENU_ITEM(ui_lookup_widget(main_widgets.window, "menu_show_messages_window1")),
		show);
	ignore_callback = FALSE;
	ui_widget_show_hide(main_widgets.message_window_notebook, show);
	/* set the input focus back to the editor */
	keybindings_send_command(GEANY_KEY_GROUP_FOCUS, GEANY_KEYS_FOCUS_EDITOR);
}
Esempio n. 5
0
void on_toolbutton_goto_entry_activate(GtkAction *action, const gchar *text, gpointer user_data)
{
	GeanyDocument *doc = document_get_current();
	gint offset;
	gint line_no;

	g_return_if_fail(doc != NULL);

	get_line_and_offset_from_text(text, &line_no, &offset);
	if (! editor_goto_line(doc->editor, line_no, offset))
		utils_beep();
	else
		keybindings_send_command(GEANY_KEY_GROUP_FOCUS, GEANY_KEYS_FOCUS_EDITOR);
}
Esempio n. 6
0
static void doit_and_select(guint group_id, guint key_id)
{
	ScintillaObject *sci = scintilla_get_current();

	if (sci)
	{
		int before = sci_get_current_position(sci), after;

		if (key_id != GEANY_KEYS_GOTO_LINE || !geany_data->toolbar_prefs->visible)
			keybindings_send_command(group_id, key_id);
		else if (go_to_line1_item)
			g_signal_emit_by_name(go_to_line1_item, "activate");
		else
		{
			if (geany_data->prefs->beep_on_errors)
				gdk_beep();
			return;
		}

		after = sci_get_current_position(sci);
		if (before != after)
			sci_set_anchor(sci, before);
	}
}
Esempio n. 7
0
void on_toolbutton_compile_clicked(GtkAction *action, gpointer user_data)
{
	keybindings_send_command(GEANY_KEY_GROUP_BUILD, GEANY_KEYS_BUILD_COMPILE);
}