diff options
author | neonloop | 2021-08-21 00:10:44 +0000 |
---|---|---|
committer | neonloop | 2021-08-21 00:10:44 +0000 |
commit | 41fff233f29b6ee7274f4bf525052dcf0fa56c00 (patch) | |
tree | cfcc8fc9ae57b694d353cba8752a1f8fd99dc78e /util.c | |
parent | f89bcd0179f4e07fe403894053c624d4983090c3 (diff) | |
download | picoarch-41fff233f29b6ee7274f4bf525052dcf0fa56c00.tar.gz picoarch-41fff233f29b6ee7274f4bf525052dcf0fa56c00.tar.bz2 picoarch-41fff233f29b6ee7274f4bf525052dcf0fa56c00.zip |
Updates message display and adds loading message to pcsx
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -0,0 +1,29 @@ +#include "util.h" + +void string_truncate(char *string, size_t max_len) { + size_t len = strlen(string) + 1; + if (len <= max_len) return; + + strncpy(&string[max_len - 4], "...\0", 4); +} + +void string_wrap(char *string, size_t max_len, size_t max_lines) { + char *line = string; + + for (size_t i = 1; i < max_lines; i++) { + char *p = line; + char *prev; + do { + prev = p; + p = strchr(prev+1, ' '); + } while (p && p - line < (int)max_len); + + if (!p && strlen(line) < max_len) break; + + if (prev && prev != line) { + line = prev + 1; + *prev = '\n'; + } + } + string_truncate(line, max_len); +} |