editor: Display only the basename of the current file in the window title

This commit is contained in:
apio 2024-03-29 20:36:44 +01:00
parent 6c8a4ad995
commit 662a315597
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -9,6 +9,7 @@
#include "EditorWidget.h" #include "EditorWidget.h"
#include <ctype.h> #include <ctype.h>
#include <luna/PathParser.h>
#include <luna/Utf8.h> #include <luna/Utf8.h>
#include <os/File.h> #include <os/File.h>
#include <os/FileSystem.h> #include <os/FileSystem.h>
@ -42,7 +43,9 @@ Result<void> EditorWidget::load_file(const os::Path& path)
m_path = path; m_path = path;
String title = TRY(String::format("Text Editor - %s"_sv, m_path.name().chars())); auto basename = TRY(PathParser::basename(m_path.name()));
String title = TRY(String::format("Text Editor - %s"_sv, basename.chars()));
window()->set_title(title.view()); window()->set_title(title.view());
TRY(recalculate_lines()); TRY(recalculate_lines());