zsh-users
 help / color / mirror / code / Atom feed
* zcurses move issue
@ 2024-01-16 16:12 Ray Andrews
  2024-01-16 19:03 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Ray Andrews @ 2024-01-16 16:12 UTC (permalink / raw)
  To: Zsh Users

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.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: zcurses move issue
  2024-01-16 16:12 zcurses move issue Ray Andrews
@ 2024-01-16 19:03 ` Bart Schaefer
  2024-01-16 19:18   ` Ray Andrews
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2024-01-16 19:03 UTC (permalink / raw)
  To: Zsh Users

On Tue, Jan 16, 2024 at 8:13 AM Ray Andrews <rayandrews@eastlink.ca> wrote:
>
> This looks like a bug but maybe it's a feature:

With very few exceptions the zcurses subcommands are directly
translated into calls to the ncurses library.  In this case, wmove().

I think it's important that we continue to faithfully reproduce the
library behavior, even if it seems inconvenient.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: zcurses move issue
  2024-01-16 19:03 ` Bart Schaefer
@ 2024-01-16 19:18   ` Ray Andrews
  0 siblings, 0 replies; 3+ messages in thread
From: Ray Andrews @ 2024-01-16 19:18 UTC (permalink / raw)
  To: zsh-users


On 2024-01-16 11:03, Bart Schaefer wrote:
> On Tue, Jan 16, 2024 at 8:13 AM Ray Andrews <rayandrews@eastlink.ca> wrote:
>> This looks like a bug but maybe it's a feature:
> With very few exceptions the zcurses subcommands are directly
> translated into calls to the ncurses library.  In this case, wmove().
>
> I think it's important that we continue to faithfully reproduce the
> library behavior, even if it seems inconvenient.

As you think best.  But it does seem buggy.  Can one not move to 
position zero?  Anyway my hack has served reliably for a long time so 
letting sleeping dogs lay isn't a a big deal.  Seems that ncurses could 
have used a bit more testing. I could have made myself useful back in 
the day.


BTW, I only got one copy of this post!  Did something change? It's my 
preference, still I myself didn't do anything.

>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-01-16 19:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 16:12 zcurses move issue Ray Andrews
2024-01-16 19:03 ` Bart Schaefer
2024-01-16 19:18   ` Ray Andrews

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).