Now I have rewritten find_window_name() again, it is much cleaner this
way, no need for unnecessary temporary variables anymore :)
It works the same as before but I still get the "assignment from
incompatible pointer type" warning...
rp_window *
find_window_name (char *name, int match_type)
{
typedef int (*compare_window_name_function)(char *name1, char *name2,
int length);
compare_window_name_function my_compare;
switch(match_type)
{
case MATCH_EXACT:
my_compare = strcmp;
break;
case MATCH_IGNORECASE:
my_compare = strcasecmp;
break;
case MATCH_PREFIX:
my_compare = strncmp;
break;
case MATCH_IGNORECASE | MATCH_PREFIX:
my_compare = strncasecmp;
break;
default:
my_compare = strncmp;
}
// number of the currently selected window
int current_win_number = current_window() ? current_window()->number : 0;
rp_window_elem *cur;
int may_return = 1;
if (defaults.select_style == SELECT_PREFER_NOTSELECTED)
may_return = 0;
rp_window *first_match = NULL;
list_for_each_entry (cur, &rp_current_group->mapped_windows, node)
{
if (!my_compare (name, window_name(cur->win), strlen(name)))
{
if (may_return)
{
return cur->win;
}
else
{
if(cur->win->number == current_win_number)
may_return = 1;
if(!first_match)
first_match = cur->win;
}
}
}
return first_match;
}
_______________________________________________
Ratpoison-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/ratpoison-devel