[mcclim-devel] How to get Swedish characters/Latin-1 to work! + best way to do pop-up menu?

Peter Braroe peter.braroe at newsmachine.com
Fri Feb 17 18:39:50 UTC 2006


Hello!

Well I tried the tip, but on my first attempt it bugged out... and then
i saw that a ' had snuck in and - sucsess! 

Please find the file i used enclosed!

What I trying to figgure the best way for now is:

 - How to i most elegantly pop-up a window? 
(for instance "Are you sure you would like to quit? Save first?)

 - How to make items in a formated list clickable through translations
 
and other things... 

Happy weekend to you all!

/Peter 


On Wed, 2006-02-15 at 19:13 +0100, Troels Henriksen wrote:
> "Peter Braroe" <peter.braroe at newsmachine.com> writes:
> 
> > I now need to get Swedish characters like ÅÄÖ åäö to work i.e. latin-1
> > support, when I google it seems that this should work but when I type a
> > Swedish character it does not register - is there something special that I
> > should do? I am using latest CMUCL under Linux... 
> 
> Look at the bottom tip on http://mcclim.cliki.net/Tip
> 
> You are required to manually find the keysym for the characters you want to
> support, though.
> 
-------------- next part --------------
;;; Non-ASCII input
;;;
;;; Out-of-the-box, McCLIM only supports ASCII input. If you use the CLX backend (most likely the
;;; default for your platform), you can use the following trick to enable more characters.
;;;
;;; You must redefine the clim-clx::translate function:

(in-package :clim-clx)


(defun translate (src src-start src-end afont dst dst-start)
  (let ((min-char-index (xlib:font-min-char afont))
	(max-char-index (xlib:font-max-char afont)))
    (if (stringp src)
	(loop for i from src-start below src-end
	      for j from dst-start
	      for index = (char-code (aref src i))
	      while (<= min-char-index index max-char-index)
	      do (setf (aref dst j) index)
	      finally (return i))
      (loop for i from src-start below src-end
	    for j from dst-start
	    for index = (if (characterp (aref src i))
			    (char-code (aref src i)) (aref src i))
	    while (<= min-char-index index max-char-index)
	    do (setf (aref dst j) index)
	    finally (return i)))))

;;
;; Without this function, the CLX backend is incapable of handling Unicode characters.
;;

;;
;; Use this function to add the characters you need:
;;

(defun fix-character (character keysym)
  "Setup character to work in CLX and McCLIM."
  (xlib::define-keysym character keysym)
  (goatee::add-gesture-command-to-table character 'goatee::insert-character
                                       goatee::*simple-area-gesture-table*))


(defun fix-swedish-input ()
  "Adds Swedish special characters."
  (fix-character #\? 229)
  (fix-character #\? 197)
  (fix-character #\? 228)
  (fix-character #\? 196)
  (fix-character #\? 246)
  (fix-character #\? 214))

  
;;
;; For example:
;;

(defun fix-danish-input ()
  "Adds Danish special characters."
  (fix-character #\? 230)
  (fix-character #\? 198)
  (fix-character #\? 248)
  (fix-character #\? 216)
  (fix-character #\? 229)
  (fix-character #\? 197))

;; Or:

(defun fix-german-input ()
  "Adds German special characters."
  (fix-character #\? 228)
  (fix-character #\? 246)
  (fix-character #\? 252)
  (fix-character #\? 196)
  (fix-character #\? 214)
  (fix-character #\? 220)
  (fix-character #\? 223))

;; You should now have non-ASCII input. In editor-panes, at least.




More information about the mcclim-devel mailing list