frontend: add a line editor for shell input
This commit is contained in:
27
frontend/line-ed/prompt.c
Normal file
27
frontend/line-ed/prompt.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <stdio.h>
|
||||
#include "line-ed.h"
|
||||
#include "prompt.h"
|
||||
|
||||
void show_prompt(struct line_ed *ed)
|
||||
{
|
||||
int type = PROMPT_MAIN;
|
||||
if (ed->l_scope_type) {
|
||||
type = PROMPT_CONT;
|
||||
|
||||
/* this is a temporary solution to show the current
|
||||
* scope type, until prompts are implemented properly. */
|
||||
fputs(ed->l_scope_type, stdout);
|
||||
}
|
||||
|
||||
if (ed->l_continuations > 0) {
|
||||
type = PROMPT_CONT;
|
||||
}
|
||||
|
||||
fputs(ed->l_prompt[type], stdout);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
unsigned long prompt_length(struct line_ed *ed, int prompt_id)
|
||||
{
|
||||
return strlen(ed->l_prompt[prompt_id]);
|
||||
}
|
||||
Reference in New Issue
Block a user