Have one source of input (command line)
Command is typed in and directed to whichever VIC is active (if any).
But that VIC may be busy executing commands, so command needs to
be stored in a queue to be executed later. Queues must be protected
by a mutex so they can be read/written simultaneously.
But what to do when a VIC is busy executing an SF script... does the
incoming command get executed before skipping to the next SF script
in the stack? or must we 'break' first? And if we break, are the commands
for here sucked in? That is, script is running, but we want to execute
a command. Is our first command 'break'? Will the stop a running script?
With a stepped pseudo multitasker, it's possible for one long command
to back-up the whole system. Each command could be started in a seperate
thread where supported, otherwise it's not possible to get around this.
Must somehow be able to do a non-blocking read. Under Unix it's possible
to select() on stdin, so you can go do something while waiting for a keystroke.
(This also works great with curses)
I'm fairly sure that it's not possible to select() on stdin under windows,
probably not on Amiga either. Windows has a kb_hit() function, if I could
translate all the windows keyboard scan codes into their curses counterparts
this will give a nice historied command line for windows too.
I'm toying with the idea of making the core
a daemon, and then the console telnets in. This allows a select of the
input stream, since all versions can select() on TCP/IP i/o. This may
add some security issues - like only accepting one connection and/or
only accepting connections from localhost.
Direction:
Get the input functions working under unix with a select() on stdin.
Although this wont work anywhere else, the underlying code for marshalling
the state(.py) and buffering commands will be sound (and cross-platform).
Move the input functionality into state.py, since it knows which VIC
has focus etc, and will be responsible for the buffering anyway.
IDEA: Should commands just be stuffed into new SF files and added to the stack?
(auto-generate filename, and whack in $room dir)
PROS: Gives singular input model, can stop/restart, no special-case code needed,
Don't need to worry about what state the VIC is in (run/step/idle)
CONS: have to write to disk, so maybe a bit slower