Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
zcurses move issue
- X-seq: zsh-users 29499
- From: Ray Andrews <rayandrews@xxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: zcurses move issue
- Date: Tue, 16 Jan 2024 08:12:50 -0800
- Archived-at: <https://zsh.org/users/29499>
- List-id: <zsh-users.zsh.org>
This looks like a bug but maybe it's a feature:
I have a zcurses window and I want to write to it one line -- actually
'element' because the lines might wrap -- at a time so I iterate inside
a 'for' loop. To write each line you need to grab the cursor position
which is wherever the last write stopped, then you move to the next line:
# 'array[1]' is mouse vertial position.
zcurses position $win array
zcurses move "$win" $(( array[1])) $3
... looks logical. However the top line in the window is line '0', and
if you use 'zcurses move' to move to line zero all hell breaks loose.
(It will start at line zero automatically but that's besides the point
here, I need a for loop that starts at the beginning). So in practice
I've been doing this:
(( line_count > 1 )) && zcurses move "$win" $(( array[1] + 1 )) $3
... and if I print 'line_count' against 'array[1]' I get:
1 - 0
2 - 0
3 - 1
4 - 2
... but I need a consistent relationship so I've been using this nasty
little hack:
integer aaa
(( aaa = array[1] + 1 ))
[[ "$line_count" > '1' ]] && (( aaa++ ))
... and the relationship vis. 'aaa' is:
1 - 1
2 - 2
3 - 3
.... All good, and it converts the mouse 'Y' value to 'one-based' which
is fine, just so long as it's consistent. However it would be better if
'zcurses move' simply accepted '0' as input -- at the top of the loop
the first move is 'no change' but so what? Perhaps it would be neater to
simply convert from 'move, write' to 'write, move'. Still, asking for a
null move seems to me to be permissible -- move to where you already are.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author