Support for meta and hyper keys added
Support for the compose key has also been added but it's just the button code for now, no support for actually composing stuff. There are plans for that in a fixme.
This commit is contained in:
parent
9a37fbf04a
commit
8c28c57925
@ -17,7 +17,7 @@ type Backend interface {
|
|||||||
// Whatever the application draws from within this event handler must be
|
// Whatever the application draws from within this event handler must be
|
||||||
// the first thing that appears on-screen.
|
// the first thing that appears on-screen.
|
||||||
//
|
//
|
||||||
// The OnResize evnt handler must run whenever the window is resized.
|
// The OnResize event handler must run whenever the window is resized.
|
||||||
// The backend must push updates to the screen after OnResize has been
|
// The backend must push updates to the screen after OnResize has been
|
||||||
// run.
|
// run.
|
||||||
//
|
//
|
||||||
@ -45,8 +45,8 @@ type Backend interface {
|
|||||||
Draw ()
|
Draw ()
|
||||||
}
|
}
|
||||||
|
|
||||||
// BackendFactory should completely initialize a backend, and return it. If
|
// BackendFactory must completely initialize a backend, and return it. If
|
||||||
// anything goes wrong, it should stop, clean up any resources and return an
|
// anything goes wrong, it must stop, clean up any resources and return an
|
||||||
// error so another backend can be chosen.
|
// error so another backend can be chosen.
|
||||||
type BackendFactory func (
|
type BackendFactory func (
|
||||||
application *Application,
|
application *Application,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package x
|
package x
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
import "unicode"
|
import "unicode"
|
||||||
import "github.com/jezek/xgb/xproto"
|
import "github.com/jezek/xgb/xproto"
|
||||||
import "github.com/jezek/xgbutil/keybind"
|
import "github.com/jezek/xgbutil/keybind"
|
||||||
@ -36,10 +37,15 @@ var buttonCodeTable = map[xproto.Keysym] stone.Button {
|
|||||||
0xFFE2: stone.KeyRightShift,
|
0xFFE2: stone.KeyRightShift,
|
||||||
0xFFE3: stone.KeyLeftControl,
|
0xFFE3: stone.KeyLeftControl,
|
||||||
0xFFE4: stone.KeyRightControl,
|
0xFFE4: stone.KeyRightControl,
|
||||||
|
|
||||||
|
0xFFE7: stone.KeyLeftMeta,
|
||||||
|
0xFFE8: stone.KeyRightMeta,
|
||||||
0xFFE9: stone.KeyLeftAlt,
|
0xFFE9: stone.KeyLeftAlt,
|
||||||
0xFFEA: stone.KeyRightAlt,
|
0xFFEA: stone.KeyRightAlt,
|
||||||
0xFFEB: stone.KeyLeftSuper,
|
0xFFEB: stone.KeyLeftSuper,
|
||||||
0xFFEC: stone.KeyRightSuper,
|
0xFFEC: stone.KeyRightSuper,
|
||||||
|
0xFFED: stone.KeyLeftHyper,
|
||||||
|
0xFFEE: stone.KeyRightHyper,
|
||||||
|
|
||||||
0xFFFF: stone.KeyDelete,
|
0xFFFF: stone.KeyDelete,
|
||||||
|
|
||||||
@ -55,6 +61,14 @@ var buttonCodeTable = map[xproto.Keysym] stone.Button {
|
|||||||
0xFFC7: stone.KeyF10,
|
0xFFC7: stone.KeyF10,
|
||||||
0xFFC8: stone.KeyF11,
|
0xFFC8: stone.KeyF11,
|
||||||
0xFFC9: stone.KeyF12,
|
0xFFC9: stone.KeyF12,
|
||||||
|
|
||||||
|
// TODO: send this whenever a compose key, dead key, etc is pressed,
|
||||||
|
// and then send the resulting character while witholding the key
|
||||||
|
// presses that were used to compose it. As far as the program is
|
||||||
|
// concerned, a magical key with the final character was pressed and the
|
||||||
|
// KeyDead key is just so that the program might provide some visual
|
||||||
|
// feedback to the user while input is being waited for.
|
||||||
|
0xFF20: stone.KeyDead,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (backend *Backend) keycodeToButton (
|
func (backend *Backend) keycodeToButton (
|
||||||
@ -84,7 +98,7 @@ func (backend *Backend) keycodeToButton (
|
|||||||
symbol3 = symbol1
|
symbol3 = symbol1
|
||||||
case symbol3 == 0 && symbol4 == 0:
|
case symbol3 == 0 && symbol4 == 0:
|
||||||
symbol3 = symbol1
|
symbol3 = symbol1
|
||||||
symbol2 = symbol2
|
symbol4 = symbol2
|
||||||
case symbol4 == 0:
|
case symbol4 == 0:
|
||||||
symbol4 = 0
|
symbol4 = 0
|
||||||
}
|
}
|
||||||
@ -123,6 +137,8 @@ func (backend *Backend) keycodeToButton (
|
|||||||
|
|
||||||
var selectedKeysym xproto.Keysym
|
var selectedKeysym xproto.Keysym
|
||||||
var selectedRune rune
|
var selectedRune rune
|
||||||
|
|
||||||
|
fmt.Printf("AAA\t%X\t%X\t%X\t%X\n", symbol1, symbol2, symbol3, symbol4)
|
||||||
|
|
||||||
// big ol list in the middle
|
// big ol list in the middle
|
||||||
switch {
|
switch {
|
||||||
|
41
examples/printbuttons/main.go
Normal file
41
examples/printbuttons/main.go
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "os"
|
||||||
|
import "image"
|
||||||
|
import _ "image/png"
|
||||||
|
import "git.tebibyte.media/sashakoshka/stone"
|
||||||
|
import _ "git.tebibyte.media/sashakoshka/stone/backends/x"
|
||||||
|
|
||||||
|
var application = &stone.Application { }
|
||||||
|
|
||||||
|
func main () {
|
||||||
|
application.SetTitle("press any key")
|
||||||
|
application.SetSize(8, 1)
|
||||||
|
|
||||||
|
iconFile16, err := os.Open("assets/scaffold16.png")
|
||||||
|
if err != nil { panic(err) }
|
||||||
|
icon16, _, err := image.Decode(iconFile16)
|
||||||
|
if err != nil { panic(err) }
|
||||||
|
iconFile16.Close()
|
||||||
|
iconFile32, err := os.Open("assets/scaffold32.png")
|
||||||
|
if err != nil { panic(err) }
|
||||||
|
icon32, _, err := image.Decode(iconFile32)
|
||||||
|
if err != nil { panic(err) }
|
||||||
|
iconFile16.Close()
|
||||||
|
|
||||||
|
application.SetIcon([]image.Image { icon16, icon32 })
|
||||||
|
|
||||||
|
application.OnPress(onPress)
|
||||||
|
application.OnRelease(onRelease)
|
||||||
|
|
||||||
|
err = application.Run()
|
||||||
|
if err != nil { panic(err) }
|
||||||
|
}
|
||||||
|
|
||||||
|
func onPress (button stone.Button) {
|
||||||
|
println("press", button)
|
||||||
|
}
|
||||||
|
|
||||||
|
func onRelease (button stone.Button) {
|
||||||
|
println("release", button)
|
||||||
|
}
|
14
input.go
14
input.go
@ -33,10 +33,14 @@ const (
|
|||||||
KeyRightShift Button = 21
|
KeyRightShift Button = 21
|
||||||
KeyLeftControl Button = 22
|
KeyLeftControl Button = 22
|
||||||
KeyRightControl Button = 23
|
KeyRightControl Button = 23
|
||||||
KeyLeftAlt Button = 24
|
KeyLeftMeta Button = 24
|
||||||
KeyRightAlt Button = 25
|
KeyRightMeta Button = 25
|
||||||
KeyLeftSuper Button = 26
|
KeyLeftAlt Button = 26
|
||||||
KeyRightSuper Button = 27
|
KeyRightAlt Button = 27
|
||||||
|
KeyLeftSuper Button = 28
|
||||||
|
KeyRightSuper Button = 29
|
||||||
|
KeyLeftHyper Button = 30
|
||||||
|
KeyRightHyper Button = 31
|
||||||
|
|
||||||
KeyDelete Button = 127
|
KeyDelete Button = 127
|
||||||
|
|
||||||
@ -67,6 +71,8 @@ const (
|
|||||||
KeyF10 Button = 153
|
KeyF10 Button = 153
|
||||||
KeyF11 Button = 154
|
KeyF11 Button = 154
|
||||||
KeyF12 Button = 155
|
KeyF12 Button = 155
|
||||||
|
|
||||||
|
KeyDead Button = 156
|
||||||
)
|
)
|
||||||
|
|
||||||
// Printable returns whether or not the character could show up on screen. If
|
// Printable returns whether or not the character could show up on screen. If
|
||||||
|
Loading…
Reference in New Issue
Block a user