I am trying to compare words isolated in GTK textview against a list of keywords and cant seem to figure out how to do that. I am working(learning) in C.
gchar word[][10] = {"auto", "continue", "enum".....
I am moving iters word by word through the text buffer, then trying
gtk_text_iter_get_text(&start,&end);
so can end up with word[1] as "auto" and the iters finding the word "auto" in the textview. but cant find a way to compare them to confirm a match. attempts to use gtk_text_iter_forward_search() results in things like highlighting the "auto" in automobile.
I have tried 'strcmp()' but that always returns true no matter what is in the text view.
I am working on syntax highlighting kind of thing and have comments , single/double quotes, escape sequence/format specifiers and numbers all able to highlight but am stuck on getting highlighting on words, any nudge in the right direction is appreciated.
I found a solution to this by checking if the textiters where at the start and end of a word.
inside a for loop that iterates the array of C keywords, so now if I type 'auto' it will highlight , but if I carry on to 'automobile', the text tag is removed. the while loop scans the line the cursor is in and the line above word by word. I am only a month into learning C and GTK so not very advanced but maybe posting the solution I found will help some one else that is just learning too.