]> git.saurik.com Git - cycript.git/commitdiff
Speed up tab completion and hide $cy* identifiers.
authorJay Freeman (saurik) <saurik@saurik.com>
Mon, 4 Jan 2016 03:11:49 +0000 (19:11 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Mon, 4 Jan 2016 03:11:49 +0000 (19:11 -0800)
Complete.cpp

index 1b1d0dc3742749700f7d227eee454ba05e8b393c..8240068428fc4e060dd5308415bf7868e93c173b 100644 (file)
@@ -146,7 +146,7 @@ _visible char **CYComplete(const char *word, const std::string &line, CYUTF8Stri
         return NULL;
 
     // XXX: use an std::set?
         return NULL;
 
     // XXX: use an std::set?
-    typedef std::vector<std::string> Completions;
+    typedef std::vector<CYUTF8String> Completions;
     Completions completions;
 
     std::string common;
     Completions completions;
 
     std::string common;
@@ -160,27 +160,30 @@ _visible char **CYComplete(const char *word, const std::string &line, CYUTF8Stri
         CYString *string(dynamic_cast<CYString *>(value->value_));
         _assert(string != NULL);
 
         CYString *string(dynamic_cast<CYString *>(value->value_));
         _assert(string != NULL);
 
-        std::string completion;
+        CYUTF8String completion;
         if (string->size_ != 0)
         if (string->size_ != 0)
-            completion.assign(string->value_, string->size_);
+            completion = {string->value_, string->size_};
         else if (driver.mode_ == CYDriver::AutoMessage)
             completion = "]";
         else
             continue;
 
         else if (driver.mode_ == CYDriver::AutoMessage)
             completion = "]";
         else
             continue;
 
+        if (CYStartsWith(completion, "$cy"))
+            continue;
+
         completions.push_back(completion);
 
         if (!rest) {
             common = completion;
             rest = true;
         } else {
         completions.push_back(completion);
 
         if (!rest) {
             common = completion;
             rest = true;
         } else {
-            size_t limit(completion.size()), size(common.size());
+            size_t limit(completion.size), size(common.size());
             if (size > limit)
                 common = common.substr(0, limit);
             else
                 limit = size;
             for (limit = 0; limit != size; ++limit)
             if (size > limit)
                 common = common.substr(0, limit);
             else
                 limit = size;
             for (limit = 0; limit != size; ++limit)
-                if (common[limit] != completion[limit])
+                if (common[limit] != completion.data[limit])
                     break;
             if (limit != size)
                 common = common.substr(0, limit);
                     break;
             if (limit != size)
                 common = common.substr(0, limit);
@@ -202,7 +205,7 @@ _visible char **CYComplete(const char *word, const std::string &line, CYUTF8Stri
     results[0] = strdup(common.c_str());
     size_t index(0);
     for (Completions::const_iterator i(completions.begin()); i != completions.end(); ++i)
     results[0] = strdup(common.c_str());
     size_t index(0);
     for (Completions::const_iterator i(completions.begin()); i != completions.end(); ++i)
-        results[++index] = strdup(i->c_str());
+        results[++index] = strdup(i->data);
     results[count + 1] = NULL;
 
     return results;
     results[count + 1] = NULL;
 
     return results;