2 Implements statusbar interface functions.
4 Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved. <BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "EditStatusBar.h"
10 #include "UefiShellDebug1CommandsLib.h"
13 BOOLEAN StatusBarNeedRefresh
;
14 BOOLEAN StatusStringChanged
;
17 Initialization function for Status Bar.
19 @retval EFI_SUCCESS The operation was successful.
20 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
21 @sa StatusBarSetStatusString
29 // initialize the statusbar
32 StatusBarNeedRefresh
= TRUE
;
33 StatusStringChanged
= FALSE
;
36 // status string set to ""
38 return (StatusBarSetStatusString (L
""));
42 Cleanup function for the status bar.
50 // free the status string and backvar's status string
52 SHELL_FREE_NON_NULL (StatusString
);
56 UINT32 Foreground
: 4;
57 UINT32 Background
: 3;
58 } STATUS_BAR_COLOR_ATTRIBUTES
;
61 STATUS_BAR_COLOR_ATTRIBUTES Colors
;
63 } STATUS_BAR_COLOR_UNION
;
66 Cause the status bar to refresh it's printing on the screen.
68 @param[in] EditorFirst TRUE to indicate the first launch of the editor.
70 @param[in] LastRow LastPrintable row.
71 @param[in] LastCol Last printable column.
72 @param[in] FileRow Row in the file.
73 @param[in] FileCol Column in the file.
74 @param[in] InsertMode TRUE to indicate InsertMode. FALSE otherwise.
76 @retval EFI_SUCCESS The operation was successful.
80 IN BOOLEAN EditorFirst
,
88 STATUS_BAR_COLOR_UNION Orig
;
89 STATUS_BAR_COLOR_UNION New
;
91 if (!StatusStringChanged
&& StatusBarNeedRefresh
) {
92 StatusBarSetStatusString (L
"\0");
95 // when it's called first time after editor launch, so refresh is mandatory
97 if (!StatusBarNeedRefresh
&& !StatusStringChanged
) {
102 // back up the screen attributes
104 Orig
.Data
= gST
->ConOut
->Mode
->Attribute
;
106 New
.Colors
.Foreground
= Orig
.Colors
.Background
& 0xF;
107 New
.Colors
.Background
= Orig
.Colors
.Foreground
& 0x7;
109 gST
->ConOut
->EnableCursor (gST
->ConOut
, FALSE
);
110 gST
->ConOut
->SetAttribute (gST
->ConOut
, New
.Data
& 0x7F);
115 EditorClearLine (LastRow
, LastCol
, LastRow
);
118 // print row, column fields
120 if (FileRow
!= (UINTN
)(-1) && FileCol
!= (UINTN
)(-1)) {
123 (INT32
)(LastRow
) - 1,
132 (INT32
)(LastRow
) - 1,
139 // print insert mode field
142 ShellPrintEx ((INT32
)(LastCol
) - 21, (INT32
)(LastRow
) - 1, L
"|%s| Help: Ctrl-E", L
"INS");
144 ShellPrintEx ((INT32
)(LastCol
) - 21, (INT32
)(LastRow
) - 1, L
"|%s| Help: Ctrl-E", L
"OVR");
147 // restore the old screen attributes
149 gST
->ConOut
->SetAttribute (gST
->ConOut
, Orig
.Data
);
152 // restore position in edit area
154 gST
->ConOut
->EnableCursor (gST
->ConOut
, TRUE
);
156 StatusBarNeedRefresh
= FALSE
;
157 StatusStringChanged
= FALSE
;
163 Set the status string text part.
165 @param[in] Str The string to use.
167 @retval EFI_SUCCESS The operation was successful.
168 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
171 StatusBarSetStatusString (
175 StatusStringChanged
= TRUE
;
178 // free the old status string
180 SHELL_FREE_NON_NULL (StatusString
);
181 StatusString
= CatSPrint (NULL
, L
"%s", Str
);
182 if (StatusString
== NULL
) {
183 return EFI_OUT_OF_RESOURCES
;
190 Function to retrieve the current status string.
192 @return The string that is used.
199 return (StatusString
);
203 Function to set the need refresh boolean to TRUE.
210 StatusBarNeedRefresh
= TRUE
;
214 Function to get the need refresh boolean to TRUE.
216 @retval TRUE The status bar needs to be refreshed.
223 return (StatusBarNeedRefresh
);