From c93c944f4b8d8fd28b2f8cd66397db6af13a8d27 Mon Sep 17 00:00:00 2001 From: ac_stef Date: Fri, 12 Sep 2008 14:39:20 +0000 Subject: [PATCH] case insensitive tab-completion git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2547 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/command.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/source/src/command.cpp b/source/src/command.cpp index 7eaf6ec1..e96b9824 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -418,6 +418,8 @@ void resetcomplete() completeplayer = NULL; } +int _strncmpi(const char *a, const char *b, int len) { while(len--) if(tolower(*a++) != tolower(*b++)) return *--a - *--b; return 0; } + bool nickcomplete(char *s) { if(!players.length()) return false; @@ -437,7 +439,7 @@ bool nickcomplete(char *s) for(int i=idx; iname, cp, completesize)) + if(p && !_strncmpi(p->name, cp, completesize)) { *cp = '\0'; s_strcat(s, p->name); @@ -476,11 +478,11 @@ void commandcomplete(char *s) } } } - if(*cp == '/') - { + if(*cp == '/' || *cp == ';') + { // commandname completion int idx = 0; enumerate(*idents, ident, id, - if(strncmp(id.name, cp+1, completesize)==0 && idx++==completeidx) + if(_strncmpi(id.name, cp+1, completesize)==0 && idx++==completeidx) { cp[1] = '\0'; s_strcat(s, id.name); @@ -490,12 +492,12 @@ void commandcomplete(char *s) if(completeidx>=idx) completeidx = 0; } else - { + { // argument completion cvector &list = strncmp(s, "/newent", 7) ? maplist : newentlist; loopv(list) { int j = (i + completeidx) % list.length(); - if(!strncmp(list[j], cp + 1, completesize)) + if(!_strncmpi(list[j], cp + 1, completesize)) { cp[1] = '\0'; s_strcat(s, list[j]);