App-Guiio
view release on metacpan or search on metacpan
lib/App/Guiio/Ascii.pm view on Meta::CPAN
$EndY[$controlStartIndex] = $lineCount;
$ControlType[$controlStartIndex] = 'Button';
}
else
{
push(@StartX,$colCount);
push(@StartY,$lineCount);
push(@EndX,$colCount+$offSet);
push(@EndY,$lineCount);
push(@Properties,'');
push(@ControlType,'ButtTop');
}
$colCount += $offSet;
$i += $offSet;
}
elsif (substr($input,$i) =~ m/^\|[^|]+\|.*/s and ((is_control_exists($colCount,$lineCount,'ButtTop',\@StartX,\@StartY,\@EndX,\@EndY,\@ControlType) ==
is_control_exists($colCount+(index(substr($input,$i+1),'|')+1),$lineCount,'ButtTop',\@StartX,\@StartY,\@EndX,\@EndY,\@ControlType) and
is_control_exists($colCount,$lineCount,'ButtTop',\@StartX,\@StartY,\@EndX,\@EndY,\@ControlType) >= 0 ) or (
is_control_exists($colCount,$lineCount,'ListTop',\@StartX,\@StartY,\@EndX,\@EndY,\@ControlType) ==
is_control_exists($colCount+(index(substr($input,$i+1),'|')+1),$lineCount,'ListTop',\@StartX,\@StartY,\@EndX,\@EndY,\@ControlType) and
is_control_exists($colCount,$lineCount,'ListTop',\@StartX,\@StartY,\@EndX,\@EndY,\@ControlType) >= 0)))
{
set_detected_components($colCount,$lineCount,$RecognizedCharacters,$lastState,\@StartX,\@EndX,\@StartY,\@EndY,\@ControlType,\@Properties);
my $startIndex = is_control_exists($colCount,$lineCount,'ButtTop',\@StartX,\@StartY,\@EndX,\@EndY,\@ControlType);
my $endIndex = is_control_exists($colCount+(index(substr($input,$i+1),'|')+1),$lineCount,'ButtTop',\@StartX,\@StartY,\@EndX,\@EndY,\@ControlType);
if ($startIndex == $endIndex and $startIndex >= 0) # this is clearly the text part of the button
{
$EndY[$startIndex] = $lineCount;
$Properties[$startIndex] = AddProperty($Properties[$startIndex],'Text',substr($input,($i+1),index(substr($input,$i+1),'|')));
}
$startIndex = is_control_exists($colCount,$lineCount,'ListTop',\@StartX,\@StartY,\@EndX,\@EndY,\@ControlType);
$endIndex = is_control_exists($colCount+index(substr($input,$i+1),'|')+1,$lineCount,'ListTop',\@StartX,\@StartY,\@EndX,\@EndY,\@ControlType);
if ($startIndex == $endIndex and $startIndex >= 0)
{
$EndY[$startIndex] = $lineCount;
$Properties[$startIndex] = AddProperty($Properties[$startIndex],'Items',substr($input,($i+1),index(substr($input,$i+1),'|')));
}
$i += index(substr($input,$i+1),'|')+1;
$colCount += index(substr($input,$i+1),'|')+1;
}
elsif (substr($input,$i) =~ m/^_+.*/s)
{
set_detected_components($colCount,$lineCount,$RecognizedCharacters,$lastState,\@StartX,\@EndX,\@StartY,\@EndY,\@ControlType,\@Properties);
$lastState = '';
$RecognizedCharacters = '';
$Property = '';
push(@StartX,$colCount); # we set StartX to be our current position minus one, as the control begins one before this character on the following line
push(@StartY,$lineCount);
push(@EndY, $lineCount);
push(@Properties,$Property);
push(@ControlType,'ComboHeader');
while(substr($input,$i,1) eq '_')
{
$i++;
$colCount++;
}
$i--;
$colCount--;
push(@EndX,$colCount); # we offset the last occurance of _ in that portion of the substring by 3 as the combobox infact ends after 3 characters on the following line
$colCount--;
}
elsif (substr($input,$i) =~ m/^\[Combo *\|V\].*/s and is_control_exists($colCount,$lineCount,'ComboHeader',\@StartX,\@StartY,\@EndX,\@EndY,\@ControlType) >= 0 and
is_control_exists($colCount+index(substr($input,$i),']'),$lineCount,'ComboHeader',\@StartX,\@StartY,\@EndX,\@EndY,\@ControlType) >= 0 and
is_control_exists($colCount+index(substr($input,$i),']'),$lineCount,'ComboHeader',\@StartX,\@StartY,\@EndX,\@EndY,\@ControlType) ==
is_control_exists($colCount,$lineCount,'ComboHeader',\@StartX,\@StartY,\@EndX,\@EndY,\@ControlType)) # found the content part of the combobox
{
my $controlIndex = is_control_exists($colCount,$lineCount,'ComboHeader',\@StartX,\@StartY,\@EndX,\@EndY,\@ControlType);
$ControlType[$controlIndex] = 'Combobox';
$EndY[$controlIndex] = $lineCount;
$i += index(substr($input,$i),']');
$colCount += index(substr($input,$i),']');
}
elsif (substr($input,$i) =~ m/^<-+>.*/s or substr($input,$i) =~ m/^\[=+\].*/s or substr($input,$i) =~ m/^=+\[\]=+.*/s or substr($input,$i) =~ m/^\[_+\].*/s) # picks up horizontal scroll bar, horizontal slider, progress bar, or textbox patterns
{
set_detected_components($colCount,$lineCount,$RecognizedCharacters,$lastState,\@StartX,\@EndX,\@StartY,\@EndY,\@ControlType,\@Properties);
$Property = '';
push(@StartX,$colCount);
push(@StartY,$lineCount);
push(@EndY, $lineCount);
push(@Properties,$Property);
if (substr($input,$i) =~ m/^<-+>.*/s)
{
push(@EndX, $colCount+(index($input,'>',$i)-$i));
$colCount += (index($input,'>',$i))-$i;
$i += (index($input,'>',$i))-$i;
push(@ControlType,'Horizontal Scroll');
}
elsif (substr($input,$i) =~ m/^\[=+\].*/s)
{
push (@EndX, $colCount+(index($input,']',$i)-$i));
$colCount+= (index($input,']',$i))-$i;
$i += (index($input,']',$i))-$i;
push(@ControlType,'Progress Bar');
}
elsif (substr($input,$i) =~ m/^\[_+\].*/s) # Define textbox
{
push (@EndX, $colCount+(index($input,']',$i))-$i);
$colCount+= (index($input,']',$i))-$i;
$i += (index($input,']',$i))-$i;
push (@ControlType, 'Textbox');
}
else{ # Horizontal Slider Control
my $substr = substr($input,$i);
$i += index ($substr,']')+1;
$colCount += index ($substr,']')+1;
$substr = substr($substr,index($substr,']')+1);
# I apologize for the following section of code looking unpleasent
# I tried using Perl's regular expression system with the pos function and after several hours
# of research and attempts, never got it to work quite like I wanted it to (it returned the length of the string, as opposed to
# the first character in the string where the pattern no longer matches)
my $curSliderChar;
my $SliderCount = 0;
while(substr($substr,$SliderCount,1) eq '=')
{
$i++;
$colCount++;
$SliderCount++;
}
push (@EndX, $colCount);
push(@ControlType,'Horizontal Slider');
}
( run in 1.494 second using v1.01-cache-2.11-cpan-5b529ec07f3 )