September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
|
|
@ -1 +1,6 @@
|
|||
Show how to link user defined methods to user defined keys. An example of this is the facility provided by emacs for [http://www.gnu.org/software/emacs/manual/html_node/emacs/Key-Bindings.html key bindings]. These key bindings may be application-specific or system-wide; state which you have done.
|
||||
Show how to link user defined methods to user defined keys.
|
||||
|
||||
An example of this is the facility provided by emacs for [http://www.gnu.org/software/emacs/manual/html_node/emacs/Key-Bindings.html key bindings].
|
||||
|
||||
These key bindings may be application-specific or system-wide; state which you have done.
|
||||
<br><br>
|
||||
|
|
|
|||
58
Task/Keyboard-macros/Go/keyboard-macros.go
Normal file
58
Task/Keyboard-macros/Go/keyboard-macros.go
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
package main
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -lX11
|
||||
#include <stdlib.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/keysym.h>
|
||||
|
||||
static inline Window DefaultRootWindow_macro(Display *dpy) {
|
||||
return ScreenOfDisplay(dpy, DefaultScreen(dpy))->root;
|
||||
}
|
||||
|
||||
static inline int getXEvent_type(XEvent event) {
|
||||
return event.type;
|
||||
}
|
||||
|
||||
static inline XKeyEvent getXEvent_xkey(XEvent event) {
|
||||
return event.xkey;
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
import "fmt"
|
||||
import "unsafe"
|
||||
|
||||
func main() {
|
||||
d := C.XOpenDisplay(nil)
|
||||
f7, f6 := C.CString("F7"), C.CString("F6")
|
||||
defer C.free(unsafe.Pointer(f7))
|
||||
defer C.free(unsafe.Pointer(f6))
|
||||
|
||||
if d != nil {
|
||||
C.XGrabKey(d, C.int(C.XKeysymToKeycode(d, C.XStringToKeysym(f7))),
|
||||
C.Mod1Mask, /* normally it's Alt */
|
||||
C.DefaultRootWindow_macro(d), C.True, C.GrabModeAsync, C.GrabModeAsync)
|
||||
C.XGrabKey(d, C.int(C.XKeysymToKeycode(d, C.XStringToKeysym(f6))),
|
||||
C.Mod1Mask,
|
||||
C.DefaultRootWindow_macro(d), C.True, C.GrabModeAsync, C.GrabModeAsync)
|
||||
|
||||
var event C.XEvent
|
||||
for {
|
||||
C.XNextEvent(d, &event)
|
||||
if C.getXEvent_type(event) == C.KeyPress {
|
||||
xkeyEvent := C.getXEvent_xkey(event)
|
||||
s := C.XLookupKeysym(&xkeyEvent, 0)
|
||||
if s == C.XK_F7 {
|
||||
fmt.Println("something's happened")
|
||||
} else if s == C.XK_F6 {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
C.XUngrabKey(d, C.int(C.XKeysymToKeycode(d, C.XStringToKeysym(f7))), C.Mod1Mask, C.DefaultRootWindow_macro(d))
|
||||
C.XUngrabKey(d, C.int(C.XKeysymToKeycode(d, C.XStringToKeysym(f6))), C.Mod1Mask, C.DefaultRootWindow_macro(d))
|
||||
} else {
|
||||
fmt.Println("XOpenDisplay did not succeed")
|
||||
}
|
||||
}
|
||||
22
Task/Keyboard-macros/Julia/keyboard-macros.julia
Normal file
22
Task/Keyboard-macros/Julia/keyboard-macros.julia
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using Gtk
|
||||
|
||||
function keypresswindow()
|
||||
tcount = 0
|
||||
txt = "Press a Number Key"
|
||||
win = GtkWindow("Keyboard Macros Test", 300, 50) |> (GtkFrame() |> ((vbox = GtkBox(:v)) |> (lab = GtkLabel(txt))))
|
||||
function keycall(w, event)
|
||||
ch = Char(event.keyval)
|
||||
if isdigit(ch)
|
||||
set_gtk_property!(lab, :label, "Keyboard Macro Number $ch Invoked.")
|
||||
end
|
||||
end
|
||||
signal_connect(keycall, win, "key-press-event")
|
||||
|
||||
cond = Condition()
|
||||
endit(w) = notify(cond)
|
||||
signal_connect(endit, win, :destroy)
|
||||
showall(win)
|
||||
wait(cond)
|
||||
end
|
||||
|
||||
keypresswindow()
|
||||
39
Task/Keyboard-macros/Perl/keyboard-macros.pl
Normal file
39
Task/Keyboard-macros/Perl/keyboard-macros.pl
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
use Term::ReadKey;
|
||||
|
||||
ReadMode 4; # change to raw input mode
|
||||
|
||||
sub logger { my($message) = @_; print "$message\n" }
|
||||
|
||||
while (1) {
|
||||
if (my $c = ReadKey 0) { # read a single character
|
||||
if ($c eq 'q') { logger "QUIT"; last }
|
||||
elsif ($c =~ /\n|\r/) { logger "CR" }
|
||||
elsif ($c eq "j") { logger "down" }
|
||||
elsif ($c eq "k") { logger "up" }
|
||||
elsif ($c eq "h") { logger "left" }
|
||||
elsif ($c eq "l") { logger "right" }
|
||||
|
||||
elsif ($c eq "J") { logger "DOWN" }
|
||||
elsif ($c eq "K") { logger "UP" }
|
||||
elsif ($c eq "H") { logger "LEFT" }
|
||||
elsif ($c eq "L") { logger "RIGHT" }
|
||||
|
||||
elsif ($c eq "\e") { # handle a few escape sequences
|
||||
my $esc = ReadKey 0;
|
||||
$esc .= ReadKey 0;
|
||||
if ($esc eq "[A") { logger "up" }
|
||||
elsif ($esc eq "[B") { logger "down" }
|
||||
elsif ($esc eq "[C") { logger "right" }
|
||||
elsif ($esc eq "[D") { logger "left" }
|
||||
elsif ($esc eq "[5") { logger "page up" }
|
||||
elsif ($esc eq "[6") { logger "page down" }
|
||||
else { logger "Unrecognized escape: $esc"; }
|
||||
}
|
||||
|
||||
else { logger "you typed: $c"; }
|
||||
}
|
||||
}
|
||||
|
||||
ReadMode 0; # reset the terminal to normal mode
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
♀/*REXX program can re-define most keys (including F keys) on a PC keyboard.*/
|
||||
/*REXX program can re-define most keys (including F keys) on a PC keyboard.*/
|
||||
trace off
|
||||
parse arg !
|
||||
if !all(arg()) then exit
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue