2 Implements statusbar interface functions.
4 Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved. <BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "EditStatusBar.h"
16 #include "UefiShellDebug1CommandsLib.h"
19 BOOLEAN StatusBarNeedRefresh
;
20 BOOLEAN StatusStringChanged
;
23 Initialization function for Status Bar.
25 @retval EFI_SUCCESS The operation was successful.
26 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
27 @sa StatusBarSetStatusString
35 // initialize the statusbar
38 StatusBarNeedRefresh
= TRUE
;
39 StatusStringChanged
= FALSE
;
42 // status string set to ""
44 return (StatusBarSetStatusString (L
""));
48 Cleanup function for the status bar.
56 // free the status string and backvar's status string
58 SHELL_FREE_NON_NULL (StatusString
);
62 UINT32 Foreground
: 4;
63 UINT32 Background
: 3;
64 } STATUS_BAR_COLOR_ATTRIBUTES
;
67 STATUS_BAR_COLOR_ATTRIBUTES Colors
;
69 } STATUS_BAR_COLOR_UNION
;
72 Cause the status bar to refresh it's printing on the screen.
74 @param[in] EditorFirst TRUE to indicate the first launch of the editor.
76 @param[in] LastRow LastPrintable row.
77 @param[in] LastCol Last printable column.
78 @param[in] FileRow Row in the file.
79 @param[in] FileCol Column in the file.
80 @param[in] InsertMode TRUE to indicate InsertMode. FALSE otherwise.
82 @retval EFI_SUCCESS The operation was successful.
86 IN BOOLEAN EditorFirst
,
94 STATUS_BAR_COLOR_UNION Orig
;
95 STATUS_BAR_COLOR_UNION New
;
97 if (!StatusStringChanged
&& StatusBarNeedRefresh
) {
98 StatusBarSetStatusString (L
"\0");
101 // when it's called first time after editor launch, so refresh is mandatory
103 if (!StatusBarNeedRefresh
&& !StatusStringChanged
) {
108 // back up the 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
->EnableCursor (gST
->ConOut
, FALSE
);
116 gST
->ConOut
->SetAttribute (gST
->ConOut
, New
.Data
& 0x7F);
121 EditorClearLine (LastRow
, LastCol
, LastRow
);
124 // print row, column fields
126 if (FileRow
!= (UINTN
)(-1) && FileCol
!= (UINTN
)(-1)) {
129 (INT32
)(LastRow
) - 1,
138 (INT32
)(LastRow
) - 1,
145 // print insert mode field
148 ShellPrintEx ((INT32
)(LastCol
) - 21, (INT32
)(LastRow
) - 1, L
"|%s| Help: Ctrl-E", L
"INS");
150 ShellPrintEx ((INT32
)(LastCol
) - 21, (INT32
)(LastRow
) - 1, L
"|%s| Help: Ctrl-E", L
"OVR");
153 // restore the old screen attributes
155 gST
->ConOut
->SetAttribute (gST
->ConOut
, Orig
.Data
);
158 // restore position in edit area
160 gST
->ConOut
->EnableCursor (gST
->ConOut
, TRUE
);
162 StatusBarNeedRefresh
= FALSE
;
163 StatusStringChanged
= FALSE
;
169 Set the status string text part.
171 @param[in] Str The string to use.
173 @retval EFI_SUCCESS The operation was successful.
174 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
177 StatusBarSetStatusString (
181 StatusStringChanged
= TRUE
;
184 // free the old status string
186 SHELL_FREE_NON_NULL (StatusString
);
187 StatusString
= CatSPrint (NULL
, L
"%s", Str
);
188 if (StatusString
== NULL
) {
189 return EFI_OUT_OF_RESOURCES
;
196 Function to retrieve the current status string.
198 @return The string that is used.
205 return (StatusString
);
209 Function to set the need refresh boolean to TRUE.
216 StatusBarNeedRefresh
= TRUE
;
220 Function to get the need refresh boolean to TRUE.
222 @retval TRUE The status bar needs to be refreshed.
229 return (StatusBarNeedRefresh
);