update for HEAD-2003091401
[reactos.git] / subsys / system / usetup / fslist.c
1 /*
2  *  ReactOS kernel
3  *  Copyright (C) 2003 ReactOS Team
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 /*
20  * COPYRIGHT:       See COPYING in the top level directory
21  * PROJECT:         ReactOS text-mode setup
22  * FILE:            subsys/system/usetup/fslist.c
23  * PURPOSE:         Filesystem list functions
24  * PROGRAMMER:      Eric Kohl
25  *                  Casper S. Hornstrup (chorns@users.sourceforge.net)
26  */
27
28 #include <ddk/ntddk.h>
29 #include <ddk/ntddscsi.h>
30
31 #include <ntdll/rtl.h>
32
33 //#include <ntos/minmax.h>
34
35 #include "usetup.h"
36 #include "console.h"
37 #include "fslist.h"
38
39
40 /* FUNCTIONS ****************************************************************/
41
42 PFILE_SYSTEM_LIST
43 CreateFileSystemList (SHORT Left,
44                       SHORT Top,
45                       BOOLEAN ForceFormat,
46                       FILE_SYSTEM ForceFileSystem)
47 {
48   PFILE_SYSTEM_LIST List;
49
50   List = (PFILE_SYSTEM_LIST)RtlAllocateHeap (ProcessHeap, 0, sizeof(FILE_SYSTEM_LIST));
51   if (List == NULL)
52     return NULL;
53
54   List->Left = Left;
55   List->Top = Top;
56
57   List->ForceFormat = ForceFormat;
58   List->FileSystemCount = 1;
59   if (ForceFormat)
60     {
61       List->CurrentFileSystem = ForceFileSystem;
62     }
63   else
64     {
65       List->FileSystemCount++;
66       List->CurrentFileSystem = FsKeep;
67     }
68
69   return List;
70 }
71
72
73 VOID
74 DestroyFileSystemList (PFILE_SYSTEM_LIST List)
75 {
76   RtlFreeHeap (ProcessHeap, 0, List);
77 }
78
79
80 VOID
81 DrawFileSystemList (PFILE_SYSTEM_LIST List)
82 {
83   COORD coPos;
84   ULONG Written;
85   ULONG Index;
86
87   Index = 0;
88
89   coPos.X = List->Left;
90   coPos.Y = List->Top + Index;
91   FillConsoleOutputAttribute (0x17,
92                               50,
93                               coPos,
94                               &Written);
95   FillConsoleOutputCharacter (' ',
96                               50,
97                               coPos,
98                               &Written);
99
100   if (List->CurrentFileSystem == FsFat)
101     {
102       SetInvertedTextXY (List->Left,
103                          List->Top + Index,
104                          " Format partition as FAT file system ");
105     }
106   else
107     {
108       SetTextXY (List->Left,
109                  List->Top + Index,
110                  " Format partition as FAT file system ");
111     }
112   Index++;
113
114   if (List->ForceFormat == FALSE)
115     {
116       coPos.X = List->Left;
117       coPos.Y = List->Top + Index;
118       FillConsoleOutputAttribute (0x17,
119                                   50,
120                                   coPos,
121                                   &Written);
122       FillConsoleOutputCharacter (' ',
123                                   50,
124                                   coPos,
125                                   &Written);
126
127       if (List->CurrentFileSystem == FsKeep)
128         {
129           SetInvertedTextXY (List->Left,
130                              List->Top + Index,
131                              " Keep current file system (no changes) ");
132         }
133       else
134         {
135           SetTextXY (List->Left,
136                      List->Top + Index,
137                      " Keep current file system (no changes) ");
138         }
139     }
140 }
141
142
143 VOID
144 ScrollDownFileSystemList (PFILE_SYSTEM_LIST List)
145 {
146   if ((ULONG) List->CurrentFileSystem < List->FileSystemCount - 1)
147     {
148       (ULONG) List->CurrentFileSystem++;
149       DrawFileSystemList (List);
150     }
151 }
152
153
154 VOID
155 ScrollUpFileSystemList (PFILE_SYSTEM_LIST List)
156 {
157   if ((ULONG) List->CurrentFileSystem > 0)
158     {
159       (ULONG) List->CurrentFileSystem--;
160       DrawFileSystemList (List);
161     }
162 }
163
164 /* EOF */