Commit Graph

32 Commits

Author SHA1 Message Date
Kartik K. Agaram
e5e3640cfb 4119
Running example programs after a long time.
2017-11-10 00:47:45 -08:00
Kartik K. Agaram
1441e507b6 3917
Redo commit 3905 to always shutdown cleanly on any error raised.
2017-06-16 16:56:29 -07:00
Kartik K. Agaram
909adb27f9 3905
Standardize exit paths. Most layers now don't need to know about termbox.

We can't really use `assert` in console-mode apps; it can't just exit because
we want to be able to check assertion failures in tests.
2017-06-10 15:41:42 -07:00
Kartik K. Agaram
5e7f0caab5 3878 2017-05-26 19:49:43 -07:00
Kartik K. Agaram
2b25071710 3877 2017-05-26 17:36:16 -07:00
Kartik K. Agaram
852d9b4393 3864
Being able to `cout` directly in raw mode isn't going to be more than a
neat gimmick; we need to maintain control over colors. (The sandbox/ app
was getting messed up because it just so happened that the next thing being
printed to screen after the `Run` button was clear-display-from, which
used `cout` with the same colors as the button.)
2017-05-19 00:56:51 -07:00
Kartik K. Agaram
537ad74ccc 3862
As the finishing touch on commit 3860, completely decouple the termbox
API between moving the cursor and printing at the cursor.
2017-05-19 00:09:18 -07:00
Kartik K. Agaram
ee1a18f050 3860 - stop buffering the screen in termbox
To achieve this we have to switch to a model of the screen in termbox that
is closer to the underlying terminal.

Before:
  a screen is a grid of characters
  writing out of bounds does nothing

After:
  a screen is a scrolling raster of characters
  writing out of bounds wraps to next line and scrolls if necessary

To move to the new model, it was essential that I migrate my fake screen
at the same time to mimic it. This is why the first attempt (commit 3824)
failed (commit 3858). This is also why this commit can't be split into
smaller pieces.

The fake screen now 'scrolls' by rotating screen lines from top to bottom.
There's still no notion of a scrollback buffer.

The newer model is richer; it permits repl-like apps that upstream termbox
can't do easily. It also permits us to simply use `printf` or `cout` to
write to the screen, and everything mostly works as you would expect. Exceptions:

  a) '\n' won't do what you expect. You need to explicitly print both '\n'
  and '\r'.

  b) backspace won't do what you expect. It only moves the cursor back,
  without erasing the previous character. It does not wrap.

  Both behaviors exactly mimic my existing terminal's emulation of vt100.

The catch: it's easy to accidentally scroll in apps. Out-of-bounds prints
didn't matter before, but they're bugs now. To help track them down, use
the `save-top-idx`, `assert-no-scroll` pair of helpers.

  An important trick is to wrap the cursor before rather after printing
  a character. Otherwise we end up scrolling every time we print to the
  bottom-right character. This means that the cursor position can be invalid
  at the start of a print, and we need to handle that.

In the process we also lose the ability to hide and show the screen. We
have to show the prints happening. Seems apt for a "white-box" platform
like Mu.
2017-05-18 09:57:57 -07:00
Kartik K. Agaram
27ec57de4c 3858
Lose the ability to hide the cursor. If we want to stop buffering the screen
in termbox, it needs to go.

What's more, it has no tests.
2017-05-13 20:48:16 -07:00
Kartik K. Agaram
6f4ce86543 3857 2017-05-13 18:39:41 -07:00
Kartik K. Agaram
0c0d1ea5cd 3854
Revert commits 3824, 3850 and 3852. We'll redo them more carefully.
2017-05-13 12:42:17 -07:00
Kartik K. Agaram
45bcfcfe10 3849 2017-05-10 16:13:25 -07:00
Kartik K. Agaram
769a68cf1d 3842
Always start with an untouched screen that can scroll on printing "\r\n".
We can still clear the screen as needed.

Also drop support for hiding the cursor.
2017-05-04 23:20:37 -07:00
Kartik K. Agaram
ace7ffb714 3824 - experiment: stop buffering in termbox
Now it's much more apparent why things are slow. You can see each repaint
happening. Already I fixed one performance bug -- in clear-rest-of-screen.

Since this subverts Mu's fake screen there may be bugs.

Another salubrious side effect: I've finally internalized that switching
to raw mode doesn't have to clear the screen. That was just an artifact
of how termbox abstracted operations. Now I can conceive of using termbox
to build a repl as well.

(I was inspired to poke into termbox internals by
http://viewsourcecode.org/snaptoken/kilo and
https://github.com/antirez/linenoise)
2017-04-16 15:05:31 -07:00
Kartik K. Agaram
5a26c015a4 3597 - typo in screen checking
Thanks Ella Couch for reporting this.
2016-10-27 09:06:17 -07:00
Kartik K. Agaram
9a81d7460f 3561 2016-10-22 16:56:07 -07:00
Kartik K. Agaram
6c96a437ce 3522 2016-10-19 22:10:35 -07:00
Kartik K. Agaram
f9d069b53c 3306 - better error messages when mixing up screen/console
Thanks Ella Couch for finding this.
2016-09-08 12:12:06 -07:00
Kartik K. Agaram
c7a836797a 3271
Disallow defining multiple globals at once.
2016-08-28 17:06:49 -07:00
Kartik K. Agaram
7fd010710c 3259
Prefer preincrement operators wherever possible. Old versions of
compilers used to be better at optimizing them. Even if we don't care
about performance it's useful to make unary operators look like unary
operators wherever possible, and to distinguish the 'statement form'
which doesn't care about the value of the expression from the
postincrement which usually increments as a side-effect in some larger
computation (and so is worth avoiding except for some common idioms, or
perhaps even there).
2016-08-26 13:40:19 -07:00
Kartik K. Agaram
15fdc5d9b8 3164
Have $print in console mode rotate through the screen rather than simply
block at the bottom.
2016-08-09 20:09:58 -07:00
Kartik K. Agaram
cf3ac87f17 3163
Experimental: kinda support $print in console mode.

It's not perfect and probably will never be, because 'cout' buffers
differently from termbox primitives, which can cause console-aware
newlines to show up before other (console-oblivious) prints, like in
this example program:

  def main [
    open-console
    $print [abc], 10/newline
    $print [def], 10/newline
    wait-for-some-interaction
    close-console
  ]

And then there's the problem that there's no way for cout to update
Display_column. So mixing $print and print will be confusing.

Perhaps we should just not mess with Display_* variables inside $print?
But then we'll only ever be able to see a single line of $print at a
time.
2016-08-09 16:48:49 -07:00
Kartik K. Agaram
a97df2ad5d 3162 2016-08-09 16:33:30 -07:00
Kartik K. Agaram
8d72e56521 3120
Always show instruction before any transforms in error messages.

This is likely going to make some errors unclear because they *need* to
show the original instruction. But if we don't have tests for those
situations did they ever really work?
2016-07-21 19:22:03 -07:00
Kartik K. Agaram
9dcbec398c 2990
Standardize quotes around reagents in error messages.

I'm still sure there's issues. For example, the messages when
type-checking 'copy'. I'm not putting quotes around them because in
layer 60 I end up creating dilated reagents, and then it's a bit much to
have quotes and (two kinds of) brackets. But I'm sure I'm doing that
somewhere..
2016-05-20 22:11:34 -07:00
Kartik K. Agaram
acc4792d2f 2803
Show more thorough information about instructions in the trace, but keep
the original form in error messages.
2016-03-21 02:25:52 -07:00
Kartik K. Agaram
b24eb4766a 2773 - switch to 'int'
This should eradicate the issue of 2771.
2016-03-13 20:26:47 -07:00
Kartik K. Agaram
1b76245c63 2712 2016-02-26 13:04:55 -08:00
Kartik K. Agaram
9f95c7451b 2685
Stack of plans for cleaning up replace_type_ingredients() and a couple
of other things, from main problem to subproblems:

  include type names in the type_tree rather than in the separate properties vector
  make type_tree and string_tree real cons cells, with separate leaf nodes
  redo the vocabulary for dumping various objects:
    do we really need to_string and debug_string?
    can we have a version with *all* information?
    can we have to_string not call debug_string?

This commit nibbles at the edges of the final task, switching from
member method syntax to global function like almost everything else. I'm
mostly using methods just for STL in this project.
2016-02-19 13:42:45 -08:00
Kartik K. Agaram
5a49cfeccb 2553 - keep failed specializations from generating spurious errors
Thanks Caleb Couch.
2015-12-28 13:02:06 -08:00
Kartik K. Agaram
601ff75bc7 three bugs fixed
- notes
bug in edit/ triggers in immutable but not master branch
bug triggered by changes to layer 059: we're finding an unspecialized call to 'length' in 'append_6'

hard to debug because trace isn't complete
just bring out the big hammer: use a new log file

length_2 from recipes.mu is not being deleted (bug #1)
so reload doesn't switch length to length_2 when variant_already_exists (bug #2)
so we end up saving in Recipe for a primitive ordinal
so no valid specialization is found for 'length' (bug #3)

why doesn't it trigger in a non-interactive scenario?
argh, wasn't checking for an empty line at end. ok, confidence restored.
2015-12-15 10:20:41 -08:00
Kartik K. Agaram
c603cd6cef 2430 - make room for more transforms 2015-11-13 10:08:57 -08:00