From: ·······@gmail.com
Subject: :input :value multiple lines
Date: 
Message-ID: <1175013755.118035.236260@b75g2000hsg.googlegroups.com>
Hi,

I have a list with value: '((C 3) (D 5)).  When I try to put this
value in to an inputbox with cl-who (:input :value *list*), he only
shows me "((C" in the input box.  To make sure that there was nothing
wrong with my list, I tried to print like this: (:p (str *list*)), and
then he prints it a it is.
In the source code of the html-page the inputbox is shown on multiple
lines, I think a new line is started after every space:
<input value="((C
                       3)
                      (D ....
How can I fully show this list in the inputbox?
Thanks!

From: Zach Beane
Subject: Re: :input :value multiple lines
Date: 
Message-ID: <m3wt12hbm7.fsf@unnamed.xach.com>
·······@gmail.com writes:

> Hi,
> 
> I have a list with value: '((C 3) (D 5)).  When I try to put this
> value in to an inputbox with cl-who (:input :value *list*), he only
> shows me "((C" in the input box.  To make sure that there was nothing
> wrong with my list, I tried to print like this: (:p (str *list*)), and
> then he prints it a it is.
> In the source code of the html-page the inputbox is shown on multiple
> lines, I think a new line is started after every space:
> <input value="((C
>                        3)
>                       (D ....
> How can I fully show this list in the inputbox?

You might have more luck if you set *PRINT-PRETTY* to nil.

Zach
From: ·······@gmail.com
Subject: Re: :input :value multiple lines
Date: 
Message-ID: <1175025160.971639.160570@o5g2000hsb.googlegroups.com>
>
> You might have more luck if you set *PRINT-PRETTY* to nil.
>
> Zach

Okay I read the other post first, but this is the solution.
Thanks!
From: Pascal Bourguignon
Subject: Re: :input :value multiple lines
Date: 
Message-ID: <873b3qwnf9.fsf@voyager.informatimago.com>
·······@gmail.com writes:

> Hi,
>
> I have a list with value: '((C 3) (D 5)).  When I try to put this
> value in to an inputbox with cl-who (:input :value *list*), he only
> shows me "((C" in the input box.  To make sure that there was nothing
> wrong with my list, I tried to print like this: (:p (str *list*)), and
> then he prints it a it is.
> In the source code of the html-page the inputbox is shown on multiple
> lines, I think a new line is started after every space:
> <input value="((C
>                        3)
>                       (D ....
> How can I fully show this list in the inputbox?

This is not possible:

Location: http://www.w3.org/TR/html4/interact/forms.html

17.4.1 Control types created with INPUT

The control type defined by the INPUT element depends on the value of
the type attribute:

text
    Creates a single-line text input control.

Use a TEXTAREA element, where you can specify a number of columns and
a number of rows.

-- 
__Pascal Bourguignon__
http://www.informatimago.com
http://pjb.ogamita.org
From: ·······@gmail.com
Subject: Re: :input :value multiple lines
Date: 
Message-ID: <1175023766.207160.301540@n76g2000hsh.googlegroups.com>
On 27 mrt, 20:28, Pascal Bourguignon <····@informatimago.com> wrote:
> ·······@gmail.com writes:
> > Hi,
>
> > I have a list with value: '((C 3) (D 5)).  When I try to put this
> > value in to an inputbox with cl-who (:input :value *list*), he only
> > shows me "((C" in the input box.  To make sure that there was nothing
> > wrong with my list, I tried to print like this: (:p (str *list*)), and
> > then he prints it a it is.
> > In the source code of the html-page the inputbox is shown on multiple
> > lines, I think a new line is started after every space:
> > <input value="((C
> >                        3)
> >                       (D ....
> > How can I fully show this list in the inputbox?
>
> This is not possible:
>
> Location:http://www.w3.org/TR/html4/interact/forms.html
>
> 17.4.1 Control types created with INPUT
>
> The control type defined by the INPUT element depends on the value of
> the type attribute:
>
> text
>     Creates a single-line text input control.
>
> Use a TEXTAREA element, where you can specify a number of columns and
> a number of rows.
>
> --
> __Pascal Bourguignon__http://www.informatimago.comhttp://pjb.ogamita.org

But that's what I want, I want the list to be shown in a single line.
For some reason when I try to put it in an inputbox, it prints it on
multiple lines.  When I put it in a <p> and print it with (str
*list*), it prints the list like it is, in one line.  That's what I
want except I can't get it to print it in one line in an inputbox.
The list is just created like this:
(defparameter *list* '((C 4) (B 5)))
and
(:p (str *list*)) just print the list like I want it: ((C 4) (B 5))
but
(:input :name inp :value *list* :size "40") only gives me the value
"((C" in the inputbox.

Did I misunderstand, or is it really not possible to print the *list*
in an inputbox? I don't want multiple lines.

Thanks for the quick response.
From: Pascal Bourguignon
Subject: Re: :input :value multiple lines
Date: 
Message-ID: <87y7lgv7fb.fsf@voyager.informatimago.com>
·······@gmail.com writes:

> On 27 mrt, 20:28, Pascal Bourguignon <····@informatimago.com> wrote:
>> ·······@gmail.com writes:
>> > I have a list with value: '((C 3) (D 5)).  When I try to put this
>> > value in to an inputbox with cl-who (:input :value *list*), he only
>> > shows me "((C" in the input box.  To make sure that there was nothing
>> > wrong with my list, I tried to print like this: (:p (str *list*)), and
>> > then he prints it a it is.
>> > In the source code of the html-page the inputbox is shown on multiple
>> > lines, I think a new line is started after every space:
>> > <input value="((C
>> >                        3)
>> >                       (D ....
>> > How can I fully show this list in the inputbox?
>>
>> This is not possible:
>> [...]
>> Use a TEXTAREA element, where you can specify a number of columns and
>> a number of rows.
>
> But that's what I want, I want the list to be shown in a single line.
> For some reason when I try to put it in an inputbox, it prints it on
> multiple lines.  When I put it in a <p> and print it with (str
> *list*), it prints the list like it is, in one line.  That's what I
> want except I can't get it to print it in one line in an inputbox.

Well, then you don't seem to know some basics of HTML.  (This is not a
question related to lisp, really).  You might want to read some HTML
introduction, or the references, like http://www.w3.org/TR/html4

In HTML files, there are several kind of data, text that is
interpreted according to different rules (cf PCDATA, CDATA).

For the text you put between tags like <p> some text </p>, the white
spaces (including newlines) are collapsed to a single space.  So if
you write:

<p> (some
       multi
       line
       form)
</p>

it will render as:

    (some multi
    line form)

assuming a narrow window, or as:

    (some multi line form)

assuming a wider window.


In the case of attribute values, the rules to interpret the text are
different, and newlines become significant.


> The list is just created like this:
> (defparameter *list* '((C 4) (B 5)))
> and
> (:p (str *list*)) just print the list like I want it: ((C 4) (B 5))
> but
> (:input :name inp :value *list* :size "40") only gives me the value
> "((C" in the inputbox.

What happens here, is that the lisp function that converts the (:input
...) form into html must translate the *list* which is a lisp LIST
into a string.  It probably does that using PRIN1 or (FORMAT NIL "~S"
item), and depending on variables such as *PRINT-PRETTY* and
*PRINT-RIGHT-MARGIN*, this generates a string with newlines.


> Did I misunderstand, or is it really not possible to print the *list*
> in an inputbox? I don't want multiple lines.

You can try setting *print-pretty* to nil, but I would rather
explicitely generate the string, since you may not know exactly how
the html generating library your using is converting the list into a
string itself (it may bind *print-pretty* to true, or even not use the
lisp printer).


Try something like:

(:input :name inp 
        :value (let ((*print-pretty* nil)) (prin1-to-string *list*))
        :size 40) ; or (length (let ((*print-pretty* nil)) (prin1-to-string *list*)))


-- 
__Pascal Bourguignon__
http://www.informatimago.com
http://pjb.ogamita.org