Terminal control/Preserve screen: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 181: | Line 181: | ||
print("$ESC[?1049l") |
print("$ESC[?1049l") |
||
}</lang> |
}</lang> |
||
=={{header|M2000 Interpreter}}== |
|||
M2000 Console can used for graphics also. Here is a small example how we can preserve attributes. We use Hold to save temporary console bitmap, and Release to restore old console bitmap. These statements used for animation too. |
|||
We can set the refresh rate using refresh statement, so we can make drawings before next refresh. |
|||
If we change Mode (size of font), or Window size (console witdh/height), or use a Form statement to set character resolution (number characters in a row by row number) which automatic calculate size and line spacing, then saved consoled bitmap erased. To preserve screen from this situation we have to preserve last form's arguments, or window's arguments or mode's argument. |
|||
<lang M2000 Interpreter> |
|||
Module PreserveScreen { |
|||
Bold 1 |
|||
Font "Arial" |
|||
Paper=#225511 |
|||
SplitScreenRow=0 |
|||
Cls Paper, SplitScreenRow |
|||
Print "Test" |
|||
Gosub GetState |
|||
Font "Tahoma" |
|||
Bold 1 : Italic 1: Pen 15 |
|||
cls 0, 5 |
|||
For i=1 to 100 : Print i: Next i |
|||
Move 6000,6000 |
|||
For i=1000 to 6000 step 1000 : Circle i : Next i |
|||
WaitKey$=Key$ |
|||
Gosub RestoreState |
|||
Print "End" |
|||
End |
|||
GetState: |
|||
prevfont$=fontname$ |
|||
prevbold=bold |
|||
previtalic=italic |
|||
prevpen=pen |
|||
posx=pos |
|||
posy=row |
|||
graphicx=pos.x |
|||
graphicy=pos.y |
|||
OldPaper=Paper |
|||
OldSplit=SplitScreenRow |
|||
Hold |
|||
Return |
|||
RestoreState: |
|||
Paper=OldPaper |
|||
SplitScreenRow=OldSplit |
|||
Cls Paper, SplitScreenRow |
|||
Release |
|||
font prevfont$ |
|||
bold prevbold |
|||
italic previtalic |
|||
pen prevpen |
|||
cursor posx, posy |
|||
move graphicx, graphicy |
|||
Return |
|||
} |
|||
PreserveScreen |
|||
</lang> |
|||
=={{header|Mathematica}}== |
=={{header|Mathematica}}== |