mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:07:44 +00:00
LibVT: Implement G0..G3 and VT100 translation table
This commit is contained in:
parent
aaa1382bd6
commit
49ccda5d97
3 changed files with 106 additions and 1 deletions
59
Userland/Libraries/LibVT/CharacterSet.h
Normal file
59
Userland/Libraries/LibVT/CharacterSet.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) 2021, The SerenityOS Developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace VT {
|
||||
|
||||
enum CharacterSet {
|
||||
Iso_8859_1,
|
||||
Null,
|
||||
UserDefined,
|
||||
VT100,
|
||||
};
|
||||
|
||||
class CharacterSetTranslator {
|
||||
public:
|
||||
u32 translate_code_point(CharacterSet active_set, u32 code_point)
|
||||
{
|
||||
// Only translate 0x7F and lower
|
||||
if (code_point > 127)
|
||||
return code_point;
|
||||
|
||||
// FIXME: implement other character sets
|
||||
if (active_set != CharacterSet::VT100)
|
||||
return code_point;
|
||||
|
||||
// VT100 translation table - https://en.wikipedia.org/wiki/Box-drawing_character#Unix,_CP/M,_BBS
|
||||
switch (code_point) {
|
||||
case 0x6A:
|
||||
return 0x2518;
|
||||
case 0x6B:
|
||||
return 0x2510;
|
||||
case 0x6C:
|
||||
return 0x250C;
|
||||
case 0x6D:
|
||||
return 0x2514;
|
||||
case 0x6E:
|
||||
return 0x253C;
|
||||
case 0x71:
|
||||
return 0x2500;
|
||||
case 0x74:
|
||||
return 0x251C;
|
||||
case 0x75:
|
||||
return 0x2524;
|
||||
case 0x76:
|
||||
return 0x2534;
|
||||
case 0x77:
|
||||
return 0x252C;
|
||||
case 0x78:
|
||||
return 0x2502;
|
||||
}
|
||||
return code_point;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue