1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Refactored history

This commit is contained in:
James Booth 2012-05-02 02:14:29 +01:00
parent 5fe3b1ff79
commit 30dbbad544

View File

@ -29,6 +29,8 @@
static PHistory history;
void _stringify_input(char *inp, int size, char *string);
void history_init(void)
{
history = p_history_new(MAX_HISTORY);
@ -42,24 +44,26 @@ void history_append(char *inp)
char * history_previous(char *inp, int *size)
{
char inp_str[*size + 1];
int i;
for (i = 0; i < *size; i++) {
inp_str[i] = inp[i];
}
inp_str[*size] = '\0';
_stringify_input(inp, *size, inp_str);
return p_history_previous(history, inp_str);
}
char *history_next(char *inp, int *size)
{
char inp_str[*size + 1];
int i;
for (i = 0; i < *size; i++) {
inp_str[i] = inp[i];
}
inp_str[*size] = '\0';
_stringify_input(inp, *size, inp_str);
return p_history_next(history, inp_str);
}
void _stringify_input(char *inp, int size, char *string)
{
int i;
for (i = 0; i < size; i++) {
string[i] = inp[i];
}
string[size] = '\0';
}