From: Andreas K. <and...@Ac...> - 2001-11-08 22:25:43
|
> -----Original Message----- > From: Dan Kuchler [mailto:da...@ku...] > Sent: Thursday, November 08, 2001 2:21 PM > To: je...@ac... > Cc: and...@ac... > Subject: Enhancement to ::textutil tcllib package > > > > Jeff and Andreas, > I have a possible enhancement for the ::textutil::adjust > procedure. > > I was using it today for a project, and it met all my > requirements except for one. I had a requirement that > the lines in the return string couldn't be longer than > the '-length' specified, even if the input line was longer > than '-length'. I accomplished this by splitting words > that were longer than '-length' into multiple words. > > Here is an example: > > package require textutil > > set foo "budget code 1: 01234567890-01234567890-01234567890 \ > budget code 2: 01234567890-01234567890-01234567890 some more text here." > > puts "foo: **[::textutil::adjust $foo -justify left -length 30]**" > > gives: > > foo: **budget code 1: > 01234567890-01234567890-0123456 > 7890 budget code 2: > 01234567890-01234567890-0123456 > 7890 some more text here.** > > With the original behaviour this would have > given: > > foo: **budget code 1: > 01234567890-01234567890-01234567890 > budget code 2: > 01234567890-01234567890-01234567890 > some more text here.** > > This patch/enhancement is useful when you have truly > fixed length fields (a database, entry widgets, etc.) > that you need to fit data into. The existing behavior > doesn't work because the line can be longer than the > '-length' specified if a single word is too long. > > I hardcoded this behavior but was wondering if it would > be worthwhile adding as an option. If you have any ideas > what I should call this option let me know. I would prefer this behaviour as an option. ... My shot at its name: -strict, or -strictlength (for strict length requirements) > If this is 'generally useful' I can submit a patch that > implements this as a flag instead of hard codes this. > > Thanks, > --Dan -- Andreas Kupries <and...@Ac...> Developer @ http://www.ActiveState.com |