#include ONCE "window9.bi"

sub SetSelectTextEditorGadget(iGadget as Long , iBegin as Long , iEnd as Long) export
	
	dim as GtkTextBuffer ptr  buffer
	
	dim as GtkTextIter  iter1, iter2 , iterstart , iterend
	
	dim as gint char_offset1 = 0 , char_offset2 = -1
	
	if iBegin = 0 then exit sub 
	'
	buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( gadgetid(iGadget) ))
	
	gtk_text_buffer_get_iter_at_offset (buffer, @iterstart, char_offset1)
	
	gtk_text_buffer_get_iter_at_offset (buffer, @iterend, char_offset2)
	
	char_offset1 = iBegin - 1
	
	char_offset2 = iEnd       
	
	gtk_text_buffer_get_iter_at_offset (buffer,@iter1, char_offset1)
	
	gtk_text_buffer_get_iter_at_offset (buffer, @iter2,char_offset2)   
	
	gtk_text_buffer_remove_tag_by_name (buffer,"gui_tag_bg_fg",@iterstart,@iterend)
	
	gtk_text_buffer_apply_tag_by_name(buffer, "gui_tag_bg_fg",@iter1, @iter2)
	
	gtk_text_buffer_place_cursor(buffer, @iter2 )    	
	
End Sub