Skip to content

Commit

Permalink
update all
Browse files Browse the repository at this point in the history
  • Loading branch information
cadmio committed Dec 20, 2022
1 parent 638acff commit cadc64b
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions search_replace.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ void replaceButtonClicked (GtkButton *button, gpointer userData)
-1,
NULL);

searchString(litos, replaceString);

highlightWord(litos);

gtk_entry_set_text(GTK_ENTRY(replace_entry),"");
Expand All @@ -128,28 +130,6 @@ void replaceButtonClicked (GtkButton *button, gpointer userData)
g_print("%d replacement\n", count_replaced);
}

void countOccurences(gpointer search_context) /* Count occurences */
{
GtkTextIter iter, start, end;

gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER(highlightSearchBuffer), &iter);

gtk_source_search_context_forward (search_context, &iter, &start, &end, NULL);

gint counter = gtk_source_search_context_get_occurrences_count (search_context);

char str[80];

sprintf(str, "%d occurences", counter);

gtk_label_set_label (
GTK_LABEL(lbl_number_occurences),
str
);

g_print("%d occurences\n", counter);
}

void highlightWord(struct lit *litos)
{
GtkTextBuffer *buffer = GTK_TEXT_BUFFER(highlightSearchBuffer);
Expand All @@ -174,6 +154,28 @@ void highlightWord(struct lit *litos)
g_signal_connect (highlightSearchBuffer, "notify::text", G_CALLBACK (clearSearchHighlight), litos->search_context); /* when file gets modified, remove search highlights*/
}

void countOccurences(gpointer search_context) /* Count occurences */
{
GtkTextIter iter, start, end;

gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER(highlightSearchBuffer), &iter);

gtk_source_search_context_forward (search_context, &iter, &start, &end, NULL);

gint counter = gtk_source_search_context_get_occurrences_count (search_context);

char str[80];

sprintf(str, "%d occurences", counter);

gtk_label_set_label (
GTK_LABEL(lbl_number_occurences),
str
);

g_print("%d occurences\n", counter);
}

/* Called when Ctrl+B, Ctrl+i, etc is toggled */
void applyTags (struct lit *litos, const char *tag)
{
Expand Down

0 comments on commit cadc64b

Please sign in to comment.