mirror of
https://github.com/louisrubet/rpn
synced 2025-01-04 11:01:35 +01:00
Manage cmdline
This commit is contained in:
parent
d0947b73a0
commit
e7d0f60aa1
2 changed files with 13 additions and 9 deletions
8
TODO
8
TODO
|
@ -4,14 +4,14 @@
|
||||||
general:
|
general:
|
||||||
|
|
||||||
entry:
|
entry:
|
||||||
- parse en entier la ligne de commande puis si pas de pb de syntaxe entrer
|
- gestion des flèches haut/bas
|
||||||
- entrée sur plusieurs lignes
|
- autocompletion avec tab
|
||||||
|
- alt-R + recherche
|
||||||
|
- entrée interactive sur plusieurs lignes
|
||||||
- entrée d'une variable sans '' = rcl
|
- entrée d'une variable sans '' = rcl
|
||||||
- rpn <"commande entière">
|
|
||||||
- entrée de commande shell avec $commande shell, résultat dans une chaîne (?)
|
- entrée de commande shell avec $commande shell, résultat dans une chaîne (?)
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
print
|
print
|
||||||
alias
|
alias
|
||||||
alt-R + recherche ?
|
|
||||||
date / time
|
date / time
|
||||||
|
|
14
src/rpn.cpp
14
src/rpn.cpp
|
@ -39,7 +39,7 @@ using namespace std;
|
||||||
#include "stack.h"
|
#include "stack.h"
|
||||||
|
|
||||||
static const char CURSOR[] = "> ";
|
static const char CURSOR[] = "> ";
|
||||||
static const char SHOW_STACK_SEPARATOR[] = ":\t";
|
static const string g_show_stack_separator = ":\t";
|
||||||
static int g_verbose = 0;
|
static int g_verbose = 0;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -608,7 +608,7 @@ public:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void show_stack(stack& st)
|
static void show_stack(stack& st, const string& separator = g_show_stack_separator)
|
||||||
{
|
{
|
||||||
if (st.size() == 1)
|
if (st.size() == 1)
|
||||||
{
|
{
|
||||||
|
@ -617,9 +617,11 @@ public:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
bool show_sep = (! separator.empty());
|
||||||
for (int i = st.size()-1; i>=0; i--)
|
for (int i = st.size()-1; i>=0; i--)
|
||||||
{
|
{
|
||||||
cout<<i+1<<SHOW_STACK_SEPARATOR;
|
if (show_sep)
|
||||||
|
cout<<i+1<<separator;
|
||||||
((object*)st[i])->show();
|
((object*)st[i])->show();
|
||||||
cout<<endl;
|
cout<<endl;
|
||||||
}
|
}
|
||||||
|
@ -729,7 +731,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||||
string entry;
|
string entry;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// entry
|
// make one string from entry
|
||||||
for (i=1; i<argc; i++)
|
for (i=1; i<argc; i++)
|
||||||
{
|
{
|
||||||
entry += argv[i];
|
entry += argv[i];
|
||||||
|
@ -740,9 +742,11 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||||
ret = program::parse(entry, prog);
|
ret = program::parse(entry, prog);
|
||||||
if (ret == ret_ok)
|
if (ret == ret_ok)
|
||||||
{
|
{
|
||||||
|
string separator = "";
|
||||||
|
|
||||||
// run it
|
// run it
|
||||||
ret = prog.run(st, hp);
|
ret = prog.run(st, hp);
|
||||||
program::show_stack(st);
|
program::show_stack(st, separator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue