Skip to content

Commit

Permalink
Fix packaging issues; add support for ISO function keys
Browse files Browse the repository at this point in the history
* .elpaignore: Add xcb-xkb.el as it does not work on Emacs 24.

* xcb-types.el:
* xcb-xim.el:
  Fix compilation errors on Emacs 24.

* README.md: Renamed from README.org, or its content will be taken as the
  long description of this package by GNU ELPA.

* xcb-keysyms.el (xcb:keysyms:-xf86-keys, xcb:keysyms:keysym->event): Fix
  typos about XF86keysym.

* xcb-keysyms.el (xcb:keysyms:-iso-function-keys)
  (xcb:keysyms:event->keysym, xcb:keysyms:keysym->event): Add support for
  ISO function keys.
  • Loading branch information
ch11ng committed Sep 26, 2015
1 parent e0645b9 commit f8261bc
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .elpaignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Makefile
README.md
el_client.el

# Exclude xcb-xkb.el for now, as it does not work on Emacs 24
xcb-xkb.el
9 changes: 5 additions & 4 deletions README.org → README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#+TITLE: X protocol Emacs Lisp Binding
# X protocol Emacs Lisp Binding

XELB (X protocol Emacs Lisp Binding) is a pure Elisp implementation of X11
protocol based on the XML description files from XCB project.
It features an object-oriented API and permits a certain degree of concurrency.
It should enable you to implement some low-level X11 applications.
Please refer to [[https://github.com/ch11ng/xelb/blob/master/xelb.el][xelb.el]] for more details.
Please refer to [xelb.el](https://github.com/ch11ng/xelb/blob/master/xelb.el)
for more details.

*Note to Emacs 24 users*:
**Note to Emacs 24 users**:
If you install XELB from source (rather than GNU ELPA), be sure to install
=cl-generic= package from GNU ELPA first.
`cl-generic` package from GNU ELPA first.
44 changes: 36 additions & 8 deletions xcb-keysyms.el
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ SHIFT LOCK is ignored."
;; This list is largely base on 'lispy_function_keys' in 'keyboard.c'.
;; Emacs has a built-in variable `x-keysym-table' providing Latin-1 and legacy
;; keysyms, which seems not very useful here.
;; FIXME: shall we also include 'iso_lispy_function_keys' there?
(defconst xcb:keysyms:-function-keys
`[ ;#xff00 - #xff0f
,@(make-list 8 nil) backspace tab linefeed clear nil return nil nil
Expand Down Expand Up @@ -240,6 +239,26 @@ SHIFT LOCK is ignored."
,@(make-list 15 nil) delete]
"Emacs event representations of X function keys (keysym #xff00 to #xffff).")

;; From 'iso_lispy_function_keys' in 'keyboard.c'
(defconst xcb:keysyms:-iso-function-keys
`[
;#xfe00 - #xfe0f
,@(make-list 16 nil)
;#xfe10 - #xfe1f
,@(make-list 16 nil)
;#xfe20 - #xfe2f
iso-lefttab iso-move-line-up iso-move-line-down iso-partial-line-up
iso-partial-line-down iso-partial-space-left iso-partial-space-right
iso-set-margin-left iso-set-margin-right iso-release-margin-left
iso-release-margin-right iso-release-both-margins iso-fast-cursor-left
iso-fast-cursor-right iso-fast-cursor-up iso-fast-cursor-down
;#xfe30 - #xfe3f
iso-continuous-underline iso-discontinuous-underline iso-emphasize
iso-center-object iso-enter ,@(make-list 11 nil)
;everything else
,@(make-list 192 nil)]
"Emacs event representations of ISO function keys (#xfe00 to #xfeff).")

;; This list is adapted from 'XF86keysym.h' in X source.
;; FIXME: We've intentionally left out keysyms outside the range 0x1008FF00 ~
;; 0x1008FFFF.
Expand All @@ -248,7 +267,7 @@ SHIFT LOCK is ignored."
`[ ;#x1008ff00 - #x1008ff0f
nil XF86ModeLock XF86MonBrightnessUp XF86MonBrightnessDown
XF86KbdLightOnOff XF86KbdBrightnessUp XF86KbdBrightnessDown
,@(make-list 9 0)
,@(make-list 9 nil)
;#x1008ff10 - #x1008ff1f
XF86Standby XF86AudioLowerVolume XF86AudioMute XF86AudioRaiseVolume
XF86AudioPlay XF86AudioStop XF86AudioPrev XF86AudioNext XF86HomePage
Expand Down Expand Up @@ -291,11 +310,12 @@ SHIFT LOCK is ignored."
XF86FrameForward XF86Time
;#x1008ffa0 - #x1008ffaf
XF86Select XF86View XF86TopMenu XF86Red XF86Green XF86Yellow XF86Blue
XF86Suspend XF86Hibernate XF86TouchpadToggle ,@(make-list 6 0)
XF86Suspend XF86Hibernate XF86TouchpadToggle ,@(make-list 6 nil)
;#x1008ffb0 - #x1008ffbf
XF86TouchpadOn XF86TouchpadOff XF86AudioMicMute ,@(make-list 13 0)
XF86TouchpadOn XF86TouchpadOff XF86AudioMicMute ,@(make-list 13 nil)
;everything rest
,@(make-list 64 0)])
,@(make-list 64 nil)]
"Emacs event representations of XF86keysym (#x1008ff00 - #x1008ffff)")

(defun xcb:keysyms:event->keysym (event)
"Translate Emacs key event EVENT to X Keysym.
Expand All @@ -319,7 +339,12 @@ This function returns nil when it fails to convert an event."
(if (setq keysym (cl-position event
xcb:keysyms:-xf86-keys))
;; XF86 keys
(logior keysym #x1008ff00))))))
(logior keysym #x1008ff00)
(if (setq keysym
(cl-position event
xcb:keysyms:-iso-function-keys))
;; ISO function keys
(logior keysym #xfe00)))))))
(if (and (<= #x20 event) (>= #xff event)) ;Latin-1
(setq keysym event)
(when (and (<= #x100 event) (>= #x10ffff event)) ;Unicode
Expand Down Expand Up @@ -354,8 +379,11 @@ this function will also return symbols for pure modifiers keys."
(- keysym #x1000000))
((and (<= 1 keysym) (>= 5 keysym)) ;ButtonPress assuemd
(intern-soft (format "down-mouse-%d" keysym)))
((and (<= #x1008ff00) (>= #x1008ffff))
(aref xcb:keysyms:-xf86-keys (logand keysym #xff))))))
((and (<= #x1008ff00 keysym) (>= #x1008ffff keysym))
(aref xcb:keysyms:-xf86-keys (logand keysym #xff)))
((and (<= #xfe00 keysym) (>= #xfeff keysym))
(aref xcb:keysyms:-iso-function-keys
(logand keysym #xff))))))
(when (and (not allow-modifiers)
(memq event
'(lshift* rshift* lcontrol* rcontrol*
Expand Down
6 changes: 4 additions & 2 deletions xcb-types.el
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,11 @@

;;;; Struct type

(defvar xcb:lsb t "Non-nil for LSB first (i.e., little-endian), nil otherwise.
(eval-and-compile
(defvar xcb:lsb t
"Non-nil for LSB first (i.e., little-endian), nil otherwise.
Consider let-bind it rather than change its global value.")
Consider let-bind it rather than change its global value."))

(defclass xcb:-struct ()
((~lsb :initarg :~lsb
Expand Down
5 changes: 3 additions & 2 deletions xcb-xim.el
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@

;;;; Basic requests packet format

(defvar xim:lsb xcb:lsb "Non-nil for LSB first, nil otherwise.
(eval-and-compile
(defvar xim:lsb xcb:lsb "Non-nil for LSB first, nil otherwise.
Consider let-bind it rather than change its global value.")
Consider let-bind it rather than change its global value."))

(defclass xim:-struct (xcb:-struct)
((~lsb :initform (symbol-value 'xim:lsb)))
Expand Down

0 comments on commit f8261bc

Please sign in to comment.