mirror of
https://github.com/tmux/tmux.git
synced 2025-09-03 22:43:58 +00:00
Step 2 of the Grand Plan To Make UTF-8 Better.
Split grid into two arrays, one containing grid attributes/flags/colours (keeps the name grid_cell for now) and a separate with the character data (called text). The text is stored as a u_short but is treated as a uint64_t elsewhere; eventually the grid will have two arrays. I'm not happy with the naming so that might change. Still need to decide where to go from here. I'm not sure whether to combine the peek/set functions together, and also whether to continue to treat the text as a uint64_t (and convert to/from Unicode) or make it a char array (of size one when UTF-8 disabled, eight when enabled) and keep everything as UTF-8. Also since UTF-8 will eventually become an attribute of the grid itself it might be nice to move all the padding crap into grid.c.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
/* $Id: window-copy.c,v 1.50 2009-02-13 21:39:45 nicm Exp $ */
|
||||
/* $Id: window-copy.c,v 1.51 2009-03-28 16:30:05 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -465,9 +465,9 @@ void
|
||||
window_copy_copy_line(
|
||||
struct window_pane *wp, char **buf, size_t *off, u_int sy, u_int sx, u_int ex)
|
||||
{
|
||||
const struct grid_cell *gc;
|
||||
u_int i, j, xx;
|
||||
u_char data[4];
|
||||
u_int i, j, xx;
|
||||
uint64_t text;
|
||||
u_char data[4];
|
||||
|
||||
if (sx > ex)
|
||||
return;
|
||||
@ -480,8 +480,8 @@ window_copy_copy_line(
|
||||
|
||||
if (sx < ex) {
|
||||
for (i = sx; i < ex; i++) {
|
||||
gc = grid_peek_cell(wp->base.grid, i, sy);
|
||||
utf8_split(gc->data, data);
|
||||
text = grid_peek_text(wp->base.grid, i, sy);
|
||||
utf8_split(text, data);
|
||||
|
||||
*buf = xrealloc(*buf, 1, (*off) + 4);
|
||||
for (j = 0; j < sizeof data; j++) {
|
||||
@ -501,26 +501,28 @@ int
|
||||
window_copy_is_space(struct window_pane *wp, u_int px, u_int py)
|
||||
{
|
||||
const struct grid_cell *gc;
|
||||
const char *spaces = " -_@";
|
||||
uint64_t text;
|
||||
const char *spaces = " -_@";
|
||||
|
||||
gc = grid_peek_cell(wp->base.grid, px, py);
|
||||
if (gc->flags & GRID_FLAG_PADDING)
|
||||
return (0);
|
||||
if (gc->data == 0x00 || gc->data > 0xff)
|
||||
text = grid_peek_text(wp->base.grid, px, py);
|
||||
if (text == 0x00 || text == 0x7f || text > 0xff)
|
||||
return (0);
|
||||
return (strchr(spaces, gc->data) != NULL);
|
||||
return (strchr(spaces, text) != NULL);
|
||||
}
|
||||
|
||||
u_int
|
||||
window_copy_find_length(struct window_pane *wp, u_int py)
|
||||
{
|
||||
const struct grid_cell *gc;
|
||||
u_int px;
|
||||
uint64_t text;
|
||||
u_int px;
|
||||
|
||||
px = wp->base.grid->size[py];
|
||||
while (px > 0) {
|
||||
gc = grid_peek_cell(wp->base.grid, px - 1, py);
|
||||
if (gc->data != 0x20)
|
||||
text = grid_peek_text(wp->base.grid, px - 1, py);
|
||||
if (text != 0x20)
|
||||
break;
|
||||
px--;
|
||||
}
|
||||
|
Reference in New Issue
Block a user