summaryrefslogtreecommitdiffstats
path: root/history.c
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2021-12-16 17:11:12 +0100
committerLouis Burda <quent.burda@gmail.com>2021-12-20 15:31:31 +0100
commit3eea7a245a7ed49127a222628543f9509a6ff2b6 (patch)
tree345a923819b73bc88b551af5f708476239b6b7d9 /history.c
parent15a8fe2cf2b16af8739a7ec2b64b5c5f184161b8 (diff)
downloadtmus-3eea7a245a7ed49127a222628543f9509a6ff2b6.tar.gz
tmus-3eea7a245a7ed49127a222628543f9509a6ff2b6.zip
Switched most buffers to wide chars, added general ref class, now clear mpd errors, added track and command completion
Diffstat (limited to 'history.c')
-rw-r--r--history.c28
1 files changed, 26 insertions, 2 deletions
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 <string.h>
@@ -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;
+}