1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 18:17:45 +00:00

LibCore: Move Stream-based file into the Core namespace

This commit is contained in:
Tim Schumacher 2023-02-09 03:02:46 +01:00 committed by Linus Groh
parent a96339b72b
commit 606a3982f3
218 changed files with 748 additions and 643 deletions

View file

@ -602,7 +602,7 @@ ErrorOr<void> Editor::interrupted()
m_finish = false;
{
auto stderr_stream = TRY(Core::Stream::File::standard_error());
auto stderr_stream = TRY(Core::File::standard_error());
TRY(reposition_cursor(*stderr_stream, true));
if (TRY(m_suggestion_display->cleanup()))
TRY(reposition_cursor(*stderr_stream, true));
@ -648,7 +648,7 @@ ErrorOr<void> Editor::handle_resize_event(bool reset_origin)
set_origin(m_origin_row, 1);
auto stderr_stream = TRY(Core::Stream::File::standard_error());
auto stderr_stream = TRY(Core::File::standard_error());
TRY(reposition_cursor(*stderr_stream, true));
TRY(m_suggestion_display->redisplay(m_suggestion_manager, m_num_lines, m_num_columns));
@ -665,7 +665,7 @@ ErrorOr<void> Editor::really_quit_event_loop()
{
m_finish = false;
{
auto stderr_stream = TRY(Core::Stream::File::standard_error());
auto stderr_stream = TRY(Core::File::standard_error());
TRY(reposition_cursor(*stderr_stream, true));
TRY(stderr_stream->write_entire_buffer("\n"sv.bytes()));
}
@ -731,7 +731,7 @@ auto Editor::get_line(DeprecatedString const& prompt) -> Result<DeprecatedString
strip_styles(true);
{
auto stderr_stream = Core::Stream::File::standard_error().release_value_but_fixme_should_propagate_errors();
auto stderr_stream = Core::File::standard_error().release_value_but_fixme_should_propagate_errors();
auto prompt_lines = max(current_prompt_metrics().line_metrics.size(), 1ul) - 1;
for (size_t i = 0; i < prompt_lines; ++i)
stderr_stream->write_entire_buffer("\n"sv.bytes()).release_value_but_fixme_should_propagate_errors();
@ -1173,7 +1173,7 @@ ErrorOr<void> Editor::handle_read_event()
for (auto& view : completion_result.insert)
insert(view);
auto stderr_stream = TRY(Core::Stream::File::standard_error());
auto stderr_stream = TRY(Core::File::standard_error());
TRY(reposition_cursor(*stderr_stream));
if (completion_result.style_to_apply.has_value()) {
@ -1252,7 +1252,7 @@ ErrorOr<void> Editor::cleanup_suggestions()
// We probably have some suggestions drawn,
// let's clean them up.
if (TRY(m_suggestion_display->cleanup())) {
auto stderr_stream = TRY(Core::Stream::File::standard_error());
auto stderr_stream = TRY(Core::File::standard_error());
TRY(reposition_cursor(*stderr_stream));
m_refresh_needed = true;
}
@ -1326,7 +1326,7 @@ ErrorOr<void> Editor::cleanup()
if (new_lines < m_shown_lines)
m_extra_forward_lines = max(m_shown_lines - new_lines, m_extra_forward_lines);
auto stderr_stream = TRY(Core::Stream::File::standard_error());
auto stderr_stream = TRY(Core::File::standard_error());
TRY(reposition_cursor(*stderr_stream, true));
auto current_line = num_lines() - 1;
TRY(VT::clear_lines(current_line, m_extra_forward_lines, *stderr_stream));

View file

@ -9,6 +9,7 @@
#include <AK/ScopedValueRollback.h>
#include <AK/StringBuilder.h>
#include <AK/TemporaryChange.h>
#include <LibCore/File.h>
#include <LibLine/Editor.h>
#include <stdio.h>
#include <sys/wait.h>
@ -341,7 +342,7 @@ void Editor::enter_search()
auto& search_string = search_string_result.value();
// Manually cleanup the search line.
auto stderr_stream = Core::Stream::File::standard_error().release_value_but_fixme_should_propagate_errors();
auto stderr_stream = Core::File::standard_error().release_value_but_fixme_should_propagate_errors();
reposition_cursor(*stderr_stream).release_value_but_fixme_should_propagate_errors();
auto search_metrics = actual_rendered_string_metrics(search_string, {});
auto metrics = actual_rendered_string_metrics(search_prompt, {});
@ -433,7 +434,7 @@ void Editor::go_end()
void Editor::clear_screen()
{
warn("\033[3J\033[H\033[2J");
auto stream = Core::Stream::File::standard_error().release_value_but_fixme_should_propagate_errors();
auto stream = Core::File::standard_error().release_value_but_fixme_should_propagate_errors();
VT::move_absolute(1, 1, *stream).release_value_but_fixme_should_propagate_errors();
set_origin(1, 1);
m_refresh_needed = true;
@ -528,7 +529,7 @@ void Editor::edit_in_external_editor()
{
auto write_fd = dup(fd);
auto stream = Core::Stream::File::adopt_fd(write_fd, Core::Stream::OpenMode::Write).release_value_but_fixme_should_propagate_errors();
auto stream = Core::File::adopt_fd(write_fd, Core::File::OpenMode::Write).release_value_but_fixme_should_propagate_errors();
StringBuilder builder;
builder.append(Utf32View { m_buffer.data(), m_buffer.size() });
auto bytes = builder.string_view().bytes();
@ -569,7 +570,7 @@ void Editor::edit_in_external_editor()
}
{
auto file = Core::Stream::File::open({ file_path, strlen(file_path) }, Core::Stream::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
auto file = Core::File::open({ file_path, strlen(file_path) }, Core::File::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
auto contents = file->read_until_eof().release_value_but_fixme_should_propagate_errors();
StringView data { contents };
while (data.ends_with('\n'))

View file

@ -7,6 +7,7 @@
#include <AK/BinarySearch.h>
#include <AK/Function.h>
#include <AK/StringBuilder.h>
#include <LibCore/File.h>
#include <LibLine/SuggestionDisplay.h>
#include <LibLine/VT.h>
#include <stdio.h>
@ -17,7 +18,7 @@ ErrorOr<void> XtermSuggestionDisplay::display(SuggestionManager const& manager)
{
did_display();
auto stderr_stream = TRY(Core::Stream::File::standard_error());
auto stderr_stream = TRY(Core::File::standard_error());
size_t longest_suggestion_length = 0;
size_t longest_suggestion_byte_length = 0;
@ -161,7 +162,7 @@ ErrorOr<bool> XtermSuggestionDisplay::cleanup()
did_cleanup();
if (m_lines_used_for_last_suggestions) {
auto stderr_stream = TRY(Core::Stream::File::standard_error());
auto stderr_stream = TRY(Core::File::standard_error());
TRY(VT::clear_lines(0, m_lines_used_for_last_suggestions, *stderr_stream));
m_lines_used_for_last_suggestions = 0;
return true;