[Top][All Lists]

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

Re: ncurses and line feed in multi line fields

From: Thomas Dickey
Subject: Re: ncurses and line feed in multi line fields
Date: Tue, 28 May 2013 18:54:03 -0400
User-agent: Mutt/1.5.20 (2009-06-14)

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...

Thomas E. Dickey <address@hidden>

Attachment: signature.asc
Description: Digital signature

reply via email to

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