mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-01 15:43:36 +03:00
5e1499d104
This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
49 lines
1.3 KiB
C++
49 lines
1.3 KiB
C++
/*
|
||
* Copyright (c) 2020, Hüseyin Aslıtürk <asliturk@hotmail.com>
|
||
*
|
||
* SPDX-License-Identifier: BSD-2-Clause
|
||
*/
|
||
|
||
#include "CharacterMap.h"
|
||
#include <AK/StringBuilder.h>
|
||
#include <LibKeyboard/CharacterMapFile.h>
|
||
#include <errno.h>
|
||
#include <serenity.h>
|
||
|
||
namespace Keyboard {
|
||
|
||
ErrorOr<CharacterMap> CharacterMap::load_from_file(ByteString const& map_name)
|
||
{
|
||
auto result = TRY(CharacterMapFile::load_from_file(map_name));
|
||
|
||
return CharacterMap(map_name, result);
|
||
}
|
||
|
||
CharacterMap::CharacterMap(ByteString const& map_name, CharacterMapData const& map_data)
|
||
: m_character_map_data(map_data)
|
||
, m_character_map_name(map_name)
|
||
{
|
||
}
|
||
|
||
int CharacterMap::set_system_map()
|
||
{
|
||
return setkeymap(m_character_map_name.characters(), m_character_map_data.map, m_character_map_data.shift_map, m_character_map_data.alt_map, m_character_map_data.altgr_map, m_character_map_data.shift_altgr_map);
|
||
}
|
||
|
||
ErrorOr<CharacterMap> CharacterMap::fetch_system_map()
|
||
{
|
||
CharacterMapData map_data;
|
||
char keymap_name[50 + 1] = { 0 };
|
||
|
||
if (getkeymap(keymap_name, sizeof(keymap_name), map_data.map, map_data.shift_map, map_data.alt_map, map_data.altgr_map, map_data.shift_altgr_map) < 0)
|
||
return Error::from_errno(errno);
|
||
|
||
return CharacterMap { keymap_name, map_data };
|
||
}
|
||
|
||
ByteString const& CharacterMap::character_map_name() const
|
||
{
|
||
return m_character_map_name;
|
||
}
|
||
}
|