Permalink
Browse files

3854

Revert commits 3824, 3850 and 3852. We'll redo them more carefully.
  • Loading branch information...
akkartik committed May 13, 2017
1 parent 8195ed4 commit 0c0d1ea5cdb96a98e7eb62edbd1acb534ae12940
View
@@ -7,6 +7,7 @@
:(before "End Globals")
int Display_row = 0;
int Display_column = 0;
bool Autodisplay = true;
:(before "End Includes")
#define CHECK_SCREEN \
@@ -37,7 +38,6 @@ case OPEN_CONSOLE: {
:(before "End Primitive Recipe Implementations")
case OPEN_CONSOLE: {
tb_init();
tb_clear();
Display_row = Display_column = 0;
int width = tb_width();
int height = tb_height();
@@ -83,6 +83,21 @@ case CLEAR_DISPLAY: {
break;
}
:(before "End Primitive Recipe Declarations")
SYNC_DISPLAY,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "sync-display", SYNC_DISPLAY);
:(before "End Primitive Recipe Checks")
case SYNC_DISPLAY: {
break;
}
:(before "End Primitive Recipe Implementations")
case SYNC_DISPLAY: {
CHECK_SCREEN;
tb_sync();
break;
}
:(before "End Primitive Recipe Declarations")
PRINT_CHARACTER_TO_DISPLAY,
:(before "End Primitive Recipe Numbers")
@@ -118,7 +133,7 @@ case PRINT_CHARACTER_TO_DISPLAY: {
int height = (h >= 0) ? h : 0;
int width = (w >= 0) ? w : 0;
int c = ingredients.at(0).at(0);
int color = TB_WHITE;
int color = TB_BLACK;
if (SIZE(ingredients) > 1) {
color = ingredients.at(1).at(0);
}
@@ -133,6 +148,7 @@ case PRINT_CHARACTER_TO_DISPLAY: {
Display_column = 0;
++Display_row;
tb_set_cursor(Display_column, Display_row);
if (Autodisplay) tb_present();
}
break;
}
@@ -141,13 +157,15 @@ case PRINT_CHARACTER_TO_DISPLAY: {
tb_change_cell(Display_column-1, Display_row, ' ', color, bg_color);
--Display_column;
tb_set_cursor(Display_column, Display_row);
if (Autodisplay) tb_present();
}
break;
}
if (Display_column < width-1) {
++Display_column;
tb_set_cursor(Display_column, Display_row);
}
if (Autodisplay) tb_present();
break;
}
@@ -194,6 +212,7 @@ case MOVE_CURSOR_ON_DISPLAY: {
Display_row = ingredients.at(0).at(0);
Display_column = ingredients.at(1).at(0);
tb_set_cursor(Display_column, Display_row);
if (Autodisplay) tb_present();
break;
}
@@ -213,6 +232,7 @@ case MOVE_CURSOR_DOWN_ON_DISPLAY: {
if (Display_row < height-1) {
++Display_row;
tb_set_cursor(Display_column, Display_row);
if (Autodisplay) tb_present();
}
break;
}
@@ -231,6 +251,7 @@ case MOVE_CURSOR_UP_ON_DISPLAY: {
if (Display_row > 0) {
--Display_row;
tb_set_cursor(Display_column, Display_row);
if (Autodisplay) tb_present();
}
break;
}
@@ -251,6 +272,7 @@ case MOVE_CURSOR_RIGHT_ON_DISPLAY: {
if (Display_column < width-1) {
++Display_column;
tb_set_cursor(Display_column, Display_row);
if (Autodisplay) tb_present();
}
break;
}
@@ -269,6 +291,7 @@ case MOVE_CURSOR_LEFT_ON_DISPLAY: {
if (Display_column > 0) {
--Display_column;
tb_set_cursor(Display_column, Display_row);
if (Autodisplay) tb_present();
}
break;
}
@@ -284,6 +307,7 @@ void move_cursor_to_start_of_next_line_on_display() {
else Display_row = 0;
Display_column = 0;
tb_set_cursor(Display_column, Display_row);
if (Autodisplay) tb_present();
}
:(before "End Primitive Recipe Declarations")
@@ -318,6 +342,67 @@ 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;
}
:(before "End Primitive Recipe Declarations")
HIDE_DISPLAY,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "hide-display", HIDE_DISPLAY);
:(before "End Primitive Recipe Checks")
case HIDE_DISPLAY: {
break;
}
:(before "End Primitive Recipe Implementations")
case HIDE_DISPLAY: {
CHECK_SCREEN;
Autodisplay = false;
break;
}
:(before "End Primitive Recipe Declarations")
SHOW_DISPLAY,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "show-display", SHOW_DISPLAY);
:(before "End Primitive Recipe Checks")
case SHOW_DISPLAY: {
break;
}
:(before "End Primitive Recipe Implementations")
case SHOW_DISPLAY: {
CHECK_SCREEN;
Autodisplay = true;
tb_present();
break;
}
//:: Keyboard/mouse management
:(before "End Primitive Recipe Declarations")
@@ -441,6 +526,7 @@ case CLEAR_LINE_ON_DISPLAY: {
tb_change_cell(x, Display_row, ' ', TB_WHITE, TB_BLACK);
}
tb_set_cursor(Display_column, Display_row);
if (Autodisplay) tb_present();
break;
}
@@ -466,5 +552,6 @@ case CLEAR_DISPLAY_FROM: {
tb_change_cell(column, row, ' ', TB_WHITE, TB_BLACK);
}
}
if (Autodisplay) tb_present();
break;
}
View
@@ -50,6 +50,13 @@ def clear-screen screen:&:screen -> screen:&:screen [
*screen <- put *screen, cursor-column:offset, 0
]
def sync-screen screen:&:screen -> screen:&:screen [
local-scope
load-ingredients
return-if screen # do nothing for fake screens
sync-display
]
def fake-screen-is-empty? screen:&:screen -> result:bool [
local-scope
load-ingredients
@@ -101,27 +108,15 @@ def print screen:&:screen, c:char -> screen:&:screen [
row:num <- get *screen, cursor-row:offset
row <- round row
legal?:bool <- greater-or-equal row, 0
{
break-if legal?
row <- copy 0
}
return-unless legal?
legal? <- lesser-than row, height
{
break-if legal?
row <- subtract height, 1
}
return-unless legal?
column:num <- get *screen, cursor-column:offset
column <- round column
legal? <- greater-or-equal column, 0
{
break-if legal?
column <- copy 0
}
return-unless legal?
legal? <- lesser-than column, width
{
break-if legal?
column <- subtract width, 1
}
return-unless legal?
#? $print [print-character (], row, [, ], column, [): ], c, 10/newline
# special-case: newline
{
@@ -609,6 +604,38 @@ 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 hide-screen screen:&:screen -> screen:&:screen [
local-scope
load-ingredients
return-if screen # fake screen; do nothing
# real screen
hide-display
]
def show-screen screen:&:screen -> screen:&:screen [
local-scope
load-ingredients
return-if screen # fake screen; do nothing
# real screen
show-display
]
def print screen:&:screen, s:text -> screen:&:screen [
local-scope
load-ingredients
View
@@ -276,6 +276,7 @@ bool start_search_editor(search_direction dir) {
tb_change_cell(col, bottom_screen_line, '/', TB_WHITE, TB_BLACK);
++col;
tb_set_cursor(col, bottom_screen_line);
tb_present();
string pattern;
while (true) {
int key = read_key();
@@ -293,21 +294,25 @@ bool start_search_editor(search_direction dir) {
if (col > /*slash*/1) {
--col;
tb_set_cursor(col, bottom_screen_line);
tb_present();
}
}
else if (key == TB_KEY_ARROW_RIGHT) {
if (col-/*slash*/1 < SIZE(pattern)) {
++col;
tb_set_cursor(col, bottom_screen_line);
tb_present();
}
}
else if (key == TB_KEY_HOME || key == TB_KEY_CTRL_A) {
col = /*skip slash*/1;
tb_set_cursor(col, bottom_screen_line);
tb_present();
}
else if (key == TB_KEY_END || key == TB_KEY_CTRL_E) {
col = SIZE(pattern)+/*skip slash*/1;
tb_set_cursor(col, bottom_screen_line);
tb_present();
}
else if (key == TB_KEY_BACKSPACE || key == TB_KEY_BACKSPACE2) {
if (col > /*slash*/1) {
@@ -325,6 +330,7 @@ bool start_search_editor(search_direction dir) {
tb_change_cell(SIZE(pattern)+/*skip slash*/1, bottom_screen_line, ' ', TB_WHITE, TB_BLACK);
}
tb_set_cursor(col, bottom_screen_line);
tb_present();
}
}
else if (key == TB_KEY_CTRL_K) {
@@ -333,6 +339,7 @@ bool start_search_editor(search_direction dir) {
for (int x = col; x < old_pattern_size+/*slash*/1; ++x)
tb_change_cell(x, bottom_screen_line, ' ', TB_WHITE, TB_BLACK);
tb_set_cursor(col, bottom_screen_line);
tb_present();
}
else if (key == TB_KEY_CTRL_U) {
int old_pattern_size = SIZE(pattern);
@@ -342,6 +349,7 @@ bool start_search_editor(search_direction dir) {
for (int x = SIZE(pattern)+/*slash*/1; x < old_pattern_size+/*skip slash*/1; ++x)
tb_change_cell(x, bottom_screen_line, ' ', TB_WHITE, TB_BLACK);
tb_set_cursor(/*start of pattern skipping slash*/1, bottom_screen_line);
tb_present();
}
else if (key < 128) { // ascii only
// update pattern
@@ -352,6 +360,7 @@ bool start_search_editor(search_direction dir) {
tb_change_cell(x, bottom_screen_line, pattern.at(x-/*slash*/1), TB_WHITE, TB_BLACK);
++col;
tb_set_cursor(col, bottom_screen_line);
tb_present();
}
}
}
@@ -435,6 +444,7 @@ void render() {
render_line(screen_row, "~", /*cursor_line?*/false);
// move cursor back to display row at the end
tb_set_cursor(0, Display_row);
tb_present();
}
int lines_hidden(int screen_row) {
View
@@ -1,12 +1,14 @@
0. main's ingredients
1. assertion failures or errors inside scenarios
2. screen background color
3. more touch event types
4. sandbox isolation
5. errors in reading/writing files (missing directory, others?)
6. has-more-events?
3. has-more-events?
4. hide/show screen
5. more touch event types
6. sandbox isolation
7. errors in reading/writing files (missing directory, others?)
termbox issues are implementation-specific and not worth testing:
whether we clear junk from other processes
latency in interpreting low-level escape characters
calls to update-cursor are currently duplicated:
View
@@ -6,8 +6,10 @@ def main text:text [
local-scope
load-ingredients
open-console
hide-screen 0/screen
e:&:editor <- new-editor text, 0/left, 5/right
render 0/screen, e
show-screen 0/screen
wait-for-event 0/console
close-console
]
Oops, something went wrong.

0 comments on commit 0c0d1ea

Please sign in to comment.