Esempio n. 1
0
static void dump_history(void)
{
    printf("command history:\n");
    uint ptr = ptrprev(history_next);
    int i;
    for (i=0; i < HISTORY_LEN; i++) {
        if (history_line(ptr)[0] != 0)
            printf("\t%s\n", history_line(ptr));
        ptr = ptrprev(ptr);
    }
}
Esempio n. 2
0
static void add_history(const char *line)
{
    // reject some stuff
    if (line[0] == 0)
        return;

    uint last = ptrprev(history_next);
    if (strcmp(line, history_line(last)) == 0)
        return;

    strlcpy(history_line(history_next), line, LINE_LEN);
    history_next = ptrnext(history_next);
}
Esempio n. 3
0
File: console.c Progetto: xkentr/lk
static void add_history(const char *line)
{
	// reject some stuff
	if (line[0] == 0)
		return;

	uint last = ptrprev(history_next);
	if (strcmp(line, history_line(last)) == 0)
		return;

	char* hl = history_line(history_next);
	strncpy(hl, line, LINE_LEN-1);
	hl[LINE_LEN-1] = '\0';
	history_next = ptrnext(history_next);
}
Esempio n. 4
0
static const char *prev_history(uint *cursor)
{
    uint i;
    const char *str = history_line(*cursor);

    /* if we are already at head, stop here */
    if (*cursor == history_next)
        return str;

    /* back up one */
    i = ptrprev(*cursor);

    /* if the next one is gonna be null */
    if (history_line(i)[0] == '\0')
        return str;

    /* update the cursor */
    *cursor = i;
    return str;
}
Esempio n. 5
0
static uint start_history_cursor(void)
{
    return ptrprev(history_next);
}