From ee1a18f050a5458ade460720091e20ce6b335011 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 18 May 2017 09:44:37 -0700 Subject: 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. --- edit/009-sandbox-test.mu | 2 -- 1 file changed, 2 deletions(-) (limited to 'edit/009-sandbox-test.mu') diff --git a/edit/009-sandbox-test.mu b/edit/009-sandbox-test.mu index 023015ed..badd795b 100644 --- a/edit/009-sandbox-test.mu +++ b/edit/009-sandbox-test.mu @@ -130,10 +130,8 @@ after [ # toggle its expected-response, and save session sandbox <- toggle-expected-response sandbox save-sandboxes env, resources - hide-screen screen screen <- render-sandbox-side screen, env, render screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env - show-screen screen loop +next-event } ] -- cgit 1.4.1-2-gfad0