in reply to Re: Estimating height of TEXTAREA from content
in thread Estimating height of TEXTAREA from content

The width and height of a TEXTAREA is specified in characters, not pixels.

Plus, I set the font size to monospace 10pt with CSS, so its guaranteed to be monospace (which is the default anyway).

(You can see it in action here if you are curious.)

Anyway, let me restate: Given an 80-character soft-wrapping of a multi-paragraph scalar of English words in a monospace font ($content), what will the height of it be in characters ($rows)?

-Andrew.


Andrew Tomazos  |  andrew@tomazos.com  |  www.tomazos.com
  • Comment on Re^2: Estimating height of TEXTAREA from content

Replies are listed 'Best First'.
Re^3: Estimating height of TEXTAREA from content
by simonm (Vicar) on Jul 25, 2005 at 05:33 UTC
    Given an 80-character soft-wrapping of a multi-paragraph scalar of English words in a monospace font ($content), what will the height of it be in characters ($rows)?

    Wrap it yourself and count the lines:

    use Text::Wrap; my $rows = split("\n", fill('','', $content););

      Nice! In a fit of jealousy for not having thought of this myself I'll point out that the default column width for Text::Wrap is 76 characters. So an amended line if the stated 80 is the real case.

      use Text::Wrap; $Text::Wrap::columns = 80; # and continue as above...
      Thanks. FYI: Use of implicit split to @_ deprecated.

      my @rows = split("\n", fill('','', $content)); my $rows = $#rows + 1;

      Maybe?

      -Andrew.


      Andrew Tomazos  |  andrew@tomazos.com  |  www.tomazos.com
Re^3: Estimating height of TEXTAREA from content
by merlyn (Sage) on Jul 25, 2005 at 03:09 UTC
      I think you're confusing this for an optional layout problem that could be left to the user agent.

      I am all for the seperation of content from presentation, I just don't know how to do that in this case. I want to present my visitor an editable article, I have to put something in the character width and character height of the TEXTAREA. Tell me how not to fight it.

      -Andrew.


      Andrew Tomazos  |  andrew@tomazos.com  |  www.tomazos.com
        I have to put something in the character width and character height of the TEXTAREA. Tell me how not to fight it.
        Users know how to operate scrollbars. In other words, don't worry about it. Use natural numbers that make sense for your overall design, and if it ends up with scrollbars, that's life.

        -- Randal L. Schwartz, Perl hacker
        Be sure to read my standard disclaimer if this is a reply.