работающее сохранение
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
const std = @import("std");
|
||||
const dvui = @import("dvui");
|
||||
const WindowContext = @import("../WindowContext.zig");
|
||||
const document_json = @import("../persistence/document_json.zig");
|
||||
const Document = @import("../models/Document.zig");
|
||||
const json_io = @import("../persistence/json_io.zig");
|
||||
|
||||
pub fn menuBar(ctx: *WindowContext) void {
|
||||
var m = dvui.menu(@src(), .horizontal, .{ .background = true, .expand = .horizontal });
|
||||
@@ -35,7 +36,7 @@ fn openDocumentDialog(ctx: *WindowContext) void {
|
||||
defer ctx.allocator.free(path_z);
|
||||
|
||||
const path = path_z[0..path_z.len];
|
||||
const doc = document_json.loadFromFile(ctx.allocator, path) catch |err| {
|
||||
const doc = json_io.loadFromFile(Document, ctx.allocator, path) catch |err| {
|
||||
std.debug.print("Open file error: {}\n", .{err});
|
||||
return;
|
||||
};
|
||||
@@ -58,7 +59,7 @@ fn saveAsDialog(ctx: *WindowContext) void {
|
||||
defer ctx.allocator.free(path_z);
|
||||
|
||||
const path_raw = path_z[0..path_z.len];
|
||||
document_json.saveToFile(&open_doc.document, path_raw) catch |err| {
|
||||
json_io.saveToFile(Document, &open_doc.document, path_raw) catch |err| {
|
||||
std.debug.print("Save file error: {}\n", .{err});
|
||||
return;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user