TianoCore EDK2 master
Loading...
Searching...
No Matches
EditTitleBar.c
Go to the documentation of this file.
1
10#include "EditTitleBar.h"
12
13CHAR16 *Title = NULL;
14
25 CONST CHAR16 *Prompt
26 )
27{
28 SHELL_FREE_NON_NULL (Title);
29 if (Prompt == NULL) {
30 Title = CatSPrint (NULL, L"");
31 } else {
32 //
33 // set Title
34 //
35 Title = CatSPrint (NULL, L"%s", Prompt);
36 }
37
38 if (Title == NULL) {
39 return EFI_OUT_OF_RESOURCES;
40 }
41
42 return EFI_SUCCESS;
43}
44
48VOID
50 VOID
51 )
52{
53 SHELL_FREE_NON_NULL (Title);
54 Title = NULL;
55}
56
57typedef struct {
58 UINT32 Foreground : 4;
59 UINT32 Background : 4;
61
62typedef union {
64 UINTN Data;
66
83 IN CONST CHAR16 *FileName OPTIONAL,
84 IN CONST EDIT_FILE_TYPE FileType,
85 IN CONST BOOLEAN ReadOnly,
86 IN CONST BOOLEAN Modified,
87 IN CONST UINTN LastCol,
88 IN CONST UINTN LastRow,
89 IN CONST UINTN Offset,
90 IN CONST UINTN Size
91 )
92{
95 CONST CHAR16 *FileNameTmp;
96 INTN TempInteger;
97
98 //
99 // backup the old screen attributes
100 //
101 Orig.Data = gST->ConOut->Mode->Attribute;
102 New.Data = 0;
103 New.Colors.Foreground = Orig.Colors.Background & 0xF;
104 New.Colors.Background = Orig.Colors.Foreground & 0x7;
105
106 gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);
107
108 //
109 // clear the title line
110 //
111 EditorClearLine (1, LastCol, LastRow);
112
113 if (Title != NULL) {
114 //
115 // print the new title bar prefix
116 //
118 0,
119 0,
120 L"%s ",
121 Title
122 );
123 }
124
125 if (FileName == NULL) {
126 gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
127 return EFI_SUCCESS;
128 }
129
130 //
131 // First Extract the FileName from fullpath
132 //
133 FileNameTmp = FileName;
134 for (TempInteger = StrLen (FileNameTmp) - 1; TempInteger >= 0; TempInteger--) {
135 if (FileNameTmp[TempInteger] == L'\\') {
136 break;
137 }
138 }
139
140 FileNameTmp = FileNameTmp + TempInteger + 1;
141
142 //
143 // the space for file name is 20 characters
144 //
145 if (StrLen (FileNameTmp) <= 20) {
146 ShellPrintEx (-1, -1, L"%s ", FileNameTmp);
147 for (TempInteger = StrLen (FileNameTmp); TempInteger < 20; TempInteger++) {
148 ShellPrintEx (-1, -1, L" ");
149 }
150 } else {
151 for (TempInteger = 0; TempInteger < 17; TempInteger++) {
152 ShellPrintEx (-1, -1, L"%c", FileNameTmp[TempInteger]);
153 }
154
155 //
156 // print "..."
157 //
158 ShellPrintEx (-1, -1, L"... ");
159 }
160
161 //
162 // print file type field
163 //
164 switch (FileType) {
165 case FileTypeAscii:
166 case FileTypeUnicode:
167 if (FileType == FileTypeAscii) {
168 ShellPrintEx (-1, -1, L" ASCII ");
169 } else {
170 ShellPrintEx (-1, -1, L" UNICODE ");
171 }
172
173 //
174 // print read-only field for text files
175 //
176 if (ReadOnly) {
177 ShellPrintEx (-1, -1, L"ReadOnly ");
178 } else {
179 ShellPrintEx (-1, -1, L" ");
180 }
181
182 break;
183 case FileTypeDiskBuffer:
184 case FileTypeMemBuffer:
185 //
186 // Print the offset.
187 //
188 ShellPrintEx (-1, -1, L"Offset %X | Size %X", Offset, Size);
189 case FileTypeFileBuffer:
190 break;
191 default:
192 break;
193 }
194
195 //
196 // print modified field
197 //
198 if (Modified) {
199 ShellPrintEx (-1, -1, L"Modified");
200 }
201
202 //
203 // restore the old attribute
204 //
205 gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
206
207 return EFI_SUCCESS;
208}
UINT64 UINTN
INT64 INTN
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
Definition: String.c:30
EFI_STATUS MainTitleBarInit(CONST CHAR16 *Prompt)
Definition: EditTitleBar.c:24
EFI_STATUS MainTitleBarRefresh(IN CONST CHAR16 *FileName OPTIONAL, IN CONST EDIT_FILE_TYPE FileType, IN CONST BOOLEAN ReadOnly, IN CONST BOOLEAN Modified, IN CONST UINTN LastCol, IN CONST UINTN LastRow, IN CONST UINTN Offset, IN CONST UINTN Size)
Definition: EditTitleBar.c:82
VOID MainTitleBarCleanup(VOID)
Definition: EditTitleBar.c:49
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
EFI_STATUS EFIAPI ShellPrintEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR16 *Format,...)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_SYSTEM_TABLE * gST
CHAR16 *EFIAPI CatSPrint(IN CHAR16 *String OPTIONAL, IN CONST CHAR16 *FormatString,...)
Definition: UefiLibPrint.c:827
VOID EditorClearLine(IN UINTN Row, IN UINTN LastCol, IN UINTN LastRow)
EFI_SIMPLE_TEXT_OUTPUT_MODE * Mode
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut
Definition: UefiSpec.h:2064