Example #1
0
void ntshell_execute(
        ntshell_t *p,
        int (*func_read)(char *buf, int cnt),
        int (*func_write)(const char *buf, int cnt),
        int (*func_cb)(const char *text))
{
    ntshell_user_data_t user_data;

    user_data.editor = &(p->editor);
    user_data.history = &(p->history);
    user_data.func_read = func_read;
    user_data.func_write = func_write;
    user_data.func_cb = func_cb;

    p->parser.user_data = &user_data;

    vtparse_init(&(p->parser), parser_callback);
    text_editor_init(GET_EDITOR(&(p->parser)));
    text_history_init(GET_HISTORY(&(p->parser)));
    SUGGEST_INDEX(&(p->parser)) = -1;

    SERIAL_WRITE(&(p->parser), ">", 1);
    while(1)
    {
        unsigned char ch;
        SERIAL_READ(&(p->parser), (char *)&ch, sizeof(ch));
        vtparse(&(p->parser), &ch, sizeof(ch));
    }
}
int main()
{
    unsigned char buf[1024];
    int bytes;
    vtparse_t parser;

    vtparse_init(&parser, parser_callback);

    while(1) {
        bytes = read(0, buf, 1024);
        vtparse(&parser, buf, bytes);
    }
}
Example #3
0
void BarConsoleInit()
{
    unsigned threadId = 0;
    CONSOLE_SCREEN_BUFFER_INFO csbi;
    memset(&g_BarConsole, 0, sizeof(g_BarConsole));

    SetConsoleCP(CP_UTF8);
    SetConsoleOutputCP(CP_UTF8);

    g_BarConsole.StdIn  = GetStdHandle(STD_INPUT_HANDLE);
    g_BarConsole.StdOut = GetStdHandle(STD_OUTPUT_HANDLE);

    GetConsoleScreenBufferInfo(g_BarConsole.StdOut, &csbi);

    g_BarConsole.DefaultAttributes = csbi.wAttributes;
    g_BarConsole.CurrentAttributes = csbi.wAttributes;

    vtparse_init(&g_BarConsole.Parser, BarParseCallback);
}
Example #4
0
void vtesc_init(struct vtesc_executor *executor) {
	assert(vtparse_init(&executor->parser, NULL) != NULL);
	executor->parser.cb = vtparse_callback;
	executor->parser.user_data = executor;
}