Core - mr-martian/quest-editor GitHub Wiki

Overview

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

Tasks

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;
}

Basic APIs

Buffer APIs

Interface RBuf

at(pos: int)

Get byte/char at position.

insert(data: string|array|utf8_rope, pos: int|points=point())

Insert data into

range(begin: int, end: int): string|array|utf8_rope
private points: vector

the current location of the insertion point.

point(): int
goto(pos: int)

set the point. If point

private length: int

The number of code points in the buffer. If the buffer is a binary buffer, this is equivalent to size.

private size: int

The total size in bytes of the buffer.

SBuf

DBuf

Media APIs

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.

Interface BasicMediaPlayer

Player(string fileName, autostart=True)

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.

play()

Idempotent.

begin playing the sound file in the shell. If player is already playing, this has no effect.

pause()

Idempotent.

Pause any currently playing sound file. if player is already paused, this has no effect.

seek(float seconds)

set the play time to seconds.

position()

Get the current position being played in the file.

optional convenience functions

forward(float seconds)

readable seek(position() + seconds)

backward(float seconds)

readable seek(position() - seconds)

⚠️ **GitHub.com Fallback** ⚠️