Core - mr-martian/quest-editor GitHub Wiki
Quest Core behaves much like a virtual operating system. It does this to be competitive with the other text-editor-turned-os: Emacs.
But it should be kept in mind that simplicity is the primary concern during the inclusion of any necessary complexity. Everything must be as simple as possible, but not simpler.
Here are the ways in which Core is like an OS kernel:
- Core provides simple preemptive task scheduling
- the thread pool scheduler monitors the amount of time that a thread runs and generally limits it to 1 ms, but this will be configurable to some extent.
- Core provides a number of APIs for plugins to access hardware functionality
- playing sound
- drawing graphics
- listening to hardware events
- writing to disks (maybe eventually virtual disks)?
- obtaining memory in which to compute stuff (normally this would be done with a buffer context/buffer local variables, but some plugins might want Moar.)
- Core provides "IPC" (Inter-plugin-communication) mechanisms
In Quest, every function written in vellum and linked in some way into Core is something like an app. When the user runs a function "interactively" (using emacs terminology), Core takes the function, performs argument type checking, grabs the buffer where the function was invoked as context, and creates a Task, which is simply the notion of a function with arguments to be run. It places the task in the task queue, where it will then eventually get scheduled for handling by the thread pool.
struct Task
{
function<any> work;
SBuf* context;
vector<any> args;
}
Get byte/char at position.
Insert data into
the current location of the insertion point.
set the point. If point
The number of code points in the buffer. If the buffer is a binary buffer, this is equivalent to size.
The total size in bytes of the buffer.
for early versions of quest, it will be sufficient to simply supply a function that allows specifying a file to play, which will simply be sent to the shell, and the shell process will handle it. Eventually, for someone to be able to interact with sound and video files, some plugins may desire a richer media api.
Construct a SoundPlayer object. If autostart is True, then the file immediately begins playing upon successful construction.
It deduces correct media type (if applicable) based on file extension. this interface makes no dictations on supported file types: it is up to shells.
Idempotent.
begin playing the sound file in the shell. If player is already playing, this has no effect.
Idempotent.
Pause any currently playing sound file. if player is already paused, this has no effect.
set the play time to seconds.
Get the current position being played in the file.
readable seek(position() + seconds)
readable seek(position() - seconds)