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

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Terminal control/Cursor movement step by step in the Ada 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 Ada programming language

Source code in the ada programming language

with Ada.Text_Io;

with Ansi;

procedure Movement is
   use Ada.Text_Io;
begin
   Put (Ansi.Store);
   Put (Ansi.Position (Row => 20, Column => 40));

   for A in 1 .. 15 loop
      Put (Ansi.Back);
      delay 0.020;
   end loop;

   for A in 1 .. 15 loop
      Put (Ansi.Up);
      delay 0.050;
   end loop;

   for A in 1 .. 15 loop
      Put (Ansi.Forward);
      delay 0.020;
   end loop;

   for A in 1 .. 15 loop
      Put (Ansi.Down);
      delay 0.050;
   end loop;

   delay 1.000;
   Put (Ansi.Horizontal (Column => 1));
   delay 2.000;
   Put (Ansi.Position (1, 1));
   delay 2.000;
   Put (Ansi.Restore);
end Movement;


  

You may also check:How to resolve the algorithm Boolean values step by step in the Befunge programming language
You may also check:How to resolve the algorithm Flatten a list step by step in the EchoLisp programming language
You may also check:How to resolve the algorithm Loops/Infinite step by step in the TI-89 BASIC programming language
You may also check:How to resolve the algorithm Conjugate transpose step by step in the Rust programming language
You may also check:How to resolve the algorithm Image convolution step by step in the J programming language