mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 17:57:35 +00: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
4 changed files with 12 additions and 9 deletions
|
@ -439,12 +439,8 @@ Variant FileSystemModel::data(const ModelIndex& index, ModelRole role) const
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role == ModelRole::MimeData) {
|
if (role == ModelRole::MimeData) {
|
||||||
if (index.column() == Column::Name) {
|
if (index.column() == Column::Name)
|
||||||
StringBuilder builder;
|
return URL::create_with_file_scheme(node.full_path()).serialize();
|
||||||
builder.append("file://");
|
|
||||||
builder.append(node.full_path());
|
|
||||||
return builder.to_string();
|
|
||||||
}
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <AK/ScopedValueRollback.h>
|
#include <AK/ScopedValueRollback.h>
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
#include <AK/TemporaryChange.h>
|
#include <AK/TemporaryChange.h>
|
||||||
|
#include <AK/URL.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/DirIterator.h>
|
#include <LibCore/DirIterator.h>
|
||||||
#include <LibCore/Event.h>
|
#include <LibCore/Event.h>
|
||||||
|
@ -66,7 +67,8 @@ void Shell::print_path(const String& path)
|
||||||
printf("%s", path.characters());
|
printf("%s", path.characters());
|
||||||
return;
|
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
|
String Shell::prompt() const
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/LexicalPath.h>
|
#include <AK/LexicalPath.h>
|
||||||
|
#include <AK/URL.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/DirIterator.h>
|
#include <LibCore/DirIterator.h>
|
||||||
#include <LibCore/EventLoop.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));
|
auto full_path = LexicalPath::canonicalized_path(String::formatted("/usr/src/serenity/dummy/dummy/{}", symbol.filename));
|
||||||
if (access(full_path.characters(), F_OK) == 0) {
|
if (access(full_path.characters(), F_OK) == 0) {
|
||||||
linked = true;
|
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);
|
out("\033[34;1m{}:{}\033[0m", LexicalPath(symbol.filename).basename(), symbol.line_number);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <AK/QuickSort.h>
|
#include <AK/QuickSort.h>
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
|
#include <AK/URL.h>
|
||||||
#include <AK/Utf8View.h>
|
#include <AK/Utf8View.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibCore/ArgsParser.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) {
|
if (!flag_disable_hyperlinks) {
|
||||||
auto full_path = Core::File::real_path_for(path_for_hyperlink);
|
auto full_path = Core::File::real_path_for(path_for_hyperlink);
|
||||||
if (!full_path.is_null()) {
|
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…
Add table
Add a link
Reference in a new issue