+void print_string_with_switches(char *buffer, int line_width,
+ int nb_patterns, int *switches) {
+ int w, current = 0, next;
+ if(switches) {
+ for(w = 0; w < nb_patterns && switches[2 * w] < line_width; w++) {
+ if(switches[2 * w] < switches[2 * w + 1]) {
+ next = switches[2 * w];
+ if(next > line_width) { next = line_width; }
+ if(next > current) { addnstr(buffer + current, next - current); }
+ attron(global_attr_hits);
+ current = next;
+ next = switches[2 * w + 1];
+ if(next > line_width) { next = line_width; }
+ if(next > current) { addnstr(buffer + current, next - current); }
+ attroff(global_attr_hits);
+ current = next;
+ }
+ }
+ if(current < line_width) {
+ addnstr(buffer + current, line_width - current);
+ }
+ } else {
+ addnstr(buffer, line_width);
+ }
+}
+