about summary refs log tree commit diff stats
path: root/080display.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-08-09 16:42:11 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-08-09 16:48:49 -0700
commitcf3ac87f17aa866d96c8f66735127809431b2cb3 (patch)
tree9bdf7784ec83e70683a6e86291869514be2a7c5a /080display.cc
parenta97df2ad5dc504fb090b54302fdc41f010d887bf (diff)
downloadmu-cf3ac87f17aa866d96c8f66735127809431b2cb3.tar.gz
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.
Diffstat (limited to '080display.cc')
-rw-r--r--080display.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/080display.cc b/080display.cc
index c05a4f99..2fcdfbf1 100644
--- a/080display.cc
+++ b/080display.cc
@@ -286,6 +286,19 @@ case MOVE_CURSOR_LEFT_ON_DISPLAY: {
   break;
 }
 
+//: as a convenience, make $print mostly work in console mode
+:(before "End $print 10/newline Special-cases")
+else if (tb_is_active()) {
+  move_cursor_to_start_of_next_line_on_display();
+}
+:(code)
+void move_cursor_to_start_of_next_line_on_display() {
+  if (Display_row < tb_height()-1) Display_row++;
+  Display_column = 0;
+  tb_set_cursor(Display_column, Display_row);
+  if (Autodisplay) tb_present();
+}
+
 :(before "End Primitive Recipe Declarations")
 DISPLAY_WIDTH,
 :(before "End Primitive Recipe Numbers")