1981 - clear screen below editors in C

Environment much more responsive now. And it doesn't slow down as much
just because I'm on a larger screen.
This commit is contained in:
Kartik K. Agaram 2015-08-12 13:49:51 -07:00
parent 66b14a0322
commit fec4d874ae
2 changed files with 48 additions and 7 deletions

View File

@ -369,3 +369,26 @@ case INTERACTIONS_LEFT: {
products.at(0).push_back(tb_event_ready());
break;
}
//: a hack to make edit.mu more responsive
:(before "End Primitive Recipe Declarations")
CLEAR_DISPLAY_FROM,
:(before "End Primitive Recipe Numbers")
Recipe_ordinal["clear-display-from"] = CLEAR_DISPLAY_FROM;
:(before "End Primitive Recipe Implementations")
case CLEAR_DISPLAY_FROM: {
// todo: error checking
int row = ingredients.at(0).at(0);
int column = ingredients.at(1).at(0);
int left = ingredients.at(2).at(0);
int right = ingredients.at(3).at(0);
int height=tb_height();
for (; row < height; ++row, column=left) { // start column from left in every inner loop except first
for (; column <= right; ++column) {
tb_change_cell(column, row, ' ', TB_WHITE, TB_BLACK);
}
}
if (Autodisplay) tb_present();
break;
}

32
edit.mu
View File

@ -244,8 +244,7 @@ recipe render [
*before-cursor <- copy prev
}
# clear rest of screen
clear-line-delimited screen, column, right
clear-rest-of-screen screen, row, left, right
clear-screen-from screen, row, column, left, right
reply row, screen/same-as-ingredient:0
]
@ -322,9 +321,8 @@ recipe render-string [
recipe clear-line-delimited [
local-scope
screen:address <- next-ingredient
left:number <- next-ingredient
column:number <- next-ingredient
right:number <- next-ingredient
column:number <- copy left
{
done?:boolean <- greater-than column, right
break-if done?
@ -334,6 +332,26 @@ recipe clear-line-delimited [
}
]
recipe clear-screen-from [
local-scope
screen:address <- next-ingredient
row:number <- next-ingredient
column:number <- next-ingredient
left:number <- next-ingredient
right:number <- next-ingredient
# if it's the real screen, use the optimized primitive
{
break-if screen
clear-display-from row, column, left, right
reply screen/same-as-ingredient:0
}
# if not, go the slower route
move-cursor screen, row, column
clear-line-delimited screen, column, right
clear-rest-of-screen screen, row, left, right
reply screen/same-as-ingredient:0
]
recipe clear-rest-of-screen [
local-scope
screen:address <- next-ingredient
@ -598,8 +616,7 @@ recipe editor-event-loop [
left:number <- get *editor, left:offset
right:number <- get *editor, right:offset
row <- add row, 1
move-cursor screen, row, left
clear-line-delimited screen, left, right
clear-screen-from screen, row, left, left, right
loop
}
]
@ -4201,7 +4218,8 @@ recipe render-recipes [
}
# draw dotted line after recipes
draw-horizontal screen, row, left, right, 9480/horizontal-dotted
clear-rest-of-screen screen, row, left, right
row <- add row, 1
clear-screen-from screen, row, left, left, right
reply screen/same-as-ingredient:0
]