Compare commits

..

3 Commits

Author SHA1 Message Date
9e65131452
editor: Avoid showing an error dialog when pressing Ctrl+S
All checks were successful
Build and test / build (push) Successful in 1m52s
2024-10-26 14:00:57 +02:00
d908ccea6b
wind: Move some stuff from String to RefString 2024-10-26 14:00:26 +02:00
e3613d1653
loginui+2048: Replace String with RefString 2024-10-26 13:43:20 +02:00
6 changed files with 16 additions and 16 deletions

View File

@ -1,4 +1,4 @@
#include <luna/String.h>
#include <luna/RefString.h>
#include <luna/Utf8.h>
#include <stdlib.h>
#include <time.h>
@ -325,7 +325,7 @@ class GameWidget final : public ui::Widget
canvas.fill(colors[tile.color]);
auto fmt = TRY(String::format("%d"_sv, tile.number));
auto fmt = TRY(RefString::format("%d"_sv, tile.number));
auto font = ui::Font::default_bold_font();
auto rect = ui::align({ 0, 0, canvas.width, canvas.height },

View File

@ -157,7 +157,7 @@ Result<void> EditorWidget::save_file()
if (m_path.is_empty())
{
TRY(save_file_as());
return err(ENOENT);
return {};
}
auto file = TRY(os::File::open_or_create(m_path.view(), os::File::WriteOnly));

View File

@ -7,7 +7,7 @@
*
*/
#include <luna/String.h>
#include <luna/RefString.h>
#include <os/ArgumentParser.h>
#include <os/Config.h>
#include <os/File.h>
@ -68,7 +68,7 @@ Result<int> luna_main(int argc, char** argv)
if (!username.is_empty())
{
auto flag = String::format("--user=%s"_sv, username.chars()).release_value();
auto flag = RefString::format("--user=%s"_sv, username.chars()).release_value();
StringView startui_command[] = { "/usr/bin/startui", flag.view() };
os::Process::exec(startui_command[0], Slice<StringView>(startui_command, 2));
@ -118,7 +118,7 @@ Result<int> luna_main(int argc, char** argv)
stage = Stage::PasswordInput;
label.set_text("Password:");
String title = String::format("Log in: %s"_sv, data.chars()).release_value();
RefString title = RefString::format("Log in: %s"_sv, data.chars()).release_value();
window->set_title(title.view());
input.clear();
@ -160,7 +160,7 @@ Result<int> luna_main(int argc, char** argv)
return;
}
auto flag = String::format("--user=%s"_sv, pw->pw_name).release_value();
auto flag = RefString::format("--user=%s"_sv, pw->pw_name).release_value();
StringView startui_command[] = { "/usr/bin/startui", flag.view() };
os::Process::exec(startui_command[0], Slice<StringView>(startui_command, 2));

View File

@ -2,7 +2,7 @@
#include "Mouse.h"
#include "Screen.h"
#include <luna/Alignment.h>
#include <luna/String.h>
#include <luna/RefString.h>
#include <os/File.h>
#include <os/SharedMemory.h>
#include <sys/mman.h>
@ -35,9 +35,9 @@ static Result<void> handle_create_window_message(Client& client)
request.rect = request.rect.normalized();
auto name = TRY_OR_IPC_ERROR(String::from_cstring("Window"));
auto name = TRY_OR_IPC_ERROR(RefString::from_cstring("Window"));
auto shm_path = TRY_OR_IPC_ERROR(String::format("/wind-shm-%d-%lu"_sv, client.conn->fd(), time(NULL)));
auto shm_path = TRY_OR_IPC_ERROR(RefString::format("/wind-shm-%d-%lu"_sv, client.conn->fd(), time(NULL)));
auto* window = new (std::nothrow) Window(request.rect, move(name));
if (!window)
@ -88,7 +88,7 @@ static Result<void> handle_set_window_title_message(Client& client)
ui::SetWindowTitleRequest request;
if (!TRY(client.conn->read_message(request))) return {};
auto name = COPY_IPC_STRING(request.title);
auto name = TRY(RefString::from_string(COPY_IPC_STRING(request.title)));
os::println("wind: SetWindowTitle(\"%s\") for window %d", name.chars(), request.window);

View File

@ -22,7 +22,7 @@ void Window::focus()
g_windows.append(this);
}
Window::Window(ui::Rect r, String&& n) : surface(r), name(move(n))
Window::Window(ui::Rect r, RefString&& n) : surface(r), name(move(n))
{
auto font = ui::Font::default_font();
titlebar = ui::Rect { 0, 0, 0, 0 };

View File

@ -1,6 +1,6 @@
#pragma once
#include <luna/LinkedList.h>
#include <luna/String.h>
#include <luna/RefString.h>
#include <ui/Canvas.h>
#include <ui/Color.h>
#include <ui/Rect.h>
@ -13,14 +13,14 @@ struct Window : public LinkedListNode<Window>
ui::Rect surface;
ui::Rect titlebar;
u32* pixels;
String name;
String shm_path;
RefString name;
RefString shm_path;
bool dirty { false };
Client* client;
int id;
ui::WindowAttributes attributes { 0 };
Window(ui::Rect, String&&);
Window(ui::Rect, RefString&&);
~Window();
void focus();