diff options
-rw-r--r-- | 080display.cc | 31 | ||||
-rw-r--r-- | 081print.mu | 16 | ||||
-rw-r--r-- | termbox/termbox.c | 21 | ||||
-rw-r--r-- | termbox/termbox.h | 3 | ||||
-rw-r--r-- | termbox/x.cc | 4 |
5 files changed, 8 insertions, 67 deletions
diff --git a/080display.cc b/080display.cc index 17023e61..eb9cf0a9 100644 --- a/080display.cc +++ b/080display.cc @@ -59,6 +59,7 @@ case CLOSE_CONSOLE: { } :(before "End Primitive Recipe Implementations") case CLOSE_CONSOLE: { + tb_clear(); tb_shutdown(); break; } @@ -336,36 +337,6 @@ case DISPLAY_HEIGHT: { break; } -:(before "End Primitive Recipe Declarations") -HIDE_CURSOR_ON_DISPLAY, -:(before "End Primitive Recipe Numbers") -put(Recipe_ordinal, "hide-cursor-on-display", HIDE_CURSOR_ON_DISPLAY); -:(before "End Primitive Recipe Checks") -case HIDE_CURSOR_ON_DISPLAY: { - break; -} -:(before "End Primitive Recipe Implementations") -case HIDE_CURSOR_ON_DISPLAY: { - CHECK_SCREEN; - tb_set_cursor(TB_HIDE_CURSOR, TB_HIDE_CURSOR); - break; -} - -:(before "End Primitive Recipe Declarations") -SHOW_CURSOR_ON_DISPLAY, -:(before "End Primitive Recipe Numbers") -put(Recipe_ordinal, "show-cursor-on-display", SHOW_CURSOR_ON_DISPLAY); -:(before "End Primitive Recipe Checks") -case SHOW_CURSOR_ON_DISPLAY: { - break; -} -:(before "End Primitive Recipe Implementations") -case SHOW_CURSOR_ON_DISPLAY: { - CHECK_SCREEN; - tb_set_cursor(Display_row, Display_column); - break; -} - //:: Keyboard/mouse management :(before "End Primitive Recipe Declarations") diff --git a/081print.mu b/081print.mu index f654a5ae..d795e617 100644 --- a/081print.mu +++ b/081print.mu @@ -597,22 +597,6 @@ def screen-height screen:&:screen -> height:num [ height <- display-height ] -def hide-cursor screen:&:screen -> screen:&:screen [ - local-scope - load-ingredients - return-if screen # fake screen; do nothing - # real screen - hide-cursor-on-display -] - -def show-cursor screen:&:screen -> screen:&:screen [ - local-scope - load-ingredients - return-if screen # fake screen; do nothing - # real screen - show-cursor-on-display -] - def print screen:&:screen, s:text -> screen:&:screen [ local-scope load-ingredients diff --git a/termbox/termbox.c b/termbox/termbox.c index 7fff7d7c..6a22f109 100644 --- a/termbox/termbox.c +++ b/termbox/termbox.c @@ -23,7 +23,6 @@ extern int wcwidth (wchar_t); #include "output.inl" #include "input.inl" -#define IS_CURSOR_HIDDEN(cx, cy) (cx == -1 || cy == -1) #define LAST_COORD_INIT -1 static struct termios orig_tios; @@ -39,8 +38,8 @@ static int winch_fds[2]; static int lastx = LAST_COORD_INIT; static int lasty = LAST_COORD_INIT; -static int cursor_x = -1; -static int cursor_y = -1; +static int cursor_x = 0; +static int cursor_y = 0; static uint16_t background = TB_BLACK; static uint16_t foreground = TB_WHITE; @@ -102,11 +101,10 @@ int tb_init(void) bytebuffer_init(&input_buffer, 128); bytebuffer_init(&output_buffer, 32 * 1024); - bytebuffer_puts(&output_buffer, funcs[T_ENTER_CA]); bytebuffer_puts(&output_buffer, funcs[T_ENTER_KEYPAD]); - bytebuffer_puts(&output_buffer, funcs[T_HIDE_CURSOR]); bytebuffer_puts(&output_buffer, funcs[T_ENTER_MOUSE]); bytebuffer_puts(&output_buffer, funcs[T_ENTER_BRACKETED_PASTE]); + bytebuffer_flush(&output_buffer, inout); update_term_size(); return 0; @@ -116,10 +114,7 @@ void tb_shutdown(void) { if (termw == -1) return; - bytebuffer_puts(&output_buffer, funcs[T_SHOW_CURSOR]); bytebuffer_puts(&output_buffer, funcs[T_SGR0]); - bytebuffer_puts(&output_buffer, funcs[T_CLEAR_SCREEN]); - bytebuffer_puts(&output_buffer, funcs[T_EXIT_CA]); bytebuffer_puts(&output_buffer, funcs[T_EXIT_KEYPAD]); bytebuffer_puts(&output_buffer, funcs[T_EXIT_MOUSE]); bytebuffer_puts(&output_buffer, funcs[T_EXIT_BRACKETED_PASTE]); @@ -144,14 +139,9 @@ int tb_is_active(void) void tb_set_cursor(int cx, int cy) { assert(termw != -1); - if (IS_CURSOR_HIDDEN(cursor_x, cursor_y) && !IS_CURSOR_HIDDEN(cx, cy)) - bytebuffer_puts(&output_buffer, funcs[T_SHOW_CURSOR]); - if (!IS_CURSOR_HIDDEN(cursor_x, cursor_y) && IS_CURSOR_HIDDEN(cx, cy)) - bytebuffer_puts(&output_buffer, funcs[T_HIDE_CURSOR]); cursor_x = cx; cursor_y = cy; - if (!IS_CURSOR_HIDDEN(cursor_x, cursor_y)) - write_cursor(cursor_x, cursor_y); + write_cursor(cursor_x, cursor_y); bytebuffer_flush(&output_buffer, inout); } @@ -316,8 +306,7 @@ static void send_clear(void) { send_attr(foreground, background); bytebuffer_puts(&output_buffer, funcs[T_CLEAR_SCREEN]); - if (!IS_CURSOR_HIDDEN(cursor_x, cursor_y)) - write_cursor(cursor_x, cursor_y); + write_cursor(cursor_x, cursor_y); bytebuffer_flush(&output_buffer, inout); /* we need to invalidate cursor position too and these two vars are diff --git a/termbox/termbox.h b/termbox/termbox.h index a86bc6ca..97e3f524 100644 --- a/termbox/termbox.h +++ b/termbox/termbox.h @@ -44,9 +44,6 @@ void tb_set_clear_attributes(uint16_t fg, uint16_t bg); /* Move the cursor. Upper-left character is (0, 0). */ void tb_set_cursor(int cx, int cy); -/* To hide the cursor, call tb_set_cursor(TB_HIDE_CURSOR, TB_HIDE_CURSOR). - * Cursor starts out hidden. */ -#define TB_HIDE_CURSOR -1 /* Modify a specific cell of the screen. */ void tb_change_cell(int x, int y, uint32_t ch, uint16_t fg, uint16_t bg); diff --git a/termbox/x.cc b/termbox/x.cc index 5c7fb0a6..f6b04693 100644 --- a/termbox/x.cc +++ b/termbox/x.cc @@ -3,10 +3,10 @@ int main() { tb_init(); - tb_clear(); - tb_change_cell(0, 0, 'a', TB_WHITE, TB_BLACK); tb_event x; tb_poll_event(&x); + std::cout << "a\nb\r\nc\r\n"; + tb_poll_event(&x); tb_shutdown(); return 0; } |