void _pluma_cmd_edit_redo (GtkAction *action, PlumaWindow *window) { PlumaView *active_view; GtkSourceBuffer *active_document; pluma_debug (DEBUG_COMMANDS); active_view = pluma_window_get_active_view (window); g_return_if_fail (active_view); active_document = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view))); gtk_source_buffer_redo (active_document); pluma_view_scroll_to_cursor (active_view); gtk_widget_grab_focus (GTK_WIDGET (active_view)); }
static gboolean run_search (PlumaView *view, gboolean wrap_around, gboolean search_backwards) { PlumaDocument *doc; GtkTextIter start_iter; GtkTextIter match_start; GtkTextIter match_end; gboolean found = FALSE; doc = PLUMA_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view))); if (!search_backwards) { gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (doc), NULL, &start_iter); found = pluma_document_search_forward (doc, &start_iter, NULL, &match_start, &match_end); } else { gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (doc), &start_iter, NULL); found = pluma_document_search_backward (doc, NULL, &start_iter, &match_start, &match_end); } if (!found && wrap_around) { if (!search_backwards) found = pluma_document_search_forward (doc, NULL, NULL, /* FIXME: set the end_inter */ &match_start, &match_end); else found = pluma_document_search_backward (doc, NULL, /* FIXME: set the start_inter */ NULL, &match_start, &match_end); } if (found) { gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc), &match_start); gtk_text_buffer_move_mark_by_name (GTK_TEXT_BUFFER (doc), "selection_bound", &match_end); pluma_view_scroll_to_cursor (view); } else { gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc), &start_iter); } return found; }
static gchar * get_next_misspelled_word (PlumaView *view) { PlumaDocument *doc; CheckRange *range; gint start, end; gchar *word; PlumaSpellChecker *spell; g_return_val_if_fail (view != NULL, NULL); doc = PLUMA_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view))); g_return_val_if_fail (doc != NULL, NULL); range = get_check_range (doc); g_return_val_if_fail (range != NULL, NULL); spell = get_spell_checker_from_document (doc); g_return_val_if_fail (spell != NULL, NULL); word = get_current_word (doc, &start, &end); if (word == NULL) return NULL; pluma_debug_message (DEBUG_PLUGINS, "Word to check: %s", word); while (pluma_spell_checker_check_word (spell, word, -1)) { g_free (word); if (!goto_next_word (doc)) return NULL; /* may return null if we reached the end of the selection */ word = get_current_word (doc, &start, &end); if (word == NULL) return NULL; pluma_debug_message (DEBUG_PLUGINS, "Word to check: %s", word); } if (!goto_next_word (doc)) update_current (doc, gtk_text_buffer_get_char_count (GTK_TEXT_BUFFER (doc))); if (word != NULL) { GtkTextIter s, e; range->mw_start = start; range->mw_end = end; pluma_debug_message (DEBUG_PLUGINS, "Select [%d, %d]", start, end); gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (doc), &s, start); gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (doc), &e, end); gtk_text_buffer_select_range (GTK_TEXT_BUFFER (doc), &s, &e); pluma_view_scroll_to_cursor (view); } else { range->mw_start = -1; range->mw_end = -1; } return word; }