2 Implements titlebar interface functions.
4 Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "EditTitleBar.h"
16 #include "UefiShellDebug1CommandsLib.h"
21 Initialize a title bar.
23 @param[in] Prompt The prompt to print in the title bar.
25 @retval EFI_SUCCESS The initialization was successful.
26 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
34 SHELL_FREE_NON_NULL (Title
);
36 Title
= CatSPrint (NULL
, L
"");
41 Title
= CatSPrint (NULL
, L
"%s", Prompt
);
44 return EFI_OUT_OF_RESOURCES
;
51 Clean up the memory used.
59 SHELL_FREE_NON_NULL (Title
);
64 UINT32 Foreground
: 4;
65 UINT32 Background
: 4;
66 } TITLE_BAR_COLOR_ATTRIBUTES
;
69 TITLE_BAR_COLOR_ATTRIBUTES Colors
;
71 } TITLE_BAR_COLOR_UNION
;
74 Refresh function for MainTitleBar
76 @param[in] FileName The open file's name (or NULL).
77 @param[in] FileType The type fo the file.
78 @param[in] ReadOnly TRUE if the file is read only. FALSE otherwise.
79 @param[in] Modified TRUE if the file was modified. FALSE otherwise.
80 @param[in] LastCol The last printable column.
81 @param[in] LastRow The last printable row.
82 @param[in] Offset The offset into the file. (only for mem/disk)
83 @param[in] Size The file's size. (only for mem/disk)
85 @retval EFI_SUCCESS The operation was successful.
90 IN CONST CHAR16
*FileName OPTIONAL
,
91 IN CONST EDIT_FILE_TYPE FileType
,
92 IN CONST BOOLEAN ReadOnly
,
93 IN CONST BOOLEAN Modified
,
94 IN CONST UINTN LastCol
,
95 IN CONST UINTN LastRow
,
96 IN CONST UINTN Offset
,
100 TITLE_BAR_COLOR_UNION Orig
;
101 TITLE_BAR_COLOR_UNION New
;
102 CONST CHAR16
*FileNameTmp
;
107 // backup the old screen attributes
109 Orig
.Data
= gST
->ConOut
->Mode
->Attribute
;
110 New
.Colors
.Foreground
= Orig
.Colors
.Background
;
111 New
.Colors
.Background
= Orig
.Colors
.Foreground
;
113 gST
->ConOut
->SetAttribute (gST
->ConOut
, New
.Data
);
116 // clear the title line
118 EditorClearLine (1, LastCol
, LastRow
);
122 // print the new title bar prefix
131 if (FileName
== NULL
) {
132 gST
->ConOut
->SetAttribute (gST
->ConOut
, Orig
.Data
);
136 // First Extract the FileName from fullpath
138 FileNameTmp
= FileName
;
139 for (TempInteger
= StrLen (FileNameTmp
) - 1; TempInteger
>= 0; TempInteger
--) {
140 if (FileNameTmp
[TempInteger
] == L
'\\') {
145 FileNameTmp
= FileNameTmp
+ TempInteger
+ 1;
148 // the space for file name is 20 characters
150 if (StrLen (FileNameTmp
) <= 20) {
151 ShellPrintEx (-1,-1, L
"%s ", FileNameTmp
);
152 for (TempInteger
= StrLen (FileNameTmp
); TempInteger
< 20; TempInteger
++) {
153 ShellPrintEx (-1,-1, L
" ");
157 for (TempInteger
= 0; TempInteger
< 17; TempInteger
++) {
158 ShellPrintEx (-1,-1, L
"%c", FileNameTmp
[TempInteger
]);
163 ShellPrintEx (-1,-1, L
"... ");
166 // print file type field
170 case FileTypeUnicode
:
171 if (FileType
== FileTypeAscii
){
172 ShellPrintEx (-1,-1, L
" UNICODE ");
175 // print read-only field for text files
178 ShellPrintEx (-1,-1, L
"ReadOnly ");
180 ShellPrintEx (-1,-1, L
" ");
183 case FileTypeDiskBuffer
:
184 case FileTypeMemBuffer
:
188 ShellPrintEx (-1,-1, L
"Offset %X | Size %X", Offset
, Size
);
189 case FileTypeFileBuffer
:
195 // print modified field
198 ShellPrintEx (-1,-1, L
"Modified");
201 // restore the old attribute
203 gST
->ConOut
->SetAttribute (gST
->ConOut
, Orig
.Data
);