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.
83 @retval EFI_SUCCESS The operation was successful.
88 IN CONST CHAR16
*FileName OPTIONAL
,
89 IN CONST EDIT_FILE_TYPE FileType
,
96 TITLE_BAR_COLOR_UNION Orig
;
97 TITLE_BAR_COLOR_UNION New
;
98 CONST CHAR16
*FileNameTmp
;
103 // backup the old screen attributes
105 Orig
.Data
= gST
->ConOut
->Mode
->Attribute
;
106 New
.Colors
.Foreground
= Orig
.Colors
.Background
;
107 New
.Colors
.Background
= Orig
.Colors
.Foreground
;
109 gST
->ConOut
->SetAttribute (gST
->ConOut
, New
.Data
);
112 // clear the title line
114 EditorClearLine (1, LastCol
, LastRow
);
118 // print the new title bar prefix
127 if (FileName
== NULL
) {
128 gST
->ConOut
->SetAttribute (gST
->ConOut
, Orig
.Data
);
132 // First Extract the FileName from fullpath
134 FileNameTmp
= FileName
;
135 for (TempInteger
= StrLen (FileNameTmp
) - 1; TempInteger
>= 0; TempInteger
--) {
136 if (FileNameTmp
[TempInteger
] == L
'\\') {
141 FileNameTmp
= FileNameTmp
+ TempInteger
+ 1;
144 // the space for file name is 20 characters
146 if (StrLen (FileNameTmp
) <= 20) {
147 ShellPrintEx (-1,-1, L
"%s ", FileNameTmp
);
148 for (TempInteger
= StrLen (FileNameTmp
); TempInteger
< 20; TempInteger
++) {
149 ShellPrintEx (-1,-1, L
" ");
153 for (TempInteger
= 0; TempInteger
< 17; TempInteger
++) {
154 ShellPrintEx (-1,-1, L
"%c", FileNameTmp
[TempInteger
]);
159 ShellPrintEx (-1,-1, L
"... ");
162 // print file type field
166 case FileTypeUnicode
:
167 if (FileType
== FileTypeAscii
){
168 ShellPrintEx (-1,-1, L
" UNICODE ");
171 // print read-only field for text files
174 ShellPrintEx (-1,-1, L
"ReadOnly ");
176 ShellPrintEx (-1,-1, L
" ");
179 case FileTypeDiskBuffer
:
180 case FileTypeMemBuffer
:
185 case FileTypeFileBuffer
:
189 // print modified field
192 ShellPrintEx (-1,-1, L
"Modified");
195 // restore the old attribute
197 gST
->ConOut
->SetAttribute (gST
->ConOut
, Orig
.Data
);