2 Implements statusbar interface functions.
4 Copyright (c) 2005 - 2011, 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
36 // initialize the statusbar
39 StatusBarNeedRefresh
= TRUE
;
40 StatusStringChanged
= FALSE
;
43 // status string set to ""
45 return (StatusBarSetStatusString (L
""));
49 Cleanup function for the status bar.
58 // free the status string and backvar's status string
60 SHELL_FREE_NON_NULL (StatusString
);
64 UINT32 Foreground
: 4;
65 UINT32 Background
: 4;
66 } STATUS_BAR_COLOR_ATTRIBUTES
;
69 STATUS_BAR_COLOR_ATTRIBUTES Colors
;
71 } STATUS_BAR_COLOR_UNION
;
74 Cause the status bar to refresh it's printing on the screen.
76 @param[in] EditorFirst TRUE to indicate the first launch of the editor.
78 @param[in] LastRow LastPrintable row.
79 @param[in] LastCol Last printable column.
80 @param[in] FileRow Row in the file.
81 @param[in] FileCol Column in the file.
82 @param[in] InsertMode TRUE to indicate InsertMode. FALSE otherwise.
84 @retval EFI_SUCCESS The operation was successful.
89 IN BOOLEAN EditorFirst
,
97 STATUS_BAR_COLOR_UNION Orig
;
98 STATUS_BAR_COLOR_UNION New
;
100 if (!StatusStringChanged
&& StatusBarNeedRefresh
) {
101 StatusBarSetStatusString (L
"\0");
104 // when it's called first time after editor launch, so refresh is mandatory
106 if (!StatusBarNeedRefresh
&& !StatusStringChanged
) {
111 // back up the screen attributes
113 Orig
.Data
= gST
->ConOut
->Mode
->Attribute
;
114 New
.Colors
.Foreground
= Orig
.Colors
.Background
;
115 New
.Colors
.Background
= Orig
.Colors
.Foreground
;
117 gST
->ConOut
->EnableCursor (gST
->ConOut
, FALSE
);
118 gST
->ConOut
->SetAttribute (gST
->ConOut
, New
.Data
);
123 EditorClearLine (LastRow
, LastCol
, LastRow
);
126 // print row, column fields
128 if (FileRow
!= (UINTN
)(-1) && FileCol
!= (UINTN
)(-1)) {
131 (INT32
)(LastRow
) - 1,
140 (INT32
)(LastRow
) - 1,
147 // print insert mode field
150 ShellPrintEx ((INT32
)(LastCol
) - 21, (INT32
)(LastRow
) - 1, L
"|%s| Help: Ctrl-E", L
"INS");
152 ShellPrintEx ((INT32
)(LastCol
) - 21, (INT32
)(LastRow
) - 1, L
"|%s| Help: Ctrl-E", L
"OVR");
155 // restore the old screen attributes
157 gST
->ConOut
->SetAttribute (gST
->ConOut
, Orig
.Data
);
160 // restore position in edit area
162 gST
->ConOut
->EnableCursor (gST
->ConOut
, TRUE
);
164 StatusBarNeedRefresh
= FALSE
;
165 StatusStringChanged
= FALSE
;
171 Set the status string text part.
173 @param[in] Str The string to use.
175 @retval EFI_SUCCESS The operation was successful.
176 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
180 StatusBarSetStatusString (
184 StatusStringChanged
= TRUE
;
187 // free the old status string
189 SHELL_FREE_NON_NULL (StatusString
);
190 StatusString
= CatSPrint (NULL
, L
"%s", Str
);
191 if (StatusString
== NULL
) {
192 return EFI_OUT_OF_RESOURCES
;
199 Function to retrieve the current status string.
201 @return The string that is used.
209 return (StatusString
);
213 Function to set the need refresh boolean to TRUE.
221 StatusBarNeedRefresh
= TRUE
;
225 Function to get the need refresh boolean to TRUE.
227 @retval TRUE The status bar needs to be refreshed.
235 return (StatusBarNeedRefresh
);