C语言 设置使用 Print (gnu-efi) 打印的文本的颜色



我想使用Print函数调用将一些文本打印到屏幕上。有没有办法(或任何其他功能(来设置文本的颜色?

这将设置您的打印颜色:

uefi_call_wrapper(SystemTable->ConOut->SetAttribute, 1, SystemTable->ConOut, EFI_YELLOW); //SET TEXT COLOR

只需EFI_COLORNAME->红色,黄色,绿色,蓝色等。但是,它非常有限。

为了再次设置颜色,我们使用代码:

`uefi_call_wrapper(SystemTable->ConOut->SetAttribute, 1, SystemTable->ConOut, EFI_BACKGROUND_MAGENTA);` //SET BACK COLOR    

简单地EFI_BACKGROUND_COLORNAME->磁,黑色,蓝色,棕色等。但是,它非常有限。我想你可以定义自定义颜色,比如EFI_BACKGROUND_MYSPECIALCOLOR

还有基于 gnu 的完整代码:

/*
* UEFI:SIMPLE - UEFI development made easy
* Copyright © 2014-2018 Pete Batard <pete@akeo.ie> - Public Domain
* See COPYING for the full licensing terms.
*/
#include <efi.h>
#include <efilib.h>
#include <stdio.h>
// Application entrypoint (must be set to 'efi_main' for gnu-efi crt0 compatibility)
EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
UINTN Event;
#if defined(_GNU_EFI)
InitializeLib(ImageHandle, SystemTable);
#endif
/*
* In addition to the standard %-based flags, Print() supports the following:
*   %N       Set output attribute to normal
*   %H       Set output attribute to highlight
*   %E       Set output attribute to error
*   %B       Set output attribute to blue color
*   %V       Set output attribute to green color
*   %r       Human readable version of a status code
*/
uefi_call_wrapper(SystemTable->ConOut->SetAttribute, 1, SystemTable->ConOut, EFI_BACKGROUND_MAGENTA); //SET BACK COLOR  
Print(L"n***DO NOT DISPLAY THIS***%Nnn");
uefi_call_wrapper(SystemTable->ConOut->ClearScreen, 1, SystemTable->ConOut); //CLEAR SCREEN
uefi_call_wrapper(SystemTable->ConOut->SetAttribute, 1, SystemTable->ConOut, EFI_YELLOW); //SET TEXT COLOR  
Print(L"n*** UEFI:HELLO MY FRIEND, bla bla and some other very necessary messages... ***%Nnn");
uefi_call_wrapper(SystemTable->ConOut->SetAttribute, 1, SystemTable->ConOut, EFI_RED); //SET TEXT COLOR
Print(L"PRESS ANY KEY TO EXIT.%Nn");
SystemTable->ConIn->Reset(SystemTable->ConIn, FALSE);
SystemTable->BootServices->WaitForEvent(1, &SystemTable->ConIn->WaitForKey, &Event);
#if defined(_DEBUG)
// If running in debug mode, use the EFI shut down call to close QEMU
SystemTable->RuntimeServices->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, NULL);
#endif
return EFI_SUCCESS;
}

如果您询问如何更改打印自己的单元格背景。好吧,IDK。

你可以这样做(没有 gnu efi(:

system_table->ConOut->SetAttribute(system_table->ConOut, 0x0E);

它将文本着色为黄色。

相关内容

  • 没有找到相关文章

最新更新