Debian Codegraph @

Debconf/FrontEnd/Noninteractive.pm

raw
1 #!/usr/bin/perl
2
3 =head1 NAME
4
5 Debconf::FrontEnd::Noninteractive - non-interactive FrontEnd
6
7 =cut
8
9 package Debconf::FrontEnd::Noninteractive;
10 use warnings;
11 use strict;
12 use Debconf::Encoding qw(width wrap);
13 use Debconf::Gettext;
14 use base qw(Debconf::FrontEnd);
15
16 =head1 DESCRIPTION
17
18 This FrontEnd is completly non-interactive.
19
20 =cut
21
22 =item init
23
24 tty not needed
25
26 =cut
27
28 sub init {
29 my $this=shift;
30
31 $this->SUPER::init(@_);
32
33 $this->need_tty(0);
34 }
35
36 =item display
37
38 Displays text wrapped to fit on the screen. If a title has been set and has
39 not yet been displayed, displays it first.
40
41 =cut
42
43 sub display {
44 my $this=shift;
45 my $text=shift;
46
47 # Hardcode the width because we might not have any console
48 $Debconf::Encoding::columns=76;
49 $this->display_nowrap(wrap('','',$text));
50 }
51
52 =item display_nowrap
53
54 Displays text. If a title has been set and has not yet been displayed,
55 displays it first.
56
57 =cut
58
59 sub display_nowrap {
60 my $this=shift;
61 my $text=shift;
62
63 # Silly split elides trailing null matches.
64 my @lines=split(/\n/, $text);
65 push @lines, "" if $text=~/\n$/;
66
67 # Add to the display any pending title.
68 my $title=$this->title;
69 if (length $title) {
70 unshift @lines, $title, ('-' x width $title), '';
71 $this->title('');
72 }
73
74 foreach (@lines) {
75 print "$_\n";
76 }
77 }
78
79 1