Skip to content

Commit

Permalink
Commit to C99 or above for smart terminal features
Browse files Browse the repository at this point in the history
With Rebol taking more responsibility for the implementation of the
cursoring and per-key terminal functionality of the Windows console,
an increasing amount of libRebol code is used to implement the smart
console.  libRebol is much more readable and manageable when it can
use the REBOL_IMPLICIT_END functionality.  But that depends on variadic
macros, which requires C99 or higher.

This commits to the idea that if you want rich console features (like
history and tab completion) that the code implementing it is only
available in C99 builds or higher.  This embraces a general philosophy
that while C89 builds are still going to be kept working on Travis
for the core, advanced features (ODBC, ZeroMQ, smart console) will
use the more streamlined form of libRebol.
  • Loading branch information
hostilefork committed Mar 10, 2020
1 parent 1006275 commit f90611e
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 173 deletions.
11 changes: 9 additions & 2 deletions extensions/stdio/p-stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ EXTERN_C REBDEV Dev_StdIO;

#include "readline.h"

extern STD_TERM *Term_IO;
STD_TERM *Term_IO = nullptr;
#if defined(REBOL_SMART_CONSOLE)
extern STD_TERM *Term_IO;
STD_TERM *Term_IO = nullptr;
#endif

// The history mechanism is deliberately separated out from the line-editing
// mechanics. The I/O layer is only supposed to emit keystrokes and let the
Expand All @@ -46,6 +48,7 @@ int Line_History_Index; // Current position in the line history
#define Line_Count \
rebUnboxInteger("length of", Line_History, rebEND)

#if defined(REBOL_SMART_CONSOLE)

extern REBVAL *Read_Line(STD_TERM *t);

Expand Down Expand Up @@ -263,6 +266,8 @@ REBVAL *Read_Line(STD_TERM *t)
return line;
}

#endif // if defined(REBOL_SMART_CONSOLE)


//
// Console_Actor: C
Expand Down Expand Up @@ -310,6 +315,7 @@ REB_R Console_Actor(REBFRM *frame_, REBVAL *port, const REBVAL *verb)
if (Req(req)->modes & RDM_NULL)
return rebValue("copy #{}", rebEND);

#if defined(REBOL_SMART_CONSOLE)
if (Term_IO) {
REBVAL *result = Read_Line(Term_IO);
if (rebDid("void?", rebQ1(result), rebEND)) { // HALT received
Expand All @@ -326,6 +332,7 @@ REB_R Console_Actor(REBFRM *frame_, REBVAL *port, const REBVAL *verb)
assert(rebDid("text?", result, rebEND));
return rebValue("as binary!", rebR(result), rebEND);
}
#endif

// !!! A fixed size buffer is used to gather console input. This is
// re-used between READ requests.
Expand Down
Loading

0 comments on commit f90611e

Please sign in to comment.