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 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include "EditTitleBar.h"
11 #include "UefiShellDebug1CommandsLib.h"
16 Initialize a title bar.
18 @param[in] Prompt The prompt to print in the title bar.
20 @retval EFI_SUCCESS The initialization was successful.
21 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
28 SHELL_FREE_NON_NULL (Title
);
30 Title
= CatSPrint (NULL
, L
"");
35 Title
= CatSPrint (NULL
, L
"%s", Prompt
);
38 return EFI_OUT_OF_RESOURCES
;
45 Clean up the memory used.
52 SHELL_FREE_NON_NULL (Title
);
57 UINT32 Foreground
: 4;
58 UINT32 Background
: 4;
59 } TITLE_BAR_COLOR_ATTRIBUTES
;
62 TITLE_BAR_COLOR_ATTRIBUTES Colors
;
64 } TITLE_BAR_COLOR_UNION
;
67 Refresh function for MainTitleBar
69 @param[in] FileName The open file's name (or NULL).
70 @param[in] FileType The type fo the file.
71 @param[in] ReadOnly TRUE if the file is read only. FALSE otherwise.
72 @param[in] Modified TRUE if the file was modified. FALSE otherwise.
73 @param[in] LastCol The last printable column.
74 @param[in] LastRow The last printable row.
75 @param[in] Offset The offset into the file. (only for mem/disk)
76 @param[in] Size The file's size. (only for mem/disk)
78 @retval EFI_SUCCESS The operation was successful.
82 IN CONST CHAR16
*FileName OPTIONAL
,
83 IN CONST EDIT_FILE_TYPE FileType
,
84 IN CONST BOOLEAN ReadOnly
,
85 IN CONST BOOLEAN Modified
,
86 IN CONST UINTN LastCol
,
87 IN CONST UINTN LastRow
,
88 IN CONST UINTN Offset
,
92 TITLE_BAR_COLOR_UNION Orig
;
93 TITLE_BAR_COLOR_UNION New
;
94 CONST CHAR16
*FileNameTmp
;
99 // backup the old screen attributes
101 Orig
.Data
= gST
->ConOut
->Mode
->Attribute
;
103 New
.Colors
.Foreground
= Orig
.Colors
.Background
& 0xF;
104 New
.Colors
.Background
= Orig
.Colors
.Foreground
& 0x7;
106 gST
->ConOut
->SetAttribute (gST
->ConOut
, New
.Data
& 0x7F);
109 // clear the title line
111 EditorClearLine (1, LastCol
, LastRow
);
115 // print the new title bar prefix
124 if (FileName
== NULL
) {
125 gST
->ConOut
->SetAttribute (gST
->ConOut
, Orig
.Data
);
129 // First Extract the FileName from fullpath
131 FileNameTmp
= FileName
;
132 for (TempInteger
= StrLen (FileNameTmp
) - 1; TempInteger
>= 0; TempInteger
--) {
133 if (FileNameTmp
[TempInteger
] == L
'\\') {
138 FileNameTmp
= FileNameTmp
+ TempInteger
+ 1;
141 // the space for file name is 20 characters
143 if (StrLen (FileNameTmp
) <= 20) {
144 ShellPrintEx (-1,-1, L
"%s ", FileNameTmp
);
145 for (TempInteger
= StrLen (FileNameTmp
); TempInteger
< 20; TempInteger
++) {
146 ShellPrintEx (-1,-1, L
" ");
150 for (TempInteger
= 0; TempInteger
< 17; TempInteger
++) {
151 ShellPrintEx (-1,-1, L
"%c", FileNameTmp
[TempInteger
]);
156 ShellPrintEx (-1,-1, L
"... ");
159 // print file type field
163 case FileTypeUnicode
:
164 if (FileType
== FileTypeAscii
){
165 ShellPrintEx (-1,-1, L
" ASCII ");
167 ShellPrintEx (-1,-1, L
" UNICODE ");
170 // print read-only field for text files
173 ShellPrintEx (-1,-1, L
"ReadOnly ");
175 ShellPrintEx (-1,-1, L
" ");
178 case FileTypeDiskBuffer
:
179 case FileTypeMemBuffer
:
183 ShellPrintEx (-1,-1, L
"Offset %X | Size %X", Offset
, Size
);
184 case FileTypeFileBuffer
:
190 // print modified field
193 ShellPrintEx (-1,-1, L
"Modified");
196 // restore the old attribute
198 gST
->ConOut
->SetAttribute (gST
->ConOut
, Orig
.Data
);