File: io.e

package info (click to toggle)
entity 0.7.2-6
  • links: PTS
  • area: main
  • in suites: woody
  • size: 5,352 kB
  • ctags: 5,272
  • sloc: ansic: 61,707; sh: 7,921; makefile: 732; perl: 399
file content (74 lines) | stat: -rwxr-xr-x 1,473 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env entity

<!--
<io
	fd="1"
	oninput="got_part"
	onwrite="progress"
	onerror="got_messed"
	mode="line,chunk"
 />
-->

<object title="io">
  <perl>
  <![CDATA[
  sub get_part
  {
    my $out = enode("io.dest");
    my $node = shift;
    my $data = shift; #this does a buffer copy! use @_[1]
    my $size = shift;

    if($size == 0)
    {
      $node->attrib("fd" => -1);
      print "hello? you there?\n";
      return;
    }
    # print "'", $data, "'\n";

    chomp($data); ## kill \n's
    $out->write("write - * '$data' *\n");
    $out->attrib ("_sendq" => "_sendq - % '$data' %\n");
    print "size  = $size\n";
  }
  sub openfiles
  {
    print "opening files\n";
    my $infile = enode("entry.src")->attrib("text");
    my $outfile = enode("entry.dest")->attrib("text");

    open(INFILE, "$infile") or die "unable to open $infile";
    open(OUTFILE, "$outfile");

    my $src = enode("io.src");
    print "-=",$src->attrib("oninput"),"=-\n";

    $src->attrib("fd" => fileno(INFILE) );

    enode("io.dest")->attrib("fd" => fileno(OUTFILE) );
  }
  ]]>
  </perl>

  <window ondelete="entity:exit">
    <label text="Source"/>
    <entry name="src" text="cat /etc/passwd |" onenter="openfiles"/>
    <label text="Dest"/>
    <entry name="dest" text="| cat" onenter="openfiles"/>

    <button label="copy" onclick="openfiles"/>

  </window>
    
  <io 
    name="src"
    mode="line"
    onnewdata="get_part" 
   />
  <io 
    name="dest"
   />
</object>