From 3eea7a245a7ed49127a222628543f9509a6ff2b6 Mon Sep 17 00:00:00 2001 From: Louis Burda Date: Thu, 16 Dec 2021 17:11:12 +0100 Subject: Switched most buffers to wide chars, added general ref class, now clear mpd errors, added track and command completion --- history.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'history.c') diff --git a/history.c b/history.c index f933272..eb1b936 100644 --- a/history.c +++ b/history.c @@ -1,5 +1,4 @@ #include "history.h" -#include "link.h" #include "util.h" #include @@ -45,7 +44,6 @@ history_free(struct history *history) free(ln); } history->list = LIST_HEAD; - free(history->query); history->query = NULL; history->cmd = NULL; } @@ -170,6 +168,8 @@ inputln_addch(struct inputln *line, wchar_t c) line->len++; line->cur++; + + line->buf[line->len] = '\0'; } void @@ -189,3 +189,27 @@ inputln_del(struct inputln *line, int n) line->len -= n; line->cur -= n; } + +void +inputln_copy(struct inputln *dst, struct inputln *src) +{ + if (dst->buf) { + free(dst->buf); + dst->buf = NULL; + } + dst->len = src->len; + dst->buf = wcsdup(src->buf); + ASSERT(dst->buf != NULL); + dst->cap = src->len + 1; + dst->cur = dst->len; +} + +void +inputln_replace(struct inputln *line, const wchar_t *str) +{ + line->buf = wcsdup(str); + ASSERT(line->buf != NULL); + line->len = wcslen(str); + line->cap = line->len + 1; + line->cur = line->len; +} -- cgit v1.2.3-71-gd317