File: StdWindow.pm

package info (click to toggle)
snap 0.08-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 440 kB
  • ctags: 473
  • sloc: perl: 7,033; makefile: 117; sh: 70
file content (143 lines) | stat: -rw-r--r-- 1,602 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
package StdWindow;

use FileHandle;

sub new
{
  my $class = shift;
  my $handle = shift;
  my $self = {};
  my ($width, $height);

  bless($self, $class);
  $self->{"handle"} = $handle;
  $self->{"oldwin"} = shift;

  return $self;
}

sub redraw
{
}

sub clear
{
}

sub print
{
  my ($self, $text) = @_;

  $self->{"oldwin"}->print($text) if (defined $self->{"oldwin"});

  $text =~ s/~.*?;//g;

  while ($text ne "")
    {
      # Now the guts...

      my $line;
      my $pos = index($text, "\n") + 1;

      if ($pos > 0)
        { $line = substr($text, 0, $pos); }
      else
        { $line = $text; }

      $text =~ s/^\Q$line\E//;

      $self->{"buffer"} .= $line;

      if ($line =~ /\n/)
        {
	  my $buf = $self->{"buffer"};
	  my $handle = $self->{"handle"};

	  print $handle $buf;
	  $self->{"buffer"} = "";
	};
    }
}

sub page_up
{
}

sub page_down
{
}

sub width
{
  return 80;
}

sub height
{
  return -1;
}

sub TIEHANDLE
{
  my $class = shift;
  my $obj = shift;

  return $obj;
}

sub WRITE
{
  my $self = shift;

  $self->print("WRITE not supported...\n");
}

sub PRINT
{
  my $self = shift;
  my $var;

  foreach $var (@_)
    { $self->print($var); }
}

sub PRINTF
{
  my $self = shift;

  $self->print("PRINTF not supported...\n");
}

sub READ
{
  my $self = shift;

  $self->print("On STDIN?  Nuhuh...\n");
}

sub READLINE
{
  my $self = shift;

  $self->print("On STDIN?  Nuhuh...\n");
}

sub GETC
{
  my $self = shift;

  $self->print("On STDIN?  Nuhuh...\n");
}

sub CLOSE
{
  my $self = shift;
  
  $self->print("CLOSE not supported...\n");
}

sub DESTROY
{
}

1;