Commit ee23d7ee by castro

non crashable search.c

parent 931a6ca8
Showing with 5 additions and 9 deletions
......@@ -30,12 +30,9 @@ void asenda (GtkTextView *text_view, const gchar *replace, const gchar *text, Gt
if (found)
{
gtk_text_buffer_select_range (buffer, &mstart, &mend);
last_pos = gtk_text_buffer_create_mark (buffer, "last_pos", &mend, FALSE);
gtk_text_view_scroll_mark_onscreen(text_view, last_pos);
}
gtk_text_buffer_delete (buffer, &mstart, &mend);
gtk_text_buffer_insert (buffer, &mstart, replace, -1);
}
}
// funktsioon selleks kui search nuppu vajutatakse
void Otsi_nupp_vajutatud (GtkWidget *search_button, tab *Tab)
......@@ -62,8 +59,8 @@ void Jargmine_nupp_vajutatud (GtkWidget *next_button, tab *Tab)
text = gtk_entry_get_text (GTK_ENTRY (Tab->search_entry));
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (Tab->TextView));
last_pos = gtk_text_buffer_get_mark (buffer, "last_pos");
if (last_pos == NULL)
return;
......@@ -76,20 +73,19 @@ void Asenda_nupp_vajutatud (GtkWidget *asenda_nupp, tab *Tab)
const gchar *text, *replace;
GtkTextBuffer *buffer;
GtkTextMark *last_pos;
GtkTextIter *mstart, *mend, iter;
gboolean found;
GtkTextIter iter;
text = gtk_entry_get_text (GTK_ENTRY (Tab->search_entry));
replace = gtk_entry_get_text (GTK_ENTRY (Tab->replace_entry));
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (Tab->TextView));
gtk_text_buffer_get_start_iter (buffer, &iter);
last_pos = gtk_text_buffer_get_mark (buffer, "last_pos");
if (last_pos == NULL)
return;
gtk_text_buffer_get_start_iter (buffer, &iter);
asenda (GTK_TEXT_VIEW (Tab->TextView), replace, text, &iter);
//gtk_text_buffer_insert (buffer, mstart, replace, -1);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment