diff --git a/cmd-parse.y b/cmd-parse.y index 65ffad84..02e30550 100644 --- a/cmd-parse.y +++ b/cmd-parse.y @@ -1273,6 +1273,16 @@ yylex(void) continue; } + if (ch == '\r') { + /* + * Treat \r\n as \n. + */ + ch = yylex_getc(); + if (ch != '\n') { + yylex_ungetc(ch); + ch = '\r'; + } + } if (ch == '\n') { /* * End of line. Update the line number. @@ -1619,6 +1629,13 @@ yylex_token(int ch) log_debug("%s: end at EOF", __func__); break; } + if (state == NONE && ch == '\r') { + ch = yylex_getc(); + if (ch != '\n') { + yylex_ungetc(ch); + ch = '\r'; + } + } if (state == NONE && ch == '\n') { log_debug("%s: end at EOL", __func__); break; diff --git a/mode-tree.c b/mode-tree.c index 5a4e3bbc..50e65499 100644 --- a/mode-tree.c +++ b/mode-tree.c @@ -261,19 +261,21 @@ mode_tree_up(struct mode_tree_data *mtd, int wrap) } } -void +int mode_tree_down(struct mode_tree_data *mtd, int wrap) { if (mtd->current == mtd->line_size - 1) { if (wrap) { mtd->current = 0; mtd->offset = 0; - } + } else + return (0); } else { mtd->current++; if (mtd->current > mtd->offset + mtd->height - 1) mtd->offset++; } + return (1); } void * diff --git a/options-table.c b/options-table.c index 3a9845eb..7220f94b 100644 --- a/options-table.c +++ b/options-table.c @@ -397,7 +397,7 @@ const struct options_table_entry options_table[] = { .type = OPTIONS_TABLE_STRING, .scope = OPTIONS_TABLE_SERVER, .flags = OPTIONS_TABLE_IS_ARRAY, - .default_str = "", + .default_str = "linux*:AX@", .separator = ",", .text = "List of terminal capabilities overrides." }, diff --git a/tmux.1 b/tmux.1 index 655b3626..28153e41 100644 --- a/tmux.1 +++ b/tmux.1 @@ -1359,8 +1359,8 @@ specified multiple times. .Op Fl B Ar name:what:format .Op Fl C Ar size .Op Fl f Ar flags -.Op Fl r Ar pane:report .Op Fl l Op Ar target-pane +.Op Fl r Ar pane:report .Op Fl t Ar target-client .Op Ar adjustment .Xc diff --git a/tmux.h b/tmux.h index 36de238c..2fe2e4f5 100644 --- a/tmux.h +++ b/tmux.h @@ -3187,7 +3187,7 @@ int mode_tree_set_current(struct mode_tree_data *, uint64_t); void mode_tree_each_tagged(struct mode_tree_data *, mode_tree_each_cb, struct client *, key_code, int); void mode_tree_up(struct mode_tree_data *, int); -void mode_tree_down(struct mode_tree_data *, int); +int mode_tree_down(struct mode_tree_data *, int); struct mode_tree_data *mode_tree_start(struct window_pane *, struct args *, mode_tree_build_cb, mode_tree_draw_cb, mode_tree_search_cb, mode_tree_menu_cb, mode_tree_height_cb, mode_tree_key_cb, void *, diff --git a/tty.c b/tty.c index f6d5618e..28dca400 100644 --- a/tty.c +++ b/tty.c @@ -2778,7 +2778,6 @@ static void tty_colours(struct tty *tty, const struct grid_cell *gc) { struct grid_cell *tc = &tty->cell; - int have_ax; /* No changes? Nothing is necessary. */ if (gc->fg == tc->fg && gc->bg == tc->bg && gc->us == tc->us) @@ -2792,28 +2791,18 @@ tty_colours(struct tty *tty, const struct grid_cell *gc) */ if (COLOUR_DEFAULT(gc->fg) || COLOUR_DEFAULT(gc->bg)) { /* - * If don't have AX but do have op, send sgr0 (op can't - * actually be used because it is sometimes the same as sgr0 - * and sometimes isn't). This resets both colours to default. - * + * If don't have AX, send sgr0. This resets both colours to default. * Otherwise, try to set the default colour only as needed. */ - have_ax = tty_term_flag(tty->term, TTYC_AX); - if (!have_ax && tty_term_has(tty->term, TTYC_OP)) + if (!tty_term_flag(tty->term, TTYC_AX)) tty_reset(tty); else { if (COLOUR_DEFAULT(gc->fg) && !COLOUR_DEFAULT(tc->fg)) { - if (have_ax) - tty_puts(tty, "\033[39m"); - else if (tc->fg != 7) - tty_putcode_i(tty, TTYC_SETAF, 7); + tty_puts(tty, "\033[39m"); tc->fg = gc->fg; } if (COLOUR_DEFAULT(gc->bg) && !COLOUR_DEFAULT(tc->bg)) { - if (have_ax) - tty_puts(tty, "\033[49m"); - else if (tc->bg != 0) - tty_putcode_i(tty, TTYC_SETAB, 0); + tty_puts(tty, "\033[49m"); tc->bg = gc->bg; } } @@ -2825,7 +2814,7 @@ tty_colours(struct tty *tty, const struct grid_cell *gc) /* * Set the background colour. This must come after the foreground as - * tty_colour_fg() can call tty_reset(). + * tty_colours_fg() can call tty_reset(). */ if (!COLOUR_DEFAULT(gc->bg) && gc->bg != tc->bg) tty_colours_bg(tty, gc); @@ -2973,6 +2962,15 @@ tty_colours_fg(struct tty *tty, const struct grid_cell *gc) struct grid_cell *tc = &tty->cell; char s[32]; + /* + * If the current colour is an aixterm bright colour and the new is not, + * reset because some terminals do not clear bright correctly. + */ + if (tty->cell.fg >= 90 && + tty->cell.bg <= 97 && + (gc->fg < 90 || gc->fg > 97)) + tty_reset(tty); + /* Is this a 24-bit or 256-colour colour? */ if (gc->fg & COLOUR_FLAG_RGB || gc->fg & COLOUR_FLAG_256) { if (tty_try_colour(tty, gc->fg, "38") == 0) diff --git a/window-buffer.c b/window-buffer.c index e2c36ed4..abdfa125 100644 --- a/window-buffer.c +++ b/window-buffer.c @@ -408,8 +408,17 @@ window_buffer_do_delete(void *modedata, void *itemdata, struct window_buffer_itemdata *item = itemdata; struct paste_buffer *pb; - if (item == mode_tree_get_current(data->data)) - mode_tree_down(data->data, 0); + if (item == mode_tree_get_current(data->data) && + !mode_tree_down(data->data, 0)) { + /* + *If we were unable to select the item further down we are at + * the end of the list. Move one element up instead, to make + * sure that we preserve a valid selection or we risk having + * the tree build logic reset it to the first item. + */ + mode_tree_up(data->data, 0); + } + if ((pb = paste_get_name(item->name)) != NULL) paste_free(pb); } @@ -508,7 +517,7 @@ window_buffer_key(struct window_mode_entry *wme, struct client *c, struct window_buffer_itemdata *item; int finished; - if (paste_get_top(NULL) == NULL) { + if (paste_is_empty()) { finished = 1; goto out; } @@ -541,7 +550,7 @@ window_buffer_key(struct window_mode_entry *wme, struct client *c, } out: - if (finished || paste_get_top(NULL) == NULL) + if (finished || paste_is_empty()) window_pane_reset_mode(wp); else { mode_tree_draw(mtd);