=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/status.c,v retrieving revision 1.50 retrieving revision 1.51 diff -c -r1.50 -r1.51 *** src/usr.bin/tmux/status.c 2009/11/20 06:33:26 1.50 --- src/usr.bin/tmux/status.c 2009/11/20 07:01:12 1.51 *************** *** 1,4 **** ! /* $OpenBSD: status.c,v 1.50 2009/11/20 06:33:26 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: status.c,v 1.51 2009/11/20 07:01:12 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 705,717 **** struct screen old_status; size_t len; struct grid_cell gc; if (c->tty.sx == 0 || c->tty.sy == 0) return (0); memcpy(&old_status, &c->status, sizeof old_status); screen_init(&c->status, c->tty.sx, 1, 0); ! len = strlen(c->message_string); if (len > c->tty.sx) len = c->tty.sx; --- 705,720 ---- struct screen old_status; size_t len; struct grid_cell gc; + int utf8flag; if (c->tty.sx == 0 || c->tty.sy == 0) return (0); memcpy(&old_status, &c->status, sizeof old_status); screen_init(&c->status, c->tty.sx, 1, 0); ! utf8flag = options_get_number(&s->options, "status-utf8"); ! ! len = screen_write_strlen(utf8flag, "%s", c->message_string); if (len > c->tty.sx) len = c->tty.sx; *************** *** 723,729 **** screen_write_start(&ctx, NULL, &c->status); screen_write_cursormove(&ctx, 0, 0); ! screen_write_puts(&ctx, &gc, "%.*s", (int) len, c->message_string); for (; len < c->tty.sx; len++) screen_write_putc(&ctx, &gc, ' '); --- 726,732 ---- screen_write_start(&ctx, NULL, &c->status); screen_write_cursormove(&ctx, 0, 0); ! screen_write_nputs(&ctx, len, &gc, utf8flag, "%s", c->message_string); for (; len < c->tty.sx; len++) screen_write_putc(&ctx, &gc, ' '); *************** *** 812,833 **** int status_prompt_redraw(struct client *c) { ! struct screen_write_ctx ctx; struct session *s = c->session; struct screen old_status; size_t i, size, left, len, off; ! char ch; ! struct grid_cell gc; if (c->tty.sx == 0 || c->tty.sy == 0) return (0); memcpy(&old_status, &c->status, sizeof old_status); screen_init(&c->status, c->tty.sx, 1, 0); - off = 0; ! len = strlen(c->prompt_string); if (len > c->tty.sx) len = c->tty.sx; memcpy(&gc, &grid_default_cell, sizeof gc); colour_set_fg(&gc, options_get_number(&s->options, "message-fg")); --- 815,838 ---- int status_prompt_redraw(struct client *c) { ! struct screen_write_ctx ctx; struct session *s = c->session; struct screen old_status; size_t i, size, left, len, off; ! struct grid_cell gc, *gcp; ! int utf8flag; if (c->tty.sx == 0 || c->tty.sy == 0) return (0); memcpy(&old_status, &c->status, sizeof old_status); screen_init(&c->status, c->tty.sx, 1, 0); ! utf8flag = options_get_number(&s->options, "status-utf8"); ! ! len = screen_write_strlen(utf8flag, "%s", c->prompt_string); if (len > c->tty.sx) len = c->tty.sx; + off = 0; memcpy(&gc, &grid_default_cell, sizeof gc); colour_set_fg(&gc, options_get_number(&s->options, "message-fg")); *************** *** 837,870 **** screen_write_start(&ctx, NULL, &c->status); screen_write_cursormove(&ctx, 0, 0); ! screen_write_puts(&ctx, &gc, "%.*s", (int) len, c->prompt_string); left = c->tty.sx - len; if (left != 0) { ! if (c->prompt_index < left) ! size = strlen(c->prompt_buffer); ! else { off = c->prompt_index - left + 1; ! if (c->prompt_index == strlen(c->prompt_buffer)) left--; size = left; } ! screen_write_puts( ! &ctx, &gc, "%.*s", (int) left, c->prompt_buffer + off); ! for (i = len + size; i < c->tty.sx; i++) ! screen_write_putc(&ctx, &gc, ' '); ! ! /* Draw a fake cursor. */ ! ch = ' '; ! screen_write_cursormove(&ctx, len + c->prompt_index - off, 0); ! if (c->prompt_index < strlen(c->prompt_buffer)) ! ch = c->prompt_buffer[c->prompt_index]; ! gc.attr ^= GRID_ATTR_REVERSE; ! screen_write_putc(&ctx, &gc, ch); } screen_write_stop(&ctx); if (grid_compare(c->status.grid, old_status.grid) == 0) { screen_free(&old_status); --- 842,871 ---- screen_write_start(&ctx, NULL, &c->status); screen_write_cursormove(&ctx, 0, 0); ! screen_write_nputs(&ctx, len, &gc, utf8flag, "%s", c->prompt_string); left = c->tty.sx - len; if (left != 0) { ! size = screen_write_strlen(utf8flag, "%s", c->prompt_buffer); ! if (c->prompt_index >= left) { off = c->prompt_index - left + 1; ! if (c->prompt_index == size) left--; size = left; } ! screen_write_nputs( ! &ctx, left, &gc, utf8flag, "%s", c->prompt_buffer + off); ! for (i = len + size; i < c->tty.sx; i++) ! screen_write_putc(&ctx, &gc, ' '); } screen_write_stop(&ctx); + + /* Apply fake cursor. */ + off = len + c->prompt_index - off; + gcp = grid_view_get_cell(c->status.grid, off, 0); + gcp->attr ^= GRID_ATTR_REVERSE; if (grid_compare(c->status.grid, old_status.grid) == 0) { screen_free(&old_status);