[Top][All Lists]

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

[Patch/Feature] Preservation of Leading Whitespace in Form Fields

From: Leon Winter
Subject: [Patch/Feature] Preservation of Leading Whitespace in Form Fields
Date: Tue, 17 Nov 2015 09:37:53 +0100
User-agent: Mutt/1.5.24 (2015-08-30)


I have been wondering for a while why fields of the forms library of ncurses
discard leading whitespace, e.g.

 set_field_buffer (field, 0, "    test");

will display "test" instead of showing the leading whitespaces as well. From an
outside perspective it could seem that whitespaces are used for padding in the
leading and trailing position and thus cannot be supported as real content. When
justifying the content, the library would trim the string and then apply the new
However looking in the source code, one can see that is not entirely true as the
"trimming" process is only applied when rendering the field contents. When
setting the buffer actually the whole content is taken but when it comes to
displaying such content, the macros Get_Start_Of_Data and After_End_Of_Data are
used to select the embedded string (in between leading and trailing whitespace)
which then get shown to the screen.

The attached patch removes the usage of Get_Start_Of_Data in the justification
functions which results in leading whitespace not being discarded. I could
imagine it might cause problems in certain multi-line scenarios. My testing in
single-line non-scrolling cases has been successful.

I do understand that this behaviour has been that way for a very long time and
one might not apply the patch and change it but instead keep the old and make
this new handling optional, e.g. by using field_opts.

Best regards,

Attachment: ncurses-forms-leading-whitespace.diff
Description: Text Data

reply via email to

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