mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +00:00
Everywhere: Rename {Deprecated => Byte}String
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')
This commit is contained in:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -230,11 +230,11 @@ void Editor::get_terminal_size()
|
|||
m_num_lines = ws.ws_row;
|
||||
}
|
||||
|
||||
void Editor::add_to_history(DeprecatedString const& line)
|
||||
void Editor::add_to_history(ByteString const& line)
|
||||
{
|
||||
if (line.is_empty())
|
||||
return;
|
||||
DeprecatedString histcontrol = getenv("HISTCONTROL");
|
||||
ByteString histcontrol = getenv("HISTCONTROL");
|
||||
auto ignoredups = histcontrol == "ignoredups" || histcontrol == "ignoreboth";
|
||||
auto ignorespace = histcontrol == "ignorespace" || histcontrol == "ignoreboth";
|
||||
if (ignoredups && !m_history.is_empty() && line == m_history.last().entry)
|
||||
|
@ -270,7 +270,7 @@ ErrorOr<Vector<Editor::HistoryEntry>> Editor::try_load_history(StringView path)
|
|||
return history;
|
||||
}
|
||||
|
||||
bool Editor::load_history(DeprecatedString const& path)
|
||||
bool Editor::load_history(ByteString const& path)
|
||||
{
|
||||
auto history_or_error = try_load_history(path);
|
||||
if (history_or_error.is_error())
|
||||
|
@ -322,7 +322,7 @@ static void merge(It0&& begin0, It0 const& end0, It1&& begin1, It1 const& end1,
|
|||
}
|
||||
}
|
||||
|
||||
bool Editor::save_history(DeprecatedString const& path)
|
||||
bool Editor::save_history(ByteString const& path)
|
||||
{
|
||||
// Note: Use a dummy entry to simplify merging.
|
||||
Vector<HistoryEntry> final_history { { "", 0 } };
|
||||
|
@ -345,7 +345,7 @@ bool Editor::save_history(DeprecatedString const& path)
|
|||
// Skip the dummy entry:
|
||||
for (auto iter = final_history.begin() + 1; iter != final_history.end(); ++iter) {
|
||||
auto const& entry = *iter;
|
||||
auto buffer = DeprecatedString::formatted("{}::{}\n\n", entry.timestamp, entry.entry);
|
||||
auto buffer = ByteString::formatted("{}::{}\n\n", entry.timestamp, entry.entry);
|
||||
auto maybe_error = file->write_until_depleted(buffer.bytes());
|
||||
if (maybe_error.is_error())
|
||||
return false;
|
||||
|
@ -373,7 +373,7 @@ void Editor::insert(Utf32View const& string)
|
|||
insert(string.code_points()[i]);
|
||||
}
|
||||
|
||||
void Editor::insert(DeprecatedString const& string)
|
||||
void Editor::insert(ByteString const& string)
|
||||
{
|
||||
for (auto ch : Utf8View { string })
|
||||
insert(ch);
|
||||
|
@ -389,7 +389,7 @@ void Editor::insert(u32 const cp)
|
|||
{
|
||||
StringBuilder builder;
|
||||
builder.append(Utf32View(&cp, 1));
|
||||
auto str = builder.to_deprecated_string();
|
||||
auto str = builder.to_byte_string();
|
||||
if (m_pending_chars.try_append(str.characters(), str.length()).is_error())
|
||||
return;
|
||||
|
||||
|
@ -419,7 +419,7 @@ void Editor::register_key_input_callback(KeyBinding const& binding)
|
|||
return register_key_input_callback(binding.keys, move(internal_function));
|
||||
}
|
||||
|
||||
return register_key_input_callback(binding.keys, [binding = DeprecatedString(binding.binding)](auto& editor) {
|
||||
return register_key_input_callback(binding.keys, [binding = ByteString(binding.binding)](auto& editor) {
|
||||
editor.insert(binding);
|
||||
return false;
|
||||
});
|
||||
|
@ -703,7 +703,7 @@ ErrorOr<void> Editor::really_quit_event_loop()
|
|||
return {};
|
||||
}
|
||||
|
||||
auto Editor::get_line(DeprecatedString const& prompt) -> Result<DeprecatedString, Editor::Error>
|
||||
auto Editor::get_line(ByteString const& prompt) -> Result<ByteString, Editor::Error>
|
||||
{
|
||||
initialize();
|
||||
m_is_editing = true;
|
||||
|
@ -727,7 +727,7 @@ auto Editor::get_line(DeprecatedString const& prompt) -> Result<DeprecatedString
|
|||
}
|
||||
restore();
|
||||
if (line) {
|
||||
DeprecatedString result { line, (size_t)line_length, Chomp };
|
||||
ByteString result { line, (size_t)line_length, Chomp };
|
||||
free(line);
|
||||
return result;
|
||||
}
|
||||
|
@ -787,7 +787,7 @@ auto Editor::get_line(DeprecatedString const& prompt) -> Result<DeprecatedString
|
|||
if (loop.exec() == Retry)
|
||||
return get_line(prompt);
|
||||
|
||||
return m_input_error.has_value() ? Result<DeprecatedString, Editor::Error> { m_input_error.value() } : Result<DeprecatedString, Editor::Error> { m_returned_line };
|
||||
return m_input_error.has_value() ? Result<ByteString, Editor::Error> { m_input_error.value() } : Result<ByteString, Editor::Error> { m_returned_line };
|
||||
}
|
||||
|
||||
ErrorOr<void> Editor::try_update_once()
|
||||
|
@ -944,7 +944,7 @@ ErrorOr<void> Editor::handle_read_event()
|
|||
case InputState::CSIExpectFinal: {
|
||||
m_state = m_previous_free_state;
|
||||
auto is_in_paste = m_state == InputState::Paste;
|
||||
for (auto& parameter : DeprecatedString::copy(csi_parameter_bytes).split(';')) {
|
||||
for (auto& parameter : ByteString::copy(csi_parameter_bytes).split(';')) {
|
||||
if (auto value = parameter.to_uint(); value.has_value())
|
||||
csi_parameters.append(value.value());
|
||||
else
|
||||
|
@ -1532,14 +1532,14 @@ ErrorOr<void> Editor::refresh_display()
|
|||
dbgln("Drawn Spans:");
|
||||
for (auto& sentry : m_drawn_spans.m_spans_starting) {
|
||||
for (auto& entry : sentry.value) {
|
||||
dbgln("{}-{}: {}", sentry.key, entry.key, entry.value.to_deprecated_string());
|
||||
dbgln("{}-{}: {}", sentry.key, entry.key, entry.value.to_byte_string());
|
||||
}
|
||||
}
|
||||
dbgln("==========================================================================");
|
||||
dbgln("Current Spans:");
|
||||
for (auto& sentry : m_current_spans.m_spans_starting) {
|
||||
for (auto& entry : sentry.value) {
|
||||
dbgln("{}-{}: {}", sentry.key, entry.key, entry.value.to_deprecated_string());
|
||||
dbgln("{}-{}: {}", sentry.key, entry.key, entry.value.to_byte_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1613,7 +1613,7 @@ ErrorOr<void> Editor::reposition_cursor(Stream& stream, bool to_end)
|
|||
|
||||
ErrorOr<void> VT::move_absolute(u32 row, u32 col, Stream& stream)
|
||||
{
|
||||
return stream.write_until_depleted(DeprecatedString::formatted("\033[{};{}H", row, col).bytes());
|
||||
return stream.write_until_depleted(ByteString::formatted("\033[{};{}H", row, col).bytes());
|
||||
}
|
||||
|
||||
ErrorOr<void> VT::move_relative(int row, int col, Stream& stream)
|
||||
|
@ -1630,9 +1630,9 @@ ErrorOr<void> VT::move_relative(int row, int col, Stream& stream)
|
|||
col = -col;
|
||||
|
||||
if (row > 0)
|
||||
TRY(stream.write_until_depleted(DeprecatedString::formatted("\033[{}{}", row, x_op).bytes()));
|
||||
TRY(stream.write_until_depleted(ByteString::formatted("\033[{}{}", row, x_op).bytes()));
|
||||
if (col > 0)
|
||||
TRY(stream.write_until_depleted(DeprecatedString::formatted("\033[{}{}", col, y_op).bytes()));
|
||||
TRY(stream.write_until_depleted(ByteString::formatted("\033[{}{}", col, y_op).bytes()));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -1662,36 +1662,36 @@ Style Editor::find_applicable_style(size_t offset) const
|
|||
return style;
|
||||
}
|
||||
|
||||
DeprecatedString Style::Background::to_vt_escape() const
|
||||
ByteString Style::Background::to_vt_escape() const
|
||||
{
|
||||
if (is_default())
|
||||
return "";
|
||||
|
||||
if (m_is_rgb) {
|
||||
return DeprecatedString::formatted("\e[48;2;{};{};{}m", m_rgb_color[0], m_rgb_color[1], m_rgb_color[2]);
|
||||
return ByteString::formatted("\e[48;2;{};{};{}m", m_rgb_color[0], m_rgb_color[1], m_rgb_color[2]);
|
||||
} else {
|
||||
return DeprecatedString::formatted("\e[{}m", (u8)m_xterm_color + 40);
|
||||
return ByteString::formatted("\e[{}m", (u8)m_xterm_color + 40);
|
||||
}
|
||||
}
|
||||
|
||||
DeprecatedString Style::Foreground::to_vt_escape() const
|
||||
ByteString Style::Foreground::to_vt_escape() const
|
||||
{
|
||||
if (is_default())
|
||||
return "";
|
||||
|
||||
if (m_is_rgb) {
|
||||
return DeprecatedString::formatted("\e[38;2;{};{};{}m", m_rgb_color[0], m_rgb_color[1], m_rgb_color[2]);
|
||||
return ByteString::formatted("\e[38;2;{};{};{}m", m_rgb_color[0], m_rgb_color[1], m_rgb_color[2]);
|
||||
} else {
|
||||
return DeprecatedString::formatted("\e[{}m", (u8)m_xterm_color + 30);
|
||||
return ByteString::formatted("\e[{}m", (u8)m_xterm_color + 30);
|
||||
}
|
||||
}
|
||||
|
||||
DeprecatedString Style::Hyperlink::to_vt_escape(bool starting) const
|
||||
ByteString Style::Hyperlink::to_vt_escape(bool starting) const
|
||||
{
|
||||
if (is_empty())
|
||||
return "";
|
||||
|
||||
return DeprecatedString::formatted("\e]8;;{}\e\\", starting ? m_link : DeprecatedString::empty());
|
||||
return ByteString::formatted("\e]8;;{}\e\\", starting ? m_link : ByteString::empty());
|
||||
}
|
||||
|
||||
void Style::unify_with(Style const& other, bool prefer_other)
|
||||
|
@ -1720,7 +1720,7 @@ void Style::unify_with(Style const& other, bool prefer_other)
|
|||
m_is_empty &= other.m_is_empty;
|
||||
}
|
||||
|
||||
DeprecatedString Style::to_deprecated_string() const
|
||||
ByteString Style::to_byte_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append("Style { "sv);
|
||||
|
@ -1767,13 +1767,13 @@ DeprecatedString Style::to_deprecated_string() const
|
|||
|
||||
builder.append('}');
|
||||
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
ErrorOr<void> VT::apply_style(Style const& style, Stream& stream, bool is_starting)
|
||||
{
|
||||
if (is_starting) {
|
||||
TRY(stream.write_until_depleted(DeprecatedString::formatted("\033[{};{};{}m{}{}{}",
|
||||
TRY(stream.write_until_depleted(ByteString::formatted("\033[{};{};{}m{}{}{}",
|
||||
style.bold() ? 1 : 22,
|
||||
style.underline() ? 4 : 24,
|
||||
style.italic() ? 3 : 23,
|
||||
|
@ -1795,7 +1795,7 @@ ErrorOr<void> VT::clear_lines(size_t count_above, size_t count_below, Stream& st
|
|||
} else {
|
||||
// Go down count_below lines.
|
||||
if (count_below > 0)
|
||||
TRY(stream.write_until_depleted(DeprecatedString::formatted("\033[{}B", count_below).bytes()));
|
||||
TRY(stream.write_until_depleted(ByteString::formatted("\033[{}B", count_below).bytes()));
|
||||
// Then clear lines going upwards.
|
||||
for (size_t i = count_below + count_above; i > 0; --i) {
|
||||
TRY(stream.write_until_depleted("\033[2K"sv.bytes()));
|
||||
|
@ -2190,11 +2190,11 @@ Result<Vector<size_t, 2>, Editor::Error> Editor::vt_dsr()
|
|||
return Vector<size_t, 2> { row, col };
|
||||
}
|
||||
|
||||
DeprecatedString Editor::line(size_t up_to_index) const
|
||||
ByteString Editor::line(size_t up_to_index) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(Utf32View { m_buffer.data(), min(m_buffer.size(), up_to_index) });
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
void Editor::remove_at_index(size_t index)
|
||||
|
@ -2316,11 +2316,11 @@ bool Editor::Spans::contains_up_to_offset(Spans const& other, size_t offset) con
|
|||
if constexpr (LINE_EDITOR_DEBUG) {
|
||||
dbgln("Compare for {}-{} failed, no entry", entry.key, left_entry.key);
|
||||
for (auto& x : entry.value)
|
||||
dbgln("Have: {}-{} = {}", entry.key, x.key, x.value.to_deprecated_string());
|
||||
dbgln("Have: {}-{} = {}", entry.key, x.key, x.value.to_byte_string());
|
||||
}
|
||||
return false;
|
||||
} else if (value_it->value != left_entry.value) {
|
||||
dbgln_if(LINE_EDITOR_DEBUG, "Compare for {}-{} failed, different values: {} != {}", entry.key, left_entry.key, value_it->value.to_deprecated_string(), left_entry.value.to_deprecated_string());
|
||||
dbgln_if(LINE_EDITOR_DEBUG, "Compare for {}-{} failed, different values: {} != {}", entry.key, left_entry.key, value_it->value.to_byte_string(), left_entry.value.to_byte_string());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue