Added window command.
authorEric Kohl <eric.kohl@reactos.org>
Fri, 24 Sep 1999 22:03:11 +0000 (22:03 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Fri, 24 Sep 1999 22:03:11 +0000 (22:03 +0000)
svn path=/trunk/; revision=669

rosapps/cmd/cmd.h
rosapps/cmd/cmdtable.c
rosapps/cmd/config.h
rosapps/cmd/makefile
rosapps/cmd/misc.c
rosapps/cmd/msgbox.c
rosapps/cmd/window.c [new file with mode: 0644]

index 24276f3..28e25b7 100644 (file)
@@ -287,6 +287,9 @@ BOOL   IsValidPathName (LPCTSTR);
 BOOL   IsValidFileName (LPCTSTR);
 BOOL   IsValidDirectory (LPCTSTR);
 BOOL   FileGetString (HANDLE, LPTSTR, INT);
 BOOL   IsValidFileName (LPCTSTR);
 BOOL   IsValidDirectory (LPCTSTR);
 BOOL   FileGetString (HANDLE, LPTSTR, INT);
+#ifndef __REACTOS__
+HWND   GetConsoleWindow(VOID);
+#endif
 
 
 /* Prototypes for MOVE.C */
 
 
 /* Prototypes for MOVE.C */
@@ -363,7 +366,8 @@ INT cmd_vol (LPTSTR, LPTSTR);
 /* Prototypes for WHERE.C */
 BOOL SearchForExecutable (LPCTSTR, LPTSTR);
 
 /* Prototypes for WHERE.C */
 BOOL SearchForExecutable (LPCTSTR, LPTSTR);
 
-
+/* Prototypes for WINDOW.C */
+INT CommandWindow (LPTSTR, LPTSTR);
 
 
 /* The MSDOS Batch Commands [MS-DOS 5.0 User's Guide and Reference p359] */
 
 
 /* The MSDOS Batch Commands [MS-DOS 5.0 User's Guide and Reference p359] */
index 352118e..fc8a483 100644 (file)
@@ -217,6 +217,10 @@ COMMAND cmds[] =
        {_T("vol"), 0, cmd_vol},
 #endif
 
        {_T("vol"), 0, cmd_vol},
 #endif
 
+#ifdef INCLUDE_CMD_WINDOW
+        {_T("window"), 0, CommandWindow},
+#endif
+
        {NULL, 0, NULL}
 };
 
        {NULL, 0, NULL}
 };
 
index 591d372..2a93103 100644 (file)
@@ -95,6 +95,9 @@
 #define INCLUDE_CMD_BEEP
 #define INCLUDE_CMD_VERIFY
 #define INCLUDE_CMD_VOL
 #define INCLUDE_CMD_BEEP
 #define INCLUDE_CMD_VERIFY
 #define INCLUDE_CMD_VOL
+#ifndef __REACTOS__
+#define INCLUDE_CMD_WINDOW
+#endif
 
 /*
 commands that do not have a define:
 
 /*
 commands that do not have a define:
index 61a3782..9a906c3 100644 (file)
@@ -12,7 +12,7 @@ OBJECTS = cmd.o attrib.o alias.o batch.o beep.o call.o chcp.o choice.o \
           goto.o history.o if.o internal.o label.o locale.o memory.o misc.o \
           move.o msgbox.o path.o pause.o prompt.o redir.o ren.o screen.o \
           set.o shift.o start.o time.o timer.o title.o type.o ver.o \
           goto.o history.o if.o internal.o label.o locale.o memory.o misc.o \
           move.o msgbox.o path.o pause.o prompt.o redir.o ren.o screen.o \
           set.o shift.o start.o time.o timer.o title.o type.o ver.o \
-          verify.o vol.o where.o cmd.coff
+          verify.o vol.o where.o window.o cmd.coff
 
 CLEAN_FILES = *.o cmd.exe cmd.sym cmd.coff
 
 
 CLEAN_FILES = *.o cmd.exe cmd.sym cmd.coff
 
@@ -46,7 +46,7 @@ $(TARGET:%=../$(DIST_DIR)/apps/%): ../$(DIST_DIR)/apps/%: %
 ifeq ($(DOSCLI),yes)
        $(CP) $* ..\$(DIST_DIR)\apps\$*
 else
 ifeq ($(DOSCLI),yes)
        $(CP) $* ..\$(DIST_DIR)\apps\$*
 else
-       $(CP) $* ../$(DIST_DIR)/apps/$*
+       $(CP) $* ../$(DIST_DIR)/apps\$*
 endif
 
 include ../rules.mak
 endif
 
 include ../rules.mak
index 26c6b14..6523182 100644 (file)
@@ -295,3 +295,32 @@ BOOL FileGetString (HANDLE hFile, LPTSTR lpBuffer, INT nBufferLength)
 
        return TRUE;
 }
 
        return TRUE;
 }
+
+#ifndef __REACTOS__
+/*
+ * GetConsoleWindow - returns the handle to the current console window
+ */
+HWND GetConsoleWindow(VOID)
+{
+       TCHAR original[256];    /* stores original title*/
+       TCHAR temp[256];                /* stores temp title*/
+
+       HWND h=0;
+
+       GetConsoleTitle(original,sizeof(original));
+
+       _tcscpy(temp,original);
+       _tcscat(temp,_T("-xxx   "));
+
+       if((h = FindWindow("tty",temp)) == NULL )
+       {
+               SetConsoleTitle(temp);
+               h=FindWindow("tty",temp);
+               SetConsoleTitle(original);
+       }
+
+       return h;
+}
+#endif
+
+/* EOF */
\ No newline at end of file
index f6d3354..c04e2bb 100644 (file)
 #define _SYNTAX_CHECK
 
 
 #define _SYNTAX_CHECK
 
 
-
-HWND GetConsoleWindow(VOID)
-{
-       TCHAR original[256];    /*holds original title*/
-       TCHAR temp[256];        /*holds temp title*/
-
-       HWND h=0;
-
-       GetConsoleTitle(original,sizeof(original));
-
-       _tcscpy(temp,original);
-       _tcscat(temp,_T("-xxx   "));
-
-       if( FindWindow(0,temp) == NULL )
-       {
-               SetConsoleTitle(temp);
-               h=FindWindow(0,temp);
-               SetConsoleTitle(original);
-       }
-
-       return h;
-}
-
-
 INT CommandMsgbox (LPTSTR cmd, LPTSTR param)
 {
        //used to parse command line
 INT CommandMsgbox (LPTSTR cmd, LPTSTR param)
 {
        //used to parse command line
@@ -171,7 +147,8 @@ INT CommandMsgbox (LPTSTR cmd, LPTSTR param)
        prompt = param;
 
        hWnd=GetConsoleWindow ();
        prompt = param;
 
        hWnd=GetConsoleWindow ();
-       //DebugPrintf("FindWindow hWnd = %d\n",hWnd);   
+//        DebugPrintf("FindWindow hWnd = %d\n",hWnd); 
+        ConErrPrintf("FindWindow hWnd = %d\n",hWnd); 
 
        switch (
                MessageBox(hWnd,prompt,title,uType)
 
        switch (
                MessageBox(hWnd,prompt,title,uType)
diff --git a/rosapps/cmd/window.c b/rosapps/cmd/window.c
new file mode 100644 (file)
index 0000000..4e207b5
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+ * WINDOW.C - internal command.
+ *
+ * clone from 4nt window command
+ *
+ * 10 Sep 1999
+ *     started - Dr.F <dfaustus@freemail.it>
+ *
+ *
+ */
+
+#include "config.h"
+
+#ifdef INCLUDE_CMD_WINDOW
+
+#include "cmd.h"
+#include <windows.h>
+#include <stdlib.h>
+#include <string.h>
+#include <tchar.h>
+
+
+#define A_MIN          0x01
+#define A_MAX          0x02
+#define A_RESTORE      0x04
+#define A_POS          0x08
+#define A_SIZE         0x10
+
+
+
+
+INT CommandWindow (LPTSTR cmd, LPTSTR param)
+{
+       LPTSTR *p;
+       INT argc,i;
+
+       INT iAction=0;
+
+       LPTSTR title=0;
+
+       HWND hWnd;
+       WINDOWPLACEMENT wp;
+       RECT pos;
+
+       LPTSTR tmp;
+
+       if (_tcsncmp (param, _T("/?"), 2) == 0)
+       {
+               ConOutPuts(_T(
+                             "change console window aspect\n"
+                             "\n"
+                                       "WINDOW [/POS[=]left,top,width,heigth]\n"
+                                       "              [MIN|MAX|RESTORE]\n"
+                                       "\n"                                    
+                                       "/POS          specify window placement and dimensions\n"
+                                       "MIN           minimize the winodw\n"
+                                       "MAX           maximize the winodw\n"
+                                       "RESTORE       restore the window"                                      
+                                  ));
+               return 0;
+       }
+
+       p=split(param,&argc);
+
+       for(i=0;i <argc;i++)
+       {
+               if (_tcsicmp(p[i],_T("min"))==0)
+               {
+                       iAction |=A_MIN;
+                       continue;
+               }
+
+               if (_tcsicmp(p[i],_T("max"))==0)
+               {
+                       iAction |=A_MAX;
+                       continue;
+               }
+
+               if (_tcsicmp(p[i],_T("restore"))==0)
+               {
+                       iAction |=A_RESTORE;
+                       continue;
+               }
+
+               if (_tcsnicmp(p[i],_T("/pos"),4)==0)
+               {
+                       iAction |=A_POS;
+                       tmp = p[i]+4;
+                       if (*tmp == _T('='))
+                               tmp++;
+
+                       pos.left=_ttoi(tmp);
+                       if(!(tmp=_tcschr(tmp,_T(','))))
+                       {
+                               error_invalid_parameter_format(p[i]);
+                               freep(p);
+                               return 1;
+                       }
+
+                       pos.top=_ttoi(++tmp);
+                       if(!(tmp=_tcschr(tmp,_T(','))))
+                       {
+                               error_invalid_parameter_format(p[i]);
+                               freep(p);
+                               return 1;
+                       }
+
+                       pos.right=_ttoi(++tmp)+pos.left;
+                       if(!(tmp=_tcschr(tmp,_T(','))))
+                       {
+                               error_invalid_parameter_format(p[i]);
+                               freep(p);
+                               return 1;
+                       }
+                       pos.bottom=_ttoi(++tmp)+pos.top;
+
+                       continue;
+               }
+
+               if (_tcsnicmp(p[i],_T("/size"),5)==0)
+               {
+                       iAction |=A_SIZE;
+                       continue;
+               }
+
+#if 0
+               if(*p[i] != _T('"'))
+               {
+                       error_invalid_parameter_format(p[i]);
+                       
+                       freep(p);
+                       return 1;
+               }
+#endif
+
+               //none of them=window title
+               if (title)
+               {
+                       error_invalid_parameter_format(p[i]);
+                       freep(p);
+                       return 1;
+               }
+
+               if (p[i][0] ==_T('"'))
+               {
+                       title = (p[i]+1);
+                       *_tcschr(p[i]+1,_T('"'))=0;
+                       continue;
+               }
+               title = p[i];
+       }
+
+       if(title)
+               SetConsoleTitle(title);
+
+       hWnd=GetConsoleWindow();
+
+       wp.length=sizeof(WINDOWPLACEMENT);
+       GetWindowPlacement(hWnd,&wp);
+
+       if(iAction & A_POS)
+       {
+               wp.rcNormalPosition = pos;
+       }
+
+       if(iAction & A_MIN)
+               wp.showCmd=SW_MINIMIZE;
+
+       if(iAction & A_MAX)
+               wp.showCmd=SW_SHOWMAXIMIZED;
+
+       if(iAction & A_RESTORE)
+               wp.showCmd=SW_RESTORE;
+
+       wp.length=sizeof(WINDOWPLACEMENT);
+       SetWindowPlacement(hWnd,&wp);
+
+       return 0;
+}
+
+#endif /* INCLUDE_CMD_WINDOW */