[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Patch] forms: Allow shrinking of dynamic fields

From: Leon Winter
Subject: [Patch] forms: Allow shrinking of dynamic fields
Date: Tue, 15 Jan 2019 13:35:58 +0100
User-agent: Mutt/1.10.1 (2018-07-13)


we have the use case that there are two modes a field can be in:
- one for entering data
- one for displaying data (in a formatted way, e.g. with "USD %2.8f")

Therefore a situation can occur where the allowed input into a field should be
limited to a number even lower than the width of the field. Only in the later
displaying mode the whole display width of the field would be used.
We implemented these two modes by repeatedly calling set_max_field.
However if we pass a length smaller than the current length of the field, it
would be rejected with E_BAD_ARGUMENT.
With this simple patch one would be able to indeed be able to shrink a field.
For full backwards-compatibility the new behaviour would only apply if the new
feature O_INPUT_LIMIT would be set.

Regarding the naming: Because my initial concern was the input limit I called
the feature after than but the patch actually allows shrinking of dcols and
maxgrow so one could easily argue the feature name should be O_ALLOW_SHRINK or
similiar which would also be fine by me.
Suprisingly I haven't observed negative side-effects by decreasing dcols and
maxgrow in such manner albeit I could imagine where could be some. Before the
change it was a valid assumption that

    maxgrow >= dcols >= cols

which would not hold afterwards.


Attachment: ncurses-input-limit.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]