## STAGING
-* registrar: doesnt match open windows when new file created and is then opened for edit or line number
* registrar: group by hostname or group env var in registrar
-* registrar: should cleanup invalid windows
* tide: gap buffer does not handle UTF-8 currently
## BACKLOG
if (!path) return;
/* search for an existing window */
for (TWindow* win = Windows; win; win = win->next) {
+ /* refresh the filepath and crudely determine if window still valid */
+ free(win->path);
+ win->path = NULL;
+ char* file = readprop(x, win->win, "FILE", XA_STRING, NULL);
+ win->path = (file ? file : NULL);
+
if (win->path && !strcmp(win->path, path)) {
+ /* double check that the window id didnt get reassigned to a non-tide window */
printf("found open window: 0x%x '%s'\n", (unsigned int)win->win, win->path);
x11_error_clear();
char* type = readprop(x, win->win, "TIDE", XA_STRING, 0);
XSync(x->display, False);
}
+TWindow* win_sweep(TWindow* win) {
+ if (win) {
+ if (win->path) {
+ win->next = win_sweep(win->next);
+ } else {
+ TWindow* dead = win;
+ printf("swept: %x\n", (unsigned)win->win);
+ win = win_sweep(win->next);
+ free(dead);
+ }
+ }
+ return win;
+}
+
void propnotify(XConf* x, XEvent* e) {
(void)e;
Atom type;
XSync(x->display, False);
/* cleanup any invalid windows */
-// TWindow* wins = Windows;
-// Windows = NULL;
-// while (wins && wins->next) {
-// TWindow* curr = wins;
-// wins = curr->next;
-// if (!wins->path) {
-// free(curr);
-// } else {
-// curr->next = Windows;
-// Windows = curr;
-// }
-// }
+ Windows = win_sweep(Windows);
}
void find_windows(XConf* x) {