[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cursor control
From: |
Jose |
Subject: |
Re: cursor control |
Date: |
Tue, 16 Apr 2013 18:44:09 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 |
On 04/16/2013 05:58 PM, Przemek Klosowski wrote:
On 04/16/2013 08:20 AM, Jose wrote:
I need to control the position of the cursor in the terminal within one
script. I have tried VT100 control commands, but either they do not work
as expected or I am doing something wrong. For example:
octave:8> for n=1:10
> disp(a);
> printf("%s",[0x1B '[' 2 'A']);
> endfor
1 2
1 2
1 2
....
The previous code should have displayed the matrix a on top of itself
all the time.
Several problems here:
- the escape sequence ESC [ val A uses ASCII codes, not binary values,
so you need to use printf("%s",[0x1B '[2A']);
Spot on, this was the main problem.
I forgot to mention in my previous mail that 'a' is a matrix, and that
is why I wanted to use disp instead of printf.
So a working script example, for future reference:
-----------------
a=[1 2;3 4];
for n=1:10
disp(a++);
printf("%s",[0x1B '[' sprintf("%i",rows(a)) 'A']);
fflush(stdout);
sleep(0.5);
endfor
printf("%s",[0x1B '[' sprintf("%i",rows(a)) 'B']);
------------------
Thanks, Przemek.
J