@@ -846,57 +846,6 @@ is_ident( int ch )
846
846
return ( FALSE );
847
847
}
848
848
849
- static void
850
- program_text_changed ( GtkTextBuffer * buffer , Program * program )
851
- {
852
- gboolean editable = !program -> kit || !program -> kit -> pseudo ;
853
-
854
- if ( !program -> dirty ) {
855
- program -> dirty = TRUE;
856
- program_refresh ( program );
857
- }
858
-
859
- if ( program -> rpane_open &&
860
- editable ) {
861
- /* Fetch characters left of the cursor while we have stuff
862
- * that could be an identifier.
863
- */
864
- GtkTextIter start ;
865
- GtkTextIter end ;
866
- char * line ;
867
- char * p ;
868
-
869
- /* Set iter at cursor.
870
- */
871
- gtk_text_buffer_get_iter_at_mark ( buffer ,
872
- & end , gtk_text_buffer_get_insert ( buffer ) );
873
-
874
- /* Point an iter at the start of this line.
875
- */
876
- gtk_text_buffer_get_iter_at_line_index ( buffer ,
877
- & start , gtk_text_iter_get_line ( & end ), 0 );
878
-
879
- line = gtk_text_buffer_get_text ( buffer , & start , & end , FALSE );
880
-
881
- /* Search back from the end of the string for the start of the
882
- * identifier.
883
- */
884
- for ( p = line + strlen ( line ) - 1 ;
885
- p >= line && is_ident ( * p );
886
- p -- )
887
- ;
888
-
889
- /* Don't update the filter for empty strings. This happens
890
- * when the user clicks between tools, not when they type
891
- * stuff.
892
- */
893
- if ( strcmp ( p + 1 , "" ) != 0 )
894
- defbrowser_set_filter ( program -> defbrowser , p + 1 );
895
-
896
- g_free ( line );
897
- }
898
- }
899
-
900
849
static void
901
850
program_text_cursor_position ( GtkTextBuffer * buffer , GParamSpec * pspec ,
902
851
Program * program )
@@ -912,20 +861,33 @@ program_text_cursor_position( GtkTextBuffer *buffer, GParamSpec *pspec,
912
861
GtkTextIter cursor ;
913
862
GtkTextIter end ;
914
863
char * line ;
915
- char * p ;
864
+ char * p , * q , * r ;
916
865
917
866
/* Get iters for start / cursor / end of line.
918
867
*/
919
868
gtk_text_buffer_get_iter_at_mark ( buffer ,
920
869
& cursor , gtk_text_buffer_get_insert ( buffer ) );
921
870
gtk_text_buffer_get_iter_at_line_index ( buffer ,
922
- & start , gtk_text_iter_get_line ( & end ), 0 );
871
+ & start , gtk_text_iter_get_line ( & cursor ), 0 );
923
872
gtk_text_buffer_get_iter_at_line_index ( buffer ,
924
- & end , gtk_text_iter_get_line ( & end ), -1 );
873
+ & end , gtk_text_iter_get_line ( & cursor ), 0 );
874
+ gtk_text_iter_forward_to_line_end ( & end );
925
875
926
876
line = gtk_text_buffer_get_text ( buffer , & start , & end , FALSE );
877
+ p = line + gtk_text_iter_get_line_index ( & cursor );
878
+
879
+ /* Search back from the cursor for the first non-identifier
880
+ * char.
881
+ */
882
+ for ( q = p - 1 ; q >= line && is_ident ( * q ); q -- )
883
+ ;
884
+ q += 1 ;
885
+ for ( r = p ; r < line + strlen ( line ) && is_ident ( * r ); r ++ )
886
+ ;
887
+ * r = '\0' ;
927
888
928
- printf ( "line = <%s>\n" , line );
889
+ if ( strlen ( q ) > 1 )
890
+ defbrowser_set_filter ( program -> defbrowser , q );
929
891
930
892
g_free ( line );
931
893
}
@@ -942,16 +904,12 @@ program_set_text( Program *program, const char *text, gboolean editable )
942
904
/* Stop ::changed from firing, we don't want it to update the
943
905
* def browser filter.
944
906
*/
945
- g_signal_handlers_block_by_func ( text_buffer ,
946
- G_CALLBACK ( program_text_changed ), program );
947
907
g_signal_handlers_block_by_func ( text_buffer ,
948
908
G_CALLBACK ( program_text_cursor_position ), program );
949
909
950
910
text_view_set_text ( text_view , text , editable );
951
911
program -> text_hash = text_hash ;
952
912
953
- g_signal_handlers_unblock_by_func ( text_buffer ,
954
- G_CALLBACK ( program_text_changed ), program );
955
913
g_signal_handlers_unblock_by_func ( text_buffer ,
956
914
G_CALLBACK ( program_text_cursor_position ), program );
957
915
}
@@ -2396,10 +2354,6 @@ program_build( Program *program, GtkWidget *vbox )
2396
2354
gtk_widget_show ( swin );
2397
2355
2398
2356
program -> text = program_text_new ();
2399
- g_signal_connect (
2400
- gtk_text_view_get_buffer ( GTK_TEXT_VIEW ( program -> text ) ),
2401
- "changed" ,
2402
- G_CALLBACK ( program_text_changed ), program );
2403
2357
g_signal_connect (
2404
2358
gtk_text_view_get_buffer ( GTK_TEXT_VIEW ( program -> text ) ),
2405
2359
"notify::cursor-position" ,
0 commit comments