diff --git a/cmd/pad/main.go b/cmd/pad/main.go new file mode 100644 index 0000000..e54abdf --- /dev/null +++ b/cmd/pad/main.go @@ -0,0 +1,57 @@ +package main + +import ( + "log" + + "gioui.org/app" + "gioui.org/op" + "gioui.org/text" + "gioui.org/unit" + + "pad/internal/ui" +) + +func main() { + go func() { + w := new(app.Window) + w.Option(app.Title("Pad")) + w.Option(app.Size(unit.Dp(390), unit.Dp(844))) + if err := run(w); err != nil { + log.Fatal(err) + } + }() + app.Main() +} + +func run(w *app.Window) error { + var ops op.Ops + + shaper := text.NewShaper() + renderer := ui.New(ui.Theme{FontSize: 14}, shaper) + + elems := starterElements() + + for { + switch e := w.Event().(type) { + case app.DestroyEvent: + return e.Err + case app.FrameEvent: + gtx := app.NewContext(&ops, e) + renderer.Draw(gtx, elems) + e.Frame(&ops) + } + } +} + +// starterElements returns a hardcoded set of elements for initial testing. +func starterElements() []ui.Element { + return []ui.Element{ + ui.NewLabel("Pad", 20, ui.Region{X: 0, Y: 0, W: 390, H: 48}), + ui.NewListView(ui.Region{X: 0, Y: 48, W: 390, H: 700}, + []ui.ListItem{ + {Text: "notes.txt"}, + {Text: "ideas.txt"}, + {Text: "todo.txt"}, + }), + } +} diff --git a/doc/conflict_resolution.md b/doc/conflict_resolution.md new file mode 100644 index 0000000..0c91c02 --- /dev/null +++ b/doc/conflict_resolution.md @@ -0,0 +1,233 @@ +# Conflict Resolution Specification + +## 1. Overview + +Pad operates on a directory synced by Syncthing. External modifications to files originate from edits on other devices, delivered via Syncthing. This document specifies how Pad detects, classifies, and resolves such changes. + +## 2. Syncthing Conflict File Format + +When Syncthing detects that two devices have modified the same file, it preserves both versions: + +- **Original file** (`notes.txt`) — the local device's version (what Pad edited) +- **Conflict file** (`notes.sync-conflict-2024-05-15-1430-ABCDEF1.txt`) — the remote device's version + +**Naming pattern:** `.sync-conflict--