2 Implements titlebar interface functions.
4 (C) Copyright 2013 Hewlett-Packard Development Company, L.P.<BR>
5 Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved. <BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "EditTitleBar.h"
17 #include "UefiShellDebug1CommandsLib.h"
22 Initialize a title bar.
24 @param[in] Prompt The prompt to print in the title bar.
26 @retval EFI_SUCCESS The initialization was successful.
27 @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.
58 SHELL_FREE_NON_NULL (Title
);
63 UINT32 Foreground
: 4;
64 UINT32 Background
: 4;
65 } TITLE_BAR_COLOR_ATTRIBUTES
;
68 TITLE_BAR_COLOR_ATTRIBUTES Colors
;
70 } TITLE_BAR_COLOR_UNION
;
73 Refresh function for MainTitleBar
75 @param[in] FileName The open file's name (or NULL).
76 @param[in] FileType The type fo the file.
77 @param[in] ReadOnly TRUE if the file is read only. FALSE otherwise.
78 @param[in] Modified TRUE if the file was modified. FALSE otherwise.
79 @param[in] LastCol The last printable column.
80 @param[in] LastRow The last printable row.
81 @param[in] Offset The offset into the file. (only for mem/disk)
82 @param[in] Size The file's size. (only for mem/disk)
84 @retval EFI_SUCCESS The operation was successful.
88 IN CONST CHAR16
*FileName OPTIONAL
,
89 IN CONST EDIT_FILE_TYPE FileType
,
90 IN CONST BOOLEAN ReadOnly
,
91 IN CONST BOOLEAN Modified
,
92 IN CONST UINTN LastCol
,
93 IN CONST UINTN LastRow
,
94 IN CONST UINTN Offset
,
98 TITLE_BAR_COLOR_UNION Orig
;
99 TITLE_BAR_COLOR_UNION New
;
100 CONST CHAR16
*FileNameTmp
;
105 // backup the old screen attributes
107 Orig
.Data
= gST
->ConOut
->Mode
->Attribute
;
109 New
.Colors
.Foreground
= Orig
.Colors
.Background
& 0xF;
110 New
.Colors
.Background
= Orig
.Colors
.Foreground
& 0x7;
112 gST
->ConOut
->SetAttribute (gST
->ConOut
, New
.Data
& 0x7F);
115 // clear the title line
117 EditorClearLine (1, LastCol
, LastRow
);
121 // print the new title bar prefix
130 if (FileName
== NULL
) {
131 gST
->ConOut
->SetAttribute (gST
->ConOut
, Orig
.Data
);
135 // First Extract the FileName from fullpath
137 FileNameTmp
= FileName
;
138 for (TempInteger
= StrLen (FileNameTmp
) - 1; TempInteger
>= 0; TempInteger
--) {
139 if (FileNameTmp
[TempInteger
] == L
'\\') {
144 FileNameTmp
= FileNameTmp
+ TempInteger
+ 1;
147 // the space for file name is 20 characters
149 if (StrLen (FileNameTmp
) <= 20) {
150 ShellPrintEx (-1,-1, L
"%s ", FileNameTmp
);
151 for (TempInteger
= StrLen (FileNameTmp
); TempInteger
< 20; TempInteger
++) {
152 ShellPrintEx (-1,-1, L
" ");
156 for (TempInteger
= 0; TempInteger
< 17; TempInteger
++) {
157 ShellPrintEx (-1,-1, L
"%c", FileNameTmp
[TempInteger
]);
162 ShellPrintEx (-1,-1, L
"... ");
165 // print file type field
169 case FileTypeUnicode
:
170 if (FileType
== FileTypeAscii
){
171 ShellPrintEx (-1,-1, L
" ASCII ");
173 ShellPrintEx (-1,-1, L
" UNICODE ");
176 // print read-only field for text files
179 ShellPrintEx (-1,-1, L
"ReadOnly ");
181 ShellPrintEx (-1,-1, L
" ");
184 case FileTypeDiskBuffer
:
185 case FileTypeMemBuffer
:
189 ShellPrintEx (-1,-1, L
"Offset %X | Size %X", Offset
, Size
);
190 case FileTypeFileBuffer
:
196 // print modified field
199 ShellPrintEx (-1,-1, L
"Modified");
202 // restore the old attribute
204 gST
->ConOut
->SetAttribute (gST
->ConOut
, Orig
.Data
);