1Devel::REPL::Plugin::FaUnsceyrPrCoomnpttr(i3b)uted PerlDDeovceulm:e:nRtEaPtLi:o:nPlugin::FancyPrompt(3)
2
3
4
6 Devel::REPL::Plugin::FancyPrompt - facilitate user-defined prompts
7
9 #!/usr/bin/perl
10
11 use lib './lib';
12 use Devel::REPL;
13
14 my $repl = Devel::REPL->new;
15 $repl->load_plugin('MultiLine::PPI'); # for indent depth
16 $repl->load_plugin('Packages'); # for current package
17 $repl->load_plugin('FancyPrompt');
18 $repl->run;
19
21 FancyPrompt helps you write your own prompts. The default fancy prompt
22 resembles "irb"'s default prompt. The default "fancy_prompt" looks like
23 this:
24
25 re.pl(main):001:0> 2 + 2
26 4
27
28 "re.pl" is a constant. "main" is the current package. The first number
29 is how many lines have been read so far. The second number (only if you
30 have a "MultiLine" plugin) is how deep you are; intuitively, your
31 indent level. This default can be implemented with:
32
33 $_REPL->fancy_prompt(sub {
34 my $self = shift;
35 sprintf 're.pl(%s):%03d%s> ',
36 $self->can('current_package') ? $self->current_package : 'main',
37 $self->lines_read,
38 $self->can('line_depth') ? ':' . $self->line_depth : '';
39 });
40
41 "current_package" is provided by Devel::REPL::Plugin::Packages (which
42 tracks the current package). "line_depth" is provided by a "MultiLine"
43 plugin (probably "MultiLine::PPI").
44
45 You may also set a "fancy_continuation_prompt". The default is very
46 similar to "fancy_prompt"'s default (except "*" instead of ">").
47
49 "Devel::REPL"
50
52 Shawn M Moore, "<sartak at gmail dot com>"
53
55 Copyright (C) 2007 by Shawn M Moore
56
57 This library is free software; you can redistribute it and/or modify it
58 under the same terms as Perl itself.
59
60
61
62perl v5.12.1 2010-05-23Devel::REPL::Plugin::FancyPrompt(3)