static void process_line(t_tokenline *tl) { t_token *tokens; int words[TL_MAX_WORDS], num_words, i; tl->print(tl->user, NL); do { if (!tl->buf_len) break; history_add(tl); if (!split_line(tl, words, &num_words, FALSE)) break; if (!num_words) break; if (!strcmp(tl->buf + words[0], "help")) { if (num_words == 1) { /* * Nothing to tokenize: find the help entry * if any so its help text can be shown. */ tokens = tl->token_levels[tl->token_level]; for (i = 0; tokens[i].token; i++) { if (tokens[i].arg_type == T_ARG_HELP) { tl->parsed.last_token_entry = &tokens[i]; break; } } } else { /* Tokenize with errors turned off. */ tokenize(tl, words + 1, num_words - 1, &tokens, NULL); } show_help(tl, words, num_words); } else if (!strcmp(tl->buf + words[0], "history")) { history_show(tl); } else { if (!tokenize(tl, words, num_words, NULL, NULL)) break; if (tl->callback) tl->callback(tl->user, &tl->parsed); } } while (FALSE); tl->buf[0] = 0; tl->buf_len = 0; tl->escape_len = 0; tl->pos = 0; tl->hist_step = -1; tl->print(tl->user, tl->prompt); }
static void do_show_hist (WInput * in) { size_t len; char *r; len = get_history_length (in->history); r = history_show (&in->history, &in->widget); if (r != NULL) { input_assign_text (in, r); g_free (r); } /* Has history cleaned up or not? */ if (len != get_history_length (in->history)) in->history_changed = TRUE; }
static void do_show_hist (WInput * in) { size_t len; char *r; len = get_history_length (in->history.list); r = history_show (&in->history.list, WIDGET (in), g_list_position (in->history.list, in->history.list)); if (r != NULL) { input_assign_text (in, r); g_free (r); } /* Has history cleaned up or not? */ if (len != get_history_length (in->history.list)) in->history.changed = TRUE; }
void history_navigation(t_window *w, t_music *m, t_list *l, t_text *t, t_font *f, t_image *img) { int next; SDL_Event event; t_elem_text *e_text; next = 1; e_text = t->tail; if (e_text->prev != NULL) e_text = e_text->prev; first_left_show(w, t, f, l); while (next) { SDL_WaitEvent(&event); switch(event.type) { case SDL_QUIT: clean_exit(w, m, l, t); break; case SDL_MOUSEBUTTONUP: if (event.button.button == SDL_BUTTON_LEFT) pars_scene(w, m, l, t, f); break; case SDL_KEYDOWN: switch (event.key.keysym.sym) { case SDLK_RETURN: next = 0; events2(w, m, l, t, f, img); break; case SDLK_SPACE: next = 0; events2(w, m, l, t, f, img); break; case SDLK_LEFT: if (e_text->prev != NULL) { e_text = e_text->prev; history_show(w, t, f, e_text, l); } break; case SDLK_RIGHT: if (e_text->next != NULL && e_text->next->next != NULL) { e_text = e_text->next; history_show(w, t, f, e_text, l); } break; case SDLK_m: music_pause(m); break; case SDLK_ESCAPE: clean_exit(w, m, l, t); break; default: break; } break; default: break; } } }