How to resolve the algorithm Terminal control/Cursor movement step by step in the Raku programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Terminal control/Cursor movement step by step in the Raku programming language

Table of Contents

Problem Statement

Demonstrate how to achieve movement of the terminal cursor:

For the purpose of this task, it is not permitted to overwrite any characters or attributes on any part of the screen (so outputting a space is not a suitable solution to achieve a movement to the right).

This task has no specific requirements to trap or correct cursor movement beyond the terminal boundaries, so the implementer should decide what behavior fits best in terms of the chosen language.   Explanatory notes may be added to clarify how an out of bounds action would behave and the generation of error messages relating to an out of bounds cursor position is permitted.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Terminal control/Cursor movement step by step in the Raku programming language

Source code in the raku programming language

shell "tput cub1";                  # one position to the left
shell "tput cuf1";                  # one position to the right
shell "tput cuu1";                  # up one line
shell "tput cud1";                  # down one line
shell "tput cr";                    # beginning of line
shell "tput home";                  # top left corner

$_ = qx[stty -a &1];
my $rows = +m/'rows '    <(\d+)>/;
my $cols = +m/'columns ' <(\d+)>/;

shell "tput hpa $cols";             # end of line
shell "tput cup $rows $cols";       # bottom right corner


  

You may also check:How to resolve the algorithm Null object step by step in the COBOL programming language
You may also check:How to resolve the algorithm Accumulator factory step by step in the 8th programming language
You may also check:How to resolve the algorithm Array length step by step in the FurryScript programming language
You may also check:How to resolve the algorithm Primality by trial division step by step in the ARM Assembly programming language
You may also check:How to resolve the algorithm Strip comments from a string step by step in the Icon and Unicon programming language