Config->handle_mouse(action, button, x, y);
}
+void x11_handle_events(void) {
+ XEvent e;
+ Atom wmDeleteMessage = XInternAtom(X.display, "WM_DELETE_WINDOW", False);
+ while (XPending(X.display)) {
+ XNextEvent(X.display, &e);
+ if (!XFilterEvent(&e, None)) {
+ switch (e.type) {
+ case FocusIn: if (X.xic) XSetICFocus(X.xic); break;
+ case FocusOut: if (X.xic) XUnsetICFocus(X.xic); 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();
+ break;
+ case ConfigureNotify: // Resize the window
+ if (e.xconfigure.width != X.width || e.xconfigure.height != X.height) {
+ X.width = e.xconfigure.width;
+ X.height = e.xconfigure.height;
+ X.pixmap = XCreatePixmap(X.display, X.window, X.width, X.height, X.depth);
+ X.xft = XftDrawCreate(X.display, X.pixmap, X.visual, X.colormap);
+ }
+ break;
+ }
+ }
+ }
+}
+
void x11_loop(void) {
XEvent e;
while (Running) {
XPeekEvent(X.display,&e);
- while (XPending(X.display)) {
- XNextEvent(X.display, &e);
- if (!XFilterEvent(&e, None)) {
- switch (e.type) {
- case FocusIn: if (X.xic) XSetICFocus(X.xic); break;
- case FocusOut: if (X.xic) XUnsetICFocus(X.xic); 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: {
- Atom wmDeleteMessage = XInternAtom(X.display, "WM_DELETE_WINDOW", False);
- if (e.xclient.data.l[0] == wmDeleteMessage)
- Config->shutdown();
- }
- break;
- case ConfigureNotify: // Resize the window
- if (e.xconfigure.width != X.width || e.xconfigure.height != X.height) {
- X.width = e.xconfigure.width;
- X.height = e.xconfigure.height;
- X.pixmap = XCreatePixmap(X.display, X.window, X.width, X.height, X.depth);
- X.xft = XftDrawCreate(X.display, X.pixmap, X.visual, X.colormap);
- }
- break;
- }
- }
- }
+ x11_handle_events();
if (Running) {
/* redraw the window */
Config->redraw(X.width, X.height);
#define INCLUDE_DEFS
#include <atf.h>
#include <time.h>
+#include <setjmp.h>
enum {
LF = 0,
};
// Test Globals
-int Mods = 0;
int ExitCode = 0;
-char* PrimaryText = NULL;
-char* ClipboardText = NULL;
-
-// fake out the exit routine
-void mockexit(int code) {
- ExitCode = code;
-}
+jmp_buf ExitPad;
// Inculd the source file so we can access everything
#include "../xedit.c"
+static void initialize(void) {
+ win_init("edit");
+ win_setkeys(Bindings);
+ //win_setmouse(&MouseHandlers);
+}
+
/* Helper Functions
*****************************************************************************/
//void setup_view(enum RegionId id, char* text, int crlf, unsigned cursor) {
// return result;
//}
-/* Stubbed Functions
- *****************************************************************************/
-//bool x11_keymodsset(int mask) {
-// return ((Mods & mask) == mask);
-//}
-//
-//size_t x11_font_height(XFont fnt) {
-// return 10;
-//}
-//
-//size_t x11_font_width(XFont fnt) {
-// return 10;
-//}
-//
-//static void redraw(int width, int height) {
-// /* do nothing for unit testing */
-//}
-//
-//void x11_deinit(void) {
-// mockexit(0);
-//}
-//
-//bool x11_getsel(int selid, void(*cbfn)(char*)) {
-// cbfn(selid == PRIMARY ? PrimaryText : ClipboardText);
-// return true;
-//}
-//
-//bool x11_setsel(int selid, char* str) {
-// if (selid == PRIMARY) {
-// free(PrimaryText);
-// PrimaryText = str;
-// } else {
-// free(ClipboardText);
-// ClipboardText = str;
-// }
-// return true;
-//}
-
/* Unit Tests
*****************************************************************************/
TEST_SUITE(UnitTests) {
// }
}
+// fake out the exit routine
+void exit(int code) {
+ ExitCode = code;
+ longjmp(ExitPad, 0);
+}
+
int main(int argc, char** argv) {
+ initialize();
atf_init(argc,argv);
RUN_TEST_SUITE(UnitTests);
return atf_print_results();