alma 0.1.1

A Bevy-native modal text editor with Vim-style navigation.
Documentation
package alma:editor@0.2.0;

interface host {
  enum capability {
    buffer-observe,
    buffer-propose-edit,
    workspace-observe,
    workspace-artifact-write,
    status-publish,
  }

  resource buffer-handle;
  resource view-handle;
  resource workspace-observe-task;
  record text-range {
    start: u64,
    end: u64,
  }

  record buffer-insert {
    byte-index: u64,
    text: string,
  }

  record buffer-replace {
    range: text-range,
    text: string,
  }

  variant buffer-edit {
    set-all(string),
    insert(buffer-insert),
    replace(buffer-replace),
    delete(text-range),
  }

  record buffer-snapshot {
    revision: u64,
    text: string,
  }

  variant workspace-observe-outcome-shape {
    bytes(u64),
    rejected,
  }

  variant workspace-observe-task-poll {
    pending,
    completed(workspace-observe-outcome-shape),
    unknown,
  }

  variant workspace-observe-task-take {
    pending,
    bytes(list<u8>),
    rejected,
    unknown,
  }

  status-publish: func(view: borrow<view-handle>, text: string);
  buffer-observe: func(buffer: borrow<buffer-handle>) -> buffer-snapshot;
  buffer-propose-edit: func(buffer: borrow<buffer-handle>, edit: buffer-edit);
  workspace-observe-start: func(path: string) -> workspace-observe-task;
  workspace-observe-poll: func(task: borrow<workspace-observe-task>) -> workspace-observe-task-poll;
  workspace-observe-take: func(task: borrow<workspace-observe-task>) -> workspace-observe-task-take;
  workspace-artifact-write: func(path: string, bytes: list<u8>);
}

world plugin {
  import host;
  use host.{buffer-handle, view-handle};

  export load: func();
  export update: func(view: borrow<view-handle>, buffer: borrow<buffer-handle>);
}