libcvd-members
[Top][All Lists]
Advanced

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

[Libcvd-members] gvars3/src GUI.cc


From: Georg Klein
Subject: [Libcvd-members] gvars3/src GUI.cc
Date: Tue, 16 May 2006 11:09:55 +0000

CVSROOT:        /cvsroot/libcvd
Module name:    gvars3
Branch:         
Changes by:     Georg Klein <address@hidden>    06/05/16 11:09:55

Modified files:
        src            : GUI.cc 

Log message:
        Make tab-completion of values work on = as well

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/gvars3/src/GUI.cc.diff?tr1=1.8&tr2=1.9&r1=text&r2=text

Patches:
Index: gvars3/src/GUI.cc
diff -u gvars3/src/GUI.cc:1.8 gvars3/src/GUI.cc:1.9
--- gvars3/src/GUI.cc:1.8       Mon May  8 14:17:07 2006
+++ gvars3/src/GUI.cc   Tue May 16 11:09:55 2006
@@ -80,22 +80,32 @@
        while(tag_i != tags.end())
        {
                int text_len = strlen(szText);
-               string current = *tag_i;
+               bool bEqualsAtEnd = false;
+               if(text_len>0)
+                 if(szText[text_len-1]=='=')
+                   bEqualsAtEnd = true;
+               string sCurrent = *tag_i;
+               string sComparison = *tag_i;
+               if(bEqualsAtEnd)
+                 sComparison = sComparison + "=";
 
                tag_i++;
 
-               if(strncmp(szText, current.c_str(), text_len) == 0)
-               {
+               if(strncmp(szText, sComparison.c_str(), text_len) == 0)
+                 {
                        //If it's a prefect match, complete with the value
-                       if(text_len == current.size())
-                               current = szText + ("=" + GV3::get_var(szText));
-                               
+                       string sCompleted;
+                       if(text_len == sComparison.size())
+                         sCompleted = szText + ((bEqualsAtEnd?"":"=") + 
GV3::get_var(sCurrent));
+                       else
+                         sCompleted = sCurrent;
+                       
                        char* r;
                        
-                       if((r= (char*)malloc(current.size() + 1)) == NULL)
+                       if((r= (char*)malloc(sCompleted.size() + 1)) == NULL)
                                return 0;
 
-                       strcpy(r, current.c_str());
+                       strcpy(r, sCompleted.c_str());
                        return r;
                }
        }
@@ -630,6 +640,7 @@
 {
   mpReadlineCompleterGUI = this;
   rl_attempted_completion_function = ReadlineCompletionFunction;
+  rl_basic_word_break_characters = " \t\n\"\\'address@hidden><;|&{("; 
 }
 
 int GUI::parseArguments( const int argc, char * argv[], int start, const 
string prefix, const string execKeyword ){




reply via email to

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