poe

Уређивач .po фајлова
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 4124504b05c76685589802362d58ba3095d65c93
родитељ e76d553f1b57dbb3a869f8f10f3cfffd795c867a
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Thu,  8 Jul 2021 22:42:05 +0200

Continued work on u32_draw_string wrt tabs, p4 (just saving temporarily, this commit won't compile)

Diffstat:
Mdraw.c | 87+++++++++++++++++++++++++++++++++++++++++++++----------------------------------
Mtabs.draft | 45+++++++++++++++++++++++++++++++++++++++++++++
измењених датотека: 2, додавања: 95(+), брисања: 37(-)

diff --git a/draw.c b/draw.c @@ -287,68 +287,81 @@ draw_string(const int x, const int y, const uint16_t fg, const uint16_t bg, return s; } -/* max_cols - pack everything into this many columns - * fill_cols - this many columns from the left/right/center will be filled - * padding_* - this many cells will be skipped from * side */ +/* mc - pack text and padding into this many columns + * fc - this many columns from the left/right/center will be filled + * p_? - this many cells will be skipped from ? side + * ds - string starts being displayed from this column (will fit into c) */ void u32_draw_string(const int x, const int y, const uint16_t fg, const uint16_t bg, - const uint32_t* s, const int max_cols, const int fill_cols, - const int padding_left, const int padding_right, - const Alignment align, const int display_starts_at) + const uint32_t* s, const int mc, const int fc, + const int p_l, const int p_r, + const Alignment align, const int ds) { - int col = 0; - int c = display_starts_at; + int d = 0; /* distance, in screen columns, from x to visible + * part of the string, followed by p_l */ + + int c = 0; /* distance in screen columns from + * d + p_l to mc - p_r (part of the displayed string + * containing text, between padding; + * string fits within this many columns */ + + int r = 0; /* current rune; goes from 0..c */ + + int i = 0; /* string index */ + + + /* + * <-------- visible part ----------> + * +---------+-------+----------------+---------+ + * |d=0 | |c=0 | | + * |<-- d -->|<-p_l->|<------ c ----->|<- p_r ->| + * | |<-------------- mc -------------->| + * |<------------------ fc -------------------->| + * x (align == RIGHT here) + * */ + const uint32_t* ps = s; size_t len = u32_strlen(s); + c = mc - p_l - p_r; if (align == LEFT) { - for (col = 0; col < fill_cols; col++) - tb_change_cell(x+col, y, ' ', fg, bg); - col = 0; + d = 0; + for (r = 0; r < fc; r++) /* r wraps p_? here for filling */ + tb_change_cell(x + d + r, y, ' ', fg, bg); } else if (align == RIGHT) { - for (col = max_cols-1-fill_cols; col < max_cols; col++) - tb_change_cell(x+col, y, ' ', fg, bg); - col = max_cols-len-padding_right-1; + d = fc - mc; + /* r wraps p_? here for filling */ + for (r = 0; r < mc; r++) + tb_change_cell(x + d + r, y, ' ', fg, bg); } else if (align == CENTER) { - for (col = (max_cols-fill_cols)/2; - col < (max_cols+fill_cols)/2; col++) - tb_change_cell(x+col, y, ' ', fg, bg); - - if (s) - { - if (len > max_cols) - { - c = (len-max_cols)/2; - col = 0; - } - else - col = (max_cols-len)/2-padding_left; - } + d = (fc - mc)/2; + for (r = 0; r < mc; r++) + tb_change_cell(x + d + r, y, ' ', fg, bg); } - while (ps && *ps && col < c+max_cols-padding_right) + r = 0; + i = 0; + while (ps && *ps && r < c) { if (*ps == '\t') { - int start = col % TAB_SIZE; - int end = TAB_SIZE - (col % TAB_SIZE); - if (col < c) + if (i < ds) { /* col+TAB_SIZE * \t | * ------[ :::|: ] * | | c+padding_left=c+2 * | c - * col + * i * */ - if (end >= c) + if () { - for (int j = 0; j < end-c+padding_left; + for (int j = 0; j < ; j++) tb_change_cell(x+padding_left+ j, y, ' ', fg, bg); @@ -361,7 +374,7 @@ u32_draw_string(const int x, const int y, const uint16_t fg, const uint16_t bg, * | col+TAB_SIZE * col * */ - col += end-start; + col += TAB_SIZE; } else { @@ -397,7 +410,7 @@ u32_draw_string(const int x, const int y, const uint16_t fg, const uint16_t bg, tb_change_cell(x+padding_left+ (col-start)+j, y, ' ', fg, bg); - col += end-start; + col += TAB_SIZE; } } } diff --git a/tabs.draft b/tabs.draft @@ -56,3 +56,48 @@ while (i < len && d < c+w) i++; } + ABC\t WQ + A + |B + ||C + |||\t + 0123 45 + c + | + 01234567890123456789 + [ + ABC.::::WQ + [ | +---+----+ | + | | | + x x+padding_left + | | + | c=4 + c=0 + +c = 0..n +draw(x+padding_left+c) + + + + + + + + + + + + + + + + + + + + + + + +