aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoruser <user@clank>2026-08-19 15:25:28 +0200
committeruser <user@clank>2026-08-19 15:25:28 +0200
commit49ac13f70aa3a9224e90699fe68d8463909239db (patch)
tree303c3cee9492e23de6a1f0afc7b2feffeba5c6aa /src
parentslosh: the logo flies into place -- a particle engine, statelessly (diff)
downloadslosh-49ac13f70aa3a9224e90699fe68d8463909239db.tar.gz
slosh-49ac13f70aa3a9224e90699fe68d8463909239db.tar.xz
slosh-49ac13f70aa3a9224e90699fe68d8463909239db.zip
slosh: layout files are *.layout, not *.layout.kdl
The old name argued that the extension should say how to read the file. The argument lost to a collision: zellij speaks the same KDL syntax under that same extension with a different schema, and to anyone arriving from there .kdl said *whose* file it is -- naming the wrong owner is worse than not naming the parser. So a layout is x.layout, a project's is slosh.layout, the name says what the file is and --check says how it was read. (It is still KDL underneath; point your editor's highlighting at *.layout.) Nobody's checked-in workspace vanishes on upgrade: the project scan still finds slosh.layout.kdl, never writes it, and where both spellings exist the new one wins, because two files disagreeing needs one answer. The unparseable-file heuristic in --check learned the new suffix -- it matched '.layout.' with a trailing dot, which the new name no longer has. The webdemo overlay moves with it (demo.layout), rebuilt and boot-checked.
Diffstat (limited to 'src')
-rw-r--r--src/app_session.c2
-rw-r--r--src/config.c2
-rw-r--r--src/main.c8
-rw-r--r--src/project.c7
4 files changed, 16 insertions, 3 deletions
diff --git a/src/app_session.c b/src/app_session.c
index a62d4b3..0b228ce 100644
--- a/src/app_session.c
+++ b/src/app_session.c
@@ -228,7 +228,7 @@ bool app_apply_layout_text(app_t *a, const char *text, bool replace, char *err,
bool app_apply_layout_file(app_t *a, const char *path, bool replace, char *err,
size_t errcap) {
- /* Expanded here rather than left to a shell: `--layout "~/x.layout.kdl"` in
+ /* Expanded here rather than left to a shell: `--layout "~/x.layout"` in
* quotes, and every path arriving over the control socket, reach fopen with
* the tilde still on them. */
char pathbuf[1024], dirbuf[1024];
diff --git a/src/config.c b/src/config.c
index 10fe1e9..6060479 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1592,7 +1592,7 @@ char *config_render(const config_t *c) {
if (c->project_layout)
cb_qstr(&b, "project_layout", c->project_layout, NULL);
else
- cb_add(&b, "// project_layout \"~/.config/slosh/project.layout.kdl\"\n");
+ cb_add(&b, "// project_layout \"~/.config/slosh/project.layout\"\n");
cb_add(&b, "\n// ---- colour ----\ntheme {\n");
for (size_t i = 0; i < sizeof THEME_COLORS / sizeof *THEME_COLORS; i++)
diff --git a/src/main.c b/src/main.c
index f3fdd12..b488e56 100644
--- a/src/main.c
+++ b/src/main.c
@@ -48,7 +48,13 @@ static bool looks_like_layout(const char *path) {
char buf[1024];
kdl_node_t *root =
kdl_parse_file(path_expand(path, buf, sizeof buf), NULL, 0);
- if (!root) return strstr(path, ".layout.") != NULL;
+ if (!root) {
+ /* `x.layout` is the spelling, `x.layout.kdl` the one it replaced: both
+ * are somebody's layout, whatever it was that would not parse. */
+ size_t n = strlen(path), s = strlen(".layout");
+ if (n >= s && strcmp(path + n - s, ".layout") == 0) return true;
+ return strstr(path, ".layout.") != NULL;
+ }
bool layout = false;
for (size_t i = 0; i < root->nkids && !layout; i++) {
const char *name = root->kids[i] ? root->kids[i]->name : NULL;
diff --git a/src/project.c b/src/project.c
index 9146971..296cb25 100644
--- a/src/project.c
+++ b/src/project.c
@@ -81,6 +81,13 @@ static bool describe(const char *path, project_t *p) {
p->mtime = (int64_t)lst.st_mtime;
return true;
}
+ /* The old spelling, found but never written: see PROJECT_LAYOUT_FILE_OLD. */
+ if (exists(p->path, PROJECT_LAYOUT_FILE_OLD, &lst)) {
+ snprintf(p->layout, sizeof p->layout, "%s/%s", p->path,
+ PROJECT_LAYOUT_FILE_OLD);
+ p->mtime = (int64_t)lst.st_mtime;
+ return true;
+ }
return exists(p->path, ".git", NULL);
}