[CMD] Show the executed command in the title, do not restore the old title when it...
authorMark Jansen <mark.jansen@reactos.org>
Thu, 22 Dec 2016 21:25:37 +0000 (21:25 +0000)
committerMark Jansen <mark.jansen@reactos.org>
Thu, 22 Dec 2016 21:25:37 +0000 (21:25 +0000)
svn path=/trunk/; revision=73478

reactos/base/shell/cmd/cmd.c
reactos/base/shell/cmd/title.c

index ed162bf..acabece 100644 (file)
@@ -163,6 +163,7 @@ CRITICAL_SECTION ChildProcessRunningLock;
 BOOL bUnicodeOutput = FALSE;
 BOOL bDisableBatchEcho = FALSE;
 BOOL bDelayedExpansion = FALSE;
 BOOL bUnicodeOutput = FALSE;
 BOOL bDisableBatchEcho = FALSE;
 BOOL bDelayedExpansion = FALSE;
+BOOL bTitleSet = FALSE;
 DWORD dwChildProcessId = 0;
 HANDLE hIn;
 HANDLE hOut;
 DWORD dwChildProcessId = 0;
 HANDLE hIn;
 HANDLE hOut;
@@ -314,7 +315,7 @@ Execute(LPTSTR Full, LPTSTR First, LPTSTR Rest, PARSED_COMMAND *Cmd)
 {
     TCHAR szFullName[MAX_PATH];
     TCHAR *first, *rest, *dot;
 {
     TCHAR szFullName[MAX_PATH];
     TCHAR *first, *rest, *dot;
-    TCHAR szWindowTitle[MAX_PATH];
+    TCHAR szWindowTitle[MAX_PATH], szNewTitle[MAX_PATH*2];
     DWORD dwExitCode = 0;
     TCHAR *FirstEnd;
     TCHAR szFullCmdLine [CMDLINE_LENGTH];
     DWORD dwExitCode = 0;
     TCHAR *FirstEnd;
     TCHAR szFullCmdLine [CMDLINE_LENGTH];
@@ -377,7 +378,10 @@ Execute(LPTSTR Full, LPTSTR First, LPTSTR Rest, PARSED_COMMAND *Cmd)
         return 1;
     }
 
         return 1;
     }
 
-    GetConsoleTitle (szWindowTitle, MAX_PATH);
+    GetConsoleTitle(szWindowTitle, ARRAYSIZE(szWindowTitle));
+    bTitleSet = FALSE;
+    _stprintf(szNewTitle, _T("%s - %s%s"), szWindowTitle, First, Rest);
+    SetConsoleTitle(szNewTitle);
 
     /* check if this is a .BAT or .CMD file */
     dot = _tcsrchr (szFullName, _T('.'));
 
     /* check if this is a .BAT or .CMD file */
     dot = _tcsrchr (szFullName, _T('.'));
@@ -475,7 +479,8 @@ Execute(LPTSTR Full, LPTSTR First, LPTSTR Rest, PARSED_COMMAND *Cmd)
     /* Get code page if it has been changed */
     InputCodePage= GetConsoleCP();
     OutputCodePage = GetConsoleOutputCP();
     /* Get code page if it has been changed */
     InputCodePage= GetConsoleCP();
     OutputCodePage = GetConsoleOutputCP();
-    SetConsoleTitle(szWindowTitle);
+    if (!bTitleSet)
+        SetConsoleTitle(szWindowTitle);
 
     return dwExitCode;
 }
 
     return dwExitCode;
 }
index 1fa9179..130cb17 100644 (file)
@@ -13,6 +13,7 @@
 
 #ifdef INCLUDE_CMD_TITLE
 
 
 #ifdef INCLUDE_CMD_TITLE
 
+extern BOOL bTitleSet;
 
 INT cmd_title (LPTSTR param)
 {
 
 INT cmd_title (LPTSTR param)
 {
@@ -27,6 +28,7 @@ INT cmd_title (LPTSTR param)
         return 0;
     }
 
         return 0;
     }
 
+    bTitleSet = TRUE;
     return SetConsoleTitle (param);
 }
 
     return SetConsoleTitle (param);
 }