June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,10 @@
import extensions.
program =
[
literal chr := emptyLiteralValue.
if (console isKeyAvailable)
[
chr := console readChar
].
].

View file

@ -0,0 +1,12 @@
#!/usr/bin/perl
use strict;
use warnings;
use Term::ReadKey;
ReadMode 4;
my $key;
until(defined($key = ReadKey(-1))){
# anything
sleep 1;
}
print "got key '$key'\n";
ReadMode('restore');

View file

@ -0,0 +1,50 @@
#!/usr/bin/perl
use strict;
use warnings;
use Carp;
use POSIX;
use Term::ReadKey;
$| = 1; # don't buffer; stdout is hot now
#avoid creation of zombies
sub _cleanup_and_die{
ReadMode('restore');
print "process $$ dying\n";
die;
}
sub _cleanup_and_exit{
ReadMode('restore');
print "process $$ exiting\n";
exit 1;
}
$SIG{'__DIE__'} = \&_cleanup_and_die;
$SIG{'INT'} = \&_cleanup_and_exit;
$SIG{'KILL'} = \&_cleanup_and_exit;
$SIG{'TERM'} = \&_cleanup_and_exit;
$SIG{__WARN__} = \&_warn;
# fork into two processes:
# child process is doing anything
# parent process just listens to keyboard input
my $pid = fork();
if(not defined $pid){
print "error: resources not available.\n";
die "$!";
}elsif($pid == 0){ # child
for(0..9){
print "doing something\n";
sleep 1;
}
exit 0;
}else{ # parent
ReadMode('cbreak');
# wait until child has exited/died
while(waitpid($pid, POSIX::WNOHANG) == 0){
my $seq = ReadKey(-1);
if(defined $seq){
print "got key '$seq'\n";
}
sleep 1; # if ommitted, the cpu-load will reach up to 100%
}
ReadMode('restore');
}

View file

@ -0,0 +1,33 @@
import java.awt.event.{KeyAdapter, KeyEvent}
import javax.swing.{JFrame, SwingUtilities}
class KeypressCheck() extends JFrame {
addKeyListener(new KeyAdapter() {
override def keyPressed(e: KeyEvent): Unit = {
val keyCode = e.getKeyCode
if (keyCode == KeyEvent.VK_ENTER) {
dispose()
System.exit(0)
}
else
println(keyCode)
}
})
}
object KeypressCheck extends App {
println("Press any key to see its code or 'enter' to quit\n")
SwingUtilities.invokeLater(() => {
def foo() = {
val f = new KeypressCheck
f.setFocusable(true)
f.setVisible(true)
f.setSize(200, 200)
f.setEnabled(true)
}
foo()
})
}