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

Published on 12 May 2024 09:40 PM

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

Source code in the picolisp programming language

(call 'tput "cub1")                                # one position to the left
(call 'tput "cuf1")                                # one position to the right
(call 'tput "cuu1")                                # up one line
(call 'tput "cud1")                                # down one line
(call 'tput "cr")                                  # beginning of the line
(call 'tput "hpa" (sys "COLUMNS"))                 # end of the line
(call 'tput "home")                                # top left corner
(call 'tput "cup" (sys "LINES") (sys "COLUMNS"))   # bottom right corner

  

You may also check:How to resolve the algorithm Fairshare between two and more step by step in the Mathematica / Wolfram Language programming language
You may also check:How to resolve the algorithm Strip comments from a string step by step in the Fantom programming language
You may also check:How to resolve the algorithm Sort numbers lexicographically step by step in the Action! programming language
You may also check:How to resolve the algorithm Egyptian division step by step in the Rust programming language
You may also check:How to resolve the algorithm String concatenation step by step in the SAS programming language