Compare commits

..

No commits in common. "264d1798dce3b303068373f4d2dab06030a1d0fa" and "f5802ca3e5294a798bc5fc07d9b76baaf64f521d" have entirely different histories.

7 changed files with 378 additions and 923 deletions

View File

@ -167,14 +167,14 @@ namespace BAN
constexpr T& Optional<T>::value()
{
ASSERT(has_value());
return *reinterpret_cast<T*>(&m_storage);
return (T&)m_storage;
}
template<typename T>
constexpr const T& Optional<T>::value() const
{
ASSERT(has_value());
return *reinterpret_cast<const T*>(&m_storage);
return (const T&)m_storage;
}
template<typename T>
@ -182,7 +182,7 @@ namespace BAN
{
if (!has_value())
return empty;
return value();
return (T&)m_storage;
}
template<typename T>
@ -190,7 +190,7 @@ namespace BAN
{
if (!has_value())
return empty;
return value();
return (const T&)m_storage;
}
template<typename T>

View File

@ -186,10 +186,15 @@ namespace BAN
{
if (target.size() > m_size)
return false;
for (size_type i = 0; i < target.size(); i++)
if (m_data[i] != target[i])
return false;
return true;
for (size_type i = 0; i < m_size - target.size(); i++)
{
bool valid = true;
for (size_type j = 0; j < target.size() && valid; j++)
valid = (m_data[i + j] == target[j]);
if (valid)
return true;
}
return false;
}
constexpr bool contains(char ch) const

View File

@ -237,6 +237,8 @@ namespace Kernel
*ptr = m_input.front();
if (*ptr == '\r')
*ptr = '\n';
if (*ptr == 127)
*ptr++ = '\b', *ptr++ = ' ', *ptr = '\b';
m_input.pop();
ptr++;
}

View File

@ -185,10 +185,79 @@ namespace Kernel
if (event.released())
return;
const char* ansi_c_str = LibInput::key_to_utf8_ansi(event.key, event.modifier);
const char* ansi_c_str = LibInput::key_to_utf8(event.key, event.modifier);
if (event.ctrl())
{
ansi_c_str = nullptr;
switch (event.key)
{
case LibInput::Key::A: ansi_c_str = "\x01"; break;
case LibInput::Key::B: ansi_c_str = "\x02"; break;
case LibInput::Key::C: ansi_c_str = "\x03"; break;
case LibInput::Key::D: ansi_c_str = "\x04"; break;
case LibInput::Key::E: ansi_c_str = "\x05"; break;
case LibInput::Key::F: ansi_c_str = "\x06"; break;
case LibInput::Key::G: ansi_c_str = "\x07"; break;
case LibInput::Key::H: ansi_c_str = "\x08"; break;
case LibInput::Key::I: ansi_c_str = "\x09"; break;
case LibInput::Key::J: ansi_c_str = "\x0A"; break;
case LibInput::Key::K: ansi_c_str = "\x0B"; break;
case LibInput::Key::L: ansi_c_str = "\x0C"; break;
case LibInput::Key::M: ansi_c_str = "\x0D"; break;
case LibInput::Key::N: ansi_c_str = "\x0E"; break;
case LibInput::Key::O: ansi_c_str = "\x0F"; break;
case LibInput::Key::P: ansi_c_str = "\x10"; break;
case LibInput::Key::Q: ansi_c_str = "\x11"; break;
case LibInput::Key::R: ansi_c_str = "\x12"; break;
case LibInput::Key::S: ansi_c_str = "\x13"; break;
case LibInput::Key::T: ansi_c_str = "\x14"; break;
case LibInput::Key::U: ansi_c_str = "\x15"; break;
case LibInput::Key::V: ansi_c_str = "\x16"; break;
case LibInput::Key::W: ansi_c_str = "\x17"; break;
case LibInput::Key::X: ansi_c_str = "\x18"; break;
case LibInput::Key::Y: ansi_c_str = "\x19"; break;
case LibInput::Key::Z: ansi_c_str = "\x1A"; break;
default: break;
}
}
else
{
switch (event.key)
{
case LibInput::Key::Enter:
case LibInput::Key::NumpadEnter:
ansi_c_str = "\n";
break;
case LibInput::Key::Backspace:
ansi_c_str = "\b";
break;
case LibInput::Key::Escape:
ansi_c_str = "\e";
break;
case LibInput::Key::Delete:
ansi_c_str = "\x7F";
break;
case LibInput::Key::ArrowUp:
ansi_c_str = "\e[A";
break;
case LibInput::Key::ArrowDown:
ansi_c_str = "\e[B";
break;
case LibInput::Key::ArrowRight:
ansi_c_str = "\e[C";
break;
case LibInput::Key::ArrowLeft:
ansi_c_str = "\e[D";
break;
default:
break;
}
}
if (ansi_c_str)
{
auto* ptr = reinterpret_cast<const uint8_t*>(ansi_c_str);
auto* ptr = (const uint8_t*)ansi_c_str;
while (*ptr)
handle_input_byte(*ptr++);
}

View File

@ -58,10 +58,10 @@ namespace LibInput
"å", "ä", "ö",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
/*"Insert", "PrintScreen", "Delete", "Home", "End", "PageUp", "PageDown",*/ nullptr, nullptr, "\e[3~", nullptr, nullptr, nullptr, nullptr, "\n", " ",
/*"Insert", "PrintScreen", "Delete", "Home", "End", "PageUp", "PageDown",*/ nullptr, nullptr, "\x7F", nullptr, nullptr, nullptr, nullptr, "\n", " ",
"!", "\"", "#", "¤", "%", "&", "/", "§", "½",
"(", ")", "[", "]", "{", "}",
"=", "?", "+", "\\", "´", "`", "¨", "¸", "\x7F", "@", "£", "$", "",
"=", "?", "+", "\\", "´", "`", "¨", "¸", "\b \b", "@", "£", "$", "",
"\e", "\t", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
"'", "*", "^", "~", "\e[A", "\e[B", "\e[D", "\e[C",
",", ";", ".", ":", "-", "_", nullptr, nullptr, "<", ">", "|", "¬", "¦",
@ -77,10 +77,10 @@ namespace LibInput
"Å", "Ä", "Ö",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
/*"Insert", "PrintScreen", "Delete", "Home", "End", "PageUp", "PageDown",*/ nullptr, nullptr, "\e[3~", nullptr, nullptr, nullptr, nullptr, "\n", " ",
/*"Insert", "PrintScreen", "Delete", "Home", "End", "PageUp", "PageDown",*/ nullptr, nullptr, "\x7F", nullptr, nullptr, nullptr, nullptr, "\n", " ",
"!", "\"", "#", "¤", "%", "&", "/", "§", "½",
"(", ")", "[", "]", "{", "}",
"=", "?", "+", "\\", "´", "`", "¨", "¸", "\x7F", "@", "£", "$", "",
"=", "?", "+", "\\", "´", "`", "¨", "¸", "\b \b", "@", "£", "$", "",
"\e", "\t", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
"'", "*", "^", "~", "\e[A", "\e[B", "\e[D", "\e[C",
",", ";", ".", ":", "-", "_", nullptr, nullptr, "<", ">", "|", "¬", "¦",
@ -96,10 +96,10 @@ namespace LibInput
"Å", "Ä", "Ö",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
/*"Insert", "PrintScreen", "Delete", "Home", "End", "PageUp", "PageDown",*/ nullptr, nullptr, "\e[3~", nullptr, nullptr, nullptr, nullptr, "\n", " ",
/*"Insert", "PrintScreen", "Delete", "Home", "End", "PageUp", "PageDown",*/ nullptr, nullptr, "\x7F", nullptr, nullptr, nullptr, nullptr, "\n", " ",
"!", "\"", "#", "¤", "%", "&", "/", "§", "½",
"(", ")", "[", "]", "{", "}",
"=", "?", "+", "\\", "´", "`", "¨", "¸", "\x7F", "@", "£", "$", "",
"=", "?", "+", "\\", "´", "`", "¨", "¸", "\b \b", "@", "£", "$", "",
"\e", "\t", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
"'", "*", "^", "~", "\e[A", "\e[B", "\e[D", "\e[C",
",", ";", ".", ":", "-", "_", nullptr, nullptr, "<", ">", "|", "¬", "¦",

File diff suppressed because it is too large Load Diff

View File

@ -114,7 +114,6 @@ int main()
setenv("HOME", pwd->pw_dir, 1);
chdir(pwd->pw_dir);
setenv("SHELL", pwd->pw_shell, 1);
char shell_path[PATH_MAX];
strcpy(shell_path, pwd->pw_shell);