Terminal control/Cursor movement: Difference between revisions

Added Befunge example.
(Scala solution added)
(Added Befunge example.)
Line 203:
VDU 30,8 : REM Move to the bottom right corner
VDU 23,16,0;0;0;0; : REM Enable scrolling</lang>
 
=={{header|Befunge}}==
 
Assuming a terminal with support for ANSI escape sequences, you can move the cursor position with the code fragments below.
 
{|style="text-align: left;"
!Move left one column:
|<code>"D["39*,,,</code>
|-
!Move right one column:
|<code>"C["39*,,,</code>
|-
!Move up one line:
|<code>"A["39*,,,</code>
|-
!Move down one line:
|<code>"B["39*,,,</code>
|-
!Move to start of line:
|<code>94+,</code>
|-
!Move to end of line:
|<code>"C999["39*,,,,,,</code>
|-
!Move to top left:
|<code>"H["39*,,,</code>
|-
!Move to bottom right:
|<code>0"H999;999["39*>:#,_$</code>
|}
 
Note that the ''end of line'' movement is achieved by moving right 999 columns, and relies on the fact that the terminal will clamp the movement range to the width of the screen. Similarly, the ''bottom right'' movement is achieved by setting the cursor position to the 999th column of the 999th row, which again is clamped to the maximum width and height of the screen.
 
The ''start of line'' movement is simply a carriage return (ASCII 13).
 
=={{header|C}}==
Anonymous user