Git Product home page Git Product logo

ic-mini-terminal's Introduction

IC Mini Terminal (ic-mt)

Minimal keyboard input (⌨) and graphical output (📺) for programs on the Internet Computer.

Example

The Motoko package icmt (in this repo, under src) provides a simple framework for building services that interact with an icmt instance.

Below, we show an interactive Counter example.

class Counter(initCount : Nat) {
  public var count = initCount;

  public func clone () : Counter {
    Counter(count)
  };

  public func draw (d: Dim) : Types.Graphics.Elm {
    let r = Render.Render();
    let atts = Style.txtAtts(d.width / 256 + 1);
    let cr = Render.CharRender(r, Mono5x5.bitmapOfChar, atts);
    let tr = Render.TextRender(cr);
    tr.textAtts("count = " # Nat.toText(count), atts);
    r.getElm()
  };

  public func update (e : EventInfo) {
    switch (e.event) {
      case (#keyDown(keys)) {
        for (k in keys.vals()) {
          switch (k.key) {
            case ("=" or "+" or "ArrowUp" or "ArrowRight") {
              count += 1;
            };
            case ("-" or "_" or "ArrowDown" or "ArrowLeft") {
              if (count > 0) { count -= 1 };
            };
            case _ { /* ignore key */ };
          }
        }
      };
      case _ { /* ignore event */ };
    }
  };
};

The full example uses this class to instantiate the terminal/Terminal.Basic class, which adapts the simple (single-event) draw-update protocol shown below to that of the "full" icmt service protocol.

Technical spec

The ic-mt tool talks to any service on the Internet Computer that uses the mini-terminal update-view service protocol, given below in Candid syntax (eliding message-type details):

service : {
  view: (Dim, vec EventInfo) -> (Graphics) query;
  update: (vec EventInfo, GraphicsRequest) -> (vec Graphics);
}

See the full Candid spec, and general docs for Candid for further details.

Building and testing

Dependencies:

The mini terminal is a Rust project.

We typically use dfx to run the Internet Computer services (e.g., within a local replica) to run applications for the terminal.

We often write these applications in Motoko.

Inspired by

ic-mini-terminal's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ic-mini-terminal's Issues

Rename/Rebrand

The word "game" in the project title is starting to seem misleading to me.

  • This project is no longer about just making games for the Internet Computer.

  • Many people may conceive of games that would never work here, given that we want to be more minimal than what they would generally want. For instance, we can avoid resolving collisions in fine-grained ways (for now) since we assume users are generally collaborative, not combative. (e.g., They are editing text documents together, not trying to dominate each other in a zero-sum game dynamic.)

  • We may want to steer the design even more toward minimality as we introduce features. For instance, we may add notions of animation, layered graphics, etc. But we will not add 3D graphics, or extensive floating point geometry, etc., because our data is generally discrete, and higher dimensional: program dev environments, test script VMs, interpreters and document editors do not benefit from such machinery the way that a 3D game would benefit directly.

So, this issue proposes a new name "IC-MT" (or ic-mt), for "Internet Computer Minimal Terminal".

The word "mini" could also be used in place of "minimal"; I think the connotation is similar enough. We want a small code footprint outside of the IC, on the local computer's side. We want that client to be "thin" or "mini" or "minimal" (all similar ideas, I think.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.