On Tue, May 28, 2013 at 02:38:44PM -0700, Tjareson wrote:
Hello,
not sure if someone can give me a hint how to solve/approach my problem:
I'm currently developing a very light database application for using on
linux text console based on ncurses.
When working with multi line fields in forms, I run into the issue that I
don't know how to handle CR / LF at the end of a line properly. The field
buffer of a multi line field is simply always filled up with blanks until
the line ends and the next line begins.
If I save that in mysql as field type "text" I get practically one line with
a lot of blanks between each "real" line, as the field buffer cannot handle
LF as it looks. As long as I write that back into an ncurses multi line
field of exactly the same size it is not really a problem. But when the size
is different that of course doesn't work anymore.
Any ideas or hints how to handle that with a multi line field in ncurses
properly?
I'd handle it by a wrapper function for the field_buffer functions which
uses the field length (rows * cols) to set/get a more usable value, e.g.,
splitting a value up by works to set and return a string with trailing
blanks reduced to a single blank (or interpret the separator as a newline).
I haven't added a function like that to the forms library for various
reasons (not wanting to mess up compatibility - and also since most users
are for the ncurses library). But I could add an example to test/demo_forms.c
which could be reused...