LIGHT = 1
};
+/* Global State
+ *****************************************************************************/
/* variable for holding the currently selected color scheme */
-enum ColorScheme ColorBase;
+extern enum ColorScheme ColorBase;
+extern Buf Buffer;
+extern unsigned CursorPos;
+extern unsigned TargetCol;
/* Configuration
*****************************************************************************/
#include "edit.h"
-extern Buf Buffer;
-extern unsigned CursorPos;
-extern unsigned TargetCol;
-
static void special_keys(Rune key);
static void control_keys(Rune key);
static void vi_keys(Rune key);
#include "edit.h"
-struct {
- uint32_t time;
- uint32_t count;
-} Buttons[5] = { {0,0}, {0,0}, {0,0} };
-
-extern Buf Buffer;
-extern unsigned CursorPos;
-extern unsigned TargetCol;
-
#ifndef __MACH__
#include <time.h>
#else
/*****************************************************************************/
-enum {
- SINGLE_CLICK = 0,
- DOUBLE_CLICK,
- TRIPLE_CLICK
-};
-
void unused(MouseEvent* mevnt) {
(void)mevnt;
}
CursorPos = buf_byline(&Buffer, CursorPos, ScrollLines);
}
+/*****************************************************************************/
+
+enum {
+ SINGLE_CLICK = 0,
+ DOUBLE_CLICK,
+ TRIPLE_CLICK
+};
+
+struct {
+ uint32_t time;
+ uint32_t count;
+} Buttons[5] = { {0,0}, {0,0}, {0,0} };
+
void (*Actions[5][3])(MouseEvent* mevnt) = {
[MOUSE_LEFT] = {
[SINGLE_CLICK] = move_cursor,
},
};
-void handle_mouse(MouseEvent* mevnt) {
+static void handle_click(MouseEvent* mevnt) {
if (mevnt->button >= 5) return;
/* update the number of clicks */
uint32_t now = getmillis();
nclicks = (nclicks > 3 ? 1 : nclicks);
Actions[mevnt->button][nclicks-1](mevnt);
}
+
+static void handle_drag(MouseEvent* mevnt) {
+ (void)mevnt;
+}
+
+void handle_mouse(MouseEvent* mevnt) {
+ if (mevnt->type == MouseDown) {
+ handle_click(mevnt);
+ } else if (mevnt->type == MouseMove) {
+ handle_drag(mevnt);
+ }
+}
Buf Buffer;
unsigned CursorPos;
unsigned TargetCol;
+enum ColorScheme ColorBase;
void die(char* m) {
(void)m;
}
-
int main(int argc, char** argv) {
atf_init(argc,argv);
RUN_EXTERN_TEST_SUITE(BufferTests);
return xc;
}
+static void deinit(void) {
+ if (X.pixmap != None) {
+ XftDrawDestroy(X.xft);
+ XFreePixmap(X.display, X.pixmap);
+ }
+ XCloseDisplay(X.display);
+}
+
static int init(void) {
+ atexit(deinit);
signal(SIGPIPE, SIG_IGN); // Ignore the SIGPIPE signal
/* open the X display and get basic attributes */
if (!(X.display = XOpenDisplay(0)))
return XConnectionNumber(X.display);
}
-static void deinit(void) {
- if (X.pixmap != None) {
- XftDrawDestroy(X.xft);
- XFreePixmap(X.display, X.pixmap);
- }
- XCloseDisplay(X.display);
-}
-
static Rune getkey(XEvent* e) {
Rune rune = RUNE_ERR;
size_t len = 0;