bug-ncurses
[Top][All Lists]
Advanced

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

Re: ncurses and line feed in multi line fields


From: tjareson
Subject: Re: ncurses and line feed in multi line fields
Date: Thu, 30 May 2013 13:52:22 -0300
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130510 Thunderbird/17.0.6


Am 28.05.2013 19:54, schrieb Thomas Dickey:
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...

Ok, thanks for reply - at least that means that I didn't miss something. :-)

Regarding realization: my issue is that I would like to use the multiline field also to write application internal scripting, so the text also contains sql queries for example, hence I can't simply remove all except one trailing blank per line, as that might create a problem with the query syntax.

I wonder if it would make sense to simply insert a special character as CR/LF-marker whenever one hits return to indicate that a line ends here before requesting a new line from the formdriver. The only issue then is, that I can't stop the user from moving behind this CR/LF-character with the cursor, as I do not have any visibility where exactly the cursor is in the field nor what character there is in the buffer?





reply via email to

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