johnnovak / illwill

A curses inspired simple cross-platform console library for Nim
Do What The F*ck You Want To Public License
398 stars 27 forks source link

[WIP] Adding Javascript support #12

Closed JohnAD closed 4 years ago

JohnAD commented 4 years ago

This is currently a work-in-progress. Please do not accept the PR yet.

This is an attempt to add javascript support to the illwill library.

So, both

nim c readmeexample.nim

and

nim js readmeexample.nim

work. The second version creates a javascript file that can be pulled into a web page and started with something like:

<body onload="illwillOnLoad('terminal', 80, 24);">
    <p>
      <pre id="terminal" width="80" style="border: 1px solid black">
        initializing...
      </pre>
    </p>
  </body>

Many basic functions are done. Some notes:

JohnAD commented 4 years ago

Image of boxdrawing.nim on a web page:

Untitled

JohnAD commented 4 years ago

Also: I've not yet written a cursor-emulator for the PRE block.

Essentially, when generating JS, a timed event-handler will "blink" a solid block in the correct place whenever the cursor is turned on.

I'm also thinking the JS terminal should mimic a typical terminal by defaulting to a black background with white lettering.

JohnAD commented 4 years ago

I've got a little more refactoring to do, but the basics of color support are working. I've changed the box color in readmeexample.nim to blue to make it visible against the black default background.

image

JohnAD commented 4 years ago

Having looked more closely at the code and re-thought more about it, I suspect I might start over with another PR. I think I can redo this with with a tighter coupling to the existing TerminalBuffer.