Skip to content

Commit

Permalink
Add tl_mode_push/_pop functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
biot committed Nov 22, 2014
1 parent 06918ae commit acc8acb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tokenline.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,26 @@ void tl_set_callback(t_tokenline *tl, tl_callback callback)
tl->callback = callback;
}

int tl_mode_push(t_tokenline *tl, t_token *tokens)
{
if (tl->token_level == TL_MAX_TOKEN_LEVELS - 1)
return FALSE;

tl->token_levels[++tl->token_level] = tokens;

return TRUE;
}

int tl_mode_pop(t_tokenline *tl)
{
if (!tl->token_level)
return FALSE;

tl->token_level--;

return TRUE;
}

int tl_input(t_tokenline *tl, uint8_t c)
{
int ret, i;
Expand Down
2 changes: 2 additions & 0 deletions tokenline.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ void tl_init(t_tokenline *tl, t_token *tokens_top, t_token_dict *token_dict,
tl_printfunc printfunc, void *user);
void tl_set_prompt(t_tokenline *tl, char *prompt);
void tl_set_callback(t_tokenline *tl, tl_callback callback);
int tl_mode_push(t_tokenline *tl, t_token *tokens_mode);
int tl_mode_pop(t_tokenline *tl);
int tl_input(t_tokenline *tl, uint8_t c);

#ifndef NULL
Expand Down

0 comments on commit acc8acb

Please sign in to comment.