I have a slight problem controlling the cursor position in a Bash terminal window. I have a function ask a question and then wait for an answer which is either 'y' or 'n' or a carriage return. Whenever the user enters anything else it just erases the answer and waits for the next one. However, the script behaves differently when the cursor is on the bottom line of a window as compared to any other line.
The for-loop is the 'productive' part. It just puts out numbers in a column. Every 10 numbers it asks if the user wants to continue and uses the function askYesOrNo for that purpose.
The problem lies with the two lines in the function askYesOrNo (at the end of the while-loop) and when the user enters an answer that is not Y, y, N, n or Enter. The first line (now commented out) works fine when the cursor is not in the bottom line of the window. But if it is then the window scrolls up and the next answer appears in the next line.
The second version moves the cursor one line up and that's fine with the cursor at the bottom of the window but not if the question is asked elsewhere.
I want to get the screen width and cursor positions.
When I used curses, all the screen content was cleared.
So Can I use curses to get the screen size without clearing anything in the window?
Or is there any other alternative???
I can use only C or C++. (0 Replies)
Hi,
Pleae help me on this. Normally, when we say read username, the cursor will come in the first position of next line, but I want the output of the below
Normal usage
-------------
please enter username:
_
I want like the below
----------------------
please enter username:
... (2 Replies)
Hi to all!
I'm a teacher of maths and physics in an italian high school in Milan, Italy.
I need a simple program that read the position of mouse cursor in function of time and write the coordinates in a text file. The time resolution have to be something like 1/10 sec or better (I have to know... (2 Replies)
hi all,
am trying to modify a ksh script to group server names together depending on the cluster they sit in. currently the script does a
find . -name '*.pid'
to find all running servers and prints out their pids and names.
current output looks something like this :
serverA ... (1 Reply)
I need to get the cursor position, and put it inside a variable. Problem is, i don't have the tput command, or ncurses.
Apparently I was supposed to try the following:
echo -e '\E
But I don't get a value or anything. Please help. (3 Replies)
Hi there.
It's easier to explain this with a pseudo code, I hope this makes sense:
var1=hello
echo $var1
some kind of loop
echo loop counter
done
How do I hold the cursor position immediately behind the last output so I'd get something like:
hello123456789
DOS used to use ","... (5 Replies)
Discussion started by: MuntyScrunt
5 Replies
LEARN ABOUT CENTOS
purity
PURITY(6) Games Manual PURITY(6)NAME
purity - a general purpose purity test
SYNOPSIS
/usr/games/purity [ flags ] [ testname ]
DESCRIPTION
Purity is an interactive purity test program with a simple, user interface and datafile format. For each test, questions are printed to
the your terminal, and you are prompted for an answer to the current question. At a prompt, these are your choices:
y Answer "yes" to the question.
n Answer "no" to the question.
b Backup one question, if you answered it incorrectly, or someone is watching you take the test, and you don't (or do) want to
admit a different answer.
r Redraw the current question.
q Quit the test, and print the current score.
? Print a help screen for the current prompt.
k Kill a section of the test. This skips all the questions of the test until the next subject heading.
a Toggle answer mode between real answers and obfuscated answers. Real answers print "yes" and "no", while obfuscated answers
are "Maybe" and "maybe". Obfuscated answers are preferred if you are shy, and don't want people to be able to read your
answers over your shoulder as you take the test.
d Toggle dERanGe output.
s Print your current score on the test you are taking.
l Toggle score logging.
At the end of the test, your score is printed out. For most purity tests, lower scores denote more "experience" of the test material.
FLAGS
These are the command line flags for the test.
-a Show real answers (i.e. "yes" and "no") instead of obfuscated ones (i.e. "Maybe" and "maybe") as you answer the questions.
-d PrINt THe tESt in DerANgeD pRInT.
-f Take the test in fast mode. Only the questions are printed, and not any other text blocks, like the introdution, subject
headers, and the conclusion.
-l Take the test without having your score logged.
-p Print the test without prompting for answers. This is useful for making hard copies of the tests without having to edit out
the prompts by hand.
-r Decrypt the test using the Rot 13 algorithm. This is done as a form of "protection", such that if you read a rot13 test and
it offends you, it's your own fault.
-z zoom through more prompts in large text blocks. The default is to prompt the user for more when a screenful of text has been
printed without any user input.
DATAFILE FORMAT
The format of the datafiles is a very simple format, intended such that new tests can quickly and easily be converted to run with the test.
There are four types of text in a purity test datafile. Each type is contained in a bracket type of punctuation. The definitions are as
follows:
the styles of text blocks are:
{ plain text block }
[ subject header ]
( test question )
and < conclusion >
Plain text blocks are printed out character for character.
Subject headers are preceded by their subject numbers, starting at 1, and then printed as text blocks.
Questions are preceded by their numbers, and then prompt the user to answer the question, keeping track of the user's current score.
Conclusions first calculate and print the user's score for the test, then print out the conclusion as a text block.
If you wish to include any of the various bracket punctuation in your text, the backslash ("") character will escape the next character.
To print a question with parentheses, you would use the following format:
(have you ever written a purity test (like this one)?)
the output would be this:
1. have you ever written a purity test (like this one)?
and then it would have asked the user for her/his answer.
For a generic datafile, use the "sample" datafile for the test.
FILES
/var/games/purity.scores the score logfile
/usr/share/games/purity/* test data files
AUTHOR
Eric Lechner, lechner@ucscb.ucsc.edu
18 December 1989 PURITY(6)