From beb406943712975fdb299e592657a73ed60c58ad Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Sun, 21 Jan 2007 14:12:02 +0000 Subject: [PATCH] lines starting with cd will only get directories when doing tabcompletion. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2775 --- src/shell/shell_misc.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/shell/shell_misc.cpp b/src/shell/shell_misc.cpp index ebd986f0..dbdfe404 100644 --- a/src/shell/shell_misc.cpp +++ b/src/shell/shell_misc.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: shell_misc.cpp,v 1.47 2007-01-08 19:45:42 qbix79 Exp $ */ +/* $Id: shell_misc.cpp,v 1.48 2007-01-21 14:12:02 qbix79 Exp $ */ #include #include @@ -215,6 +215,8 @@ void DOS_Shell::InputCommand(char * line) { if (it_completion == l_completion.end()) it_completion = l_completion.begin(); } else { // build new completion list + // Lines starting with CD will only get directories in the list + bool dir_only = (strncasecmp(line,"CD ",3)==0); // get completion mask char *p_completion_start = strrchr(line, ' '); @@ -266,14 +268,17 @@ void DOS_Shell::InputCommand(char * line) { char *ext; // file extension if (strcmp(name, ".") && strcmp(name, "..")) { - ext = strrchr(name, '.'); - if (ext && (strcmp(ext, ".BAT") == 0 || strcmp(ext, ".COM") == 0 || strcmp(ext, ".EXE") == 0)) - // we add executables to the a seperate list and place that list infront of the normal files - executable.push_front(name); - else - l_completion.push_back(name); + if (dir_only) { //Handle the dir only case different (line starts with cd) + if(att & DOS_ATTR_DIRECTORY) l_completion.push_back(name); + } else { + ext = strrchr(name, '.'); + if (ext && (strcmp(ext, ".BAT") == 0 || strcmp(ext, ".COM") == 0 || strcmp(ext, ".EXE") == 0)) + // we add executables to the a seperate list and place that list infront of the normal files + executable.push_front(name); + else + l_completion.push_back(name); + } } - res=DOS_FindNext(); } /* Add excutable list to front of completion list. */