poe

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

чување 86e8884d8269bc422e158d157c20801ea58ebc44
родитељ b1b281c21c8a2a53c43d3f64b49cdc4b9cdde47c
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Wed,  7 Jul 2021 18:05:39 +0200

Continued work on u32_draw_string wrt tabs

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
Mdraw.c | 45++++++++++++++++++++++++---------------------
Mdraw.h | 4++--
измењених датотека: 2, додавања: 26(+), брисања: 23(-)

diff --git a/draw.c b/draw.c @@ -229,14 +229,14 @@ const char* draw_string(const int x, const int y, const uint16_t fg, const uint16_t bg, const char* s, const int max_cols, const int fill_cols, const int padding_left, const int padding_right, - const Alignment align) + const Alignment align, const int display_starts_at) { uint32_t* us = calloc(strlen(s)+1, sizeof(uint32_t)); if (!us) return NULL; u8_string_to_unicode(us, s, max_cols); u32_draw_string(x, y, fg, bg, us, max_cols, fill_cols, - padding_left, padding_right, align); + padding_left, padding_right, align, display_starts_at); free(us); return s; } @@ -248,7 +248,7 @@ 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 Alignment align, const int display_starts_at) { int col = 0; const uint32_t* ps = NULL; @@ -290,7 +290,8 @@ u32_draw_string(const int x, const int y, const uint16_t fg, const uint16_t bg, if (*ps == '\t') { int i = 0; - for (i = 0; i < TAB_SIZE - (col % TAB_SIZE) + for (i = 0; i < TAB_SIZE - + ((col - display_starts_at) % TAB_SIZE) && col+i < max_cols-padding_right; i++) tb_change_cell(x+padding_left+col+i, y, ' ', fg, bg); @@ -327,12 +328,12 @@ draw_help(const struct DrawState* state) draw_box(startx, endx, starty, endy, DLG_FG, DLG_BG); if (!draw_string(startx, starty, TITLE_FG, TITLE_BG, - help_title, w-2, strlen(help_title)+2, 1, 1, CENTER)) + help_title, w-2, strlen(help_title)+2, 1, 1, CENTER, 0)) return NULL; while (row < LEN(help)) { if (!draw_string(startx+1, starty+1+row, DLG_FG, DLG_BG, - help[row], w-2, w-2, 2, 2, LEFT)) + help[row], w-2, w-2, 2, 2, LEFT, 0)) return NULL; row++; } @@ -367,7 +368,7 @@ draw_editbox(const struct DrawState* state) draw_box(startx, endx, starty, endy, DLG_FG, DLG_BG); if (!draw_string(startx+1, starty, TITLE_FG, TITLE_BG, editbox_title, w-2, - strlen(editbox_title)+2, 1, 1, CENTER)) + strlen(editbox_title)+2, 1, 1, CENTER, 0)) return NULL; uint16_t fg = state->edit_info_focused ? EDIT_MSGID_FOCUS_FG : @@ -389,15 +390,16 @@ draw_editbox(const struct DrawState* state) curline->bg == 0 ? bg : curline->bg, curline->text + state->info_first_shown_column, - w-2, w-2, 1, 1, LEFT); + w-2, w-2, 1, 1, LEFT, + state->info_first_shown_column); } if (state->info_first_shown_row > 0) u32_draw_string(endx-2, starty+1, fg, bg, (uint32_t*)L"\u2191", - 1, 1, 0, 0, LEFT); + 1, 1, 0, 0, LEFT, 0); if (state->info_first_shown_row + (h-3)/2 + 2 <= state->info_rows_count) u32_draw_string(endx-2, starty+(h-3)/2+1, fg, bg, - (uint32_t*)L"\u2193", 1, 1, 0, 0, LEFT); + (uint32_t*)L"\u2193", 1, 1, 0, 0, LEFT, 0); fg = state->edit_info_focused ? EDIT_MSGSTR_FG : EDIT_MSGSTR_FOCUS_FG; @@ -416,7 +418,8 @@ draw_editbox(const struct DrawState* state) u32_draw_string(startx+1, endy-h/2-1+i, fg, bg, curline->text + state->input_first_shown_column, - w-2, w-2, 1, 1, LEFT); + w-2, w-2, 1, 1, LEFT, + state->input_first_shown_column); } if (state->edit_info_focused) @@ -445,11 +448,11 @@ draw_editbox(const struct DrawState* state) state->input_first_shown_row, state->input_rows_count); draw_string(startx+1, endy-2, DLG_FG, DLG_BG, - sbuf, w-2, strlen(sbuf)+2, 1, 1, LEFT); + sbuf, w-2, strlen(sbuf)+2, 1, 1, LEFT, 0); if (entry->flags != FL_NONE) if (!draw_string(endx-MAXFLAGSBUF-4-5, endy-2, DLG_FG, DLG_BG, flags_buf, MAXFLAGSBUF+4-1, MAXFLAGSBUF+4-1, 0, - 0, LEFT)) + 0, LEFT, 0)) return NULL; return state; } @@ -477,7 +480,7 @@ draw_search(const struct DrawState* state) u32_draw_string(startx+1, starty+1, SEARCH_EDIT_FG, SEARCH_EDIT_BG, state->search + state->search_input_first_shown_column, - w-3, w-3, 0, 0, LEFT); + w-3, w-3, 0, 0, LEFT, state->input_first_shown_column); tb_set_cursor(startx+1+state->search_input_display_column - state->search_input_first_shown_column, starty+1); @@ -499,13 +502,13 @@ draw_status(const struct DrawState* state) { if (!draw_string(0, state->maxy-1, PROMPT_FG, PROMPT_BG, state->prompt, state->maxx, state->maxx, 1, 1, - CENTER)) + CENTER, 0)) return NULL; } else if (state->error && state->error[0]) { if (!draw_string(0, state->maxy-1, ERROR_FG, ERROR_BG, state->error, - state->maxx, state->maxx, 1, 1, CENTER)) + state->maxx, state->maxx, 1, 1, CENTER, 0)) return NULL; } else @@ -522,7 +525,7 @@ draw_status(const struct DrawState* state) seg_size = state->maxx-1 - current_start; if (!draw_string(current_start, state->maxy-1, pseg->fg, pseg->bg, buf, seg_size, seg_size, 1, 1, - pseg->alignment)) + pseg->alignment, 0)) return NULL; pseg++; current_start += seg_size; @@ -560,7 +563,7 @@ draw_list_visible(const struct DrawState* state) if (!draw_string(0, cy, sel ? LIST_FLAGS_SEL_FG : LIST_FLAGS_FG, sel ? LIST_FLAGS_SEL_BG : LIST_FLAGS_BG, flags_buf, MAXFLAGSBUF-1+2, MAXFLAGSBUF-1+2, - 2, 0, LEFT)) + 2, 0, LEFT, 0)) return NULL; if (current->msgid) u32_draw_string(MAXFLAGSBUF-1+2, cy, sel ? @@ -569,7 +572,7 @@ draw_list_visible(const struct DrawState* state) current->msgid, state->maxx/2-MAXFLAGSBUF+1-2, state->maxx/2-MAXFLAGSBUF+1-2, 2, 0, - LEFT); + LEFT, 0); else if (current == state->entries) /* special */ draw_string(MAXFLAGSBUF-1+2, cy, sel ? LIST_MSGID_SPECIAL_SEL_FG : @@ -579,7 +582,7 @@ draw_list_visible(const struct DrawState* state) first_entry_msgid, state->maxx/2-MAXFLAGSBUF+1-2, state->maxx/2-MAXFLAGSBUF+1-2, 2, 0, - LEFT); + LEFT, 0); /* don't use msgstr_index as then the entire list will shift * when changing currently displayed plural form msgstr in an @@ -594,7 +597,7 @@ draw_list_visible(const struct DrawState* state) *(current->msgstr /*+ state->msgstr_index*/), state->maxx/2, state->maxx/2, 2, 2, - LEFT); + LEFT, 0); i++; cy++; } diff --git a/draw.h b/draw.h @@ -98,11 +98,11 @@ void draw_box(const int startx, const int endx, const int starty, const char* draw_string(const int x, const int y, const uint16_t fg, const uint16_t bg, const char* s, const int max_cols, const int fill_cols, const int padding_left, const int padding_right, - const Alignment align); + const Alignment align, const int display_starts_at); 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 Alignment align, const int display_starts_at); const struct DrawState* draw_help(const struct DrawState* state); const struct DrawState* draw_editbox(const struct DrawState* state); const struct DrawState* draw_search(const struct DrawState* state);