Here's a first patch to get playing gnugo with graphical images going in
XEmacs, I post it here so maybe others can find it...
if you want to play with it, first (load-file "gnugo-x.el") and then
(load-file "xgnugo.el")
after the game has started (e.g. M-x gnugo RET --chinese-rules
--boardsize 9), first enable images with "i" (on the other emacs, this
immediately makes them visible) and then force a full redraw with C-u
C-l (C-u is important here!)
Clicking works but a lot of other things are still broken. I got
gnugo.el from
http://www.emacswiki.org/emacs/gnugo.el
The gnugo-xpms.el came with my vendor gnugo package.
and here is a screenshot
http://imageshack.us/photo/my-images/6/xgnugo.png/ :-)
thanks for your help, Stephen! I got it working by hiding text with a
display-table (instead of invisible), a begin-glyph and a local keymap
on the extent (which does NOT work with text-properties by the way, one
source of earlier failure)
----------8<----------8<----------8<----------8<----------8<----------
*** /dev/null 2012-02-06 10:33:52.233640872 +0100
--- gnugo-x.el 2012-02-08 16:51:19.464438254 +0100
***************
*** 0 ****
--- 1,7 ----
+ (defun find-image (image-specs)
+ (let ((spec (car image-specs)))
+ (make-glyph (vector (plist-get spec :type)
+:data (plist-get spec :data)))))
+ (require 'gnugo-xpms)
+
+ (defun image-size (image-spec) '(5 . 5))
*** gnuemacs/lisp/gnugo.el 2012-02-06 11:37:53.756615226 +0100
--- xgnugo.el 2012-02-08 16:51:47.873083097 +0100
*************** a format string applied to the rest of t
*** 579,588 ****
category
,(gnugo-yy yin yang)
front-sticky
! (gnugo-position gnugo-yin))))
(unless (= (1- other-edge) p)
(add-text-properties (1+ p) (+ 2 p)
! `(category
,(gnugo-f 'ispc)
rear-nonsticky
t))
--- 579,623 ----
category
,(gnugo-yy yin yang)
front-sticky
! (gnugo-position gnugo-yin)
! ))
! (set-extent-properties (extent-at p nil 'category)
! `(face
! ,(let* ((yy (gnugo-yy yin yang))
! (s (symbol-plist yy)))
! (when (eq (car s) 'display)
! (let* ((dt (make-display-table))
! (fc (make-face yy nil t)))
! (put-display-table t "" dt)
! (set-face-display-table fc dt)
! fc)))
! begin-glyph
! ,(let* ((yy (gnugo-yy yin yang))
! (s (symbol-plist yy)))
! (when (eq (car s) 'display)
! (cadr s)))
! keymap
! ,(let* ((yy (gnugo-yy yin yang))
! (s (symbol-plist yy)))
! (when (eq (car s) 'display)
! (let ((map (make-sparse-keymap)))
! (define-key map 'button1
! '(lambda (&rest args)
! (interactive "e")
! (let ((sp
! (extent-start-position
! (event-glyph-extent
! (car args)))))
! (when sp (goto-char sp)
! (gnugo-move)))))
! map)))
! )))
(unless (= (1- other-edge) p)
(add-text-properties (1+ p) (+ 2 p)
! `(invisible
! ,(when (symbol-plist
! (gnugo-f 'ispc)) t)
! category
,(gnugo-f 'ispc)
rear-nonsticky
t))
*************** a format string applied to the rest of t
*** 652,658 ****
`(gnugo-yang
,yang
category
! ,(gnugo-yy yin yang))))
(delete-char 1)
;; do this last to avoid complications w/ font lock
;; (this also means we cannot include `intangible' in
`front-sticky')
--- 687,711 ----
`(gnugo-yang
,yang
category
! ,(gnugo-yy yin yang)
! ))
! (set-extent-properties (extent-at cut nil 'category)
! `(face
! ,(let* ((yy (gnugo-yy yin yang))
! (s (symbol-plist yy)))
! (when (eq (car s) 'display)
! (let* ((dt (make-display-table))
! (fc (make-face yy nil t)))
! (put-display-table t "" dt)
! (set-face-display-table fc dt)
! fc)))
! begin-glyph
! ,(let* ((yy (gnugo-yy yin yang))
! (s (symbol-plist yy)))
! (when (eq (car s) 'display)
! (cadr s)))
! ))
! )
(delete-char 1)
;; do this last to avoid complications w/ font lock
;; (this also means we cannot include `intangible' in
`front-sticky')
---------->8---------->8---------->8---------->8---------->8----------
Nei
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-beta