/** * This tries to duplicate the neat Eclipse editing feature where you can rename something * in place, ie you select som etext, type control-1 and start typing all occurences of the selected * text change in place at the same time. */ #include "eel.h" /* standard definitions */ int rename_in_place_active= 0; typedef struct { spot s1, s2; } t_rename_spots; zeroed buffer t_rename_spots rename_source; t_rename_spots *rename_points; int rename_points_size= 0; int rename_points_cnt= 0; int inside_rename() { if(point >= *rename_source.s1 && point <= *rename_source.s2) return 1; return 0; } int rename_when_idle(int cnt); // forward reference // deactivate rename and release its resources int deactivate_rename() { int i; rename_in_place_active= 0; highlight_off(); // release allocations for(i=0;i 0){ tag= malloc((mark-point)+1); grab(point, mark, tag); }else{ error("Nothing selected"); } // remember spot positions rename_source.s1= alloc_spot(0); set_spot(&rename_source.s1, point); rename_source.s2= alloc_spot(1); set_spot(&rename_source.s2, mark); // next find all matching occurences and highlight them too point= mark; int cnt= 0; int i; while(search(1, tag)){ if(cnt >= rename_points_size){ t_rename_spots *ts= (t_rename_spots *)malloc(sizeof(t_rename_spots)*(rename_points_size + 10)); if(rename_points_size > 0){ for(i=0;i 0){ add_buffer_when_idle(bufnum, rename_when_idle); rename_in_place_active= 1; } free(tag); }