mirror of
https://github.com/tmux/tmux.git
synced 2024-12-13 01:48:47 +00:00
Unbreak UTF-8.
This commit is contained in:
parent
7bc8be006e
commit
4cdc228353
3
CHANGES
3
CHANGES
@ -1,5 +1,6 @@
|
||||
18 January 2009
|
||||
|
||||
* Unbreak UTF-8.
|
||||
* -a flag to next-window and previous-window to select the next or previous
|
||||
window with activity or bell. Bound to M-n and M-p.
|
||||
* find-window command to search window names, titles and visible content (but
|
||||
@ -957,7 +958,7 @@
|
||||
(including mutt, emacs). No status bar yet and no key remapping or other
|
||||
customisation.
|
||||
|
||||
$Id: CHANGES,v 1.219 2009-01-18 18:31:45 nicm Exp $
|
||||
$Id: CHANGES,v 1.220 2009-01-18 21:46:30 nicm Exp $
|
||||
|
||||
LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr
|
||||
LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms
|
||||
|
2
TODO
2
TODO
@ -81,4 +81,6 @@
|
||||
errors better
|
||||
- document find-window
|
||||
- bring back -l/-p on splitw so i can do "splitw -p 75 elinks"
|
||||
- UTF-8 combining characters don't work (probably should be width 1 but are
|
||||
listed as 2)
|
||||
|
||||
|
4
input.c
4
input.c
@ -1,4 +1,4 @@
|
||||
/* $Id: input.c,v 1.73 2009-01-11 23:31:46 nicm Exp $ */
|
||||
/* $Id: input.c,v 1.74 2009-01-18 21:46:30 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -542,7 +542,9 @@ input_state_utf8(u_char ch, struct input_ctx *ictx)
|
||||
value = '_';
|
||||
|
||||
ictx->cell.data = value;
|
||||
ictx->cell.flags |= GRID_FLAG_UTF8;
|
||||
screen_write_cell(&ictx->ctx, &ictx->cell);
|
||||
ictx->cell.flags &= ~GRID_FLAG_UTF8;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: screen-write.c,v 1.26 2009-01-18 21:21:53 nicm Exp $ */
|
||||
/* $Id: screen-write.c,v 1.27 2009-01-18 21:46:30 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -514,7 +514,11 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
|
||||
const struct grid_cell *hc;
|
||||
struct grid_cell *ic, tc;
|
||||
|
||||
/* Find character width. */
|
||||
if (gc->flags & GRID_FLAG_UTF8)
|
||||
width = utf8_width(gc->data);
|
||||
else
|
||||
width = 1;
|
||||
|
||||
/* If the character is wider than the screen, don't print it. */
|
||||
if (width > screen_size_x(s)) {
|
||||
@ -570,7 +574,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
|
||||
break;
|
||||
grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
|
||||
}
|
||||
} else if (utf8_width(hc->data) > 1) {
|
||||
} else if (hc->flags & GRID_FLAG_UTF8 && utf8_width(hc->data) > 1) {
|
||||
/*
|
||||
* An UTF-8 wide cell; overwrite following padding cells only.
|
||||
*/
|
||||
@ -593,6 +597,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
|
||||
ic->flags |= GRID_FLAG_PADDING;
|
||||
}
|
||||
|
||||
not_utf8:
|
||||
/* Write the actual cell. */
|
||||
grid_view_set_cell(gd, s->cx, s->cy, gc);
|
||||
|
||||
|
3
tmux.h
3
tmux.h
@ -1,4 +1,4 @@
|
||||
/* $Id: tmux.h,v 1.240 2009-01-18 18:31:45 nicm Exp $ */
|
||||
/* $Id: tmux.h,v 1.241 2009-01-18 21:46:30 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -426,6 +426,7 @@ struct msg_resize_data {
|
||||
#define GRID_FLAG_FG256 0x1
|
||||
#define GRID_FLAG_BG256 0x2
|
||||
#define GRID_FLAG_PADDING 0x4
|
||||
#define GRID_FLAG_UTF8 0x8
|
||||
|
||||
/* Grid cell. */
|
||||
struct grid_cell {
|
||||
|
16
tty.c
16
tty.c
@ -1,4 +1,4 @@
|
||||
/* $Id: tty.c,v 1.60 2009-01-18 21:35:09 nicm Exp $ */
|
||||
/* $Id: tty.c,v 1.61 2009-01-18 21:46:30 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -680,20 +680,18 @@ tty_cmd_cell(struct tty *tty, struct screen *s, u_int oy, va_list ap)
|
||||
if (gc->flags & GRID_FLAG_PADDING)
|
||||
return;
|
||||
|
||||
/* Handle special characters. Should never come into this function.*/
|
||||
if (gc->data < 0x20 || gc->data == 0x7f)
|
||||
return;
|
||||
|
||||
/* Set the attributes. */
|
||||
tty_attributes(tty, gc);
|
||||
|
||||
/* If not UTF8 multibyte, write directly. */
|
||||
if (gc->data <= 0xff) {
|
||||
/* If not UTF-8, write directly. */
|
||||
if (!(gc->flags & GRID_FLAG_UTF8)) {
|
||||
if (gc->data > 0xff || gc->data < 0x20 || gc->data == 0x7f)
|
||||
return;
|
||||
tty_putc(tty, gc->data);
|
||||
return;
|
||||
}
|
||||
|
||||
/* If the terminal doesn't support UTF8, write _s. */
|
||||
/* If the terminal doesn't support UTF-8, write underscores. */
|
||||
if (!(tty->flags & TTY_UTF8)) {
|
||||
width = utf8_width(gc->data);
|
||||
while (width-- > 0)
|
||||
@ -701,7 +699,7 @@ tty_cmd_cell(struct tty *tty, struct screen *s, u_int oy, va_list ap)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Unpack UTF-8 and write it. */
|
||||
/* Otherwise, unpack UTF-8 and write it. */
|
||||
utf8_split(gc->data, out);
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (out[i] == 0xff)
|
||||
|
Loading…
Reference in New Issue
Block a user