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");
96 // when it's called first time after editor launch, so refresh is mandatory
98 if (!StatusBarNeedRefresh
&& !StatusStringChanged
) {
103 // back up the screen attributes
105 Orig
.Data
= gST
->ConOut
->Mode
->Attribute
;
107 New
.Colors
.Foreground
= Orig
.Colors
.Background
& 0xF;
108 New
.Colors
.Background
= Orig
.Colors
.Foreground
& 0x7;
110 gST
->ConOut
->EnableCursor (gST
->ConOut
, FALSE
);
111 gST
->ConOut
->SetAttribute (gST
->ConOut
, New
.Data
& 0x7F);
116 EditorClearLine (LastRow
, LastCol
, LastRow
);
119 // print row, column fields
121 if ((FileRow
!= (UINTN
)(-1)) && (FileCol
!= (UINTN
)(-1))) {
124 (INT32
)(LastRow
) - 1,
133 (INT32
)(LastRow
) - 1,
140 // print insert mode field
143 ShellPrintEx ((INT32
)(LastCol
) - 21, (INT32
)(LastRow
) - 1, L
"|%s| Help: Ctrl-E", L
"INS");
145 ShellPrintEx ((INT32
)(LastCol
) - 21, (INT32
)(LastRow
) - 1, L
"|%s| Help: Ctrl-E", L
"OVR");
149 // restore the old screen attributes
151 gST
->ConOut
->SetAttribute (gST
->ConOut
, Orig
.Data
);
154 // restore position in edit area
156 gST
->ConOut
->EnableCursor (gST
->ConOut
, TRUE
);
158 StatusBarNeedRefresh
= FALSE
;
159 StatusStringChanged
= FALSE
;
165 Set the status string text part.
167 @param[in] Str The string to use.
169 @retval EFI_SUCCESS The operation was successful.
170 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
173 StatusBarSetStatusString (
177 StatusStringChanged
= TRUE
;
180 // free the old status string
182 SHELL_FREE_NON_NULL (StatusString
);
183 StatusString
= CatSPrint (NULL
, L
"%s", Str
);
184 if (StatusString
== NULL
) {
185 return EFI_OUT_OF_RESOURCES
;
192 Function to retrieve the current status string.
194 @return The string that is used.
201 return (StatusString
);
205 Function to set the need refresh boolean to TRUE.
208 StatusBarSetRefresh (
212 StatusBarNeedRefresh
= TRUE
;
216 Function to get the need refresh boolean to TRUE.
218 @retval TRUE The status bar needs to be refreshed.
221 StatusBarGetRefresh (
225 return (StatusBarNeedRefresh
);