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.
35 SHELL_FREE_NON_NULL (Title
);
37 Title
= CatSPrint (NULL
, L
"");
42 Title
= CatSPrint (NULL
, L
"%s", Prompt
);
45 return EFI_OUT_OF_RESOURCES
;
52 Clean up the memory used.
60 SHELL_FREE_NON_NULL (Title
);
65 UINT32 Foreground
: 4;
66 UINT32 Background
: 4;
67 } TITLE_BAR_COLOR_ATTRIBUTES
;
70 TITLE_BAR_COLOR_ATTRIBUTES Colors
;
72 } TITLE_BAR_COLOR_UNION
;
75 Refresh function for MainTitleBar
77 @param[in] FileName The open file's name (or NULL).
78 @param[in] FileType The type fo the file.
79 @param[in] ReadOnly TRUE if the file is read only. FALSE otherwise.
80 @param[in] Modified TRUE if the file was modified. FALSE otherwise.
81 @param[in] LastCol The last printable column.
82 @param[in] LastRow The last printable row.
83 @param[in] Offset The offset into the file. (only for mem/disk)
84 @param[in] Size The file's size. (only for mem/disk)
86 @retval EFI_SUCCESS The operation was successful.
91 IN CONST CHAR16
*FileName OPTIONAL
,
92 IN CONST EDIT_FILE_TYPE FileType
,
93 IN CONST BOOLEAN ReadOnly
,
94 IN CONST BOOLEAN Modified
,
95 IN CONST UINTN LastCol
,
96 IN CONST UINTN LastRow
,
97 IN CONST UINTN Offset
,
101 TITLE_BAR_COLOR_UNION Orig
;
102 TITLE_BAR_COLOR_UNION New
;
103 CONST CHAR16
*FileNameTmp
;
108 // backup the old screen attributes
110 Orig
.Data
= gST
->ConOut
->Mode
->Attribute
;
112 New
.Colors
.Foreground
= Orig
.Colors
.Background
& 0xF;
113 New
.Colors
.Background
= Orig
.Colors
.Foreground
& 0x7;
115 gST
->ConOut
->SetAttribute (gST
->ConOut
, New
.Data
& 0x7F);
118 // clear the title line
120 EditorClearLine (1, LastCol
, LastRow
);
124 // print the new title bar prefix
133 if (FileName
== NULL
) {
134 gST
->ConOut
->SetAttribute (gST
->ConOut
, Orig
.Data
);
138 // First Extract the FileName from fullpath
140 FileNameTmp
= FileName
;
141 for (TempInteger
= StrLen (FileNameTmp
) - 1; TempInteger
>= 0; TempInteger
--) {
142 if (FileNameTmp
[TempInteger
] == L
'\\') {
147 FileNameTmp
= FileNameTmp
+ TempInteger
+ 1;
150 // the space for file name is 20 characters
152 if (StrLen (FileNameTmp
) <= 20) {
153 ShellPrintEx (-1,-1, L
"%s ", FileNameTmp
);
154 for (TempInteger
= StrLen (FileNameTmp
); TempInteger
< 20; TempInteger
++) {
155 ShellPrintEx (-1,-1, L
" ");
159 for (TempInteger
= 0; TempInteger
< 17; TempInteger
++) {
160 ShellPrintEx (-1,-1, L
"%c", FileNameTmp
[TempInteger
]);
165 ShellPrintEx (-1,-1, L
"... ");
168 // print file type field
172 case FileTypeUnicode
:
173 if (FileType
== FileTypeAscii
){
174 ShellPrintEx (-1,-1, L
" ASCII ");
176 ShellPrintEx (-1,-1, L
" UNICODE ");
179 // print read-only field for text files
182 ShellPrintEx (-1,-1, L
"ReadOnly ");
184 ShellPrintEx (-1,-1, L
" ");
187 case FileTypeDiskBuffer
:
188 case FileTypeMemBuffer
:
192 ShellPrintEx (-1,-1, L
"Offset %X | Size %X", Offset
, Size
);
193 case FileTypeFileBuffer
:
199 // print modified field
202 ShellPrintEx (-1,-1, L
"Modified");
205 // restore the old attribute
207 gST
->ConOut
->SetAttribute (gST
->ConOut
, Orig
.Data
);