- Made the partition list movable if it is necessary.

svn path=/trunk/; revision=10635
This commit is contained in:
Hartmut Birr 2004-08-21 19:30:12 +00:00
parent 0ebfb773cb
commit 9995491445
2 changed files with 172 additions and 58 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: partlist.c,v 1.27 2004/08/15 22:29:50 chorns Exp $ /* $Id: partlist.c,v 1.28 2004/08/21 19:30:12 hbirr Exp $
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS text-mode setup * PROJECT: ReactOS text-mode setup
* FILE: subsys/system/usetup/partlist.c * FILE: subsys/system/usetup/partlist.c
@ -719,24 +719,24 @@ PrintEmptyLine (PPARTLIST List)
USHORT Height; USHORT Height;
Width = List->Right - List->Left - 1; Width = List->Right - List->Left - 1;
Height = List->Bottom - List->Top - 1; Height = List->Bottom - List->Top - 2;
if (List->Line < 0 || List->Line > Height)
return;
coPos.X = List->Left + 1; coPos.X = List->Left + 1;
coPos.Y = List->Top + 1 + List->Line; coPos.Y = List->Top + 1 + List->Line;
FillConsoleOutputAttribute (0x17, if (List->Line >= 0 && List->Line <= Height)
Width, {
coPos, FillConsoleOutputAttribute (0x17,
&Written); Width,
coPos,
FillConsoleOutputCharacter (' ', &Written);
Width,
coPos,
&Written);
FillConsoleOutputCharacter (' ',
Width,
coPos,
&Written);
}
List->Line++; List->Line++;
} }
@ -758,10 +758,8 @@ PrintPartitionData (PPARTLIST List,
PCHAR PartType; PCHAR PartType;
Width = List->Right - List->Left - 1; Width = List->Right - List->Left - 1;
Height = List->Bottom - List->Top - 1; Height = List->Bottom - List->Top - 2;
if (List->Line < 0 || List->Line > Height)
return;
coPos.X = List->Left + 1; coPos.X = List->Left + 1;
coPos.Y = List->Top + 1 + List->Line; coPos.Y = List->Top + 1 + List->Line;
@ -864,24 +862,30 @@ PrintPartitionData (PPARTLIST List,
Attribute = (List->CurrentDisk == DiskEntry && Attribute = (List->CurrentDisk == DiskEntry &&
List->CurrentPartition == PartEntry) ? 0x71 : 0x17; List->CurrentPartition == PartEntry) ? 0x71 : 0x17;
FillConsoleOutputCharacter (' ', if (List->Line >= 0 && List->Line <= Height)
Width, {
coPos, FillConsoleOutputCharacter (' ',
&Written); Width,
coPos,
&Written);
}
coPos.X += 4; coPos.X += 4;
Width -= 8; Width -= 8;
FillConsoleOutputAttribute (Attribute, if (List->Line >= 0 && List->Line <= Height)
Width, {
coPos, FillConsoleOutputAttribute (Attribute,
&Written); Width,
coPos,
&Written);
}
coPos.X++; coPos.X++;
Width -= 2; Width -= 2;
WriteConsoleOutputCharacters (LineBuffer, if (List->Line >= 0 && List->Line <= Height)
min (strlen (LineBuffer), Width), {
coPos); WriteConsoleOutputCharacters (LineBuffer,
min (strlen (LineBuffer), Width),
coPos);
}
List->Line++; List->Line++;
} }
@ -901,10 +905,8 @@ PrintDiskData (PPARTLIST List,
PCHAR Unit; PCHAR Unit;
Width = List->Right - List->Left - 1; Width = List->Right - List->Left - 1;
Height = List->Bottom - List->Top - 1; Height = List->Bottom - List->Top - 2;
if (List->Line < 0 || List->Line > Height)
return;
coPos.X = List->Left + 1; coPos.X = List->Left + 1;
coPos.Y = List->Top + 1 + List->Line; coPos.Y = List->Top + 1 + List->Line;
@ -947,22 +949,26 @@ PrintDiskData (PPARTLIST List,
DiskEntry->Bus, DiskEntry->Bus,
DiskEntry->Id); DiskEntry->Id);
} }
if (List->Line >= 0 && List->Line <= Height)
FillConsoleOutputAttribute (0x17, {
Width, FillConsoleOutputAttribute (0x17,
coPos, Width,
&Written); coPos,
&Written);
FillConsoleOutputCharacter (' ',
Width, FillConsoleOutputCharacter (' ',
coPos, Width,
&Written); coPos,
&Written);
}
coPos.X++; coPos.X++;
WriteConsoleOutputCharacters (LineBuffer, if (List->Line >= 0 && List->Line <= Height)
min (strlen (LineBuffer), Width - 2), {
coPos); WriteConsoleOutputCharacters (LineBuffer,
min (strlen (LineBuffer), Width - 2),
coPos);
}
List->Line++; List->Line++;
/* Print separator line */ /* Print separator line */
@ -990,11 +996,80 @@ PrintDiskData (PPARTLIST List,
VOID VOID
DrawPartitionList (PPARTLIST List) DrawPartitionList (PPARTLIST List)
{ {
PLIST_ENTRY Entry; PLIST_ENTRY Entry, Entry2;
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry = NULL;
COORD coPos; COORD coPos;
ULONG Written; ULONG Written;
SHORT i; SHORT i;
SHORT CurrentDiskLine;
SHORT CurrentPartLine;
SHORT LastLine;
BOOL CurrentPartLineFound = FALSE;
BOOL CurrentDiskLineFound = FALSE;
/* Calculate the line of the current disk and partition */
CurrentDiskLine = 0;
CurrentPartLine = 0;
LastLine = 0;
Entry = List->DiskListHead.Flink;
while (Entry != &List->DiskListHead)
{
DiskEntry = CONTAINING_RECORD (Entry, DISKENTRY, ListEntry);
LastLine += 2;
if (CurrentPartLineFound == FALSE)
{
CurrentPartLine += 2;
}
Entry2 = DiskEntry->PartListHead.Flink;
while (Entry2 != &DiskEntry->PartListHead)
{
PartEntry = CONTAINING_RECORD (Entry2, PARTENTRY, ListEntry);
if (PartEntry == List->CurrentPartition)
{
CurrentPartLineFound = TRUE;;
}
Entry2 = Entry2->Flink;
if (CurrentPartLineFound == FALSE)
{
CurrentPartLine++;
}
LastLine++;
}
if (DiskEntry == List->CurrentDisk)
{
CurrentDiskLineFound = TRUE;
}
Entry = Entry->Flink;
if (Entry != &List->DiskListHead)
{
if (CurrentDiskLineFound == FALSE)
{
CurrentPartLine ++;
CurrentDiskLine = CurrentPartLine;
}
LastLine++;
}
else
{
LastLine--;
}
}
/* If it possible, make the disk name visible */
if (CurrentPartLine < List->Offset)
{
List->Offset = CurrentPartLine;
}
else if (CurrentPartLine - List->Offset > List->Bottom - List->Top - 2)
{
List->Offset = CurrentPartLine - (List->Bottom - List->Top - 2);
}
if (CurrentDiskLine < List->Offset && CurrentPartLine - CurrentDiskLine < List->Bottom - List->Top - 2)
{
List->Offset = CurrentDiskLine;
}
/* draw upper left corner */ /* draw upper left corner */
coPos.X = List->Left; coPos.X = List->Left;
@ -1007,10 +1082,29 @@ DrawPartitionList (PPARTLIST List)
/* draw upper edge */ /* draw upper edge */
coPos.X = List->Left + 1; coPos.X = List->Left + 1;
coPos.Y = List->Top; coPos.Y = List->Top;
FillConsoleOutputCharacter (0xC4, // '-', if (List->Offset == 0)
List->Right - List->Left - 1, {
coPos, FillConsoleOutputCharacter (0xC4, // '-',
&Written); List->Right - List->Left - 1,
coPos,
&Written);
}
else
{
FillConsoleOutputCharacter (0xC4, // '-',
List->Right - List->Left - 5,
coPos,
&Written);
coPos.X = List->Right - 5;
WriteConsoleOutputCharacters ("(\x18)", // "(up)"
3,
coPos);
coPos.X = List->Right - 2;
FillConsoleOutputCharacter (0xC4, // '-',
2,
coPos,
&Written);
}
/* draw upper right corner */ /* draw upper right corner */
coPos.X = List->Right; coPos.X = List->Right;
@ -1048,10 +1142,29 @@ DrawPartitionList (PPARTLIST List)
/* draw lower edge */ /* draw lower edge */
coPos.X = List->Left + 1; coPos.X = List->Left + 1;
coPos.Y = List->Bottom; coPos.Y = List->Bottom;
FillConsoleOutputCharacter (0xC4, // '-', if (LastLine - List->Offset <= List->Bottom - List->Top - 2)
List->Right - List->Left - 1, {
coPos, FillConsoleOutputCharacter (0xC4, // '-',
&Written); List->Right - List->Left - 1,
coPos,
&Written);
}
else
{
FillConsoleOutputCharacter (0xC4, // '-',
List->Right - List->Left - 5,
coPos,
&Written);
coPos.X = List->Right - 5;
WriteConsoleOutputCharacters ("(\x19)", // "(down)"
3,
coPos);
coPos.X = List->Right - 2;
FillConsoleOutputCharacter (0xC4, // '-',
2,
coPos,
&Written);
}
/* draw lower right corner */ /* draw lower right corner */
coPos.X = List->Right; coPos.X = List->Right;
@ -1062,7 +1175,7 @@ DrawPartitionList (PPARTLIST List)
&Written); &Written);
/* print list entries */ /* print list entries */
List->Line = 0; List->Line = - List->Offset;
Entry = List->DiskListHead.Flink; Entry = List->DiskListHead.Flink;
while (Entry != &List->DiskListHead) while (Entry != &List->DiskListHead)

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: partlist.h,v 1.22 2003/10/06 19:22:42 chorns Exp $ /* $Id: partlist.h,v 1.23 2004/08/21 19:30:12 hbirr Exp $
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS text-mode setup * PROJECT: ReactOS text-mode setup
* FILE: subsys/system/usetup/partlist.h * FILE: subsys/system/usetup/partlist.h
@ -106,6 +106,7 @@ typedef struct _PARTLIST
SHORT Bottom; SHORT Bottom;
SHORT Line; SHORT Line;
SHORT Offset;
ULONG TopDisk; ULONG TopDisk;
ULONG TopPartition; ULONG TopPartition;