package [% package %]; =begin hackers [% autogenerated_warning %] =end hackers =head1 NAME VCP::UIMachines - State machines for user interface =head1 SYNOPSIS Called by VCP::UI =head1 DESCRIPTION The user interface module L is a framework that bolts the implementation of the user interface to a state machine representing the user interface. Each state in this state machine is a method. =head1 METHOD =over =cut use strict; [%- FOR s = machine.states -%] [%- SWITCH s.class_ids -%] [%- CASE "entry_class" -%] =item [% s.id %] [% s.description | trim %] Next state: [% s.arcs_from.to %] =cut sub [% s.id %] { return '[% s.arcs_from.to %]'; } [%- CASE "exit_class" -%] =item [% s.id %] [% s.description | trim %] =cut sub [% s.id %] { return undef; } [%- CASE "prompt_class" -%] =item [% s.id %]: [% s.name %] [% s.description | trim %] Valid answers: [% FOR a = s.arcs_from -%] [% a.description %][% IF a.event.api %] ([%- a.event.api -%])[% END %] => [% a.to %] [% END %] =cut sub [% s.id %] { my ( $ui ) = @_; ## Use single-quotish HERE docs as the most robust form of quoting ## so we don't have to mess with escaping. my $prompt = <<'END_PROMPT'; [% s.name %] END_PROMPT chomp $prompt; my @valid_anwsers = ( [% FOR a = s.arcs_from -%] [ '[% a.description %]', [%- IF a.event.api %] [% a.event.api -%], [%- ELSE %] '[% a.description -%]', [%- END %] '[% a.to -%]' ], [% END -%] ); my $answer = $ui->ask( <<'END_DESCRIPTION', $prompt, \@valid_anwsers ); [% s.description %] END_DESCRIPTION return $answer->[-1]; } [%- END -%] [%- END -%] =back =head1 WARNING: AUTOGENERATED This module is autogenerated in the pre-distribution build process, so to change it, you need the master repository files in ui_machines/..., not a CPAN/PPM/tarball/.zip/etc. distribution. =head1 COPYRIGHT Copyright 2003, Perforce Software, Inc. All Rights Reserved. This module and the VCP package are licensed according to the terms given in the file LICENSE accompanying this distribution, a copy of which is included in L. =head1 AUTHOR Barrie Slaymaker =cut 1;