TianoCore EDK2 master
Loading...
Searching...
No Matches
EditStatusBar.c
Go to the documentation of this file.
1
9#include "EditStatusBar.h"
11
12CHAR16 *StatusString;
13BOOLEAN StatusBarNeedRefresh;
14BOOLEAN StatusStringChanged;
15
25 VOID
26 )
27{
28 //
29 // initialize the statusbar
30 //
31 StatusString = NULL;
32 StatusBarNeedRefresh = TRUE;
33 StatusStringChanged = FALSE;
34
35 //
36 // status string set to ""
37 //
38 return (StatusBarSetStatusString (L""));
39}
40
44VOID
46 VOID
47 )
48{
49 //
50 // free the status string and backvar's status string
51 //
52 SHELL_FREE_NON_NULL (StatusString);
53}
54
55typedef struct {
56 UINT32 Foreground : 4;
57 UINT32 Background : 3;
59
60typedef union {
62 UINTN Data;
64
80 IN BOOLEAN EditorFirst,
81 IN UINTN LastRow,
82 IN UINTN LastCol,
83 IN UINTN FileRow,
84 IN UINTN FileCol,
85 IN BOOLEAN InsertMode
86 )
87{
90
91 if (!StatusStringChanged && StatusBarNeedRefresh) {
93 }
94
95 //
96 // when it's called first time after editor launch, so refresh is mandatory
97 //
98 if (!StatusBarNeedRefresh && !StatusStringChanged) {
99 return EFI_SUCCESS;
100 }
101
102 //
103 // back up the screen attributes
104 //
105 Orig.Data = gST->ConOut->Mode->Attribute;
106 New.Data = 0;
107 New.Colors.Foreground = Orig.Colors.Background & 0xF;
108 New.Colors.Background = Orig.Colors.Foreground & 0x7;
109
110 gST->ConOut->EnableCursor (gST->ConOut, FALSE);
111 gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);
112
113 //
114 // clear status bar
115 //
116 EditorClearLine (LastRow, LastCol, LastRow);
117
118 //
119 // print row, column fields
120 //
121 if ((FileRow != (UINTN)(-1)) && (FileCol != (UINTN)(-1))) {
123 0,
124 (INT32)(LastRow) - 1,
125 L" %d,%d %s",
126 FileRow,
127 FileCol,
128 StatusString
129 );
130 } else {
132 0,
133 (INT32)(LastRow) - 1,
134 L" %s",
135 StatusString
136 );
137 }
138
139 //
140 // print insert mode field
141 //
142 if (InsertMode) {
143 ShellPrintEx ((INT32)(LastCol) - 21, (INT32)(LastRow) - 1, L"|%s| Help: Ctrl-E", L"INS");
144 } else {
145 ShellPrintEx ((INT32)(LastCol) - 21, (INT32)(LastRow) - 1, L"|%s| Help: Ctrl-E", L"OVR");
146 }
147
148 //
149 // restore the old screen attributes
150 //
151 gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
152
153 //
154 // restore position in edit area
155 //
156 gST->ConOut->EnableCursor (gST->ConOut, TRUE);
157
158 StatusBarNeedRefresh = FALSE;
159 StatusStringChanged = FALSE;
160
161 return EFI_SUCCESS;
162}
163
174 IN CHAR16 *Str
175 )
176{
177 StatusStringChanged = TRUE;
178
179 //
180 // free the old status string
181 //
182 SHELL_FREE_NON_NULL (StatusString);
183 StatusString = CatSPrint (NULL, L"%s", Str);
184 if (StatusString == NULL) {
185 return EFI_OUT_OF_RESOURCES;
186 }
187
188 return EFI_SUCCESS;
189}
190
196CONST CHAR16 *
198 VOID
199 )
200{
201 return (StatusString);
202}
203
207VOID
209 VOID
210 )
211{
212 StatusBarNeedRefresh = TRUE;
213}
214
220BOOLEAN
222 VOID
223 )
224{
225 return (StatusBarNeedRefresh);
226}
UINT64 UINTN
VOID StatusBarSetRefresh(VOID)
EFI_STATUS StatusBarRefresh(IN BOOLEAN EditorFirst, IN UINTN LastRow, IN UINTN LastCol, IN UINTN FileRow, IN UINTN FileCol, IN BOOLEAN InsertMode)
Definition: EditStatusBar.c:79
EFI_STATUS StatusBarSetStatusString(IN CHAR16 *Str)
CONST CHAR16 * StatusBarGetString(VOID)
BOOLEAN StatusBarGetRefresh(VOID)
EFI_STATUS StatusBarInit(VOID)
Definition: EditStatusBar.c:24
VOID StatusBarCleanup(VOID)
Definition: EditStatusBar.c:45
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#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