void on_go_to_line_activate(GtkMenuItem *menuitem, gpointer user_data) { static gchar value[16] = ""; gchar *result; result = dialogs_show_input_goto_line( _("Go to Line"), GTK_WINDOW(main_widgets.window), _("Enter the line you want to go to:"), value); if (result != NULL) { GeanyDocument *doc = document_get_current(); gint offset; gint line_no; g_return_if_fail(doc != NULL); get_line_and_offset_from_text(result, &line_no, &offset); if (! editor_goto_line(doc->editor, line_no, offset)) utils_beep(); /* remember value for future calls */ g_snprintf(value, sizeof(value), "%s", result); g_free(result); } }
gboolean msgwin_goto_messages_file_line(gboolean focus_editor) { GtkTreeIter iter; GtkTreeModel *model; GtkTreeSelection *selection; gboolean ret = FALSE; selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(msgwindow.tree_msg)); if (gtk_tree_selection_get_selected(selection, &model, &iter)) { gint line; guint id; gchar *string; GeanyDocument *doc; GeanyDocument *old_doc = document_get_current(); gtk_tree_model_get(model, &iter, MSG_COL_LINE, &line, MSG_COL_DOC_ID, &id, MSG_COL_STRING, &string, -1); if (line >= 0 && id > 0) { /* check doc is still open */ doc = document_find_by_id(id); if (!doc) { ui_set_statusbar(FALSE, _("The document has been closed.")); utils_beep(); } else { line = adjust_line_number(doc, line, msgwindow.line_shifts_msg); ret = navqueue_goto_line(old_doc, doc, line); if (ret && focus_editor) gtk_widget_grab_focus(GTK_WIDGET(doc->editor->sci)); } } else if (line < 0 && string != NULL) { gchar *filename; /* try with a file:line parsing */ msgwin_parse_generic_line(string, &filename, &line); if (filename != NULL) { /* use document_open_file to find an already open file, or open it in place */ doc = document_open_file(filename, FALSE, NULL, NULL); if (doc != NULL) { line = adjust_line_number(doc, line, msgwindow.line_shifts_msg); ret = (line < 0) ? TRUE : navqueue_goto_line(old_doc, doc, line); if (ret && focus_editor) gtk_widget_grab_focus(GTK_WIDGET(doc->editor->sci)); } } g_free(filename); } g_free(string); } return ret; }
void on_find_previous1_activate(GtkMenuItem *menuitem, gpointer user_data) { if (search_data.flags & GEANY_FIND_REGEXP) /* Can't reverse search order for a regex (find next ignores search backwards) */ utils_beep(); else search_find_again(TRUE); }
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); }
static void encodings_radio_item_change_cb(GtkCheckMenuItem *menuitem, gpointer user_data) { GeanyDocument *doc = document_get_current(); guint i = GPOINTER_TO_INT(user_data); if (ignore_callback || doc == NULL || encodings[i].charset == NULL || ! gtk_check_menu_item_get_active(menuitem) || utils_str_equal(encodings[i].charset, doc->encoding)) return; if (doc->readonly) { utils_beep(); return; } document_undo_add(doc, UNDO_ENCODING, g_strdup(doc->encoding)); document_set_encoding(doc, encodings[i].charset); }
static void insert_multiline_comment(GeanyDocument *doc, gint pos) { g_return_if_fail(doc != NULL); g_return_if_fail(pos == -1 || pos >= 0); if (doc->file_type == NULL) { ui_set_statusbar(FALSE, _("Please set the filetype for the current file before using this function.")); return; } if (doc->file_type->comment_open || doc->file_type->comment_single) { /* editor_insert_multiline_comment() uses editor_info.click_pos */ if (pos == -1) editor_info.click_pos = sci_get_current_position(doc->editor->sci); else editor_info.click_pos = pos; editor_insert_multiline_comment(doc->editor); } else utils_beep(); }