Step to UEFI (110)在 Shell 下面使用 Unicode 的制表符

在DOS时代,可以用Ascii制表符做出好看的界面。

tabm

同样的 Unicode 中也有制表符【参考1】

tabn

下面的代码就是枚举输出UEFI 下面定义的全部制表符。

#include  <Uefi.h>
#include  <Library/UefiLib.h>
#include  <Library/ShellCEntryLib.h>


extern EFI_BOOT_SERVICES         *gBS;
extern EFI_SYSTEM_TABLE			 *gST;
extern EFI_RUNTIME_SERVICES 	 *gRT;

int
EFIAPI
main (
  IN int Argc,
  IN CHAR16 **Argv
  )
{
	CHAR16 ChrSide[2] = {0,0};
	
ChrSide[0]=BOXDRAW_HORIZONTAL;
Print(L"BOXDRAW_HORIZONTAL [%s]\n",ChrSide);                 
ChrSide[0]=BOXDRAW_VERTICAL;
Print(L"BOXDRAW_VERTICAL [%s]\n",ChrSide);                   
ChrSide[0]=BOXDRAW_DOWN_RIGHT;
Print(L"BOXDRAW_DOWN_RIGHT [%s]\n",ChrSide);                 
ChrSide[0]=BOXDRAW_DOWN_LEFT;
Print(L"BOXDRAW_DOWN_LEFT [%s]\n",ChrSide);                  
ChrSide[0]=BOXDRAW_UP_RIGHT;
Print(L"BOXDRAW_UP_RIGHT [%s]\n",ChrSide);                   
ChrSide[0]=BOXDRAW_UP_LEFT;
Print(L"BOXDRAW_UP_LEFT [%s]\n",ChrSide);                    
ChrSide[0]=BOXDRAW_VERTICAL_RIGHT;
Print(L"BOXDRAW_VERTICAL_RIGHT [%s]\n",ChrSide);             
ChrSide[0]=BOXDRAW_VERTICAL_LEFT;
Print(L"BOXDRAW_VERTICAL_LEFT [%s]\n",ChrSide);              
ChrSide[0]=BOXDRAW_DOWN_HORIZONTAL;
Print(L"BOXDRAW_DOWN_HORIZONTAL [%s]\n",ChrSide);            
ChrSide[0]=BOXDRAW_UP_HORIZONTAL;
Print(L"BOXDRAW_UP_HORIZONTAL [%s]\n",ChrSide);              
ChrSide[0]=BOXDRAW_VERTICAL_HORIZONTAL;
Print(L"BOXDRAW_VERTICAL_HORIZONTAL [%s]\n",ChrSide);        
ChrSide[0]=BOXDRAW_DOUBLE_HORIZONTAL;
Print(L"BOXDRAW_DOUBLE_HORIZONTAL [%s]\n",ChrSide);          
ChrSide[0]=BOXDRAW_DOUBLE_VERTICAL;
Print(L"BOXDRAW_DOUBLE_VERTICAL [%s]\n",ChrSide);            
ChrSide[0]=BOXDRAW_DOWN_RIGHT_DOUBLE;
Print(L"BOXDRAW_DOWN_RIGHT_DOUBLE [%s]\n",ChrSide);          
ChrSide[0]=BOXDRAW_DOWN_DOUBLE_RIGHT;
Print(L"BOXDRAW_DOWN_DOUBLE_RIGHT [%s]\n",ChrSide);          
ChrSide[0]=BOXDRAW_DOUBLE_DOWN_RIGHT;
Print(L"BOXDRAW_DOUBLE_DOWN_RIGHT [%s]\n",ChrSide);          
ChrSide[0]=BOXDRAW_DOWN_LEFT_DOUBLE;
Print(L"BOXDRAW_DOWN_LEFT_DOUBLE [%s]\n",ChrSide);           
ChrSide[0]=BOXDRAW_DOWN_DOUBLE_LEFT;
Print(L"BOXDRAW_DOWN_DOUBLE_LEFT [%s]\n",ChrSide);           
ChrSide[0]=BOXDRAW_DOUBLE_DOWN_LEFT;
Print(L"BOXDRAW_DOUBLE_DOWN_LEFT [%s]\n",ChrSide);           
ChrSide[0]=BOXDRAW_UP_RIGHT_DOUBLE;
Print(L"BOXDRAW_UP_RIGHT_DOUBLE [%s]\n",ChrSide);            
ChrSide[0]=BOXDRAW_UP_DOUBLE_RIGHT;
Print(L"BOXDRAW_UP_DOUBLE_RIGHT [%s]\n",ChrSide);            
ChrSide[0]=BOXDRAW_DOUBLE_UP_RIGHT;
Print(L"BOXDRAW_DOUBLE_UP_RIGHT [%s]\n",ChrSide);            
ChrSide[0]=BOXDRAW_UP_LEFT_DOUBLE;
Print(L"BOXDRAW_UP_LEFT_DOUBLE [%s]\n",ChrSide);             
ChrSide[0]=BOXDRAW_UP_DOUBLE_LEFT;
Print(L"BOXDRAW_UP_DOUBLE_LEFT [%s]\n",ChrSide);             
ChrSide[0]=BOXDRAW_DOUBLE_UP_LEFT;
Print(L"BOXDRAW_DOUBLE_UP_LEFT [%s]\n",ChrSide);             
ChrSide[0]=BOXDRAW_VERTICAL_RIGHT_DOUBLE;
Print(L"BOXDRAW_VERTICAL_RIGHT_DOUBLE [%s]\n",ChrSide);      
ChrSide[0]=BOXDRAW_VERTICAL_DOUBLE_RIGHT;
Print(L"BOXDRAW_VERTICAL_DOUBLE_RIGHT [%s]\n",ChrSide);      
ChrSide[0]=BOXDRAW_DOUBLE_VERTICAL_RIGHT;
Print(L"BOXDRAW_DOUBLE_VERTICAL_RIGHT [%s]\n",ChrSide);      
ChrSide[0]=BOXDRAW_VERTICAL_LEFT_DOUBLE;
Print(L"BOXDRAW_VERTICAL_LEFT_DOUBLE [%s]\n",ChrSide);       
ChrSide[0]=BOXDRAW_VERTICAL_DOUBLE_LEFT;
Print(L"BOXDRAW_VERTICAL_DOUBLE_LEFT [%s]\n",ChrSide);       
ChrSide[0]=BOXDRAW_DOUBLE_VERTICAL_LEFT;
Print(L"BOXDRAW_DOUBLE_VERTICAL_LEFT [%s]\n",ChrSide);       
ChrSide[0]=BOXDRAW_DOWN_HORIZONTAL_DOUBLE;
Print(L"BOXDRAW_DOWN_HORIZONTAL_DOUBLE [%s]\n",ChrSide);     
ChrSide[0]=BOXDRAW_DOWN_DOUBLE_HORIZONTAL;
Print(L"BOXDRAW_DOWN_DOUBLE_HORIZONTAL [%s]\n",ChrSide);     
ChrSide[0]=BOXDRAW_DOUBLE_DOWN_HORIZONTAL;
Print(L"BOXDRAW_DOUBLE_DOWN_HORIZONTAL [%s]\n",ChrSide);     
ChrSide[0]=BOXDRAW_UP_HORIZONTAL_DOUBLE;
Print(L"BOXDRAW_UP_HORIZONTAL_DOUBLE [%s]\n",ChrSide);       
ChrSide[0]=BOXDRAW_UP_DOUBLE_HORIZONTAL;
Print(L"BOXDRAW_UP_DOUBLE_HORIZONTAL [%s]\n",ChrSide);       
ChrSide[0]=BOXDRAW_DOUBLE_UP_HORIZONTAL;
Print(L"BOXDRAW_DOUBLE_UP_HORIZONTAL [%s]\n",ChrSide);       
ChrSide[0]=BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE;
Print(L"BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE [%s]\n",ChrSide); 
ChrSide[0]=BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL;
Print(L"BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL [%s]\n",ChrSide); 
ChrSide[0]=BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL;
Print(L"BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL [%s]\n",ChrSide); 
ChrSide[0]=BLOCKELEMENT_FULL_BLOCK;
Print(L"BLOCKELEMENT_FULL_BLOCK [%s]\n",ChrSide);            
ChrSide[0]=BLOCKELEMENT_LIGHT_SHADE;
Print(L"BLOCKELEMENT_LIGHT_SHADE [%s]\n",ChrSide);           
ChrSide[0]=GEOMETRICSHAPE_UP_TRIANGLE;
Print(L"GEOMETRICSHAPE_UP_TRIANGLE [%s]\n",ChrSide);         
ChrSide[0]=GEOMETRICSHAPE_RIGHT_TRIANGLE;
Print(L"GEOMETRICSHAPE_RIGHT_TRIANGLE [%s]\n",ChrSide);      
ChrSide[0]=GEOMETRICSHAPE_DOWN_TRIANGLE;
Print(L"GEOMETRICSHAPE_DOWN_TRIANGLE [%s]\n",ChrSide);       
ChrSide[0]=GEOMETRICSHAPE_LEFT_TRIANGLE;
Print(L"GEOMETRICSHAPE_LEFT_TRIANGLE [%s]\n",ChrSide);       
ChrSide[0]=ARROW_LEFT;
Print(L"ARROW_LEFT [%s]\n",ChrSide);                         
ChrSide[0]=ARROW_UP;
Print(L"ARROW_UP [%s]\n",ChrSide);                           
ChrSide[0]=ARROW_RIGHT;
Print(L"ARROW_RIGHT [%s]\n",ChrSide);                        
ChrSide[0]=ARROW_DOWN;
Print(L"ARROW_DOWN [%s]\n",ChrSide);                         

  return EFI_SUCCESS;
}

 

上述代码运行结果:

tab4

tab3

tab2

tab1

完整的代码下载:

tabtest

使用上面的代码,绘制的一个方框:

tab5

参考:
1. https://en.wikipedia.org/wiki/Box-drawing_character

发表评论

电子邮件地址不会被公开。 必填项已用*标注