* Run commands in the background and don't block the main thread.
* refactor selection handling to buf.c to prepare for multiple selections.
-* right click to fetch file or line
* Make Fn keys execute nth command in the tags buffers
-* check for file changes when window regains focus
* 100% coverage with unit and unit-integration tests
-* refactor x11.c and win.c
* Status line should omit characters from beginning of path to make file path fit
+* right click to fetch file or line
Straight-up Bugs:
* add command env vars to set options (Tabs, Indent, etc..)
* implement command diffing logic to optimize the undo/redo log
+# Mouse Chords
+
+Mouse Sequence Description
+--------------------------------------------------------------------------------
+Pl Rl Null Selection
+Pl Rl Pl Rl Select by context
+Pl Rl Pl Rl Pl Rl Select big word
+Pl Pm Cut line or selection
+Pl Pr Paste
+Pm Rm Execute text
+Pm Pr Cancel the execution that would occur
+Pr Rr Search
+Pr Pm Cancel the search that would occur
+
# Auxillary Programs
* Visual diff tool
/* These functions must be implemented by any appliation that wishes
to use this module */
void onshutdown(void);
+void onfocus(bool focused);
void onupdate(void);
void onlayout(void);
void onscroll(double percent);
void (*handle_key)(int mods, uint32_t rune);
void (*handle_mouse)(MouseAct act, MouseBtn btn, int x, int y);
void (*shutdown)(void);
+ void (*set_focus)(bool focus);
uint32_t palette[16];
} XConfig;
.handle_key = oninput,
.handle_mouse = onmouse,
.shutdown = onshutdown,
+ .set_focus = onfocus,
.palette = COLOR_PALETTE
};
| ButtonReleaseMask
| ButtonMotionMask
| KeyPressMask
+ | FocusChangeMask
);
/* set input methods */
Config->handle_mouse(action, button, x, y);
}
+static void set_focus(bool focused) {
+ if (focused) {
+ if (X.xic) XSetICFocus(X.xic);
+ } else {
+ if (X.xic) XUnsetICFocus(X.xic);
+ }
+ Config->set_focus(focused);
+}
+
void x11_handle_event(XEvent* e) {
Atom wmDeleteMessage = XInternAtom(X.display, "WM_DELETE_WINDOW", False);
switch (e->type) {
- case KeyPress: handle_key(e); break;
- case ButtonRelease: handle_mouse(e); break;
- case ButtonPress: handle_mouse(e); break;
- case MotionNotify: handle_mouse(e); break;
- case SelectionClear: selclear(e); break;
- case SelectionNotify: selnotify(e); break;
- case SelectionRequest: selrequest(e); break;
+ case FocusIn: set_focus(true); break;
+ case FocusOut: set_focus(false); break;
+ case KeyPress: handle_key(e); break;
+ case ButtonRelease: handle_mouse(e); break;
+ case ButtonPress: handle_mouse(e); break;
+ case MotionNotify: handle_mouse(e); break;
+ case SelectionClear: selclear(e); break;
+ case SelectionNotify: selnotify(e); break;
+ case SelectionRequest: selrequest(e); break;
case ClientMessage:
if (e->xclient.data.l[0] == wmDeleteMessage)
Config->shutdown();
}
+void onfocus(bool focused) {
+}
+
void onupdate(void) {
}
before = now;
}
-static void save(void) {
- Buf* buf = win_buf(EDIT);
- if (buf->modtime != modtime(buf->path)) {
+static bool changed_externally(Buf* buf) {
+ bool modified = (buf->modtime != modtime(buf->path));
+ if (modified) {
view_append(win_view(TAGS),
- "File modified externally: Reload or Overwrite");
- } else {
- trim_whitespace();
- buf_save(win_buf(EDIT));
+ "File modified externally: Reload, Overwrite, or {SaveAs }");
}
+ return modified;
}
static void overwrite(void) {
buf_save(win_buf(EDIT));
}
+static void save(void) {
+ if (!changed_externally(win_buf(EDIT)))
+ overwrite();
+}
+
static void reload(void) {
view_reload(win_view(EDIT));
}
view_scrollto(win_view(EDIT), (off >= bend ? bend : off));
}
+void onfocus(bool focused) {
+ /* notify the user if the file has changed externally */
+ (void)changed_externally(win_buf(EDIT));
+}
+
void onupdate(void) {
static char status_bytes[256];
memset(status_bytes, 0, sizeof(status_bytes));
ChoiceIdx = vec_size(&Choices)-1;
}
+void onfocus(bool focused) {
+}
+
void onupdate(void) {
win_setregion(TAGS);
win_settext(EDIT, "");