freehoo-devel
[Top][All Lists]
Advanced

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

Re: [Freehoo-devel] [PATCH: freehoo] increased usability (resent, prev d


From: K. Viswanathan
Subject: Re: [Freehoo-devel] [PATCH: freehoo] increased usability (resent, prev diff broken)
Date: Mon, 14 Feb 2005 06:31:18 -0800 (PST)

Hi Anand Avati

You are doing a nice job by keep sending freehoo
patches. Keep up your good work. I will also join back
to contribute soon. Bye.

Regards
Visu

--- Anand Avati <address@hidden> wrote:

> group,
> looks like the previous patch doesnt work well with
> the
> incorrect-auto-insert-fix .. (in PRINTF_MESSAGE) ..
> this one looks more
> correct..
> regards,
> avati
> -- 
> 
> We will have solar energy as soon as the utility
> companies solve one
> technical problem -- how to run a sunbeam through a
> meter.
> 
> > diff -pruN freehoo/configure.ac
> freehoo-patched/configure.ac
> --- freehoo/configure.ac      2005-01-27
> 07:37:59.000000000 +0530
> +++ freehoo-patched/configure.ac      2005-02-14
> 17:34:52.000000000 +0530
> @@ -38,6 +38,11 @@
> AC_CHECK_FUNCS([completion_matches rl_co
>  if test "x${have_ding}" = "xno" -o
> "x${have_completion_matches}" = "xno" ; then
>     AC_MSG_ERROR([No readline functions found])
>  fi
> +have_regex=no
> +AC_CHECK_FUNCS([regcomp],[have_regex=yes])
> +if test "x${have_regex}" = "xno" ; then
> +   AC_MSG_ERROR([No regex support found])
> +fi
>  READLINE_LIBS=${LIBS}
>  AC_SUBST([READLINE_LIBS])
>  LIBS=${NOREADLINE_LIBS}
> diff -pruN freehoo/src/fh-utils.h
> freehoo-patched/src/fh-utils.h
> --- freehoo/src/fh-utils.h    2004-10-21
> 22:56:10.000000000 +0530
> +++ freehoo-patched/src/fh-utils.h    2005-02-14
> 17:35:22.000000000 +0530
> @@ -35,6 +35,7 @@ int temp_rl_point;
>  */
>  #define PRINTF_MESSAGE(format, args...)   \
>  {                                         \
> +  int n = rl_end;                         \
>    if (rl_end >= 0)                        \
>      {                                     \
>        temp_rl_point = rl_point;           \
> @@ -46,7 +47,7 @@ int temp_rl_point;
>                                            \
>    if (rl_end >= 0)                        \
>      {                                     \
> -      rl_do_undo ();                      \
> +      if (n) rl_do_undo ();               \
>        rl_point = temp_rl_point;           \
>        rl_reset_line_state ();             \
>      }                                     \
> diff -pruN freehoo/src/interpreter.c
> freehoo-patched/src/interpreter.c
> --- freehoo/src/interpreter.c 2004-09-02
> 13:27:58.000000000 +0530
> +++ freehoo-patched/src/interpreter.c 2005-02-14
> 17:45:08.000000000 +0530
> @@ -32,6 +32,7 @@
>  
>  #include <glib.h>
>  #include <yahoo2.h>
> +#include <regex.h>
>  
>  #include "freehoo.h"
>  #include "interpreter.h"
> @@ -48,6 +49,61 @@ char *commands[] = { "?send",
> "?who", "?
>                    "?send-file", FH_ROBOT, NULL
>  };
>  
> +char * autocomplete_buddy_regex =            
> +                /* regex header */
> +             "^\\ *\\?("
> +             
> +               /* commands which accept 1st arg as
> buddy */
> +     
>
"send|send\\-file|ignore|unignore|add|remove|reject|color\\-buddy|ping|buzz|forward|vconf\\-start|"
> +             
> +             /* commands which accpet 1st arg and beyond as
> buddies */
> +             "(forward|vconf\\-start)\\ +[a-zA-Z0-9_\\-\\ ]*|"
> 
> +             
> +             /* commands which accept 2nd arg and beyond
> +                 * as buddies, but first as non
> buddy.. like
> +                 * confroom or virtual buddy (not
> yet buddy) 
> +                 */
> +             "(alias|conf\\-start)\\ +[a-zA-Z0-9_\\-\\ ]+|"
> +
> +             /* command which accept 2nd arg only as 
> +                 * buddy, 1st arg being non buddy,
> like 
> +              * confroom
> +              */
> +             "(conf\\-add)\\ +[a-zA-Z0-9_\\-]+"
> +
> +             /* regex footer, possibly along with the 
> +              * half-d00d! at the end */
> +             ")\\ +[a-zA-Z0-9_\\-]*$" ;
> +
> +char * autocomplete_conf_regex =             
> +                /* regex header */
> +             "^\\ *\\?("
> +             
> +               /* commands which accept 1st arg as
> confroom*/
> +     
>
"conf\\-add|conf\\-join|conf\\-decline|conf\\-end|conf\\-send"
> +     
> +             /* regex footer, possibly along with the 
> +              * half conf-room*/
> +             ")\\ +[a-zA-Z0-9_\\-]*$" ;
> +
> +char * autocomplete_file_regex =             
> +                /* regex header */
> +             "^\\ *\\?("
> +             
> +               /* commands which accept 1st arg as
> filename*/
> +             "send\\-file"
> +             
> +             /* buddy name */
> +             ")\\ +[a-zA-Z0-9_\\-]+\\ +" 
> +
> +             /* regex footer, possibly along with the 
> +              * half filename*/
> +             "[a-zA-Z0-9_\\-]*$" ;
> +
> +char * autocomplete_cmd_regex =              
> +                /* still in first word or no words
> yet*/
> +             "^\\ *\\??[a-zA-Z0-9_\\-]*$" ;
> +
>  extern YList *conferences;
>  
>  SCM dynamic_commands = SCM_UNSPECIFIED;
> @@ -200,7 +256,7 @@ get_nth_buddy(int index)
>  }
>  
>  char *
> -command_generator (const char *text, int stat)
> +command_generator (const char *text, int state)
>  {
>    static int i, len;
>    static int buddy_index, toggle_index;
> @@ -209,29 +265,94 @@ command_generator (const char
> *text, int
>    char *dynamic_command;
>    char *name;
>    yahoo_account *temp_buddy;
> +  regex_t preg;
> +  char curr_char = rl_line_buffer[rl_point];
> +  conf_room *rooms;
> +  YList *conflist = NULL;
> +  static char complete_buddy = 0,
> +           complete_conf = 0,
> +           complete_toggle = 0,
> +           complete_file = 0,
> +              complete_cmd = 0; // flags because
> regex is expensive
>  
> -  if (!stat)
> +  if (!state)
>      {
>        len = strlen (text);
>        i = 0;
>        buddy_index   = 0;
>        toggle_index  = 0;
>        dynamic_cmd_index = 0;
> -    }
> +      complete_buddy = 0;
> +      complete_conf = 0;
> +      complete_toggle = 0;
> +      complete_cmd = 0;
> +      complete_file = 0;
> +      conflist = get_fh_conferences();
> +
> +     
> +      rl_line_buffer[rl_point] = '\0'; /* the
> effect should be such
> +                                      * that the cursor position
> +                                      * is at the end of line for
> +                                      * the auto completion regex
> +                                      * above (note the $ at end)
> +                                      */
> +
> +      /* check for the d00d's need in the context
> */
> +     
>
regcomp(&preg,autocomplete_buddy_regex,REG_EXTENDED|REG_ICASE);
> +      if ( 
> !regexec(&preg,rl_line_buffer,0,NULL,0))
> +        {
> +            complete_buddy = 1;
> +        }
> +       regfree(&preg);
>  
> -  // if your command takes buddy_name as argument
> then you
> -  // will have to add ur command in this check list
> -  if ((strncmp (rl_line_buffer, "?remove ", 8) ==
> 0)
> -      || (strncmp (rl_line_buffer, "?send ", 6) ==
> 0)
> -      || (strncmp (rl_line_buffer, "?reject ", 8)
> == 0)
> 
=== message truncated ===> 



                
__________________________________ 
Do you Yahoo!? 
All your favorites on one personal page – Try My Yahoo!
http://my.yahoo.com 




reply via email to

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