Commit b4983978 by castro

Liiga palju argumente oli asenda funktsioonis

parent 24bd7e67
Showing with 14 additions and 14 deletions
......@@ -2,29 +2,29 @@
GtkTextIter mstart, mend;
//Funktsioon tekstiaknast sna leidmiseks
//Funktsioon tekstiaknast sna leidmiseks
void find (GtkTextView *text_view, const gchar *text, GtkTextIter *iter)
{
GtkTextBuffer *buffer;
GtkTextMark *last_pos;
gboolean found;
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)); // Vtab teksti tekstiaknast puhvrina
found = gtk_text_iter_forward_search (iter, text, 0, &mstart, &mend, NULL); // Otsib text-i ja omistab mstart text-i algusesse ja mend text-i lppu
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)); // Vtab teksti tekstiaknast puhvrina
found = gtk_text_iter_forward_search (iter, text, 0, &mstart, &mend, NULL); // Otsib text-i ja omistab mstart text-i algusesse ja mend text-i lppu
if (found)
{
gtk_text_buffer_select_range (buffer, &mstart, &mend); // Leiab mstart iter-i ja mend iter-i asukohad puhvris
last_pos = gtk_text_buffer_create_mark (buffer, "last_pos", &mend, FALSE); // Koostab puhvris marki mend asukohal
gtk_text_view_scroll_mark_onscreen(text_view, last_pos); // Highlight-ib tekstiaknas sna
gtk_text_view_scroll_mark_onscreen(text_view, last_pos); // Highlight-ib tekstiaknas sna
}
}
//Funktsioon tekstiaknas sna asendamiseks
//Funktsioon tekstiaknas sna asendamiseks
void asenda (GtkTextView *text_view, const gchar *replace, GtkTextIter *iter)
{
GtkTextBuffer *buffer;
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)); // Vtab teksti tekstiaknast puhvrina
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)); // Vtab teksti tekstiaknast puhvrina
gtk_text_buffer_select_range (buffer, &mstart, &mend); // Leiab mstart iter-i ja mend iter-i asukohad puhvris
gtk_text_buffer_delete (buffer, &mstart, &mend); // Kustutab puhvrist mstart ja mend iter-ite vahel oleva teksti
......@@ -38,12 +38,12 @@ void Otsi_nupp_vajutatud (GtkWidget *search_button, tab *Tab)
GtkTextBuffer *buffer;
GtkTextIter iter;
text = gtk_entry_get_text (GTK_ENTRY (Tab->search_entry)); // Vtab otsingu kastist oleva teksti ja omistab selle text-ile
text = gtk_entry_get_text (GTK_ENTRY (Tab->search_entry)); // Vtab otsingu kastist oleva teksti ja omistab selle text-ile
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (Tab->TextView)); // Vtab teksti kirjutamis aknast puhvrina
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (Tab->TextView)); // Vtab teksti kirjutamis aknast puhvrina
gtk_text_buffer_get_start_iter (buffer, &iter); // Koostab iter-i puhvri alguses
find (GTK_TEXT_VIEW (Tab->TextView), text, &iter); // Funktsioon leiab tekstiaknast text-i sna
find (GTK_TEXT_VIEW (Tab->TextView), text, &iter); // Funktsioon leiab tekstiaknast text-i sna
}
// funktsioon selleks kui jargmine_nupp vajutatakse
void Jargmine_nupp_vajutatud (GtkWidget *next_button, tab *Tab)
......@@ -53,15 +53,15 @@ void Jargmine_nupp_vajutatud (GtkWidget *next_button, tab *Tab)
GtkTextMark *last_pos;
GtkTextIter iter;
text = gtk_entry_get_text (GTK_ENTRY (Tab->search_entry)); // Vtab otsingu kastist oleva teksti ja omistab selle text-ile
text = gtk_entry_get_text (GTK_ENTRY (Tab->search_entry)); // Vtab otsingu kastist oleva teksti ja omistab selle text-ile
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (Tab->TextView)); // Vtab teksti tekstiaknast puhvrina
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (Tab->TextView)); // Vtab teksti tekstiaknast puhvrina
last_pos = gtk_text_buffer_get_mark (buffer, "last_pos"); // Koostab puhvris marki
if (last_pos == NULL)
return;
gtk_text_buffer_get_iter_at_mark (buffer, &iter, last_pos); // Koostab iter-i mark-i asukohal
find (GTK_TEXT_VIEW (Tab->TextView), text, &iter); // Funktsioon leiab tekstiaknast text-i sna
find (GTK_TEXT_VIEW (Tab->TextView), text, &iter); // Funktsioon leiab tekstiaknast text-i sna
}
//funktsioon selleks kui asenda nuppu vajutatakse
void Asenda_nupp_vajutatud (GtkWidget *asenda_nupp, tab *Tab)
......@@ -74,14 +74,14 @@ void Asenda_nupp_vajutatud (GtkWidget *asenda_nupp, tab *Tab)
text = gtk_entry_get_text (GTK_ENTRY (Tab->search_entry)); // Otsingusse siestatud tekst
replace = gtk_entry_get_text (GTK_ENTRY (Tab->replace_entry)); // Tekst, mis asub asendamise teksti kastis
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (Tab->TextView)); // Vtab teksti tekstiaknast puhvrina
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (Tab->TextView)); // Vtab teksti tekstiaknast puhvrina
last_pos = gtk_text_buffer_get_mark (buffer, "last_pos"); // Koostab puhvris marki
if (last_pos == NULL)
return;
gtk_text_buffer_get_iter_at_mark (buffer, &iter, last_pos); // Koostab iteri mark-i asukohal
asenda (GTK_TEXT_VIEW (Tab->TextView), replace, text, &iter); // funktsioon asendab text-i replace-ga
asenda (GTK_TEXT_VIEW (Tab->TextView), replace, &iter); // funktsioon asendab text-i replace-ga
}
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