mirror of
https://github.com/tmux/tmux.git
synced 2025-04-01 21:41:44 +00:00
initial commit
This commit is contained in:
parent
c311202b73
commit
41ef18debb
12
popup.c
12
popup.c
@ -487,6 +487,8 @@ popup_key_cb(struct client *c, void *data, struct key_event *event)
|
||||
size_t len;
|
||||
u_int px, py, x;
|
||||
enum { NONE, LEFT, RIGHT, TOP, BOTTOM } border = NONE;
|
||||
struct window *w;
|
||||
struct window_pane *wp;
|
||||
|
||||
if (pd->md != NULL) {
|
||||
if (menu_key_cb(c, pd->md, event) == 1) {
|
||||
@ -505,14 +507,20 @@ popup_key_cb(struct client *c, void *data, struct key_event *event)
|
||||
popup_handle_drag(c, pd, m);
|
||||
goto out;
|
||||
}
|
||||
w = c->session->curw->window;
|
||||
wp = w->active;
|
||||
if (m->x < pd->px ||
|
||||
m->x > pd->px + pd->sx - 1 ||
|
||||
m->y < pd->py ||
|
||||
m->y > pd->py + pd->sy - 1) {
|
||||
if (MOUSE_BUTTONS(m->b) == MOUSE_BUTTON_3)
|
||||
goto menu;
|
||||
wp->flags |= PANE_FOCUSED;
|
||||
pd->flags &= ~POPUP_FOCUSED;
|
||||
return (0);
|
||||
}
|
||||
wp->flags &= ~PANE_FOCUSED;
|
||||
pd->flags |= POPUP_FOCUSED;
|
||||
if (pd->border_lines != BOX_LINES_NONE) {
|
||||
if (m->x == pd->px)
|
||||
border = LEFT;
|
||||
@ -559,7 +567,8 @@ popup_key_cb(struct client *c, void *data, struct key_event *event)
|
||||
bufferevent_write(job_get_event(pd->job), buf, len);
|
||||
return (0);
|
||||
}
|
||||
input_key(&pd->s, job_get_event(pd->job), event->key);
|
||||
if (pd->flags & POPUP_FOCUSED)
|
||||
input_key(&pd->s, job_get_event(pd->job), event->key);
|
||||
}
|
||||
return (0);
|
||||
|
||||
@ -723,6 +732,7 @@ popup_display(int flags, enum box_lines lines, struct cmdq_item *item, u_int px,
|
||||
|
||||
server_client_set_overlay(c, 0, popup_check_cb, popup_mode_cb,
|
||||
popup_draw_cb, popup_key_cb, popup_free_cb, popup_resize_cb, pd);
|
||||
pd->flags |= POPUP_FOCUSED;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -2595,6 +2595,8 @@ server_client_handle_key(struct client *c, struct key_event *event)
|
||||
{
|
||||
struct session *s = c->session;
|
||||
struct cmdq_item *item;
|
||||
struct window_pane *wp;
|
||||
int done;
|
||||
|
||||
/* Check the client is good to accept input. */
|
||||
if (s == NULL || (c->flags & CLIENT_UNATTACHEDFLAGS))
|
||||
@ -2612,16 +2614,16 @@ server_client_handle_key(struct client *c, struct key_event *event)
|
||||
status_message_clear(c);
|
||||
}
|
||||
if (c->overlay_key != NULL) {
|
||||
switch (c->overlay_key(c, c->overlay_data, event)) {
|
||||
case 0:
|
||||
return (0);
|
||||
case 1:
|
||||
server_client_clear_overlay(c);
|
||||
return (0);
|
||||
done = c->overlay_key(c, c->overlay_data, event);
|
||||
TAILQ_FOREACH(wp, &c->session->curw->window->panes, entry) {
|
||||
if (wp->flags & PANE_FOCUSED)
|
||||
goto focused;
|
||||
}
|
||||
if (done)
|
||||
server_client_clear_overlay(c);
|
||||
return (0);
|
||||
}
|
||||
server_client_clear_overlay(c);
|
||||
if (c->prompt_string != NULL) {
|
||||
focused: if (c->prompt_string != NULL) {
|
||||
if (status_prompt_key(c, event->key) == 0)
|
||||
return (0);
|
||||
}
|
||||
@ -2893,7 +2895,7 @@ server_client_reset_state(struct client *c)
|
||||
tty->flags &= ~TTY_BLOCK;
|
||||
|
||||
/* Get mode from overlay if any, else from screen. */
|
||||
if (c->overlay_draw != NULL) {
|
||||
if (c->overlay_draw != NULL && ~wp->flags & PANE_FOCUSED) {
|
||||
if (c->overlay_mode != NULL)
|
||||
s = c->overlay_mode(c, c->overlay_data, &cx, &cy);
|
||||
} else if (c->prompt_string == NULL)
|
||||
@ -2924,7 +2926,7 @@ server_client_reset_state(struct client *c)
|
||||
cy = tty->sy - n;
|
||||
}
|
||||
cx = c->prompt_cursor;
|
||||
} else if (c->overlay_draw == NULL) {
|
||||
} else if (c->overlay_draw == NULL || wp->flags & PANE_FOCUSED) {
|
||||
cursor = 0;
|
||||
tty_window_offset(tty, &ox, &oy, &sx, &sy);
|
||||
if (wp->xoff + s->cx >= ox && wp->xoff + s->cx <= ox + sx &&
|
||||
|
1
tmux.h
1
tmux.h
@ -3523,6 +3523,7 @@ int menu_key_cb(struct client *, void *, struct key_event *);
|
||||
#define POPUP_CLOSEEXIT 0x1
|
||||
#define POPUP_CLOSEEXITZERO 0x2
|
||||
#define POPUP_INTERNAL 0x4
|
||||
#define POPUP_FOCUSED 0x8
|
||||
typedef void (*popup_close_cb)(int, void *);
|
||||
typedef void (*popup_finish_edit_cb)(char *, size_t, void *);
|
||||
int popup_display(int, enum box_lines, struct cmdq_item *, u_int,
|
||||
|
Loading…
Reference in New Issue
Block a user