Skip to content

Commit

Permalink
drawer: % formatting is no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Nykseli committed Sep 1, 2023
1 parent 0802c53 commit c75dec0
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions src/drawer.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,28 +307,10 @@ static int find_utfs(const char* src, size_t src_len)
return utfs;
}

static void escape_text(const char* src, char* target, size_t src_len)
{
size_t srci = 0;
size_t targeti = 0;
for (; srci < src_len; srci++, targeti++) {
if (src[srci] == '%') {
target[targeti] = '%';
target[++targeti] = '%';
} else {
target[targeti] = src[srci];
}
}

target[targeti] = '\0';
}

static void draw_to_drawer(drawer* drawer, const char* text)
{
char escape_buf[256];
int utfs = find_utfs(text, strlen(text));
escape_text(text, escape_buf, strlen(text));
mvwprintw(drawer->window, drawer->current_y, drawer->current_x, "%s", escape_buf);
mvwprintw(drawer->window, drawer->current_y, drawer->current_x, "%s", text);
drawer->current_x -= utfs;
}

Expand Down

0 comments on commit c75dec0

Please sign in to comment.