v1cont / yad

Yet Another Dialog
GNU General Public License v3.0
685 stars 57 forks source link

LBL messes up the following fields #282

Open pkzc opened 1 month ago

pkzc commented 1 month ago

With yad 14.1, this creates a messed up field set:

        yad --form \
            --columns=2  --align=center \
            --field=A:LBL \
            --field=H:NUM '0!0..23' \
            --field=M:NUM '0!0..59' \
            --field=T:LBL \
            --field=M:NUM '0!0..1440'

Pressing '+', A/H counts up to 59, A/M and T/M count up infinitely.

However, this one works as expected:

        yad --form \
            --columns=2  --align=center \
            --field=A:LBL '' \
            --field=H:NUM '0!0..23' \
            --field=M:NUM '0!0..59' \
            --field=T:LBL '' \
            --field=M:NUM '0!0..1440'

I believe that the fact that an LBL field requires two arguments similarly to NUM fields is not documented anywhere. Or there is a bug somewhere.

step- commented 1 month ago

I believe all --field types take a value, LBL included.

With yad 14.1, this creates a messed up field set: ... Pressing '+', A/H counts up to 59, A/M and T/M count up infinitely.

I think '0!0..23' becomes the LBL's value, leaving '0!0..59' for the A/H counter...

    yad --form \
        --columns=2  --align=center \
        --field=A:LBL \
        --field=H:NUM '0!0..23' \
        --field=M:NUM '0!0..59' \
        --field=T:LBL \
        --field=M:NUM '0!0..1440'

However, this one works as expected:

That's because '' becomes the LBL's value, so the remaining values go to the respective owners.

I believe that the fact that an LBL field requires two arguments similarly to NUM fields is not documented anywhere. Or there is a bug somewhere.

I don't think it says anywhere that the LBL field takes only one argument instead of two but I could be wrong. Did you read anywhere that it does? I think that would be a documentation bug.

pkzc commented 1 month ago

In the man page I can see the wording "initial value..." in several places where second arguments of various fields are described, e.g. for NUM, but for LBL it, or any similar indication, is missing. This may be regarded as misleading.

On the other hand, it occured to me, that the second argument of LBL could be truly useful. Now, in the |-separated answer, I get an empty string in the place of the LBL field even if I supply a non-empty string as a second argument, but in some situations it could be useful to get back that string in the answer -- for example when writing a general processing function of the answers from several forms.

$ echo $(yad --form \
            --columns=2  --align=center \
            --field=A:LBL 'L1' \
            --field=H:NUM '1!0..23' \
            --field=M:NUM '2!0..59' \
            --field=T:LBL 'L2' \
            --field=M:NUM '3!0..1440')
|1|2||3|

Or, might this be the real bug?

step- commented 1 month ago

...it occured to me, that the second argument of LBL could be truly useful...

I agree.

Or, might this be the real bug?Or, might this be the real bug?

Currently, it appears to be intentional for the BTN, FBTN and LBL field types to output as empty strings. This is the relevant source code https://github.com/v1cont/yad/blob/c3c75f9a2886fbf35ba5edbcd9f0654a99d3eea4/src/form.c#L1552.

pkzc commented 1 month ago

OK, I see. BTN and FBTN are all right, they are reflected in the returned status, but you might consider including the LBL value in the answer string. It's a field, after all, isn't it? And in any case, perhaps, adding to the man page that LBL requires an initial value, at least an empty string currently.

I have also another improvement proposal, I will file a separate ticket for that.

cheers PK

step- commented 1 month ago

Just to be clear, I'm not the author of yad.

pkzc commented 1 month ago

Ah, OK. I hope the author or someone active also reads this issue tracker. Or do you happen to know if there is a better place to submit yad issues?

step- commented 1 month ago

This is the place to submit issues.