summaryrefslogtreecommitdiff
path: root/src/user/knob/block.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/knob/block.c')
-rw-r--r--src/user/knob/block.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/user/knob/block.c b/src/user/knob/block.c
index 90f79e3..1720f94 100644
--- a/src/user/knob/block.c
+++ b/src/user/knob/block.c
@@ -57,4 +57,20 @@ uint32_t strlen(const char *str) {
++str;
}
return len;
+}
+
+void str_trunc_fill(char *str, uint32_t len) {
+ const uint8_t orig_len = strlen(str);
+ if (orig_len > len) {
+ str[len - 4] = ' ';
+ str[len - 3] = '.';
+ str[len - 2] = '.';
+ str[len - 1] = '.';
+ str[len] = '\0';
+ }
+ else if (orig_len != len) {
+ for (uint8_t j = orig_len; j < len; ++j)
+ str[j] = ' ';
+ str[len] = '\0';
+ }
} \ No newline at end of file