ratpoison-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RP] autocomplete window name patch


From: Jess Kube
Subject: Re: [RP] autocomplete window name patch
Date: Sat, 18 Aug 2001 11:48:38 -0700 (PDT)

OK..by popular demand, here is just the diff for the new tab completion 
code. I'm not sure if we want to move this kind of functionality into the core
or not.. but there should be a way to do this one way or another.

-Jess


cvs server: Diffing .
Index: input.c
===================================================================
RCS file: /cvsroot/ratpoison/ratpoison/src/input.c,v
retrieving revision 1.17
diff -r1.17 input.c
322c322
<       {
---
>     {
325a326,330
>       else if (ch == XK_Tab)
>         {
>            cur_len = complete_window_name(str, cur_len, allocated_len);
>            update_input_window(s, prompt, str, cur_len);
>         }
Index: list.c
===================================================================
RCS file: /cvsroot/ratpoison/ratpoison/src/list.c,v
retrieving revision 1.28
diff -r1.28 list.c
187a188,240
> /* 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 <address@hidden> */
> 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;
> }
>
Index: list.h
===================================================================
RCS file: /cvsroot/ratpoison/ratpoison/src/list.h,v
retrieving revision 1.13
diff -r1.13 list.h
48a49
> int complete_window_name (char* str, int cur_len, int max_len);
55a57,58
>
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]