[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cursor control
From: |
Przemek Klosowski |
Subject: |
Re: cursor control |
Date: |
Tue, 16 Apr 2013 10:58:46 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130402 Thunderbird/17.0.5 |
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.
So, how can I control the position of the cursor?
Several problems here:
- the escape sequence ESC [ val A uses ASCII codes, not binary values,
so you need to use printf("%s",[0x1B '[2A']);
- 2 is too much---disp() advances one line so you need to go back one,
not two
- printing advances the cursor both downwards and rightwise; why don't
you use carriage return on each line:
for i=1:1000; printf("%d \r", i); endfor
- cursor control, Jose, 2013/04/16
- Re: cursor control,
Przemek Klosowski <=