VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/ShellPkg/Library/UefiShellDebug1CommandsLib/EditStatusBar.c@ 58464

最後變更 在這個檔案從58464是 58459,由 vboxsync 提交於 9 年 前

EFI/Firmware: 'svn merge /vendor/edk2/UDK2010.SR1 /vendor/edk2/current .', reverting and removing files+dirs listed in ReadMe.vbox, resolving conflicts with help from ../UDK2014.SP1/. This is a raw untested merge.

  • 屬性 svn:eol-style 設為 native
檔案大小: 4.9 KB
 
1/** @file
2 Implements statusbar interface functions.
3
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
9
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.
12
13**/
14
15#include "EditStatusBar.h"
16#include "UefiShellDebug1CommandsLib.h"
17
18CHAR16 *StatusString;
19BOOLEAN StatusBarNeedRefresh;
20BOOLEAN StatusStringChanged;
21
22/**
23 Initialization function for Status Bar.
24
25 @retval EFI_SUCCESS The operation was successful.
26 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
27 @sa StatusBarSetStatusString
28**/
29EFI_STATUS
30EFIAPI
31StatusBarInit (
32 VOID
33 )
34{
35 //
36 // initialize the statusbar
37 //
38 StatusString = NULL;
39 StatusBarNeedRefresh = TRUE;
40 StatusStringChanged = FALSE;
41
42 //
43 // status string set to ""
44 //
45 return (StatusBarSetStatusString (L""));
46}
47
48/**
49 Cleanup function for the status bar.
50**/
51VOID
52EFIAPI
53StatusBarCleanup (
54 VOID
55 )
56{
57 //
58 // free the status string and backvar's status string
59 //
60 SHELL_FREE_NON_NULL (StatusString);
61}
62
63typedef struct {
64 UINT32 Foreground : 4;
65 UINT32 Background : 3;
66} STATUS_BAR_COLOR_ATTRIBUTES;
67
68typedef union {
69 STATUS_BAR_COLOR_ATTRIBUTES Colors;
70 UINTN Data;
71} STATUS_BAR_COLOR_UNION;
72
73/**
74 Cause the status bar to refresh it's printing on the screen.
75
76 @param[in] EditorFirst TRUE to indicate the first launch of the editor.
77 FALSE otherwise.
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.
83
84 @retval EFI_SUCCESS The operation was successful.
85**/
86EFI_STATUS
87EFIAPI
88StatusBarRefresh (
89 IN BOOLEAN EditorFirst,
90 IN UINTN LastRow,
91 IN UINTN LastCol,
92 IN UINTN FileRow,
93 IN UINTN FileCol,
94 IN BOOLEAN InsertMode
95 )
96{
97 STATUS_BAR_COLOR_UNION Orig;
98 STATUS_BAR_COLOR_UNION New;
99
100 if (!StatusStringChanged && StatusBarNeedRefresh) {
101 StatusBarSetStatusString (L"\0");
102 }
103 //
104 // when it's called first time after editor launch, so refresh is mandatory
105 //
106 if (!StatusBarNeedRefresh && !StatusStringChanged) {
107 return EFI_SUCCESS;
108 }
109
110 //
111 // back up the screen attributes
112 //
113 Orig.Data = gST->ConOut->Mode->Attribute;
114 New.Data = 0;
115 New.Colors.Foreground = Orig.Colors.Background & 0xF;
116 New.Colors.Background = Orig.Colors.Foreground & 0x7;
117
118 gST->ConOut->EnableCursor (gST->ConOut, FALSE);
119 gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);
120
121 //
122 // clear status bar
123 //
124 EditorClearLine (LastRow, LastCol, LastRow);
125
126 //
127 // print row, column fields
128 //
129 if (FileRow != (UINTN)(-1) && FileCol != (UINTN)(-1)) {
130 ShellPrintEx (
131 0,
132 (INT32)(LastRow) - 1,
133 L" %d,%d %s",
134 FileRow,
135 FileCol,
136 StatusString
137 );
138 } else {
139 ShellPrintEx (
140 0,
141 (INT32)(LastRow) - 1,
142 L" %s",
143 StatusString
144 );
145 }
146
147 //
148 // print insert mode field
149 //
150 if (InsertMode) {
151 ShellPrintEx ((INT32)(LastCol) - 21, (INT32)(LastRow) - 1, L"|%s| Help: Ctrl-E", L"INS");
152 } else {
153 ShellPrintEx ((INT32)(LastCol) - 21, (INT32)(LastRow) - 1, L"|%s| Help: Ctrl-E", L"OVR");
154 }
155 //
156 // restore the old screen attributes
157 //
158 gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);
159
160 //
161 // restore position in edit area
162 //
163 gST->ConOut->EnableCursor (gST->ConOut, TRUE);
164
165 StatusBarNeedRefresh = FALSE;
166 StatusStringChanged = FALSE;
167
168 return EFI_SUCCESS;
169}
170
171/**
172 Set the status string text part.
173
174 @param[in] Str The string to use.
175
176 @retval EFI_SUCCESS The operation was successful.
177 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
178**/
179EFI_STATUS
180EFIAPI
181StatusBarSetStatusString (
182 IN CHAR16 *Str
183 )
184{
185 StatusStringChanged = TRUE;
186
187 //
188 // free the old status string
189 //
190 SHELL_FREE_NON_NULL (StatusString);
191 StatusString = CatSPrint (NULL, L"%s", Str);
192 if (StatusString == NULL) {
193 return EFI_OUT_OF_RESOURCES;
194 }
195
196 return EFI_SUCCESS;
197}
198
199/**
200 Function to retrieve the current status string.
201
202 @return The string that is used.
203**/
204CONST CHAR16*
205EFIAPI
206StatusBarGetString (
207 VOID
208 )
209{
210 return (StatusString);
211}
212
213/**
214 Function to set the need refresh boolean to TRUE.
215**/
216VOID
217EFIAPI
218StatusBarSetRefresh(
219 VOID
220 )
221{
222 StatusBarNeedRefresh = TRUE;
223}
224
225/**
226 Function to get the need refresh boolean to TRUE.
227
228 @retval TRUE The status bar needs to be refreshed.
229**/
230BOOLEAN
231EFIAPI
232StatusBarGetRefresh(
233 VOID
234 )
235{
236 return (StatusBarNeedRefresh);
237}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette