mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 17:58:18 +03:00
LibGUI+Shell+bt+ls: Use proper APIs for creating file URLs
This patch replaces ad-hoc generation of file URL strings with using URL::create_with_file_scheme().
This commit is contained in:
parent
5caaa52bee
commit
628c7f094f
Notes:
sideshowbarker
2024-07-18 17:03:38 +09:00
Author: https://github.com/MaxWipfli Commit: https://github.com/SerenityOS/serenity/commit/628c7f094f7 Pull-request: https://github.com/SerenityOS/serenity/pull/7478 Reviewed-by: https://github.com/awesomekling
@ -439,12 +439,8 @@ Variant FileSystemModel::data(const ModelIndex& index, ModelRole role) const
|
||||
}
|
||||
|
||||
if (role == ModelRole::MimeData) {
|
||||
if (index.column() == Column::Name) {
|
||||
StringBuilder builder;
|
||||
builder.append("file://");
|
||||
builder.append(node.full_path());
|
||||
return builder.to_string();
|
||||
}
|
||||
if (index.column() == Column::Name)
|
||||
return URL::create_with_file_scheme(node.full_path()).serialize();
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <AK/ScopedValueRollback.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/TemporaryChange.h>
|
||||
#include <AK/URL.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/Event.h>
|
||||
@ -66,7 +67,8 @@ void Shell::print_path(const String& path)
|
||||
printf("%s", path.characters());
|
||||
return;
|
||||
}
|
||||
printf("\033]8;;file://%s%s\033\\%s\033]8;;\033\\", hostname, path.characters(), path.characters());
|
||||
auto url = URL::create_with_file_scheme(path, {}, hostname);
|
||||
out("\033]8;;{}\033\\{}\033]8;;\033\\", url.serialize(), path);
|
||||
}
|
||||
|
||||
String Shell::prompt() const
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/URL.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
@ -57,7 +58,9 @@ int main(int argc, char** argv)
|
||||
auto full_path = LexicalPath::canonicalized_path(String::formatted("/usr/src/serenity/dummy/dummy/{}", symbol.filename));
|
||||
if (access(full_path.characters(), F_OK) == 0) {
|
||||
linked = true;
|
||||
out("\033]8;;file://{}{}?line_number={}\033\\", hostname, full_path, symbol.line_number);
|
||||
auto url = URL::create_with_file_scheme(full_path, {}, hostname);
|
||||
url.set_query(String::formatted("line_number={}", symbol.line_number));
|
||||
out("\033]8;;{}\033\\", url.serialize());
|
||||
}
|
||||
|
||||
out("\033[34;1m{}:{}\033[0m", LexicalPath(symbol.filename).basename(), symbol.line_number);
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <AK/QuickSort.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/URL.h>
|
||||
#include <AK/Utf8View.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
@ -196,7 +197,8 @@ static size_t print_name(const struct stat& st, const String& name, const char*
|
||||
if (!flag_disable_hyperlinks) {
|
||||
auto full_path = Core::File::real_path_for(path_for_hyperlink);
|
||||
if (!full_path.is_null()) {
|
||||
out("\033]8;;file://{}{}\033\\", hostname(), full_path);
|
||||
auto url = URL::create_with_file_scheme(full_path, {}, hostname());
|
||||
out("\033]8;;{}\033\\", url.serialize());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user