[nostalgia] Replace C strings with ox::StringView
This commit is contained in:
@@ -17,9 +17,11 @@ ox::String getClipboardText(Context *ctx) noexcept {
|
||||
return glfwGetClipboardString(id->window);
|
||||
}
|
||||
|
||||
void setClipboardText(Context *ctx, const ox::String &text) noexcept {
|
||||
void setClipboardText(Context *ctx, ox::CRStringView text) noexcept {
|
||||
const auto id = ctx->windowerData<GlfwImplData>();
|
||||
glfwSetClipboardString(id->window, text.c_str());
|
||||
auto cstr = ox_malloca(text.bytes() + 1, char);
|
||||
ox_strncpy(cstr.get(), text.data(), text.bytes());
|
||||
glfwSetClipboardString(id->window, cstr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace nostalgia::core {
|
||||
|
||||
ox::Result<ox::UniquePtr<Context>> init(ox::UniquePtr<ox::FileSystem> fs, const char *appName) noexcept {
|
||||
ox::Result<ox::UniquePtr<Context>> init(ox::UniquePtr<ox::FileSystem> fs, ox::CRStringView appName) noexcept {
|
||||
auto ctx = ox::make_unique<Context>();
|
||||
ctx->rom = std::move(fs);
|
||||
ctx->appName = appName;
|
||||
|
||||
@@ -192,7 +192,9 @@ ox::Error initGfx(Context *ctx) noexcept {
|
||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
|
||||
}
|
||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
|
||||
id->window = glfwCreateWindow(240 * Scale, 160 * Scale, ctx->appName, nullptr, nullptr);
|
||||
auto cstr = ox_malloca(ctx->appName.bytes() + 1, char);
|
||||
ox_strncpy(cstr.get(), ctx->appName.data(), ctx->appName.bytes());
|
||||
id->window = glfwCreateWindow(240 * Scale, 160 * Scale, cstr, nullptr, nullptr);
|
||||
if (id->window == nullptr) {
|
||||
return OxError(1, "Could not open GLFW window");
|
||||
}
|
||||
@@ -220,9 +222,11 @@ ox::Error initGfx(Context *ctx) noexcept {
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
void setWindowTitle(Context *ctx, const char *title) noexcept {
|
||||
void setWindowTitle(Context *ctx, ox::CRStringView title) noexcept {
|
||||
const auto id = ctx->windowerData<GlfwImplData>();
|
||||
glfwSetWindowTitle(id->window, title);
|
||||
auto cstr = ox_malloca(title.bytes() + 1, char);
|
||||
ox_strncpy(cstr.get(), title.data(), title.bytes());
|
||||
glfwSetWindowTitle(id->window, cstr);
|
||||
}
|
||||
|
||||
void focusWindow(Context *ctx) noexcept {
|
||||
|
||||
Reference in New Issue
Block a user