1 # Copyright 2002-2007 Interchange Development Group and others
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version. See the LICENSE file for details.
8 # $Id: row.coretag,v 1.4 2007-03-30 23:40:49 pajamian Exp $
10 UserTag row Order width
12 UserTag row Interpolate
13 UserTag row PosNumber 1
14 UserTag row Version $Revision: 1.4 $
15 UserTag row Routine <<EOR
18 my($append,$f,$i,$line,$usable);
36 $spec =~ s/\s*=\s*/=/;
37 $spec =~ s/^(\d+)/width=$1/;
38 %spec = split /[\s=]+/, $spec;
41 $spec{$_} = $def{$_} unless defined $spec{$_};
44 if($spec{'html'} && $spec{'wrap'}) {
45 ::logError("tag_column: can't have 'wrap' and 'html' specified at same time.");
49 if(! $spec{align} or $spec{align} !~ /^n/i) {
55 if (1 or $spec{html}) {
71 $usable = $spec{'width'} - $spec{'gutter'};
72 return "BAD_WIDTH" if $usable < 1;
74 if($spec{'align'} =~ /^[ln]/i) {
77 ' ' x ($usable - $len->($_[0])) .
78 ' ' x $spec{'gutter'};
81 elsif($spec{'align'} =~ /^r/i) {
83 ' ' x ($usable - $len->($_[0])) .
85 ' ' x $spec{'gutter'};
88 elsif($spec{'align'} =~ /^i/i) {
94 return "BAD JUSTIFICATION SPECIFICATION: $spec{'align'}";
98 if($spec{'spacing'} > 1) {
99 $append .= "\n" x ($spec{'spacing'} - 1);
102 if($spec{'align'} =~ /^n/i) {
103 @lines = split(/\r?\n/, $text);
105 elsif(is_yes($spec{'wrap'}) and length($text) > $usable) {
106 @lines = wrap($text,$usable);
108 elsif($spec{'align'} =~ /^i/i) {
109 $lines[0] = ' ' x $spec{'width'};
110 $lines[1] = $text . ' ' x $spec{'gutter'};
112 elsif (! $spec{'html'}) {
113 $lines[0] = substr($text,0,$usable);
116 foreach $line (@lines) {
117 push @out , &{$f}($line);
118 for($i = 1; $i < $spec{'spacing'}; $i++) {
126 my ($str, $width) = @_;
138 $b = rindex($str, " ", $width - 1);
140 push @a, substr($str, 0, $width);
141 $str = substr($str, $width);
144 push @a, substr($str, 0, $b);
145 $str = substr($str, $b + 1);
152 my($width,$text) = @_;
161 while( $text =~ s!\[col(?:umn)?\s+
165 \[/col(?:umn)?\] !!ix ) {
169 @{$lines[$i]} = tag_column($spec,$col);
170 # Discover X dimension
171 $len[$i] = length(${$lines[$i]}[0]);
172 if(defined ${$lines[$i]}[1] and ${$lines[$i]}[1] =~ /^<\s*input\s+/i) {
178 for(@len) { $totlen += $_ }
179 if ($totlen > $width) {
180 return " B A D R O W S P E C I F I C A T I O N - columns too wide.\n"
183 # Discover y dimension
185 for ($k = 1; $k < $i; $k++) {
186 $j = $#{$lines[$k]} > $j ? $#{$lines[$k]} : $j;
189 for($y = 0; $y <= $j; $y++) {
191 for($x = 0; $x < $i; $x++) {
192 if(defined ${$lines[$x]}[$y]) {
193 $line .= ${$lines[$x]}[$y];
197 elsif (($i - $x) > 1) {
198 $line .= ' ' x $len[$x];