From f52eac62259c431daac84ddb6c2a5b7ebd528c2c Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 20 Oct 2013 09:37:50 +0000 Subject: [PATCH 1/6] Don't turn on modifyOtherKeys by default, it is annoying if tmux is killed and it's left on and we can't turn it on and off like we do for attributes. It's not hard to enable in .Xresources or .Xdefaults anyway. --- tty.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tty.c b/tty.c index c989aaaa..53b415ff 100644 --- a/tty.c +++ b/tty.c @@ -224,7 +224,7 @@ tty_start_tty(struct tty *tty) tty->flags |= TTY_FOCUS; tty_puts(tty, "\033[?1004h"); } - tty_puts(tty, "\033[c\033[>4;1m\033[m"); + tty_puts(tty, "\033[c"); } tty->cx = UINT_MAX; @@ -292,7 +292,6 @@ tty_stop_tty(struct tty *tty) tty->flags &= ~TTY_FOCUS; tty_puts(tty, "\033[?1004l"); } - tty_raw(tty, "\033[>4m\033[m"); } tty_raw(tty, tty_term_string(tty->term, TTYC_RMCUP)); From bf35441608b05d52627215aa70bd52d9460812d4 Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 20 Oct 2013 17:28:43 +0000 Subject: [PATCH 2/6] Do not run any command line command from the client which starts the server until after the configuration file completes. This prevents it racing against run-shell or if-shell in .tmux.conf that run in the background. --- cfg.c | 15 +++++++++++++++ server-client.c | 9 ++++++--- server.c | 3 +++ tmux.h | 1 + 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/cfg.c b/cfg.c index c625a2fb..35192dc0 100644 --- a/cfg.c +++ b/cfg.c @@ -31,6 +31,7 @@ struct cmd_q *cfg_cmd_q; int cfg_finished; int cfg_references; struct causelist cfg_causes; +struct client *cfg_client; int load_cfg(const char *path, struct cmd_q *cmdq, char **cause) @@ -127,6 +128,20 @@ cfg_default_done(unused struct cmd_q *cmdq) cmdq_free(cfg_cmd_q); cfg_cmd_q = NULL; + + if (cfg_client != NULL) { + /* + * The client command queue starts with client_exit set to 1 so + * only continue if not empty (that is, we have been delayed + * during configuration parsing for long enough that the + * MSG_COMMAND has arrived), else the client will exit before + * the MSG_COMMAND which might tell it not to. + */ + if (!TAILQ_EMPTY(&cfg_client->cmdq->queue)) + cmdq_continue(cfg_client->cmdq); + cfg_client->references--; + cfg_client = NULL; + } } void diff --git a/server-client.c b/server-client.c index b6d4870d..82d840a0 100644 --- a/server-client.c +++ b/server-client.c @@ -155,8 +155,8 @@ server_client_lost(struct client *c) free(c->ttyname); free(c->term); - evbuffer_free (c->stdin_data); - evbuffer_free (c->stdout_data); + evbuffer_free(c->stdin_data); + evbuffer_free(c->stdout_data); if (c->stderr_data != c->stdout_data) evbuffer_free (c->stderr_data); @@ -932,7 +932,10 @@ server_client_msg_command(struct client *c, struct imsg *imsg) } cmd_free_argv(argc, argv); - cmdq_run(c->cmdq, cmdlist); + if (c != cfg_client || cfg_finished) + cmdq_run(c->cmdq, cmdlist); + else + cmdq_append(c->cmdq, cmdlist); cmd_list_free(cmdlist); return; diff --git a/server.c b/server.c index ffc25db0..8ac9321e 100644 --- a/server.c +++ b/server.c @@ -168,6 +168,9 @@ server_start(int lockfd, char *lockfile) cfg_finished = 0; cfg_references = 1; ARRAY_INIT(&cfg_causes); + cfg_client = ARRAY_FIRST(&clients); + if (cfg_client != NULL) + cfg_client->references++; if (access(TMUX_CONF, R_OK) == 0) { if (load_cfg(TMUX_CONF, cfg_cmd_q, &cause) == -1) { diff --git a/tmux.h b/tmux.h index 67192740..ddee0730 100644 --- a/tmux.h +++ b/tmux.h @@ -1510,6 +1510,7 @@ extern struct cmd_q *cfg_cmd_q; extern int cfg_finished; extern int cfg_references; extern struct causelist cfg_causes; +extern struct client *cfg_client; int load_cfg(const char *, struct cmd_q *, char **); void cfg_default_done(struct cmd_q *); void cfg_show_causes(struct session *); From 7fa55b0419b88b5568bb2fd99dd0de9fba80ac61 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 23 Oct 2013 11:31:03 +0000 Subject: [PATCH 3/6] Key to swap to other end of selection (bound to o with vi keys), from J Raynor. --- mode-key.c | 1 + tmux.1 | 1 + tmux.h | 1 + window-copy.c | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+) diff --git a/mode-key.c b/mode-key.c index 78a8bdf3..995ccdfa 100644 --- a/mode-key.c +++ b/mode-key.c @@ -292,6 +292,7 @@ const struct mode_key_entry mode_key_vi_copy[] = { { 'k', 0, MODEKEYCOPY_UP }, { 'l', 0, MODEKEYCOPY_RIGHT }, { 'n', 0, MODEKEYCOPY_SEARCHAGAIN }, + { 'o', 0, MODEKEYCOPY_OTHEREND }, { 't', 0, MODEKEYCOPY_JUMPTO }, { 'q', 0, MODEKEYCOPY_CANCEL }, { 'v', 0, MODEKEYCOPY_RECTANGLETOGGLE }, diff --git a/tmux.1 b/tmux.1 index 65849212..e815fc4e 100644 --- a/tmux.1 +++ b/tmux.1 @@ -870,6 +870,7 @@ The following keys are supported as appropriate for the mode: .It Li "Next space, end of word" Ta "E" Ta "" .It Li "Next word" Ta "w" Ta "" .It Li "Next word end" Ta "e" Ta "M-f" +.It Li "Other end of selection" Ta "o" Ta "" .It Li "Paste buffer" Ta "p" Ta "C-y" .It Li "Previous page" Ta "C-b" Ta "Page up" .It Li "Previous word" Ta "b" Ta "M-b" diff --git a/tmux.h b/tmux.h index ddee0730..81c99f9b 100644 --- a/tmux.h +++ b/tmux.h @@ -564,6 +564,7 @@ enum mode_key_cmd { MODEKEYCOPY_NEXTSPACEEND, MODEKEYCOPY_NEXTWORD, MODEKEYCOPY_NEXTWORDEND, + MODEKEYCOPY_OTHEREND, MODEKEYCOPY_PREVIOUSPAGE, MODEKEYCOPY_PREVIOUSSPACE, MODEKEYCOPY_PREVIOUSWORD, diff --git a/window-copy.c b/window-copy.c index 7a647c51..275909cd 100644 --- a/window-copy.c +++ b/window-copy.c @@ -65,6 +65,7 @@ u_int window_copy_find_length(struct window_pane *, u_int); void window_copy_cursor_start_of_line(struct window_pane *); void window_copy_cursor_back_to_indentation(struct window_pane *); void window_copy_cursor_end_of_line(struct window_pane *); +void window_copy_other_end(struct window_pane *); void window_copy_cursor_left(struct window_pane *); void window_copy_cursor_right(struct window_pane *); void window_copy_cursor_up(struct window_pane *, int); @@ -415,6 +416,10 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key) case MODEKEYCOPY_CANCEL: window_pane_reset_mode(wp); return; + case MODEKEYCOPY_OTHEREND: + for (; np != 0; np--) + window_copy_other_end(wp); + break; case MODEKEYCOPY_LEFT: for (; np != 0; np--) window_copy_cursor_left(wp); @@ -1618,6 +1623,39 @@ window_copy_cursor_end_of_line(struct window_pane *wp) window_copy_redraw_lines(wp, data->cy, 1); } +void +window_copy_other_end(struct window_pane *wp) +{ + struct window_copy_mode_data *data = wp->modedata; + struct screen *s = &data->screen; + u_int selx, sely, cx, cy, yy; + + if (!s->sel.flag) + return; + + selx = data->selx; + sely = data->sely; + cx = data->cx; + cy = data->cy; + yy = screen_hsize(data->backing) + data->cy - data->oy; + + data->selx = cx; + data->sely = yy; + data->cx = selx; + + if (sely < screen_hsize(data->backing) - data->oy) { + data->oy = screen_hsize(data->backing) - sely; + data->cy = 0; + } else if (sely > screen_hsize(data->backing) - data->oy + screen_size_y(s)) { + data->oy = screen_hsize(data->backing) - sely + screen_size_y(s) - 1; + data->cy = screen_size_y(s) - 1; + + } else + data->cy = cy + sely - yy; + + window_copy_redraw_screen(wp); +} + void window_copy_cursor_left(struct window_pane *wp) { From a6cd84869ee1543af0c44b63cae5a7908e74ba7d Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 8 Nov 2013 12:39:20 +0000 Subject: [PATCH 4/6] Correctly redraw the top two lines in copy mode when they are selected - the selection was being updated before the redraw so the markings were lost. Based on a fix from J Raynor. --- window-copy.c | 77 +++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/window-copy.c b/window-copy.c index 275909cd..d24f08e6 100644 --- a/window-copy.c +++ b/window-copy.c @@ -51,7 +51,7 @@ void window_copy_search_down(struct window_pane *, const char *); void window_copy_goto_line(struct window_pane *, const char *); void window_copy_update_cursor(struct window_pane *, u_int, u_int); void window_copy_start_selection(struct window_pane *); -int window_copy_update_selection(struct window_pane *); +int window_copy_update_selection(struct window_pane *, int); void *window_copy_get_selection(struct window_pane *, size_t *); void window_copy_copy_buffer(struct window_pane *, int, void *, size_t); void window_copy_copy_pipe( @@ -329,7 +329,7 @@ window_copy_pageup(struct window_pane *wp) data->oy = screen_hsize(data->backing); else data->oy += n; - window_copy_update_selection(wp); + window_copy_update_selection(wp, 1); window_copy_redraw_screen(wp); } @@ -458,7 +458,7 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key) else data->oy -= n; } - window_copy_update_selection(wp); + window_copy_update_selection(wp, 1); window_copy_redraw_screen(wp); break; case MODEKEYCOPY_HALFPAGEUP: @@ -469,7 +469,7 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key) else data->oy += n; } - window_copy_update_selection(wp); + window_copy_update_selection(wp, 1); window_copy_redraw_screen(wp); break; case MODEKEYCOPY_HALFPAGEDOWN: @@ -480,39 +480,39 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key) else data->oy -= n; } - window_copy_update_selection(wp); + window_copy_update_selection(wp, 1); window_copy_redraw_screen(wp); break; case MODEKEYCOPY_TOPLINE: data->cx = 0; data->cy = 0; - window_copy_update_selection(wp); + window_copy_update_selection(wp, 1); window_copy_redraw_screen(wp); break; case MODEKEYCOPY_MIDDLELINE: data->cx = 0; data->cy = (screen_size_y(s) - 1) / 2; - window_copy_update_selection(wp); + window_copy_update_selection(wp, 1); window_copy_redraw_screen(wp); break; case MODEKEYCOPY_BOTTOMLINE: data->cx = 0; data->cy = screen_size_y(s) - 1; - window_copy_update_selection(wp); + window_copy_update_selection(wp, 1); window_copy_redraw_screen(wp); break; case MODEKEYCOPY_HISTORYTOP: data->cx = 0; data->cy = 0; data->oy = screen_hsize(data->backing); - window_copy_update_selection(wp); + window_copy_update_selection(wp, 1); window_copy_redraw_screen(wp); break; case MODEKEYCOPY_HISTORYBOTTOM: data->cx = 0; data->cy = screen_size_y(s) - 1; data->oy = 0; - window_copy_update_selection(wp); + window_copy_update_selection(wp, 1); window_copy_redraw_screen(wp); break; case MODEKEYCOPY_STARTSELECTION: @@ -865,7 +865,7 @@ window_copy_mouse( if (s->mode & MODE_MOUSE_BUTTON) { if (~m->event & MOUSE_EVENT_UP) { window_copy_update_cursor(wp, m->x, m->y); - if (window_copy_update_selection(wp)) + if (window_copy_update_selection(wp, 1)) window_copy_redraw_screen(wp); return; } @@ -915,7 +915,7 @@ window_copy_scroll_to(struct window_pane *wp, u_int px, u_int py) } data->oy = gd->hsize - offset; - window_copy_update_selection(wp); + window_copy_update_selection(wp, 1); window_copy_redraw_screen(wp); } @@ -1108,7 +1108,7 @@ window_copy_goto_line(struct window_pane *wp, const char *linestr) return; data->oy = lineno; - window_copy_update_selection(wp); + window_copy_update_selection(wp, 1); window_copy_redraw_screen(wp); } @@ -1221,11 +1221,11 @@ window_copy_start_selection(struct window_pane *wp) data->sely = screen_hsize(data->backing) + data->cy - data->oy; s->sel.flag = 1; - window_copy_update_selection(wp); + window_copy_update_selection(wp, 1); } int -window_copy_update_selection(struct window_pane *wp) +window_copy_update_selection(struct window_pane *wp, int may_redraw) { struct window_copy_mode_data *data = wp->modedata; struct screen *s = &data->screen; @@ -1260,7 +1260,7 @@ window_copy_update_selection(struct window_pane *wp) screen_set_selection(s, sx, sy, data->cx, screen_hsize(s) + data->cy, data->rectflag, &gc); - if (data->rectflag) { + if (data->rectflag && may_redraw) { /* * Can't rely on the caller to redraw the right lines for * rectangle selection - find the highest line and the number @@ -1564,7 +1564,7 @@ window_copy_cursor_start_of_line(struct window_pane *wp) } } window_copy_update_cursor(wp, 0, data->cy); - if (window_copy_update_selection(wp)) + if (window_copy_update_selection(wp, 1)) window_copy_redraw_lines(wp, data->cy, 1); } @@ -1589,7 +1589,7 @@ window_copy_cursor_back_to_indentation(struct window_pane *wp) } window_copy_update_cursor(wp, px, data->cy); - if (window_copy_update_selection(wp)) + if (window_copy_update_selection(wp, 1)) window_copy_redraw_lines(wp, data->cy, 1); } @@ -1619,7 +1619,7 @@ window_copy_cursor_end_of_line(struct window_pane *wp) } window_copy_update_cursor(wp, px, data->cy); - if (window_copy_update_selection(wp)) + if (window_copy_update_selection(wp, 1)) window_copy_redraw_lines(wp, data->cy, 1); } @@ -1666,7 +1666,7 @@ window_copy_cursor_left(struct window_pane *wp) window_copy_cursor_end_of_line(wp); } else { window_copy_update_cursor(wp, data->cx - 1, data->cy); - if (window_copy_update_selection(wp)) + if (window_copy_update_selection(wp, 1)) window_copy_redraw_lines(wp, data->cy, 1); } } @@ -1689,7 +1689,7 @@ window_copy_cursor_right(struct window_pane *wp) window_copy_cursor_down(wp, 0); } else { window_copy_update_cursor(wp, data->cx + 1, data->cy); - if (window_copy_update_selection(wp)) + if (window_copy_update_selection(wp, 1)) window_copy_redraw_lines(wp, data->cy, 1); } } @@ -1719,7 +1719,7 @@ window_copy_cursor_up(struct window_pane *wp, int scroll_only) } } else { window_copy_update_cursor(wp, data->cx, data->cy - 1); - if (window_copy_update_selection(wp)) { + if (window_copy_update_selection(wp, 1)) { if (data->cy == screen_size_y(s) - 1) window_copy_redraw_lines(wp, data->cy, 1); else @@ -1757,7 +1757,7 @@ window_copy_cursor_down(struct window_pane *wp, int scroll_only) window_copy_redraw_lines(wp, data->cy - 1, 2); } else { window_copy_update_cursor(wp, data->cx, data->cy + 1); - if (window_copy_update_selection(wp)) + if (window_copy_update_selection(wp, 1)) window_copy_redraw_lines(wp, data->cy - 1, 2); } @@ -1789,7 +1789,7 @@ window_copy_cursor_jump(struct window_pane *wp) if (!(gc->flags & GRID_FLAG_PADDING) && ud.size == 1 && *ud.data == data->jumpchar) { window_copy_update_cursor(wp, px, data->cy); - if (window_copy_update_selection(wp)) + if (window_copy_update_selection(wp, 1)) window_copy_redraw_lines(wp, data->cy, 1); return; } @@ -1818,7 +1818,7 @@ window_copy_cursor_jump_back(struct window_pane *wp) if (!(gc->flags & GRID_FLAG_PADDING) && ud.size == 1 && *ud.data == data->jumpchar) { window_copy_update_cursor(wp, px, data->cy); - if (window_copy_update_selection(wp)) + if (window_copy_update_selection(wp, 1)) window_copy_redraw_lines(wp, data->cy, 1); return; } @@ -1847,7 +1847,7 @@ window_copy_cursor_jump_to(struct window_pane *wp) if (!(gc->flags & GRID_FLAG_PADDING) && ud.size == 1 && *ud.data == data->jumpchar) { window_copy_update_cursor(wp, px - 1, data->cy); - if (window_copy_update_selection(wp)) + if (window_copy_update_selection(wp, 1)) window_copy_redraw_lines(wp, data->cy, 1); return; } @@ -1876,7 +1876,7 @@ window_copy_cursor_jump_to_back(struct window_pane *wp) if (!(gc->flags & GRID_FLAG_PADDING) && ud.size == 1 && *ud.data == data->jumpchar) { window_copy_update_cursor(wp, px + 1, data->cy); - if (window_copy_update_selection(wp)) + if (window_copy_update_selection(wp, 1)) window_copy_redraw_lines(wp, data->cy, 1); return; } @@ -1924,7 +1924,7 @@ window_copy_cursor_next_word(struct window_pane *wp, const char *separators) } while (expected == 1); window_copy_update_cursor(wp, px, data->cy); - if (window_copy_update_selection(wp)) + if (window_copy_update_selection(wp, 1)) window_copy_redraw_lines(wp, data->cy, 1); } @@ -1974,7 +1974,7 @@ window_copy_cursor_next_word_end(struct window_pane *wp, const char *separators) px--; window_copy_update_cursor(wp, px, data->cy); - if (window_copy_update_selection(wp)) + if (window_copy_update_selection(wp, 1)) window_copy_redraw_lines(wp, data->cy, 1); } @@ -2012,7 +2012,7 @@ window_copy_cursor_previous_word(struct window_pane *wp, const char *separators) out: window_copy_update_cursor(wp, px, data->cy); - if (window_copy_update_selection(wp)) + if (window_copy_update_selection(wp, 1)) window_copy_redraw_lines(wp, data->cy, 1); } @@ -2029,6 +2029,8 @@ window_copy_scroll_up(struct window_pane *wp, u_int ny) return; data->oy -= ny; + window_copy_update_selection(wp, 0); + screen_write_start(&ctx, wp, NULL); screen_write_cursormove(&ctx, 0, 0); screen_write_deleteline(&ctx, ny); @@ -2038,12 +2040,9 @@ window_copy_scroll_up(struct window_pane *wp, u_int ny) window_copy_write_line(wp, &ctx, 1); if (screen_size_y(s) > 3) window_copy_write_line(wp, &ctx, screen_size_y(s) - 2); - if (s->sel.flag && screen_size_y(s) > ny) { - window_copy_update_selection(wp); + if (s->sel.flag && screen_size_y(s) > ny) window_copy_write_line(wp, &ctx, screen_size_y(s) - ny - 1); - } screen_write_cursormove(&ctx, data->cx, data->cy); - window_copy_update_selection(wp); screen_write_stop(&ctx); } @@ -2063,17 +2062,17 @@ window_copy_scroll_down(struct window_pane *wp, u_int ny) return; data->oy += ny; + window_copy_update_selection(wp, 0); + screen_write_start(&ctx, wp, NULL); screen_write_cursormove(&ctx, 0, 0); screen_write_insertline(&ctx, ny); window_copy_write_lines(wp, &ctx, 0, ny); - if (s->sel.flag && screen_size_y(s) > ny) { - window_copy_update_selection(wp); + if (s->sel.flag && screen_size_y(s) > ny) window_copy_write_line(wp, &ctx, ny); - } else if (ny == 1) /* nuke position */ + else if (ny == 1) /* nuke position */ window_copy_write_line(wp, &ctx, 1); screen_write_cursormove(&ctx, data->cx, data->cy); - window_copy_update_selection(wp); screen_write_stop(&ctx); } @@ -2090,6 +2089,6 @@ window_copy_rectangle_toggle(struct window_pane *wp) if (data->cx > px) window_copy_update_cursor(wp, px, data->cy); - window_copy_update_selection(wp); + window_copy_update_selection(wp, 1); window_copy_redraw_screen(wp); } From f0ed61f53cec00ce728fabb5fb615a75671043ea Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 9 Nov 2013 00:48:57 +0000 Subject: [PATCH 5/6] Support case insensitive searching in the same manner as emacs - all lowercase means case insensitive, any uppercase means case sensitive. From J Raynor. --- window-copy.c | 54 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/window-copy.c b/window-copy.c index d24f08e6..0c122cda 100644 --- a/window-copy.c +++ b/window-copy.c @@ -18,6 +18,7 @@ #include +#include #include #include @@ -41,11 +42,11 @@ void window_copy_write_lines( void window_copy_scroll_to(struct window_pane *, u_int, u_int); int window_copy_search_compare( - struct grid *, u_int, u_int, struct grid *, u_int); + struct grid *, u_int, u_int, struct grid *, u_int, int); int window_copy_search_lr( - struct grid *, struct grid *, u_int *, u_int, u_int, u_int); + struct grid *, struct grid *, u_int *, u_int, u_int, u_int, int); int window_copy_search_rl( - struct grid *, struct grid *, u_int *, u_int, u_int, u_int); + struct grid *, struct grid *, u_int *, u_int, u_int, u_int, int); void window_copy_search_up(struct window_pane *, const char *); void window_copy_search_down(struct window_pane *, const char *); void window_copy_goto_line(struct window_pane *, const char *); @@ -921,7 +922,7 @@ window_copy_scroll_to(struct window_pane *wp, u_int px, u_int py) int window_copy_search_compare( - struct grid *gd, u_int px, u_int py, struct grid *sgd, u_int spx) + struct grid *gd, u_int px, u_int py, struct grid *sgd, u_int spx, int cis) { const struct grid_cell *gc, *sgc; struct utf8_data ud, sud; @@ -933,21 +934,28 @@ window_copy_search_compare( if (ud.size != sud.size || ud.width != sud.width) return (0); + + if (cis && ud.size == 1) + return (tolower(ud.data[0]) == sud.data[0]); + return (memcmp(ud.data, sud.data, ud.size) == 0); } int window_copy_search_lr(struct grid *gd, - struct grid *sgd, u_int *ppx, u_int py, u_int first, u_int last) + struct grid *sgd, u_int *ppx, u_int py, u_int first, u_int last, int cis) { u_int ax, bx, px; + int matched; for (ax = first; ax < last; ax++) { if (ax + sgd->sx >= gd->sx) break; for (bx = 0; bx < sgd->sx; bx++) { px = ax + bx; - if (!window_copy_search_compare(gd, px, py, sgd, bx)) + matched = window_copy_search_compare(gd, px, py, sgd, + bx, cis); + if (!matched) break; } if (bx == sgd->sx) { @@ -960,16 +968,19 @@ window_copy_search_lr(struct grid *gd, int window_copy_search_rl(struct grid *gd, - struct grid *sgd, u_int *ppx, u_int py, u_int first, u_int last) + struct grid *sgd, u_int *ppx, u_int py, u_int first, u_int last, int cis) { u_int ax, bx, px; + int matched; for (ax = last + 1; ax > first; ax--) { if (gd->sx - (ax - 1) < sgd->sx) continue; for (bx = 0; bx < sgd->sx; bx++) { px = ax - 1 + bx; - if (!window_copy_search_compare(gd, px, py, sgd, bx)) + matched = window_copy_search_compare(gd, px, py, sgd, + bx, cis); + if (!matched) break; } if (bx == sgd->sx) { @@ -990,7 +1001,8 @@ window_copy_search_up(struct window_pane *wp, const char *searchstr) struct grid_cell gc; size_t searchlen; u_int i, last, fx, fy, px; - int utf8flag, n, wrapped, wrapflag; + int utf8flag, n, wrapped, wrapflag, cis; + const char *ptr; if (*searchstr == '\0') return; @@ -1016,13 +1028,21 @@ window_copy_search_up(struct window_pane *wp, const char *searchstr) fx--; n = wrapped = 0; + cis = 1; + for (ptr = searchstr; *ptr != '\0'; ptr++) { + if (*ptr != tolower(*ptr)) { + cis = 0; + break; + } + } + retry: sgd = ss.grid; for (i = fy + 1; i > 0; i--) { last = screen_size_x(s); if (i == fy + 1) last = fx; - n = window_copy_search_rl(gd, sgd, &px, i - 1, 0, last); + n = window_copy_search_rl(gd, sgd, &px, i - 1, 0, last, cis); if (n) { window_copy_scroll_to(wp, px, i - 1); break; @@ -1048,7 +1068,8 @@ window_copy_search_down(struct window_pane *wp, const char *searchstr) struct grid_cell gc; size_t searchlen; u_int i, first, fx, fy, px; - int utf8flag, n, wrapped, wrapflag; + int utf8flag, n, wrapped, wrapflag, cis; + const char *ptr; if (*searchstr == '\0') return; @@ -1074,13 +1095,22 @@ window_copy_search_down(struct window_pane *wp, const char *searchstr) fx++; n = wrapped = 0; + cis = 1; + for (ptr = searchstr; *ptr != '\0'; ptr++) { + if (*ptr != tolower(*ptr)) { + cis = 0; + break; + } + } + retry: sgd = ss.grid; for (i = fy + 1; i < gd->hsize + gd->sy + 1; i++) { first = 0; if (i == fy + 1) first = fx; - n = window_copy_search_lr(gd, sgd, &px, i - 1, first, gd->sx); + n = window_copy_search_lr(gd, sgd, &px, i - 1, first, gd->sx, + cis); if (n) { window_copy_scroll_to(wp, px, i - 1); break; From 7624800ddc8fa8e51164dc7c615894c086deabef Mon Sep 17 00:00:00 2001 From: benno Date: Wed, 13 Nov 2013 20:43:36 +0000 Subject: [PATCH 6/6] from nicm: : handle msgbuf_write() returning EAGAIN --- client.c | 2 +- server-client.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/client.c b/client.c index 0f2d3684..82ef9cf0 100644 --- a/client.c +++ b/client.c @@ -464,7 +464,7 @@ client_callback(unused int fd, short events, void *data) } if (events & EV_WRITE) { - if (msgbuf_write(&client_ibuf.w) < 0) + if (msgbuf_write(&client_ibuf.w) < 0 && errno != EAGAIN) goto lost_server; } diff --git a/server-client.c b/server-client.c index 82d840a0..c6257edb 100644 --- a/server-client.c +++ b/server-client.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -222,7 +223,8 @@ server_client_callback(int fd, short events, void *data) return; if (fd == c->ibuf.fd) { - if (events & EV_WRITE && msgbuf_write(&c->ibuf.w) < 0) + if (events & EV_WRITE && msgbuf_write(&c->ibuf.w) < 0 && + errno != EAGAIN) goto client_lost; if (c->flags & CLIENT_BAD) {