+ if (IS_MOUSE_RELEASE(button)) release = TRUE;
+
+ if (IS_CURSOR_MOVE(button)) {
+ if (!ui->cursor_active) {
+ ui->cursor_active = TRUE;
+ } else if (control | shift) {
+ char *move;
+ if (ui->ndragcoords > 0) return NULL;
+ ui->ndragcoords = -1;
+ move = mark_in_direction(state, ui->curx, ui->cury,
+ KEY_DIRECTION(button), control, tmpbuf);
+ if (control && !shift && *move)
+ move_cursor(button, &ui->curx, &ui->cury, w, h, FALSE);
+ return move;
+ } else {
+ move_cursor(button, &ui->curx, &ui->cury, w, h, FALSE);
+ if (ui->ndragcoords >= 0)
+ update_ui_drag(state, ui, ui->curx, ui->cury);
+ }
+ return "";
+ }
+
+ if (IS_CURSOR_SELECT(button)) {
+ if (!ui->cursor_active) {
+ ui->cursor_active = TRUE;
+ return "";
+ } else if (button == CURSOR_SELECT) {
+ if (ui->ndragcoords == -1) {
+ ui->ndragcoords = 0;
+ ui->dragcoords[0] = ui->cury * w + ui->curx;
+ ui->clickx = CENTERED_COORD(ui->curx);
+ ui->clicky = CENTERED_COORD(ui->cury);
+ return "";
+ } else release = TRUE;
+ } else if (button == CURSOR_SELECT2 && ui->ndragcoords >= 0) {
+ ui->ndragcoords = -1;
+ return "";
+ }
+ }
+
+ if (button == 27 || button == '\b') {
+ ui->ndragcoords = -1;
+ return "";
+ }
+
+ if (release) {
+ if (ui->ndragcoords > 0) {