WallShell
An easy-to-use, highly portable, CLI using C99.
|
You should only consider doing this if you are on a non-standard system that isn't Windows or Unix based.
There are several things that need to be defined:
terminos
, don't go back to a default state when a program exits.ws_setConsoleLocale()
, so if you don't call this, you can leave the define blank.#define SET_TERMINAL_LOCALE
is enough.There are two macros that need to be defined:
WallShell expects to be able to "poll" for keyboard events, rather than waiting for getc()
. Normal getc()
prevents the thread (or application) from being closed when asked.
The function that this expands to is expected to return an int (like getc()
does) if available or -2
otherwise.
The -2 comes from the fact that
EOF
is defined as -1, andgetc()
can returnEOF
in certain circumstances.
stream
does not have to be used. It's provided simply for if you need to use something similar to fgetc(stream)
.In contrast to the other one, this one is expected to be a blocking function. When prompting users, or getting virtual terminal sequences, blocking functions are much nicer to work with. Same as above, stream
does not have to be used.
You can potentially define this to use
getc()
, but it's currently defined to usegetchar()
on unix and_getch()
on windows.
Sometimes, especially on unix systems, you have to flush stdout (or whatever stream your using), before fprintf (or normal printf) will actually write to the buffer. If your system requires the stream to be flushed, simply define this.