diff -ur ratpoison/src/input.c ratpoison-tab/src/input.c --- ratpoison/src/input.c Fri Jun 1 21:32:59 2001 +++ ratpoison-tab/src/input.c Wed Aug 15 22:42:03 2001 @@ -319,10 +319,15 @@ { PRINT_DEBUG ("key %ld\n", ch); if (ch == XK_BackSpace) - { + { if (cur_len > 0) cur_len--; update_input_window(s, prompt, str, cur_len); } + else if (ch == XK_Tab) + { + cur_len = complete_window_name(str, cur_len, allocated_len); + update_input_window(s, prompt, str, cur_len); + } else { if (cur_len + nbytes > allocated_len - 1) diff -ur ratpoison/src/list.c ratpoison-tab/src/list.c --- ratpoison/src/list.c Wed Jun 6 20:55:28 2001 +++ ratpoison-tab/src/list.c Wed Aug 15 23:26:15 2001 @@ -185,6 +185,59 @@ return NULL; } +/* Auto-completion of window a window name. Partly completed name given + by 'str' with current length 'cur_len' and max length 'max_len'. + Added by Jess Kube */ +int complete_window_name (char* str, int cur_len, int max_len) +{ + rp_window *w; + char **names; + int i, count; + char ch; + + for (count = 0, w = rp_mapped_window_sentinel->next; + w != rp_mapped_window_sentinel; + w = w->next, count++); + + /* alloc an array for worst number of possible matches */ + names = malloc (count * sizeof(char*)); + + for (count = 0, w = rp_mapped_window_sentinel->next; + w != rp_mapped_window_sentinel; + w = w->next) + { + if (w->name != NULL && str_comp (str, w->name, cur_len)) + { + PRINT_DEBUG("Adding candidate window: %s") + names[count++] = w->name; + } + } + + max_len--; + while (cur_len < max_len && count > 0) + { + ch = names[0][cur_len]; + for (i = 1; i < count; i++) + { + if (toupper (ch) != toupper (names[i][cur_len])) + { + /* There is a discrepancy in match.. don't commit to this ch */ + count = 0; + break; + } + } + if (ch == '\0') + count = 0; + + /* if count is still > 0, we can commit to this char */ + if (count > 0) + str[cur_len++] = ch; + } + + free (names); + return cur_len; +} + /* Return the previous window in the list. Assumes window is in the mapped window list. */ rp_window* diff -ur ratpoison/src/list.h ratpoison-tab/src/list.h --- ratpoison/src/list.h Fri Jun 1 13:33:51 2001 +++ ratpoison-tab/src/list.h Wed Aug 15 22:41:57 2001 @@ -46,6 +46,7 @@ rp_window *find_window_next (rp_window *w); rp_window *find_window_next_with_frame (rp_window *w); rp_window *find_window_number (int n); +int complete_window_name (char* str, int cur_len, int max_len); void sort_window_list_by_number (); void append_to_list (rp_window *win, rp_window *sentinel); @@ -53,5 +54,7 @@ void remove_from_list (rp_window *win); void print_window_information (rp_window *win); + + #endif /* ! _RATPOISON_LIST_H */