Skip to content

Instantly share code, notes, and snippets.

@takaxp
Created December 24, 2014 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takaxp/6a32218a148684e8b03f to your computer and use it in GitHub Desktop.
Save takaxp/6a32218a148684e8b03f to your computer and use it in GitHub Desktop.
An inline patch for Emacs 24.4
diff -Nrc emacs-24.4_orig/configure.ac emacs-24.4_patched/configure.ac
*** emacs-24.4_orig/configure.ac 2014-12-07 01:37:53.000000000 +0900
--- emacs-24.4_patched/configure.ac 2014-12-07 01:40:06.000000000 +0900
***************
*** 1782,1788 ****
INSTALL_ARCH_INDEP_EXTRA=
fi
! NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o $macfont_file"
fi
CFLAGS="$tmp_CFLAGS"
CPPFLAGS="$tmp_CPPFLAGS"
--- 1782,1788 ----
INSTALL_ARCH_INDEP_EXTRA=
fi
! NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o macim.o $macfont_file"
fi
CFLAGS="$tmp_CFLAGS"
CPPFLAGS="$tmp_CPPFLAGS"
***************
*** 4869,4875 ****
## only costs about 1.5K of wasted binary space.
headerpad_extra=1000
if test "$HAVE_NS" = "yes"; then
! libs_nsgui="-framework AppKit"
if test "$NS_IMPL_COCOA" = "yes"; then
libs_nsgui="$libs_nsgui -framework IOKit"
fi
--- 4869,4875 ----
## only costs about 1.5K of wasted binary space.
headerpad_extra=1000
if test "$HAVE_NS" = "yes"; then
! libs_nsgui="-framework AppKit -framework Carbon -framework Cocoa"
if test "$NS_IMPL_COCOA" = "yes"; then
libs_nsgui="$libs_nsgui -framework IOKit"
fi
diff -Nrc emacs-24.4_orig/lisp/term/common-win.el emacs-24.4_patched/lisp/term/common-win.el
*** emacs-24.4_orig/lisp/term/common-win.el 2014-12-07 01:37:58.000000000 +0900
--- emacs-24.4_patched/lisp/term/common-win.el 2014-12-07 01:41:17.000000000 +0900
***************
*** 136,141 ****
--- 136,142 ----
(cons (logior (lsh 0 16) 12) 'ns-new-frame)
(cons (logior (lsh 0 16) 13) 'ns-toggle-toolbar)
(cons (logior (lsh 0 16) 14) 'ns-show-prefs)
+ (cons (logior (lsh 0 16) 15) 'mac-change-input-method)
))))
(set-terminal-parameter frame 'x-setup-function-keys t)))
diff -Nrc emacs-24.4_orig/lisp/term/ns-win.el emacs-24.4_patched/lisp/term/ns-win.el
*** emacs-24.4_orig/lisp/term/ns-win.el 2014-12-07 01:37:58.000000000 +0900
--- emacs-24.4_patched/lisp/term/ns-win.el 2014-12-07 10:40:13.000000000 +0900
***************
*** 168,174 ****
(define-key global-map [ns-new-frame] 'make-frame)
(define-key global-map [ns-toggle-toolbar] 'ns-toggle-toolbar)
(define-key global-map [ns-show-prefs] 'customize)
!
;; Set up a number of aliases and other layers to pretend we're using
;; the Choi/Mitsuharu Carbon port.
--- 168,174 ----
(define-key global-map [ns-new-frame] 'make-frame)
(define-key global-map [ns-toggle-toolbar] 'ns-toggle-toolbar)
(define-key global-map [ns-show-prefs] 'customize)
! (define-key global-map [mac-change-input-method] 'mac-change-input-method)
;; Set up a number of aliases and other layers to pretend we're using
;; the Choi/Mitsuharu Carbon port.
***************
*** 253,266 ****
;; editing window.)
(defface ns-working-text-face
! '((t :underline t))
"Face used to highlight working text during compose sequence insert."
:group 'ns)
(defvar ns-working-overlay nil
"Overlay used to highlight working text during compose sequence insert.
When text is in th echo area, this just stores the length of the working text.")
(defvar ns-working-text) ; nsterm.m
;; Test if in echo area, based on mac-win.el 2007/08/26 unicode-2.
--- 253,282 ----
;; editing window.)
(defface ns-working-text-face
! '((((background dark)) :underline "gray80")
! (t :underline "gray20"))
"Face used to highlight working text during compose sequence insert."
:group 'ns)
+ (defface ns-marked-text-face
+ '((((background dark)) :underline "gray80")
+ (t :underline "gray20"))
+ "Face used to highlight marked text during compose sequence insert."
+ :group 'ns)
+
+ (defface ns-unmarked-text-face
+ '((((background dark)) :underline "gray20")
+ (t :underline "gray80"))
+ "Face used to highlight marked text during compose sequence insert."
+ :group 'ns)
+
(defvar ns-working-overlay nil
"Overlay used to highlight working text during compose sequence insert.
When text is in th echo area, this just stores the length of the working text.")
+ (defvar ns-marked-overlay nil
+ "Overlay used to highlight marked text during compose sequence insert.")
+
(defvar ns-working-text) ; nsterm.m
;; Test if in echo area, based on mac-win.el 2007/08/26 unicode-2.
***************
*** 268,284 ****
(defun ns-in-echo-area ()
"Whether, for purposes of inserting working composition text, the minibuffer
is currently being used."
! (or isearch-mode
! (and cursor-in-echo-area (current-message))
! ;; Overlay strings are not shown in some cases.
! (get-char-property (point) 'invisible)
! (and (not (bobp))
! (or (and (get-char-property (point) 'display)
! (eq (get-char-property (1- (point)) 'display)
! (get-char-property (point) 'display)))
! (and (get-char-property (point) 'composition)
! (eq (get-char-property (1- (point)) 'composition)
! (get-char-property (point) 'composition)))))))
;; The 'interactive' here stays for subinvocations, so the ns-in-echo-area
;; always returns nil for some reason. If this WASN'T the case, we could
--- 284,304 ----
(defun ns-in-echo-area ()
"Whether, for purposes of inserting working composition text, the minibuffer
is currently being used."
! (setq mac-in-echo-area
! (or isearch-mode
! (and cursor-in-echo-area (current-message))
! ;; Overlay strings are not shown in some cases.
! (get-char-property (point) 'invisible)
! (and (not (bobp))
! (or (and (get-char-property (point) 'display)
! (eq (get-char-property (1- (point)) 'display)
! (get-char-property (point) 'display)))
! (and (get-char-property (point) 'composition)
! (eq (get-char-property (1- (point)) 'composition)
! (get-char-property (point) 'composition)))))))
! mac-in-echo-area)
!
!
;; The 'interactive' here stays for subinvocations, so the ns-in-echo-area
;; always returns nil for some reason. If this WASN'T the case, we could
***************
*** 308,326 ****
(defun ns-echo-working-text ()
"Echo contents of `ns-working-text' in message display area.
See `ns-insert-working-text'."
- (ns-delete-working-text)
(let* ((msg (current-message))
! (msglen (length msg))
! message-log-max)
(setq ns-working-overlay (length ns-working-text))
(setq msg (concat msg ns-working-text))
(put-text-property msglen (+ msglen ns-working-overlay)
'face 'ns-working-text-face msg)
(message "%s" msg)))
(defun ns-delete-working-text()
! "Delete working text and clear `ns-working-overlay'."
(interactive)
(cond
((and (overlayp ns-working-overlay)
;; Still alive?
--- 328,407 ----
(defun ns-echo-working-text ()
"Echo contents of `ns-working-text' in message display area.
See `ns-insert-working-text'."
(let* ((msg (current-message))
! (msglen (length msg))
! message-log-max)
! (if (integerp ns-working-overlay)
! (progn
! (setq msg (substring msg 0 (- (length msg) ns-working-overlay)))
! (setq msglen (length msg))))
(setq ns-working-overlay (length ns-working-text))
(setq msg (concat msg ns-working-text))
(put-text-property msglen (+ msglen ns-working-overlay)
'face 'ns-working-text-face msg)
(message "%s" msg)))
+ (defun ns-put-marked-text (event)
+ (interactive "e")
+ (let ((pos (nth 1 event))
+ (len (nth 2 event)))
+ (if (ns-in-echo-area)
+ (ns-echo-marked-text pos len)
+ (ns-insert-marked-text pos len))))
+
+ (defun ns-insert-marked-text (pos len)
+ "Insert contents of `ns-working-text' as UTF-8 string and mark with
+ `ns-working-overlay' and `ns-marked-overlay'. Any previously existing
+ working text is cleared first. The overlay is assigned the faces
+ `ns-working-text-face' and `ns-marked-text-face'."
+ (ns-delete-working-text)
+ (let ((start (point)))
+ (if (<= pos (length ns-working-text))
+ (progn
+ (put-text-property pos len 'face 'ns-working-text-face ns-working-text)
+ (insert ns-working-text)
+ (if (= len 0)
+ (overlay-put (setq ns-working-overlay
+ (make-overlay start (point) (current-buffer) nil t))
+ 'face 'ns-working-text-face)
+ (overlay-put (setq ns-working-overlay
+ (make-overlay start (point) (current-buffer) nil t))
+ 'face 'ns-unmarked-text-face)
+ (overlay-put (setq ns-marked-overlay
+ (make-overlay (+ start pos) (+ start pos len)
+ (current-buffer) nil t))
+ 'face 'ns-marked-text-face))
+ (goto-char (+ start pos))))))
+
+ (defun ns-echo-marked-text (pos len)
+ "Echo contents of `ns-working-text' in message display area.
+ See `ns-insert-working-text'."
+ (let* ((msg (current-message))
+ (msglen (length msg))
+ message-log-max)
+ (when (integerp ns-working-overlay)
+ (setq msg (substring msg 0 (- (length msg) ns-working-overlay)))
+ (setq msglen (length msg)))
+ (setq ns-working-overlay (length ns-working-text))
+ (setq msg (concat msg ns-working-text))
+ (if (= len 0)
+ (put-text-property msglen (+ msglen ns-working-overlay)
+ 'face 'ns-working-text-face msg)
+ (put-text-property msglen (+ msglen ns-working-overlay)
+ 'face 'ns-unmarked-text-face msg)
+ (put-text-property (+ msglen pos) (+ msglen pos len)
+ 'face 'ns-marked-text-face msg))
+ (message "%s" msg)))
+
(defun ns-delete-working-text()
! "Delete working text and clear `ns-working-overlay' and `ns-marked-overlay'."
(interactive)
+ (when (and (overlayp ns-marked-overlay)
+ ;; Still alive
+ (overlay-buffer ns-marked-overlay))
+ (with-current-buffer (overlay-buffer ns-marked-overlay)
+ (delete-overlay ns-marked-overlay)))
+ (setq ns-marked-overlay nil)
(cond
((and (overlayp ns-working-overlay)
;; Still alive?
***************
*** 963,968 ****
--- 1044,1509 ----
(add-to-list 'frame-creation-function-alist '(ns . x-create-frame-with-faces))
(add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system))
+
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ ;;
+ ;; Implementation of Input Method Extension for MacOS X
+ ;; written by Taiichi Hashimoto <taiichi2@mac.com>
+ ;;
+
+ (defvar mac-input-method-parameters
+ '(
+ ("com.apple.inputmethod.Kotoeri.Roman"
+ (title . "A")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.Kotoeri.Japanese"
+ (title . "あ")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.Kotoeri.Japanese.Katakana"
+ (title . "ア")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.Kotoeri.Japanese.FullWidthRoman"
+ (title . "A")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.Kotoeri.Japanese.HalfWidthKana"
+ (title . "ア")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.kotoeri.Ainu"
+ (title . "アイヌ")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.Korean.2SetKorean"
+ (title . "가2")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.Korean.3SetKorean"
+ (title . "가3")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.Korean.390Sebulshik"
+ (title . "가5")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.Korean.GongjinCheongRomaja"
+ (title . "가G")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.Korean.HNCRomaja"
+ (title . "가H")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.Tamil.AnjalIM"
+ (title . "Anjal")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.Tamil.Tamil99"
+ (title . "Tamil")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.VietnameseIM.VietnameseSimpleTelex"
+ (title . "ST")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.VietnameseIM.VietnameseTelex"
+ (title . "TX")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.VietnameseIM.VietnameseVNI"
+ (title . "VN")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.VietnameseIM.VietnameseVIQR"
+ (title . "VQ")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.SCIM.ITABC"
+ (title . "拼")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.SCIM.WBX"
+ (title . "型")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.SCIM.WBH"
+ (title . "画")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.TCIM.Zhuyin"
+ (title . "注")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.TCIM.Pinyin"
+ (title . "拼")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.TCIM.Cangjie"
+ (title . "倉")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.TCIM.Jianyi"
+ (title . "速")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.TCIM.Dayi"
+ (title . "易")
+ (cursor-color)
+ (cursor-type))
+ ("com.apple.inputmethod.TCIM.Hanin"
+ (title . "漢")
+ (cursor-color)
+ (cursor-type))
+ ("com.google.inputmethod.Japanese.Roman"
+ (title . "G")
+ (cursor-color)
+ (cursor-type))
+ ("com.google.inputmethod.Japanese.base"
+ (title . "ぐ")
+ (cursor-color)
+ (cursor-type))
+ ("com.google.inputmethod.Japanese.Katakana"
+ (title . "グ")
+ (cursor-color)
+ (cursor-type))
+ ("com.google.inputmethod.Japanese.FullWidthRoman"
+ (title . "G")
+ (cursor-color)
+ (cursor-type))
+ ("com.google.inputmethod.Japanese.HalfWidthKana"
+ (title . "グ")
+ (cursor-color)
+ (cursor-type))
+ ("jp.monokakido.inputmethod.Kawasemi.Roman"
+ (title . "K")
+ (cursor-color)
+ (cursor-type))
+ ("jp.monokakido.inputmethod.Kawasemi.Japanese"
+ (title . "か")
+ (cursor-color)
+ (cursor-type))
+ ("jp.monokakido.inputmethod.Kawasemi.Japanese.Katakana"
+ (title . "カ")
+ (cursor-color)
+ (cursor-type))
+ ("jp.monokakido.inputmethod.Kawasemi.Japanese.FullWidthRoman"
+ (title . "K")
+ (cursor-color)
+ (cursor-type))
+ ("jp.monokakido.inputmethod.Kawasemi.Japanese.HalfWidthKana"
+ (title . "カ")
+ (cursor-color)
+ (cursor-type))
+ ("jp.monokakido.inputmethod.Kawasemi.Japanese.HalfWidthRoman"
+ (title . "_K")
+ (cursor-color)
+ (cursor-type))
+ ("jp.monokakido.inputmethod.Kawasemi.Japanese.Code"
+ (title . "C")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok21.Roman"
+ (title . "A")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok21.Japanese"
+ (title . "あ")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok21.Japanese.Katakana"
+ (title . "ア")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok21.Japanese.FullWidthRoman"
+ (title . "英")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok21.Japanese.HalfWidthEiji"
+ (title . "半英")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok22.Roman"
+ (title . "A")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok22.Japanese"
+ (title . "あ")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok22.Japanese.Katakana"
+ (title . "ア")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok22.Japanese.FullWidthRoman"
+ (title . "英")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok22.Japanese.HalfWidthEiji"
+ (title . "半英")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok23.Roman"
+ (title . "A")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok23.Japanese"
+ (title . "あ")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok23.Japanese.Katakana"
+ (title . "ア")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok23.Japanese.FullWidthRoman"
+ (title . "英")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok23.Japanese.HalfWidthEiji"
+ (title . "半英")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok24.Roman"
+ (title . "A")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok24.Japanese"
+ (title . "あ")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok24.Japanese.Katakana"
+ (title . "ア")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok24.Japanese.FullWidthRoman"
+ (title . "英")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok24.Japanese.HalfWidthEiji"
+ (title . "半英")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok25.Roman"
+ (title . "A")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok25.Japanese"
+ (title . "あ")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok25.Japanese.Katakana"
+ (title . "ア")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok25.Japanese.FullWidthRoman"
+ (title . "英")
+ (cursor-color)
+ (cursor-type))
+ ("com.justsystems.inputmethod.atok25.Japanese.HalfWidthEiji"
+ (title . "半英")
+ (cursor-color)
+ (cursor-type))
+ )
+ "Alist of Mac script code vs parameters for input method on MacOSX.")
+
+
+ (defun mac-get-input-method-parameter (is key)
+ "Function to get a parameter of a input method."
+ (interactive)
+ (assq key (cdr (assoc is mac-input-method-parameters))))
+
+ (defun mac-get-input-method-title (&optional input-source)
+ "Return input method title of input source.
+ If input-source is nil, return one of current frame."
+ (if input-source
+ (cdr (mac-get-input-method-parameter input-source 'title))
+ current-input-method-title))
+
+ (defun mac-get-cursor-type (&optional input-source)
+ "Return cursor type of input source.
+ If input-source is nil, return one of current frame."
+ (if input-source
+ (or (cdr (mac-get-input-method-parameter input-source 'cursor-type))
+ (cdr (assq 'cursor-type default-frame-alist))
+ cursor-type)
+ (cdr (assq 'cursor-type (frame-parameters (selected-frame))))))
+
+ (defun mac-get-cursor-color (&optional input-source)
+ "Return cursor color of input source.
+ If input-source is nil, return one of current frame."
+ (if input-source
+ (or (cdr (mac-get-input-method-parameter input-source 'cursor-color))
+ (cdr (assq 'cursor-color default-frame-alist)))
+ (cdr (assq 'cursor-color (frame-parameters (selected-frame))))))
+
+
+ (defun mac-set-input-method-parameter (is key value)
+ "Function to set a parameter of a input method."
+ (let* ((is-param (assoc is mac-input-method-parameters))
+ (param (assq key is-param)))
+ (if is-param
+ (if param
+ (setcdr param value)
+ (setcdr is-param (cons (cons key value) (cdr is-param))))
+ (setq mac-input-method-parameters
+ (cons (list is (cons key value))
+ mac-input-method-parameters)))))
+
+
+ (defun mac-input-method-update (is)
+ "Funtion to update parameters of a input method."
+ (interactive)
+
+ (let ((title (mac-get-input-method-title is))
+ (type (mac-get-cursor-type is))
+ (color (mac-get-cursor-color is)))
+ (if (and title (not (equal title (mac-get-input-method-title))))
+ (setq current-input-method-title title))
+ (if (and type (not (equal type (mac-get-cursor-type))))
+ (setq cursor-type type))
+ (if (and color (not (equal color (mac-get-cursor-color))))
+ (set-cursor-color color))
+ (force-mode-line-update)
+ (if isearch-mode (isearch-update))))
+
+
+ (defun mac-toggle-input-method (&optional arg)
+ "Function to toggle input method on MacOSX."
+ (interactive)
+
+ (if arg
+ (progn
+ (make-local-variable 'input-method-function)
+ (setq inactivate-current-input-method-function 'mac-toggle-input-method)
+ (setq input-method-function nil)
+ (setq describe-current-input-method-function nil)
+ (mac-toggle-input-source t))
+ (kill-local-variable 'input-method-function)
+ (setq describe-current-input-method-function nil)
+ (mac-toggle-input-source nil)))
+
+
+ (defun mac-change-language-to-us ()
+ "Function to change language to us."
+ (interactive)
+ (mac-toggle-input-method nil))
+
+
+ (defun mac-handle-input-method-change ()
+ "Function run when a input method change."
+ (interactive)
+
+ (if (equal default-input-method "MacOSX")
+ (let ((input-source (mac-get-current-input-source))
+ (ascii-capable (mac-input-source-is-ascii-capable)))
+
+ (cond ((and (not current-input-method) (not ascii-capable))
+ (set-input-method "MacOSX"))
+ ((and (equal current-input-method "MacOSX") ascii-capable)
+ (toggle-input-method nil)))
+ (mac-input-method-update input-source))))
+
+ ;;
+ ;; Emacs input method for input method on MacOSX.
+ ;;
+ (register-input-method "MacOSX" "MacOSX" 'mac-toggle-input-method
+ "Mac" "Input Method on MacOSX System")
+
+
+ ;;
+ ;; Minor mode of using input methods on MacOS X
+ ;;
+ (define-minor-mode mac-input-method-mode
+ "Use input methods on MacOSX."
+ :init-value nil
+ :group 'ns
+ :global t
+
+ (if mac-input-method-mode
+ (progn
+ (setq default-input-method "MacOSX")
+ (add-hook 'minibuffer-setup-hook 'mac-change-language-to-us)
+ (mac-translate-from-yen-to-backslash))
+ (setq default-input-method nil)))
+
+ ;;
+ ;; Valiable and functions to pass key(shortcut) to system.
+ ;;
+ (defvar mac-keys-passed-to-system nil
+ "A list of keys passed to system on MacOSX.")
+
+ (defun mac-add-key-passed-to-system (key)
+ (let ((shift '(shift shft))
+ (control '(control ctrl ctl))
+ (option '(option opt alternate alt))
+ (command '(command cmd)))
+
+ (add-to-list 'mac-keys-passed-to-system
+ (cond ((symbolp key)
+ (cond ((memq key shift)
+ (cons ns-shift-key-mask nil))
+ ((memq key control)
+ (cons ns-control-key-mask nil))
+ ((memq key option)
+ (cons ns-alternate-key-mask nil))
+ ((memq key command)
+ (cons ns-command-key-mask nil))
+ (t (cons nil nil))))
+ ((numberp key) (cons 0 key))
+ ((listp key)
+ (let ((l key) (k nil) (m 0))
+ (while l
+ (cond ((memq (car l) shift)
+ (setq m (logior m ns-shift-key-mask)))
+ ((memq (car l) control)
+ (setq m (logior m ns-control-key-mask)))
+ ((memq (car l) option)
+ (setq m (logior m ns-alternate-key-mask)))
+ ((memq (car l) command)
+ (setq m (logior m ns-command-key-mask)))
+ ((numberp (car l))
+ (if (not k) (setq k (car l)))))
+ (setq l (cdr l)))
+ (cons m k)))
+ (t (cons nil nil))))))
+
+
+ ;;
+ ;; Entry Emacs event for inline input method on MacOSX.
+ ;;
+ (define-key special-event-map
+ [mac-change-input-method] 'mac-handle-input-method-change)
+
+ ;;
+ ;; Convert yen to backslash for JIS keyboard.
+ ;;
+ (defun mac-translate-from-yen-to-backslash ()
+ ;; Convert yen to backslash for JIS keyboard.
+ (interactive)
+
+ (define-key global-map [165] nil)
+ (define-key global-map [2213] nil)
+ (define-key global-map [3420] nil)
+ (define-key global-map [67109029] nil)
+ (define-key global-map [67111077] nil)
+ (define-key global-map [8388773] nil)
+ (define-key global-map [134219941] nil)
+ (define-key global-map [75497596] nil)
+ (define-key global-map [201328805] nil)
+ (define-key function-key-map [165] [?\\])
+ (define-key function-key-map [2213] [?\\]) ;; for Intel
+ (define-key function-key-map [3420] [?\\]) ;; for PowerPC
+ (define-key function-key-map [67109029] [?\C-\\])
+ (define-key function-key-map [67111077] [?\C-\\])
+ (define-key function-key-map [8388773] [?\M-\\])
+ (define-key function-key-map [134219941] [?\M-\\])
+ (define-key function-key-map [75497596] [?\C-\M-\\])
+ (define-key function-key-map [201328805] [?\C-\M-\\])
+ )
+
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(provide 'ns-win)
diff -Nrc emacs-24.4_orig/src/Makefile.in emacs-24.4_patched/src/Makefile.in
*** emacs-24.4_orig/src/Makefile.in 2014-12-07 01:37:59.000000000 +0900
--- emacs-24.4_patched/src/Makefile.in 2014-12-07 01:53:48.000000000 +0900
***************
*** 367,374 ****
SOME_MACHINE_OBJECTS = dosfns.o msdos.o \
xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \
fontset.o dbusbind.o cygw32.o \
! nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o macfont.o \
! w32.o w32console.o w32fns.o w32heap.o w32inevt.o w32notify.o \
w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \
w16select.o widget.o xfont.o ftfont.o xftfont.o ftxfont.o gtkutil.o \
xsettings.o xgselect.o termcap.o
--- 367,374 ----
SOME_MACHINE_OBJECTS = dosfns.o msdos.o \
xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \
fontset.o dbusbind.o cygw32.o \
! nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o macfont.o macim.o \
! w32.o w32console.o w32fns.o w32heap.o w32inevt.o \
w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \
w16select.o widget.o xfont.o ftfont.o xftfont.o ftxfont.o gtkutil.o \
xsettings.o xgselect.o termcap.o
diff -Nrc emacs-24.4_orig/src/keyboard.c emacs-24.4_patched/src/keyboard.c
*** emacs-24.4_orig/src/keyboard.c 2014-12-07 01:37:59.000000000 +0900
--- emacs-24.4_patched/src/keyboard.c 2014-12-07 01:58:47.000000000 +0900
***************
*** 3964,3971 ****
{
if (event->code == KEY_NS_PUT_WORKING_TEXT)
obj = list1 (intern ("ns-put-working-text"));
! else
obj = list1 (intern ("ns-unput-working-text"));
kbd_fetch_ptr = event + 1;
if (used_mouse_menu)
*used_mouse_menu = 1;
--- 3964,3973 ----
{
if (event->code == KEY_NS_PUT_WORKING_TEXT)
obj = list1 (intern ("ns-put-working-text"));
! else if (event->code == KEY_NS_UNPUT_WORKING_TEXT)
obj = list1 (intern ("ns-unput-working-text"));
+ else if (event->code == KEY_NS_PUT_MARKED_TEXT)
+ obj = Fcons (intern ("ns-put-marked-text"), event->arg);
kbd_fetch_ptr = event + 1;
if (used_mouse_menu)
*used_mouse_menu = 1;
***************
*** 11706,11711 ****
--- 11708,11715 ----
"ns-put-working-text");
initial_define_lispy_key (Vspecial_event_map, "ns-unput-working-text",
"ns-unput-working-text");
+ initial_define_lispy_key (Vspecial_event_map, "ns-put-marked-text",
+ "ns-put-marked-text");
/* Here we used to use `ignore-event' which would simple set prefix-arg to
current-prefix-arg, as is done in `handle-switch-frame'.
But `handle-switch-frame is not run from the special-map.
diff -Nrc emacs-24.4_orig/src/macim.m emacs-24.4_patched/src/macim.m
*** emacs-24.4_orig/src/macim.m 1970-01-01 09:00:00.000000000 +0900
--- emacs-24.4_patched/src/macim.m 2014-12-07 02:02:10.000000000 +0900
***************
*** 0 ****
--- 1,173 ----
+ /* Implementation of Input Method Extension for MacOS X.
+ Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+ Taiichi Hashimoto <taiichi2@mac.com>.
+ */
+
+ #include "config.h"
+
+ #ifdef NS_IMPL_COCOA
+
+ #include <math.h>
+ #include <sys/types.h>
+ #include <time.h>
+ #include <signal.h>
+ #include <unistd.h>
+
+ #include <Carbon/Carbon.h>
+
+ #include "lisp.h"
+ #include "blockinput.h"
+
+ #include "termhooks.h"
+ #include "keyboard.h"
+ #include "buffer.h"
+
+ //extern Lisp_Object Qcurrent_input_method;
+ //extern int cursor_in_echo_area;
+ static Lisp_Object Qmac_keys_passed_to_system;
+
+ void mac_init_input_method ();
+ int mac_pass_key_to_system (int code, int modifiers);
+ int mac_pass_key_directly_to_emacs ();
+ int mac_store_change_input_method_event ();
+
+ DEFUN ("mac-input-source-is-ascii-capable", Fmac_input_source_is_ascii_capable, Smac_input_source_is_ascii_capable,
+ 0, 0, 0,
+ doc: /* Is current input source ascii capable? */)
+ (void)
+ {
+ TISInputSourceRef is = TISCopyCurrentKeyboardInputSource();
+ CFBooleanRef ret = TISGetInputSourceProperty(is, kTISPropertyInputSourceIsASCIICapable);
+
+ return CFBooleanGetValue(ret)? Qt : Qnil;
+ }
+
+ DEFUN ("mac-get-input-source-list", Fmac_get_input_source_list, Smac_get_input_source_list,
+ 0, 0, 0,
+ doc: /* get input source list on MacOSX */)
+ (void)
+ {
+ NSArray *is_list = (NSArray *)TISCreateInputSourceList(NULL, false);
+ int list_size = [is_list count];
+ Lisp_Object list[list_size];
+ int i;
+
+ for (i = 0; i < list_size; i++) {
+ TISInputSourceRef is = (TISInputSourceRef)[is_list objectAtIndex:i];
+ NSString *id = (NSString *)TISGetInputSourceProperty(is, kTISPropertyInputSourceID);
+ list[i] = make_string([id UTF8String],
+ [id lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
+ }
+
+ return Flist(list_size, list);
+ }
+
+ DEFUN ("mac-get-current-input-source", Fmac_get_current_input_source, Smac_get_current_input_source,
+ 0, 0, 0,
+ doc: /* get current input source on MacOSX */)
+ (void)
+ {
+ TISInputSourceRef is = TISCopyCurrentKeyboardInputSource();
+ NSString *id = (NSString *)TISGetInputSourceProperty(is, kTISPropertyInputSourceID);
+
+ return make_string([id UTF8String],
+ [id lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
+ }
+
+ DEFUN ("mac-toggle-input-source", Fmac_toggle_input_source, Smac_toggle_input_source,
+ 1, 1, 0,
+ doc: /* toggle input source on MacOSX */)
+ (arg)
+ Lisp_Object arg;
+ {
+ TISInputSourceRef is = NULL;
+
+ if (NILP (arg))
+ {
+ is = TISCopyCurrentASCIICapableKeyboardInputSource();
+ }
+ else
+ {
+ NSString *locale;
+ NSArray *languages = [NSLocale preferredLanguages];
+ if (languages != nil) {
+ locale = [languages objectAtIndex:0];
+ } else {
+ locale = [[NSLocale currentLocale]
+ objectForKey:NSLocaleLanguageCode];
+ }
+ is = TISCopyInputSourceForLanguage((CFStringRef)locale);
+ }
+ if (is) TISSelectInputSource(is);
+
+ return arg;
+ }
+
+ int
+ mac_store_change_input_method_event ()
+ {
+ Lisp_Object dim;
+ int ret = FALSE;
+
+ dim = Fsymbol_value (intern ("default-input-method"));
+ if (STRINGP (dim) && strcmp(SDATA (dim), "MacOSX") == 0)
+ {
+ ret = TRUE;
+ }
+
+ return ret;
+ }
+
+ int
+ mac_pass_key_to_system (int code, int modifiers)
+ {
+ Lisp_Object keys = Fsymbol_value (Qmac_keys_passed_to_system);
+ Lisp_Object m, k;
+
+ while (!NILP (keys))
+ {
+ m = XCAR (XCAR (keys));
+ k = XCDR (XCAR (keys));
+ keys = XCDR (keys);
+
+ if (NUMBERP (m) && modifiers == XINT (m))
+ if (NILP (k)
+ || (NUMBERP (k) && code == XINT (k)))
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+ int
+ mac_pass_key_directly_to_emacs (void)
+ {
+
+ if (NILP (Fmac_input_source_is_ascii_capable()))
+ {
+ if (NILP (Vmac_use_input_method_on_system)
+ || this_command_key_count
+ || cursor_in_echo_area
+ || !NILP (BVAR (current_buffer, read_only)))
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+
+ void mac_init_input_method (void)
+ {
+ Qmac_keys_passed_to_system = intern ("mac-keys-passed-to-system");
+ staticpro (&Qmac_keys_passed_to_system);
+
+ DEFVAR_LISP ("mac-use-input-method-on-system", Vmac_use_input_method_on_system,
+ doc: /* If it is non-nil, use input method on system. */);
+ Vmac_use_input_method_on_system = Qt;
+
+ defsubr (&Smac_input_source_is_ascii_capable);
+ defsubr (&Smac_get_input_source_list);
+ defsubr (&Smac_get_current_input_source);
+ defsubr (&Smac_toggle_input_source);
+ }
+ #endif
diff -Nrc emacs-24.4_orig/src/nsfns.m emacs-24.4_patched/src/nsfns.m
*** emacs-24.4_orig/src/nsfns.m 2014-12-07 01:37:59.000000000 +0900
--- emacs-24.4_patched/src/nsfns.m 2014-12-07 02:03:28.000000000 +0900
***************
*** 2944,2949 ****
--- 2944,2967 ----
doc: /* Toolkit version for NS Windowing. */);
Vns_version_string = ns_appkit_version_str ();
+
+ DEFVAR_LISP ("ns-shift-key-mask", Vns_shift_key_mask,
+ doc: /* Shift key mask defined in system. */);
+ Vns_shift_key_mask = make_number (NSShiftKeyMask);
+
+ DEFVAR_LISP ("ns-control-key-mask", Vns_control_key_mask,
+ doc: /* Control key mask defined in system. */);
+ Vns_control_key_mask = make_number (NSControlKeyMask);
+
+ DEFVAR_LISP ("ns-alternate-key-mask", Vns_alternate_key_mask,
+ doc: /* Alternate key mask defined in system. */);
+ Vns_alternate_key_mask = make_number (NSAlternateKeyMask);
+
+ DEFVAR_LISP ("ns-command-key-mask", Vns_command_key_mask,
+ doc: /* Command key mask defined in system. */);
+ Vns_command_key_mask = make_number (NSCommandKeyMask);
+
+
defsubr (&Sns_read_file_name);
defsubr (&Sns_get_resource);
defsubr (&Sns_set_resource);
***************
*** 2987,2992 ****
--- 3005,3014 ----
defsubr (&Sx_show_tip);
defsubr (&Sx_hide_tip);
+ #ifdef NS_IMPL_COCOA
+ mac_init_input_method ();
+ #endif
+
as_status = 0;
as_script = Qnil;
as_result = 0;
diff -Nrc emacs-24.4_orig/src/nsterm.h emacs-24.4_patched/src/nsterm.h
*** emacs-24.4_orig/src/nsterm.h 2014-12-07 01:37:59.000000000 +0900
--- emacs-24.4_patched/src/nsterm.h 2014-12-07 02:03:45.000000000 +0900
***************
*** 483,488 ****
--- 483,490 ----
#define KEY_NS_NEW_FRAME ((1<<28)|(0<<16)|12)
#define KEY_NS_TOGGLE_TOOLBAR ((1<<28)|(0<<16)|13)
#define KEY_NS_SHOW_PREFS ((1<<28)|(0<<16)|14)
+ #define KEY_MAC_CHANGE_INPUT_METHOD ((1<<28)|(0<<16)|15)
+ #define KEY_NS_PUT_MARKED_TEXT ((1<<28)|(0<<16)|16)
/* could use list to store these, but rest of emacs has a big infrastructure
for managing a table of bitmap "records" */
diff -Nrc emacs-24.4_orig/src/nsterm.m emacs-24.4_patched/src/nsterm.m
*** emacs-24.4_orig/src/nsterm.m 2014-12-07 01:37:59.000000000 +0900
--- emacs-24.4_patched/src/nsterm.m 2014-12-07 02:09:10.000000000 +0900
***************
*** 1,29 ****
/* NeXT/Open/GNUstep / MacOSX communication module.
! Copyright (C) 1989, 1993-1994, 2005-2006, 2008-2014 Free Software
! Foundation, Inc.
! This file is part of GNU Emacs.
! GNU Emacs is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! GNU Emacs is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
! You should have received a copy of the GNU General Public License
! along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/*
! Originally by Carl Edman
! Updated by Christian Limpach (chris@nice.ch)
! OpenStep/Rhapsody port by Scott Bender (sbender@harmony-ds.com)
! MacOSX/Aqua port by Christophe de Dinechin (descubes@earthlink.net)
! GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
*/
/* This should be the first include, as it may set up #defines affecting
--- 1,29 ----
/* NeXT/Open/GNUstep / MacOSX communication module.
! Copyright (C) 1989, 1993-1994, 2005-2006, 2008-2014 Free Software
! Foundation, Inc.
! This file is part of GNU Emacs.
! GNU Emacs is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! GNU Emacs is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
! You should have received a copy of the GNU General Public License
! along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/*
! Originally by Carl Edman
! Updated by Christian Limpach (chris@nice.ch)
! OpenStep/Rhapsody port by Scott Bender (sbender@harmony-ds.com)
! MacOSX/Aqua port by Christophe de Dinechin (descubes@earthlink.net)
! GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
*/
/* This should be the first include, as it may set up #defines affecting
***************
*** 73,80 ****
/* call tracing */
#if 0
int term_trace_num = 0;
! #define NSTRACE(x) fprintf (stderr, "%s:%d: [%d] " #x "\n", \
! __FILE__, __LINE__, ++term_trace_num)
#else
#define NSTRACE(x)
#endif
--- 73,80 ----
/* call tracing */
#if 0
int term_trace_num = 0;
! #define NSTRACE(x) fprintf (stderr, "%s:%d: [%d] " #x "\n", \
! __FILE__, __LINE__, ++term_trace_num)
#else
#define NSTRACE(x)
#endif
***************
*** 83,97 ****
#if 0
int term_trace_num = 0;
#define NSTRACE_SIZE(str,size) fprintf (stderr, \
! "%s:%d: [%d] " str \
! " (S:%.0f x %.0f)\n", \
! __FILE__, __LINE__, ++term_trace_num,\
! size.height, \
! size.width)
#define NSTRACE_RECT(s,r) fprintf (stderr, \
"%s:%d: [%d] " s \
" (LL:%.0f x %.0f -> S:%.0f x %.0f)\n", \
! __FILE__, __LINE__, ++term_trace_num,\
r.origin.x, \
r.origin.y, \
r.size.height, \
--- 83,97 ----
#if 0
int term_trace_num = 0;
#define NSTRACE_SIZE(str,size) fprintf (stderr, \
! "%s:%d: [%d] " str \
! " (S:%.0f x %.0f)\n", \
! __FILE__, __LINE__, ++term_trace_num, \
! size.height, \
! size.width)
#define NSTRACE_RECT(s,r) fprintf (stderr, \
"%s:%d: [%d] " s \
" (LL:%.0f x %.0f -> S:%.0f x %.0f)\n", \
! __FILE__, __LINE__, ++term_trace_num, \
r.origin.x, \
r.origin.y, \
r.size.height, \
***************
*** 115,124 ****
#ifdef NS_IMPL_COCOA
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if (ns_use_srgb_colorspace)
! return [NSColor colorWithSRGBRed: red
! green: green
! blue: blue
! alpha: alpha];
#endif
#endif
return [NSColor colorWithCalibratedRed: red
--- 115,124 ----
#ifdef NS_IMPL_COCOA
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if (ns_use_srgb_colorspace)
! return [NSColor colorWithSRGBRed: red
! green: green
! blue: blue
! alpha: alpha];
#endif
#endif
return [NSColor colorWithCalibratedRed: red
***************
*** 142,148 ****
/* ==========================================================================
! Local declarations
========================================================================== */
--- 142,148 ----
/* ==========================================================================
! Local declarations
========================================================================== */
***************
*** 150,231 ****
in keyboard.c (lispy_function_key). I hope this is a correct way
of doing things... */
static unsigned convert_ns_to_X_keysym[] =
! {
! NSHomeFunctionKey, 0x50,
! NSLeftArrowFunctionKey, 0x51,
! NSUpArrowFunctionKey, 0x52,
! NSRightArrowFunctionKey, 0x53,
! NSDownArrowFunctionKey, 0x54,
! NSPageUpFunctionKey, 0x55,
! NSPageDownFunctionKey, 0x56,
! NSEndFunctionKey, 0x57,
! NSBeginFunctionKey, 0x58,
! NSSelectFunctionKey, 0x60,
! NSPrintFunctionKey, 0x61,
! NSClearLineFunctionKey, 0x0B,
! NSExecuteFunctionKey, 0x62,
! NSInsertFunctionKey, 0x63,
! NSUndoFunctionKey, 0x65,
! NSRedoFunctionKey, 0x66,
! NSMenuFunctionKey, 0x67,
! NSFindFunctionKey, 0x68,
! NSHelpFunctionKey, 0x6A,
! NSBreakFunctionKey, 0x6B,
!
! NSF1FunctionKey, 0xBE,
! NSF2FunctionKey, 0xBF,
! NSF3FunctionKey, 0xC0,
! NSF4FunctionKey, 0xC1,
! NSF5FunctionKey, 0xC2,
! NSF6FunctionKey, 0xC3,
! NSF7FunctionKey, 0xC4,
! NSF8FunctionKey, 0xC5,
! NSF9FunctionKey, 0xC6,
! NSF10FunctionKey, 0xC7,
! NSF11FunctionKey, 0xC8,
! NSF12FunctionKey, 0xC9,
! NSF13FunctionKey, 0xCA,
! NSF14FunctionKey, 0xCB,
! NSF15FunctionKey, 0xCC,
! NSF16FunctionKey, 0xCD,
! NSF17FunctionKey, 0xCE,
! NSF18FunctionKey, 0xCF,
! NSF19FunctionKey, 0xD0,
! NSF20FunctionKey, 0xD1,
! NSF21FunctionKey, 0xD2,
! NSF22FunctionKey, 0xD3,
! NSF23FunctionKey, 0xD4,
! NSF24FunctionKey, 0xD5,
!
! NSBackspaceCharacter, 0x08, /* 8: Not on some KBs. */
! NSDeleteCharacter, 0xFF, /* 127: Big 'delete' key upper right. */
! NSDeleteFunctionKey, 0x9F, /* 63272: Del forw key off main array. */
!
! NSTabCharacter, 0x09,
! 0x19, 0x09, /* left tab->regular since pass shift */
! NSCarriageReturnCharacter, 0x0D,
! NSNewlineCharacter, 0x0D,
! NSEnterCharacter, 0x8D,
!
! 0x41|NSNumericPadKeyMask, 0xAE, /* KP_Decimal */
! 0x43|NSNumericPadKeyMask, 0xAA, /* KP_Multiply */
! 0x45|NSNumericPadKeyMask, 0xAB, /* KP_Add */
! 0x4B|NSNumericPadKeyMask, 0xAF, /* KP_Divide */
! 0x4E|NSNumericPadKeyMask, 0xAD, /* KP_Subtract */
! 0x51|NSNumericPadKeyMask, 0xBD, /* KP_Equal */
! 0x52|NSNumericPadKeyMask, 0xB0, /* KP_0 */
! 0x53|NSNumericPadKeyMask, 0xB1, /* KP_1 */
! 0x54|NSNumericPadKeyMask, 0xB2, /* KP_2 */
! 0x55|NSNumericPadKeyMask, 0xB3, /* KP_3 */
! 0x56|NSNumericPadKeyMask, 0xB4, /* KP_4 */
! 0x57|NSNumericPadKeyMask, 0xB5, /* KP_5 */
! 0x58|NSNumericPadKeyMask, 0xB6, /* KP_6 */
! 0x59|NSNumericPadKeyMask, 0xB7, /* KP_7 */
! 0x5B|NSNumericPadKeyMask, 0xB8, /* KP_8 */
! 0x5C|NSNumericPadKeyMask, 0xB9, /* KP_9 */
! 0x1B, 0x1B /* escape */
! };
static Lisp_Object Qmodifier_value;
Lisp_Object Qalt, Qcontrol, Qhyper, Qmeta, Qsuper;
--- 150,231 ----
in keyboard.c (lispy_function_key). I hope this is a correct way
of doing things... */
static unsigned convert_ns_to_X_keysym[] =
! {
! NSHomeFunctionKey, 0x50,
! NSLeftArrowFunctionKey, 0x51,
! NSUpArrowFunctionKey, 0x52,
! NSRightArrowFunctionKey, 0x53,
! NSDownArrowFunctionKey, 0x54,
! NSPageUpFunctionKey, 0x55,
! NSPageDownFunctionKey, 0x56,
! NSEndFunctionKey, 0x57,
! NSBeginFunctionKey, 0x58,
! NSSelectFunctionKey, 0x60,
! NSPrintFunctionKey, 0x61,
! NSClearLineFunctionKey, 0x0B,
! NSExecuteFunctionKey, 0x62,
! NSInsertFunctionKey, 0x63,
! NSUndoFunctionKey, 0x65,
! NSRedoFunctionKey, 0x66,
! NSMenuFunctionKey, 0x67,
! NSFindFunctionKey, 0x68,
! NSHelpFunctionKey, 0x6A,
! NSBreakFunctionKey, 0x6B,
!
! NSF1FunctionKey, 0xBE,
! NSF2FunctionKey, 0xBF,
! NSF3FunctionKey, 0xC0,
! NSF4FunctionKey, 0xC1,
! NSF5FunctionKey, 0xC2,
! NSF6FunctionKey, 0xC3,
! NSF7FunctionKey, 0xC4,
! NSF8FunctionKey, 0xC5,
! NSF9FunctionKey, 0xC6,
! NSF10FunctionKey, 0xC7,
! NSF11FunctionKey, 0xC8,
! NSF12FunctionKey, 0xC9,
! NSF13FunctionKey, 0xCA,
! NSF14FunctionKey, 0xCB,
! NSF15FunctionKey, 0xCC,
! NSF16FunctionKey, 0xCD,
! NSF17FunctionKey, 0xCE,
! NSF18FunctionKey, 0xCF,
! NSF19FunctionKey, 0xD0,
! NSF20FunctionKey, 0xD1,
! NSF21FunctionKey, 0xD2,
! NSF22FunctionKey, 0xD3,
! NSF23FunctionKey, 0xD4,
! NSF24FunctionKey, 0xD5,
!
! NSBackspaceCharacter, 0x08, /* 8: Not on some KBs. */
! NSDeleteCharacter, 0xFF, /* 127: Big 'delete' key upper right. */
! NSDeleteFunctionKey, 0x9F, /* 63272: Del forw key off main array. */
!
! NSTabCharacter, 0x09,
! 0x19, 0x09, /* left tab->regular since pass shift */
! NSCarriageReturnCharacter, 0x0D,
! NSNewlineCharacter, 0x0D,
! NSEnterCharacter, 0x8D,
!
! 0x41|NSNumericPadKeyMask, 0xAE, /* KP_Decimal */
! 0x43|NSNumericPadKeyMask, 0xAA, /* KP_Multiply */
! 0x45|NSNumericPadKeyMask, 0xAB, /* KP_Add */
! 0x4B|NSNumericPadKeyMask, 0xAF, /* KP_Divide */
! 0x4E|NSNumericPadKeyMask, 0xAD, /* KP_Subtract */
! 0x51|NSNumericPadKeyMask, 0xBD, /* KP_Equal */
! 0x52|NSNumericPadKeyMask, 0xB0, /* KP_0 */
! 0x53|NSNumericPadKeyMask, 0xB1, /* KP_1 */
! 0x54|NSNumericPadKeyMask, 0xB2, /* KP_2 */
! 0x55|NSNumericPadKeyMask, 0xB3, /* KP_3 */
! 0x56|NSNumericPadKeyMask, 0xB4, /* KP_4 */
! 0x57|NSNumericPadKeyMask, 0xB5, /* KP_5 */
! 0x58|NSNumericPadKeyMask, 0xB6, /* KP_6 */
! 0x59|NSNumericPadKeyMask, 0xB7, /* KP_7 */
! 0x5B|NSNumericPadKeyMask, 0xB8, /* KP_8 */
! 0x5C|NSNumericPadKeyMask, 0xB9, /* KP_9 */
! 0x1B, 0x1B /* escape */
! };
static Lisp_Object Qmodifier_value;
Lisp_Object Qalt, Qcontrol, Qhyper, Qmeta, Qsuper;
***************
*** 316,388 ****
#define NSRightCommandKeyMask (0x000010 | NSCommandKeyMask)
#define NSLeftAlternateKeyMask (0x000020 | NSAlternateKeyMask)
#define NSRightAlternateKeyMask (0x000040 | NSAlternateKeyMask)
! #define EV_MODIFIERS2(flags) \
! (((flags & NSHelpKeyMask) ? \
! hyper_modifier : 0) \
! | (!EQ (ns_right_alternate_modifier, Qleft) && \
! ((flags & NSRightAlternateKeyMask) \
! == NSRightAlternateKeyMask) ? \
! parse_solitary_modifier (ns_right_alternate_modifier) : 0) \
! | ((flags & NSAlternateKeyMask) ? \
! parse_solitary_modifier (ns_alternate_modifier) : 0) \
! | ((flags & NSShiftKeyMask) ? \
! shift_modifier : 0) \
! | (!EQ (ns_right_control_modifier, Qleft) && \
! ((flags & NSRightControlKeyMask) \
! == NSRightControlKeyMask) ? \
! parse_solitary_modifier (ns_right_control_modifier) : 0) \
! | ((flags & NSControlKeyMask) ? \
! parse_solitary_modifier (ns_control_modifier) : 0) \
! | ((flags & NS_FUNCTION_KEY_MASK) ? \
! parse_solitary_modifier (ns_function_modifier) : 0) \
! | (!EQ (ns_right_command_modifier, Qleft) && \
! ((flags & NSRightCommandKeyMask) \
! == NSRightCommandKeyMask) ? \
! parse_solitary_modifier (ns_right_command_modifier) : 0) \
! | ((flags & NSCommandKeyMask) ? \
! parse_solitary_modifier (ns_command_modifier):0))
#define EV_MODIFIERS(e) EV_MODIFIERS2 ([e modifierFlags])
! #define EV_UDMODIFIERS(e) \
! ((([e type] == NSLeftMouseDown) ? down_modifier : 0) \
! | (([e type] == NSRightMouseDown) ? down_modifier : 0) \
! | (([e type] == NSOtherMouseDown) ? down_modifier : 0) \
! | (([e type] == NSLeftMouseDragged) ? down_modifier : 0) \
! | (([e type] == NSRightMouseDragged) ? down_modifier : 0) \
! | (([e type] == NSOtherMouseDragged) ? down_modifier : 0) \
! | (([e type] == NSLeftMouseUp) ? up_modifier : 0) \
! | (([e type] == NSRightMouseUp) ? up_modifier : 0) \
! | (([e type] == NSOtherMouseUp) ? up_modifier : 0))
!
! #define EV_BUTTON(e) \
! ((([e type] == NSLeftMouseDown) || ([e type] == NSLeftMouseUp)) ? 0 : \
! (([e type] == NSRightMouseDown) || ([e type] == NSRightMouseUp)) ? 2 : \
! [e buttonNumber] - 1)
/* Convert the time field to a timestamp in milliseconds. */
#define EV_TIMESTAMP(e) ([e timestamp] * 1000)
/* This is a piece of code which is common to all the event handling
methods. Maybe it should even be a function. */
! #define EV_TRAILER(e) \
! { \
! XSETFRAME (emacs_event->frame_or_window, emacsframe); \
! EV_TRAILER2 (e); \
}
! #define EV_TRAILER2(e) \
! { \
! if (e) emacs_event->timestamp = EV_TIMESTAMP (e); \
! if (q_event_ptr) \
! { \
! n_emacs_events_pending++; \
! kbd_buffer_store_event_hold (emacs_event, q_event_ptr); \
! } \
! else \
! hold_event (emacs_event); \
! EVENT_INIT (*emacs_event); \
! ns_send_appdefined (-1); \
! }
/* TODO: get rid of need for these forward declarations */
static void ns_condemn_scroll_bars (struct frame *f);
--- 316,388 ----
#define NSRightCommandKeyMask (0x000010 | NSCommandKeyMask)
#define NSLeftAlternateKeyMask (0x000020 | NSAlternateKeyMask)
#define NSRightAlternateKeyMask (0x000040 | NSAlternateKeyMask)
! #define EV_MODIFIERS2(flags) \
! (((flags & NSHelpKeyMask) ? \
! hyper_modifier : 0) \
! | (!EQ (ns_right_alternate_modifier, Qleft) && \
! ((flags & NSRightAlternateKeyMask) \
! == NSRightAlternateKeyMask) ? \
! parse_solitary_modifier (ns_right_alternate_modifier) : 0) \
! | ((flags & NSAlternateKeyMask) ? \
! parse_solitary_modifier (ns_alternate_modifier) : 0) \
! | ((flags & NSShiftKeyMask) ? \
! shift_modifier : 0) \
! | (!EQ (ns_right_control_modifier, Qleft) && \
! ((flags & NSRightControlKeyMask) \
! == NSRightControlKeyMask) ? \
! parse_solitary_modifier (ns_right_control_modifier) : 0) \
! | ((flags & NSControlKeyMask) ? \
! parse_solitary_modifier (ns_control_modifier) : 0) \
! | ((flags & NS_FUNCTION_KEY_MASK) ? \
! parse_solitary_modifier (ns_function_modifier) : 0) \
! | (!EQ (ns_right_command_modifier, Qleft) && \
! ((flags & NSRightCommandKeyMask) \
! == NSRightCommandKeyMask) ? \
! parse_solitary_modifier (ns_right_command_modifier) : 0) \
! | ((flags & NSCommandKeyMask) ? \
! parse_solitary_modifier (ns_command_modifier):0))
#define EV_MODIFIERS(e) EV_MODIFIERS2 ([e modifierFlags])
! #define EV_UDMODIFIERS(e) \
! ((([e type] == NSLeftMouseDown) ? down_modifier : 0) \
! | (([e type] == NSRightMouseDown) ? down_modifier : 0) \
! | (([e type] == NSOtherMouseDown) ? down_modifier : 0) \
! | (([e type] == NSLeftMouseDragged) ? down_modifier : 0) \
! | (([e type] == NSRightMouseDragged) ? down_modifier : 0) \
! | (([e type] == NSOtherMouseDragged) ? down_modifier : 0) \
! | (([e type] == NSLeftMouseUp) ? up_modifier : 0) \
! | (([e type] == NSRightMouseUp) ? up_modifier : 0) \
! | (([e type] == NSOtherMouseUp) ? up_modifier : 0))
!
! #define EV_BUTTON(e) \
! ((([e type] == NSLeftMouseDown) || ([e type] == NSLeftMouseUp)) ? 0 : \
! (([e type] == NSRightMouseDown) || ([e type] == NSRightMouseUp)) ? 2 : \
! [e buttonNumber] - 1)
/* Convert the time field to a timestamp in milliseconds. */
#define EV_TIMESTAMP(e) ([e timestamp] * 1000)
/* This is a piece of code which is common to all the event handling
methods. Maybe it should even be a function. */
! #define EV_TRAILER(e) \
! { \
! XSETFRAME (emacs_event->frame_or_window, emacsframe); \
! EV_TRAILER2 (e); \
}
! #define EV_TRAILER2(e) \
! { \
! if (e) emacs_event->timestamp = EV_TIMESTAMP (e); \
! if (q_event_ptr) \
! { \
! n_emacs_events_pending++; \
! kbd_buffer_store_event_hold (emacs_event, q_event_ptr); \
! } \
! else \
! hold_event (emacs_event); \
! EVENT_INIT (*emacs_event); \
! ns_send_appdefined (-1); \
! }
/* TODO: get rid of need for these forward declarations */
static void ns_condemn_scroll_bars (struct frame *f);
***************
*** 392,398 ****
/* ==========================================================================
! Utilities
========================================================================== */
--- 392,398 ----
/* ==========================================================================
! Utilities
========================================================================== */
***************
*** 544,550 ****
static void
ns_timeout (int usecs)
/* --------------------------------------------------------------------------
! Blocking timer utility used by ns_ring_bell
-------------------------------------------------------------------------- */
{
struct timespec wakeup = timespec_add (current_timespec (),
--- 544,550 ----
static void
ns_timeout (int usecs)
/* --------------------------------------------------------------------------
! Blocking timer utility used by ns_ring_bell
-------------------------------------------------------------------------- */
{
struct timespec wakeup = timespec_add (current_timespec (),
***************
*** 567,593 ****
void
ns_release_object (void *obj)
/* --------------------------------------------------------------------------
! Release an object (callable from C)
-------------------------------------------------------------------------- */
{
! [(id)obj release];
}
void
ns_retain_object (void *obj)
/* --------------------------------------------------------------------------
! Retain an object (callable from C)
-------------------------------------------------------------------------- */
{
! [(id)obj retain];
}
void *
ns_alloc_autorelease_pool (void)
/* --------------------------------------------------------------------------
! Allocate a pool for temporary objects (callable from C)
-------------------------------------------------------------------------- */
{
return [[NSAutoreleasePool alloc] init];
--- 567,593 ----
void
ns_release_object (void *obj)
/* --------------------------------------------------------------------------
! Release an object (callable from C)
-------------------------------------------------------------------------- */
{
! [(id)obj release];
}
void
ns_retain_object (void *obj)
/* --------------------------------------------------------------------------
! Retain an object (callable from C)
-------------------------------------------------------------------------- */
{
! [(id)obj retain];
}
void *
ns_alloc_autorelease_pool (void)
/* --------------------------------------------------------------------------
! Allocate a pool for temporary objects (callable from C)
-------------------------------------------------------------------------- */
{
return [[NSAutoreleasePool alloc] init];
***************
*** 597,603 ****
void
ns_release_autorelease_pool (void *pool)
/* --------------------------------------------------------------------------
! Free a pool and temporary objects it refers to (callable from C)
-------------------------------------------------------------------------- */
{
ns_release_object (pool);
--- 597,603 ----
void
ns_release_autorelease_pool (void *pool)
/* --------------------------------------------------------------------------
! Free a pool and temporary objects it refers to (callable from C)
-------------------------------------------------------------------------- */
{
ns_release_object (pool);
***************
*** 607,613 ****
/* ==========================================================================
! Focus (clipping) and screen update
========================================================================== */
--- 607,613 ----
/* ==========================================================================
! Focus (clipping) and screen update
========================================================================== */
***************
*** 739,751 ****
#ifdef NS_IMPL_COCOA
if ([view isFullscreen] && [view fsIsNative])
! {
! // Fix reappearing tool bar in fullscreen for OSX 10.7
! BOOL tbar_visible = FRAME_EXTERNAL_TOOL_BAR (f) ? YES : NO;
! NSToolbar *toolbar = [FRAME_NS_VIEW (f) toolbar];
! if (! tbar_visible != ! [toolbar isVisible])
! [toolbar setVisible: tbar_visible];
! }
#endif
ns_updating_frame = f;
--- 739,751 ----
#ifdef NS_IMPL_COCOA
if ([view isFullscreen] && [view fsIsNative])
! {
! // Fix reappearing tool bar in fullscreen for OSX 10.7
! BOOL tbar_visible = FRAME_EXTERNAL_TOOL_BAR (f) ? YES : NO;
! NSToolbar *toolbar = [FRAME_NS_VIEW (f) toolbar];
! if (! tbar_visible != ! [toolbar isVisible])
! [toolbar setVisible: tbar_visible];
! }
#endif
ns_updating_frame = f;
***************
*** 800,807 ****
/* Don't do highlighting for mouse motion during the update. */
hlinfo->mouse_face_defer = 1;
! /* If the frame needs to be redrawn,
! simply forget about any prior mouse highlighting. */
if (FRAME_GARBAGED_P (f))
hlinfo->mouse_face_window = Qnil;
--- 800,807 ----
/* Don't do highlighting for mouse motion during the update. */
hlinfo->mouse_face_defer = 1;
! /* If the frame needs to be redrawn,
! simply forget about any prior mouse highlighting. */
if (FRAME_GARBAGED_P (f))
hlinfo->mouse_face_window = Qnil;
***************
*** 859,865 ****
{
EmacsView *view = FRAME_NS_VIEW (f);
! /* if (f == MOUSE_HL_INFO (f)->mouse_face_mouse_frame) */
MOUSE_HL_INFO (f)->mouse_face_defer = 0;
block_input ();
--- 859,865 ----
{
EmacsView *view = FRAME_NS_VIEW (f);
! /* if (f == MOUSE_HL_INFO (f)->mouse_face_mouse_frame) */
MOUSE_HL_INFO (f)->mouse_face_defer = 0;
block_input ();
***************
*** 876,893 ****
ns_focus (struct frame *f, NSRect *r, int n)
/* --------------------------------------------------------------------------
Internal: Focus on given frame. During small local updates this is used to
! draw, however during large updates, ns_update_begin and ns_update_end are
! called to wrap the whole thing, in which case these calls are stubbed out.
! Except, on GNUstep, we accumulate the rectangle being drawn into, because
! the back end won't do this automatically, and will just end up flushing
! the entire window.
-------------------------------------------------------------------------- */
{
! // NSTRACE (ns_focus);
! /* static int c =0;
! fprintf (stderr, "focus: %d", c++);
! if (r) fprintf (stderr, " (%.0f, %.0f : %.0f x %.0f)", r->origin.x, r->origin.y, r->size.width, r->size.height);
! fprintf (stderr, "\n"); */
if (f != ns_updating_frame)
{
--- 876,893 ----
ns_focus (struct frame *f, NSRect *r, int n)
/* --------------------------------------------------------------------------
Internal: Focus on given frame. During small local updates this is used to
! draw, however during large updates, ns_update_begin and ns_update_end are
! called to wrap the whole thing, in which case these calls are stubbed out.
! Except, on GNUstep, we accumulate the rectangle being drawn into, because
! the back end won't do this automatically, and will just end up flushing
! the entire window.
-------------------------------------------------------------------------- */
{
! // NSTRACE (ns_focus);
! /* static int c =0;
! fprintf (stderr, "focus: %d", c++);
! if (r) fprintf (stderr, " (%.0f, %.0f : %.0f x %.0f)", r->origin.x, r->origin.y, r->size.width, r->size.height);
! fprintf (stderr, "\n"); */
if (f != ns_updating_frame)
{
***************
*** 898,910 ****
{
[focus_view unlockFocus];
[[focus_view window] flushWindow];
! /*debug_lock--; */
}
if (view)
[view lockFocus];
focus_view = view;
! /*if (view) debug_lock++; */
}
}
--- 898,910 ----
{
[focus_view unlockFocus];
[[focus_view window] flushWindow];
! /*debug_lock--; */
}
if (view)
[view lockFocus];
focus_view = view;
! /*if (view) debug_lock++; */
}
}
***************
*** 924,933 ****
static void
ns_unfocus (struct frame *f)
/* --------------------------------------------------------------------------
! Internal: Remove focus on given frame
-------------------------------------------------------------------------- */
{
! // NSTRACE (ns_unfocus);
if (gsaved)
{
--- 924,933 ----
static void
ns_unfocus (struct frame *f)
/* --------------------------------------------------------------------------
! Internal: Remove focus on given frame
-------------------------------------------------------------------------- */
{
! // NSTRACE (ns_unfocus);
if (gsaved)
{
***************
*** 942,948 ****
[focus_view unlockFocus];
[[focus_view window] flushWindow];
focus_view = NULL;
! /*debug_lock--; */
}
}
}
--- 942,948 ----
[focus_view unlockFocus];
[[focus_view window] flushWindow];
focus_view = NULL;
! /*debug_lock--; */
}
}
}
***************
*** 952,958 ****
ns_clip_to_row (struct window *w, struct glyph_row *row,
enum glyph_row_area area, BOOL gc)
/* --------------------------------------------------------------------------
! Internal (but parallels other terms): Focus drawing on given row
-------------------------------------------------------------------------- */
{
struct frame *f = XFRAME (WINDOW_FRAME (w));
--- 952,958 ----
ns_clip_to_row (struct window *w, struct glyph_row *row,
enum glyph_row_area area, BOOL gc)
/* --------------------------------------------------------------------------
! Internal (but parallels other terms): Focus drawing on given row
-------------------------------------------------------------------------- */
{
struct frame *f = XFRAME (WINDOW_FRAME (w));
***************
*** 974,980 ****
static void
ns_ring_bell (struct frame *f)
/* --------------------------------------------------------------------------
! "Beep" routine
-------------------------------------------------------------------------- */
{
NSTRACE (ns_ring_bell);
--- 974,980 ----
static void
ns_ring_bell (struct frame *f)
/* --------------------------------------------------------------------------
! "Beep" routine
-------------------------------------------------------------------------- */
{
NSTRACE (ns_ring_bell);
***************
*** 1002,1008 ****
ns_focus (frame, &surr, 1);
[[view window] cacheImageInRect: [view convertRect: surr toView:nil]];
[ns_lookup_indexed_color (NS_FACE_FOREGROUND
! (FRAME_DEFAULT_FACE (frame)), frame) set];
NSRectFill (r);
[[view window] flushWindow];
ns_timeout (150000);
--- 1002,1008 ----
ns_focus (frame, &surr, 1);
[[view window] cacheImageInRect: [view convertRect: surr toView:nil]];
[ns_lookup_indexed_color (NS_FACE_FOREGROUND
! (FRAME_DEFAULT_FACE (frame)), frame) set];
NSRectFill (r);
[[view window] flushWindow];
ns_timeout (150000);
***************
*** 1021,1027 ****
/* ==========================================================================
! Frame / window manager related functions
========================================================================== */
--- 1021,1027 ----
/* ==========================================================================
! Frame / window manager related functions
========================================================================== */
***************
*** 1029,1035 ****
static void
ns_raise_frame (struct frame *f)
/* --------------------------------------------------------------------------
! Bring window to foreground and make it active
-------------------------------------------------------------------------- */
{
NSView *view;
--- 1029,1035 ----
static void
ns_raise_frame (struct frame *f)
/* --------------------------------------------------------------------------
! Bring window to foreground and make it active
-------------------------------------------------------------------------- */
{
NSView *view;
***************
*** 1045,1051 ****
static void
ns_lower_frame (struct frame *f)
/* --------------------------------------------------------------------------
! Send window to back
-------------------------------------------------------------------------- */
{
NSView *view;
--- 1045,1051 ----
static void
ns_lower_frame (struct frame *f)
/* --------------------------------------------------------------------------
! Send window to back
-------------------------------------------------------------------------- */
{
NSView *view;
***************
*** 1060,1066 ****
static void
ns_frame_raise_lower (struct frame *f, int raise)
/* --------------------------------------------------------------------------
! External (hook)
-------------------------------------------------------------------------- */
{
NSTRACE (ns_frame_raise_lower);
--- 1060,1066 ----
static void
ns_frame_raise_lower (struct frame *f, int raise)
/* --------------------------------------------------------------------------
! External (hook)
-------------------------------------------------------------------------- */
{
NSTRACE (ns_frame_raise_lower);
***************
*** 1075,1081 ****
static void
ns_frame_rehighlight (struct frame *frame)
/* --------------------------------------------------------------------------
! External (hook): called on things like window switching within frame
-------------------------------------------------------------------------- */
{
struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (frame);
--- 1075,1081 ----
static void
ns_frame_rehighlight (struct frame *frame)
/* --------------------------------------------------------------------------
! External (hook): called on things like window switching within frame
-------------------------------------------------------------------------- */
{
struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (frame);
***************
*** 1095,1104 ****
}
}
else
! dpyinfo->x_highlight_frame = 0;
if (dpyinfo->x_highlight_frame &&
! dpyinfo->x_highlight_frame != old_highlight)
{
if (old_highlight)
{
--- 1095,1104 ----
}
}
else
! dpyinfo->x_highlight_frame = 0;
if (dpyinfo->x_highlight_frame &&
! dpyinfo->x_highlight_frame != old_highlight)
{
if (old_highlight)
{
***************
*** 1117,1123 ****
void
x_make_frame_visible (struct frame *f)
/* --------------------------------------------------------------------------
! External: Show the window (X11 semantics)
-------------------------------------------------------------------------- */
{
NSTRACE (x_make_frame_visible);
--- 1117,1123 ----
void
x_make_frame_visible (struct frame *f)
/* --------------------------------------------------------------------------
! External: Show the window (X11 semantics)
-------------------------------------------------------------------------- */
{
NSTRACE (x_make_frame_visible);
***************
*** 1150,1156 ****
void
x_make_frame_invisible (struct frame *f)
/* --------------------------------------------------------------------------
! External: Hide the window (X11 semantics)
-------------------------------------------------------------------------- */
{
NSView *view;
--- 1150,1156 ----
void
x_make_frame_invisible (struct frame *f)
/* --------------------------------------------------------------------------
! External: Hide the window (X11 semantics)
-------------------------------------------------------------------------- */
{
NSView *view;
***************
*** 1166,1172 ****
void
x_iconify_frame (struct frame *f)
/* --------------------------------------------------------------------------
! External: Iconify window
-------------------------------------------------------------------------- */
{
NSView *view;
--- 1166,1172 ----
void
x_iconify_frame (struct frame *f)
/* --------------------------------------------------------------------------
! External: Iconify window
-------------------------------------------------------------------------- */
{
NSView *view;
***************
*** 1238,1244 ****
void
x_destroy_window (struct frame *f)
/* --------------------------------------------------------------------------
! External: Delete the window
-------------------------------------------------------------------------- */
{
NSTRACE (x_destroy_window);
--- 1238,1244 ----
void
x_destroy_window (struct frame *f)
/* --------------------------------------------------------------------------
! External: Delete the window
-------------------------------------------------------------------------- */
{
NSTRACE (x_destroy_window);
***************
*** 1251,1257 ****
void
x_set_offset (struct frame *f, int xoff, int yoff, int change_grav)
/* --------------------------------------------------------------------------
! External: Position the window
-------------------------------------------------------------------------- */
{
NSView *view = FRAME_NS_VIEW (f);
--- 1251,1257 ----
void
x_set_offset (struct frame *f, int xoff, int yoff, int change_grav)
/* --------------------------------------------------------------------------
! External: Position the window
-------------------------------------------------------------------------- */
{
NSView *view = FRAME_NS_VIEW (f);
***************
*** 1303,1311 ****
int height,
bool pixelwise)
/* --------------------------------------------------------------------------
! Adjust window pixel size based on given character grid size
! Impl is a bit more complex than other terms, need to do some
! internal clipping.
-------------------------------------------------------------------------- */
{
EmacsView *view = FRAME_NS_VIEW (f);
--- 1303,1311 ----
int height,
bool pixelwise)
/* --------------------------------------------------------------------------
! Adjust window pixel size based on given character grid size
! Impl is a bit more complex than other terms, need to do some
! internal clipping.
-------------------------------------------------------------------------- */
{
EmacsView *view = FRAME_NS_VIEW (f);
***************
*** 1320,1326 ****
if (view == nil)
return;
! /*fprintf (stderr, "\tsetWindowSize: %d x %d, pixelwise %d, font size %d x %d\n", width, height, pixelwise, FRAME_COLUMN_WIDTH (f), FRAME_LINE_HEIGHT (f));*/
block_input ();
--- 1320,1326 ----
if (view == nil)
return;
! /*fprintf (stderr, "\tsetWindowSize: %d x %d, pixelwise %d, font size %d x %d\n", width, height, pixelwise, FRAME_COLUMN_WIDTH (f), FRAME_LINE_HEIGHT (f));*/
block_input ();
***************
*** 1346,1359 ****
/* If we have a toolbar, take its height into account. */
if (tb && ! [view isFullscreen])
{
! /* NOTE: previously this would generate wrong result if toolbar not
! yet displayed and fixing toolbar_height=32 helped, but
! now (200903) seems no longer needed */
! FRAME_TOOLBAR_HEIGHT (f) =
! NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)])
- FRAME_NS_TITLEBAR_HEIGHT (f);
#ifdef NS_IMPL_GNUSTEP
! FRAME_TOOLBAR_HEIGHT (f) -= 3;
#endif
}
else
--- 1346,1359 ----
/* If we have a toolbar, take its height into account. */
if (tb && ! [view isFullscreen])
{
! /* NOTE: previously this would generate wrong result if toolbar not
! yet displayed and fixing toolbar_height=32 helped, but
! now (200903) seems no longer needed */
! FRAME_TOOLBAR_HEIGHT (f) =
! NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)])
- FRAME_NS_TITLEBAR_HEIGHT (f);
#ifdef NS_IMPL_GNUSTEP
! FRAME_TOOLBAR_HEIGHT (f) -= 3;
#endif
}
else
***************
*** 1365,1404 ****
wr.size.height += FRAME_NS_TITLEBAR_HEIGHT (f)
+ FRAME_TOOLBAR_HEIGHT (f);
! /* Do not try to constrain to this screen. We may have multiple
! screens, and want Emacs to span those. Constraining to screen
! prevents that, and that is not nice to the user. */
! if (f->output_data.ns->zooming)
! f->output_data.ns->zooming = 0;
! else
! wr.origin.y += FRAME_PIXEL_HEIGHT (f) - pixelheight;
!
! [view setRows: rows andColumns: cols];
! [window setFrame: wr display: YES];
!
! /* This is a trick to compensate for Emacs' managing the scrollbar area
! as a fixed number of standard character columns. Instead of leaving
! blank space for the extra, we chopped it off above. Now for
! left-hand scrollbars, we shift all rendering to the left by the
! difference between the real width and Emacs' imagined one. For
! right-hand bars, don't worry about it since the extra is never used.
! (Obviously doesn't work for vertically split windows tho..) */
! {
! NSPoint origin = FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)
! ? NSMakePoint (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)
! - NS_SCROLL_BAR_WIDTH (f), 0)
! : NSMakePoint (0, 0);
! [view setFrame: NSMakeRect (0, 0, pixelwidth, pixelheight)];
! [view setBoundsOrigin: origin];
! }
! change_frame_size (f, width, height, 0, 1, 0, pixelwise);
! /* SET_FRAME_GARBAGED (f); // this short-circuits expose call in drawRect */
! mark_window_cursors_off (XWINDOW (f->root_window));
! cancel_mouse_face (f);
! unblock_input ();
}
--- 1365,1404 ----
wr.size.height += FRAME_NS_TITLEBAR_HEIGHT (f)
+ FRAME_TOOLBAR_HEIGHT (f);
! /* Do not try to constrain to this screen. We may have multiple
! screens, and want Emacs to span those. Constraining to screen
! prevents that, and that is not nice to the user. */
! if (f->output_data.ns->zooming)
! f->output_data.ns->zooming = 0;
! else
! wr.origin.y += FRAME_PIXEL_HEIGHT (f) - pixelheight;
!
! [view setRows: rows andColumns: cols];
! [window setFrame: wr display: YES];
!
! /* This is a trick to compensate for Emacs' managing the scrollbar area
! as a fixed number of standard character columns. Instead of leaving
! blank space for the extra, we chopped it off above. Now for
! left-hand scrollbars, we shift all rendering to the left by the
! difference between the real width and Emacs' imagined one. For
! right-hand bars, don't worry about it since the extra is never used.
! (Obviously doesn't work for vertically split windows tho..) */
! {
! NSPoint origin = FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)
! ? NSMakePoint (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)
! - NS_SCROLL_BAR_WIDTH (f), 0)
! : NSMakePoint (0, 0);
! [view setFrame: NSMakeRect (0, 0, pixelwidth, pixelheight)];
! [view setBoundsOrigin: origin];
! }
! change_frame_size (f, width, height, 0, 1, 0, pixelwise);
! /* SET_FRAME_GARBAGED (f); // this short-circuits expose call in drawRect */
! mark_window_cursors_off (XWINDOW (f->root_window));
! cancel_mouse_face (f);
! unblock_input ();
}
***************
*** 1410,1416 ****
if (!FRAME_VISIBLE_P (f))
return;
! if (! [view fsIsNative] && f->want_fullscreen == FULLSCREEN_BOTH)
{
/* Old style fs don't initiate correctly if created from
init/default-frame alist, so use a timer (not nice...).
--- 1410,1416 ----
if (!FRAME_VISIBLE_P (f))
return;
! if (! [view fsIsNative] && f->want_fullscreen == FULLSCREEN_BOTH)
{
/* Old style fs don't initiate correctly if created from
init/default-frame alist, so use a timer (not nice...).
***************
*** 1428,1434 ****
/* ==========================================================================
! Color management
========================================================================== */
--- 1428,1434 ----
/* ==========================================================================
! Color management
========================================================================== */
***************
*** 1481,1487 ****
color_table->colors[idx] = color;
[color retain];
! /*fprintf(stderr, "color_table: allocated %d\n",idx);*/
return idx;
}
--- 1481,1487 ----
color_table->colors[idx] = color;
[color retain];
! /*fprintf(stderr, "color_table: allocated %d\n",idx);*/
return idx;
}
***************
*** 1513,1526 ****
[color release];
color_table->colors[idx] = nil;
[color_table->empty_indices addObject: index];
! /*fprintf(stderr, "color_table: FREED %d\n",idx);*/
}
static int
ns_get_color (const char *name, NSColor **col)
/* --------------------------------------------------------------------------
! Parse a color name
-------------------------------------------------------------------------- */
/* On *Step, we attempt to mimic the X11 platform here, down to installing an
X11 rgb.txt-compatible color list in Emacs.clr (see ns_term_init()).
--- 1513,1526 ----
[color release];
color_table->colors[idx] = nil;
[color_table->empty_indices addObject: index];
! /*fprintf(stderr, "color_table: FREED %d\n",idx);*/
}
static int
ns_get_color (const char *name, NSColor **col)
/* --------------------------------------------------------------------------
! Parse a color name
-------------------------------------------------------------------------- */
/* On *Step, we attempt to mimic the X11 platform here, down to installing an
X11 rgb.txt-compatible color list in Emacs.clr (see ns_term_init()).
***************
*** 1532,1538 ****
float r = -1.0, g, b;
NSString *nsname = [NSString stringWithUTF8String: name];
! /*fprintf (stderr, "ns_get_color: '%s'\n", name); */
block_input ();
if ([nsname isEqualToString: @"ns_selection_bg_color"])
--- 1532,1538 ----
float r = -1.0, g, b;
NSString *nsname = [NSString stringWithUTF8String: name];
! /*fprintf (stderr, "ns_get_color: '%s'\n", name); */
block_input ();
if ([nsname isEqualToString: @"ns_selection_bg_color"])
***************
*** 1544,1557 ****
nsname = defname;
else
#endif
! if ((new = [NSColor selectedTextBackgroundColor]) != nil)
! {
! *col = [new colorUsingDefaultColorSpace];
! unblock_input ();
! return 0;
! }
! else
! nsname = NS_SELECTION_BG_COLOR_DEFAULT;
name = [nsname UTF8String];
}
--- 1544,1557 ----
nsname = defname;
else
#endif
! if ((new = [NSColor selectedTextBackgroundColor]) != nil)
! {
! *col = [new colorUsingDefaultColorSpace];
! unblock_input ();
! return 0;
! }
! else
! nsname = NS_SELECTION_BG_COLOR_DEFAULT;
name = [nsname UTF8String];
}
***************
*** 1650,1656 ****
int
ns_lisp_to_color (Lisp_Object color, NSColor **col)
/* --------------------------------------------------------------------------
! Convert a Lisp string object to a NS color
-------------------------------------------------------------------------- */
{
NSTRACE (ns_lisp_to_color);
--- 1650,1656 ----
int
ns_lisp_to_color (Lisp_Object color, NSColor **col)
/* --------------------------------------------------------------------------
! Convert a Lisp string object to a NS color
-------------------------------------------------------------------------- */
{
NSTRACE (ns_lisp_to_color);
***************
*** 1665,1671 ****
Lisp_Object
ns_color_to_lisp (NSColor *col)
/* --------------------------------------------------------------------------
! Convert a color to a lisp string with the RGB equivalent
-------------------------------------------------------------------------- */
{
EmacsCGFloat red, green, blue, alpha, gray;
--- 1665,1671 ----
Lisp_Object
ns_color_to_lisp (NSColor *col)
/* --------------------------------------------------------------------------
! Convert a color to a lisp string with the RGB equivalent
-------------------------------------------------------------------------- */
{
EmacsCGFloat red, green, blue, alpha, gray;
***************
*** 1676,1688 ****
block_input ();
if ([[col colorSpaceName] isEqualToString: NSNamedColorSpace])
! if ((str =[[col colorNameComponent] UTF8String]))
! {
! unblock_input ();
! return build_string ((char *)str);
! }
! [[col colorUsingDefaultColorSpace]
getRed: &red green: &green blue: &blue alpha: &alpha];
if (red == green && red == blue)
{
--- 1676,1688 ----
block_input ();
if ([[col colorSpaceName] isEqualToString: NSNamedColorSpace])
! if ((str =[[col colorNameComponent] UTF8String]))
! {
! unblock_input ();
! return build_string ((char *)str);
! }
! [[col colorUsingDefaultColorSpace]
getRed: &red green: &green blue: &blue alpha: &alpha];
if (red == green && red == blue)
{
***************
*** 1705,1713 ****
void
ns_query_color(void *col, XColor *color_def, int setPixel)
/* --------------------------------------------------------------------------
! Get ARGB values out of NSColor col and put them into color_def.
! If setPixel, set the pixel to a concatenated version.
! and set color_def pixel to the resulting index.
-------------------------------------------------------------------------- */
{
EmacsCGFloat r, g, b, a;
--- 1705,1713 ----
void
ns_query_color(void *col, XColor *color_def, int setPixel)
/* --------------------------------------------------------------------------
! Get ARGB values out of NSColor col and put them into color_def.
! If setPixel, set the pixel to a concatenated version.
! and set color_def pixel to the resulting index.
-------------------------------------------------------------------------- */
{
EmacsCGFloat r, g, b, a;
***************
*** 1731,1741 ****
bool alloc,
bool makeIndex)
/* --------------------------------------------------------------------------
! Return true if named color found, and set color_def rgb accordingly.
! If makeIndex and alloc are nonzero put the color in the color_table,
! and set color_def pixel to the resulting index.
! If makeIndex is zero, set color_def pixel to ARGB.
! Return false if not found
-------------------------------------------------------------------------- */
{
NSColor *col;
--- 1731,1741 ----
bool alloc,
bool makeIndex)
/* --------------------------------------------------------------------------
! Return true if named color found, and set color_def rgb accordingly.
! If makeIndex and alloc are nonzero put the color in the color_table,
! and set color_def pixel to the resulting index.
! If makeIndex is zero, set color_def pixel to ARGB.
! Return false if not found
-------------------------------------------------------------------------- */
{
NSColor *col;
***************
*** 1758,1764 ****
void
x_set_frame_alpha (struct frame *f)
/* --------------------------------------------------------------------------
! change the entire-frame transparency
-------------------------------------------------------------------------- */
{
struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
--- 1758,1764 ----
void
x_set_frame_alpha (struct frame *f)
/* --------------------------------------------------------------------------
! change the entire-frame transparency
-------------------------------------------------------------------------- */
{
struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
***************
*** 1785,1791 ****
#ifdef NS_IMPL_COCOA
{
EmacsView *view = FRAME_NS_VIEW (f);
! [[view window] setAlphaValue: alpha];
}
#endif
}
--- 1785,1791 ----
#ifdef NS_IMPL_COCOA
{
EmacsView *view = FRAME_NS_VIEW (f);
! [[view window] setAlphaValue: alpha];
}
#endif
}
***************
*** 1793,1799 ****
/* ==========================================================================
! Mouse handling
========================================================================== */
--- 1793,1799 ----
/* ==========================================================================
! Mouse handling
========================================================================== */
***************
*** 1801,1807 ****
void
x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y)
/* --------------------------------------------------------------------------
! Programmatically reposition mouse pointer in pixel coordinates
-------------------------------------------------------------------------- */
{
NSTRACE (x_set_mouse_pixel_position);
--- 1801,1807 ----
void
x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y)
/* --------------------------------------------------------------------------
! Programmatically reposition mouse pointer in pixel coordinates
-------------------------------------------------------------------------- */
{
NSTRACE (x_set_mouse_pixel_position);
***************
*** 1820,1826 ****
void
x_set_mouse_position (struct frame *f, int h, int v)
/* --------------------------------------------------------------------------
! Programmatically reposition mouse pointer in character coordinates
-------------------------------------------------------------------------- */
{
int pix_x, pix_y;
--- 1820,1826 ----
void
x_set_mouse_position (struct frame *f, int h, int v)
/* --------------------------------------------------------------------------
! Programmatically reposition mouse pointer in character coordinates
-------------------------------------------------------------------------- */
{
int pix_x, pix_y;
***************
*** 1849,1855 ****
struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (frame);
NSRect *r;
! // NSTRACE (note_mouse_movement);
dpyinfo->last_mouse_motion_frame = frame;
r = &dpyinfo->last_mouse_glyph;
--- 1849,1855 ----
struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (frame);
NSRect *r;
! // NSTRACE (note_mouse_movement);
dpyinfo->last_mouse_motion_frame = frame;
r = &dpyinfo->last_mouse_glyph;
***************
*** 1878,1887 ****
enum scroll_bar_part *part, Lisp_Object *x, Lisp_Object *y,
Time *time)
/* --------------------------------------------------------------------------
! External (hook): inform emacs about mouse position and hit parts.
! If a scrollbar is being dragged, set bar_window, part, x, y, time.
! x & y should be position in the scrollbar (the whole bar, not the handle)
! and length of scrollbar respectively
-------------------------------------------------------------------------- */
{
id view;
--- 1878,1887 ----
enum scroll_bar_part *part, Lisp_Object *x, Lisp_Object *y,
Time *time)
/* --------------------------------------------------------------------------
! External (hook): inform emacs about mouse position and hit parts.
! If a scrollbar is being dragged, set bar_window, part, x, y, time.
! x & y should be position in the scrollbar (the whole bar, not the handle)
! and length of scrollbar respectively
-------------------------------------------------------------------------- */
{
id view;
***************
*** 1905,1911 ****
if (dpyinfo->last_mouse_scroll_bar != nil && insist == 0)
{
/* TODO: we do not use this path at the moment because drag events will
! go directly to the EmacsScroller. Leaving code in for now. */
[dpyinfo->last_mouse_scroll_bar
getMouseMotionPart: (int *)part window: bar_window x: x y: y];
if (time)
--- 1905,1911 ----
if (dpyinfo->last_mouse_scroll_bar != nil && insist == 0)
{
/* TODO: we do not use this path at the moment because drag events will
! go directly to the EmacsScroller. Leaving code in for now. */
[dpyinfo->last_mouse_scroll_bar
getMouseMotionPart: (int *)part window: bar_window x: x y: y];
if (time)
***************
*** 1926,1932 ****
f = dpyinfo->last_mouse_frame;
else
f = dpyinfo->x_focus_frame ? dpyinfo->x_focus_frame
! : SELECTED_FRAME ();
if (f && FRAME_NS_P (f))
{
--- 1926,1932 ----
f = dpyinfo->last_mouse_frame;
else
f = dpyinfo->x_focus_frame ? dpyinfo->x_focus_frame
! : SELECTED_FRAME ();
if (f && FRAME_NS_P (f))
{
***************
*** 1936,1942 ****
position = [view convertPoint: position fromView: nil];
remember_mouse_glyph (f, position.x, position.y,
&dpyinfo->last_mouse_glyph);
! /*fprintf (stderr, "ns_mouse_position: %.0f, %.0f\n", position.x, position.y); */
if (bar_window) *bar_window = Qnil;
if (part) *part = 0; /*scroll_bar_handle; */
--- 1936,1942 ----
position = [view convertPoint: position fromView: nil];
remember_mouse_glyph (f, position.x, position.y,
&dpyinfo->last_mouse_glyph);
! /*fprintf (stderr, "ns_mouse_position: %.0f, %.0f\n", position.x, position.y); */
if (bar_window) *bar_window = Qnil;
if (part) *part = 0; /*scroll_bar_handle; */
***************
*** 1956,1963 ****
static void
ns_frame_up_to_date (struct frame *f)
/* --------------------------------------------------------------------------
! External (hook): Fix up mouse highlighting right after a full update.
! Can't use FRAME_MOUSE_UPDATE due to ns_frame_begin and ns_frame_end calls.
-------------------------------------------------------------------------- */
{
NSTRACE (ns_frame_up_to_date);
--- 1956,1963 ----
static void
ns_frame_up_to_date (struct frame *f)
/* --------------------------------------------------------------------------
! External (hook): Fix up mouse highlighting right after a full update.
! Can't use FRAME_MOUSE_UPDATE due to ns_frame_begin and ns_frame_end calls.
-------------------------------------------------------------------------- */
{
NSTRACE (ns_frame_up_to_date);
***************
*** 1982,1988 ****
static void
ns_define_frame_cursor (struct frame *f, Cursor cursor)
/* --------------------------------------------------------------------------
! External (RIF): set frame mouse pointer type.
-------------------------------------------------------------------------- */
{
NSTRACE (ns_define_frame_cursor);
--- 1982,1988 ----
static void
ns_define_frame_cursor (struct frame *f, Cursor cursor)
/* --------------------------------------------------------------------------
! External (RIF): set frame mouse pointer type.
-------------------------------------------------------------------------- */
{
NSTRACE (ns_define_frame_cursor);
***************
*** 2001,2007 ****
/* ==========================================================================
! Keyboard handling
========================================================================== */
--- 2001,2007 ----
/* ==========================================================================
! Keyboard handling
========================================================================== */
***************
*** 2009,2015 ****
static unsigned
ns_convert_key (unsigned code)
/* --------------------------------------------------------------------------
! Internal call used by NSView-keyDown.
-------------------------------------------------------------------------- */
{
const unsigned last_keysym = (sizeof (convert_ns_to_X_keysym)
--- 2009,2015 ----
static unsigned
ns_convert_key (unsigned code)
/* --------------------------------------------------------------------------
! Internal call used by NSView-keyDown.
-------------------------------------------------------------------------- */
{
const unsigned last_keysym = (sizeof (convert_ns_to_X_keysym)
***************
*** 2020,2026 ****
if (code == convert_ns_to_X_keysym[keysym])
return 0xFF00 | convert_ns_to_X_keysym[keysym+1];
return 0;
! /* if decide to use keyCode and Carbon table, use this line:
return code > 0xff ? 0 : 0xFF00 | ns_keycode_to_xkeysym_table[code]; */
}
--- 2020,2026 ----
if (code == convert_ns_to_X_keysym[keysym])
return 0xFF00 | convert_ns_to_X_keysym[keysym+1];
return 0;
! /* if decide to use keyCode and Carbon table, use this line:
return code > 0xff ? 0 : 0xFF00 | ns_keycode_to_xkeysym_table[code]; */
}
***************
*** 2028,2035 ****
char *
x_get_keysym_name (int keysym)
/* --------------------------------------------------------------------------
! Called by keyboard.c. Not sure if the return val is important, except
! that it be unique.
-------------------------------------------------------------------------- */
{
static char value[16];
--- 2028,2035 ----
char *
x_get_keysym_name (int keysym)
/* --------------------------------------------------------------------------
! Called by keyboard.c. Not sure if the return val is important, except
! that it be unique.
-------------------------------------------------------------------------- */
{
static char value[16];
***************
*** 2042,2048 ****
/* ==========================================================================
! Block drawing operations
========================================================================== */
--- 2042,2048 ----
/* ==========================================================================
! Block drawing operations
========================================================================== */
***************
*** 2066,2072 ****
void
ns_clear_frame (struct frame *f)
/* --------------------------------------------------------------------------
! External (hook): Erase the entire frame
-------------------------------------------------------------------------- */
{
NSView *view = FRAME_NS_VIEW (f);
--- 2066,2072 ----
void
ns_clear_frame (struct frame *f)
/* --------------------------------------------------------------------------
! External (hook): Erase the entire frame
-------------------------------------------------------------------------- */
{
NSView *view = FRAME_NS_VIEW (f);
***************
*** 2074,2083 ****
NSTRACE (ns_clear_frame);
! /* comes on initial frame because we have
! after-make-frame-functions = select-frame */
! if (!FRAME_DEFAULT_FACE (f))
! return;
mark_window_cursors_off (XWINDOW (FRAME_ROOT_WINDOW (f)));
--- 2074,2083 ----
NSTRACE (ns_clear_frame);
! /* comes on initial frame because we have
! after-make-frame-functions = select-frame */
! if (!FRAME_DEFAULT_FACE (f))
! return;
mark_window_cursors_off (XWINDOW (FRAME_ROOT_WINDOW (f)));
***************
*** 2098,2104 ****
static void
ns_clear_frame_area (struct frame *f, int x, int y, int width, int height)
/* --------------------------------------------------------------------------
! External (RIF): Clear section of frame
-------------------------------------------------------------------------- */
{
NSRect r = NSMakeRect (x, y, width, height);
--- 2098,2104 ----
static void
ns_clear_frame_area (struct frame *f, int x, int y, int width, int height)
/* --------------------------------------------------------------------------
! External (RIF): Clear section of frame
-------------------------------------------------------------------------- */
{
NSRect r = NSMakeRect (x, y, width, height);
***************
*** 2124,2130 ****
static void
ns_scroll_run (struct window *w, struct run *run)
/* --------------------------------------------------------------------------
! External (RIF): Insert or delete n lines at line vpos
-------------------------------------------------------------------------- */
{
struct frame *f = XFRAME (w->frame);
--- 2124,2130 ----
static void
ns_scroll_run (struct window *w, struct run *run)
/* --------------------------------------------------------------------------
! External (RIF): Insert or delete n lines at line vpos
-------------------------------------------------------------------------- */
{
struct frame *f = XFRAME (w->frame);
***************
*** 2163,2169 ****
/* end copy from other terms */
if (height == 0)
! return;
block_input ();
--- 2163,2169 ----
/* end copy from other terms */
if (height == 0)
! return;
block_input ();
***************
*** 2186,2192 ****
static void
ns_after_update_window_line (struct window *w, struct glyph_row *desired_row)
/* --------------------------------------------------------------------------
! External (RIF): preparatory to fringe update after text was updated
-------------------------------------------------------------------------- */
{
struct frame *f;
--- 2186,2192 ----
static void
ns_after_update_window_line (struct window *w, struct glyph_row *desired_row)
/* --------------------------------------------------------------------------
! External (RIF): preparatory to fringe update after text was updated
-------------------------------------------------------------------------- */
{
struct frame *f;
***************
*** 2224,2233 ****
static void
ns_shift_glyphs_for_insert (struct frame *f,
! int x, int y, int width, int height,
! int shift_by)
/* --------------------------------------------------------------------------
! External (RIF): copy an area horizontally, don't worry about clearing src
-------------------------------------------------------------------------- */
{
NSRect srcRect = NSMakeRect (x, y, width, height);
--- 2224,2233 ----
static void
ns_shift_glyphs_for_insert (struct frame *f,
! int x, int y, int width, int height,
! int shift_by)
/* --------------------------------------------------------------------------
! External (RIF): copy an area horizontally, don't worry about clearing src
-------------------------------------------------------------------------- */
{
NSRect srcRect = NSMakeRect (x, y, width, height);
***************
*** 2245,2251 ****
/* ==========================================================================
! Character encoding and metrics
========================================================================== */
--- 2245,2251 ----
/* ==========================================================================
! Character encoding and metrics
========================================================================== */
***************
*** 2253,2259 ****
static void
ns_compute_glyph_string_overhangs (struct glyph_string *s)
/* --------------------------------------------------------------------------
! External (RIF); compute left/right overhang of whole string and set in s
-------------------------------------------------------------------------- */
{
struct font *font = s->font;
--- 2253,2259 ----
static void
ns_compute_glyph_string_overhangs (struct glyph_string *s)
/* --------------------------------------------------------------------------
! External (RIF); compute left/right overhang of whole string and set in s
-------------------------------------------------------------------------- */
{
struct font *font = s->font;
***************
*** 2286,2292 ****
/* ==========================================================================
! Fringe and cursor drawing
========================================================================== */
--- 2286,2292 ----
/* ==========================================================================
! Fringe and cursor drawing
========================================================================== */
***************
*** 2294,2302 ****
extern int max_used_fringe_bitmap;
static void
ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row,
! struct draw_fringe_bitmap_params *p)
/* --------------------------------------------------------------------------
! External (RIF); fringe-related
-------------------------------------------------------------------------- */
{
struct frame *f = XFRAME (WINDOW_FRAME (w));
--- 2294,2302 ----
extern int max_used_fringe_bitmap;
static void
ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row,
! struct draw_fringe_bitmap_params *p)
/* --------------------------------------------------------------------------
! External (RIF); fringe-related
-------------------------------------------------------------------------- */
{
struct frame *f = XFRAME (WINDOW_FRAME (w));
***************
*** 2403,2411 ****
[img setXBMColor: ns_lookup_indexed_color(face->foreground, f)];
#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
[img drawInRect: r
! fromRect: NSZeroRect
! operation: NSCompositeSourceOver
! fraction: 1.0
respectFlipped: YES
hints: nil];
#else
--- 2403,2411 ----
[img setXBMColor: ns_lookup_indexed_color(face->foreground, f)];
#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
[img drawInRect: r
! fromRect: NSZeroRect
! operation: NSCompositeSourceOver
! fraction: 1.0
respectFlipped: YES
hints: nil];
#else
***************
*** 2425,2432 ****
int x, int y, enum text_cursor_kinds cursor_type,
int cursor_width, bool on_p, bool active_p)
/* --------------------------------------------------------------------------
! External call (RIF): draw cursor.
! Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
-------------------------------------------------------------------------- */
{
NSRect r, s;
--- 2425,2432 ----
int x, int y, enum text_cursor_kinds cursor_type,
int cursor_width, bool on_p, bool active_p)
/* --------------------------------------------------------------------------
! External call (RIF): draw cursor.
! Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
-------------------------------------------------------------------------- */
{
NSRect r, s;
***************
*** 2509,2518 ****
#ifdef NS_IMPL_COCOA
/* TODO: This makes drawing of cursor plus that of phys_cursor_glyph
! atomic. Cleaner ways of doing this should be investigated.
! One way would be to set a global variable DRAWING_CURSOR
! when making the call to draw_phys..(), don't focus in that
! case, then move the ns_unfocus() here after that call. */
NSDisableScreenUpdates ();
#endif
--- 2509,2518 ----
#ifdef NS_IMPL_COCOA
/* TODO: This makes drawing of cursor plus that of phys_cursor_glyph
! atomic. Cleaner ways of doing this should be investigated.
! One way would be to set a global variable DRAWING_CURSOR
! when making the call to draw_phys..(), don't focus in that
! case, then move the ns_unfocus() here after that call. */
NSDisableScreenUpdates ();
#endif
***************
*** 2559,2565 ****
static void
ns_draw_vertical_window_border (struct window *w, int x, int y0, int y1)
/* --------------------------------------------------------------------------
! External (RIF): Draw a vertical line.
-------------------------------------------------------------------------- */
{
struct frame *f = XFRAME (WINDOW_FRAME (w));
--- 2559,2565 ----
static void
ns_draw_vertical_window_border (struct window *w, int x, int y0, int y1)
/* --------------------------------------------------------------------------
! External (RIF): Draw a vertical line.
-------------------------------------------------------------------------- */
{
struct frame *f = XFRAME (WINDOW_FRAME (w));
***************
*** 2570,2576 ****
face = FACE_FROM_ID (f, VERTICAL_BORDER_FACE_ID);
if (face)
! [ns_lookup_indexed_color(face->foreground, f) set];
ns_focus (f, &r, 1);
NSRectFill(r);
--- 2570,2576 ----
face = FACE_FROM_ID (f, VERTICAL_BORDER_FACE_ID);
if (face)
! [ns_lookup_indexed_color(face->foreground, f) set];
ns_focus (f, &r, 1);
NSRectFill(r);
***************
*** 2581,2587 ****
static void
ns_draw_window_divider (struct window *w, int x0, int x1, int y0, int y1)
/* --------------------------------------------------------------------------
! External (RIF): Draw a window divider.
-------------------------------------------------------------------------- */
{
struct frame *f = XFRAME (WINDOW_FRAME (w));
--- 2581,2587 ----
static void
ns_draw_window_divider (struct window *w, int x0, int x1, int y0, int y1)
/* --------------------------------------------------------------------------
! External (RIF): Draw a window divider.
-------------------------------------------------------------------------- */
{
struct frame *f = XFRAME (WINDOW_FRAME (w));
***************
*** 2592,2598 ****
face = FACE_FROM_ID (f, WINDOW_DIVIDER_FACE_ID);
if (face)
! [ns_lookup_indexed_color(face->foreground, f) set];
ns_focus (f, &r, 1);
NSRectFill(r);
--- 2592,2598 ----
face = FACE_FROM_ID (f, WINDOW_DIVIDER_FACE_ID);
if (face)
! [ns_lookup_indexed_color(face->foreground, f) set];
ns_focus (f, &r, 1);
NSRectFill(r);
***************
*** 2633,2648 ****
/* ==========================================================================
! Glyph drawing operations
========================================================================== */
static int
ns_get_glyph_string_clip_rect (struct glyph_string *s, NativeRectangle *nr)
/* --------------------------------------------------------------------------
! Wrapper utility to account for internal border width on full-width lines,
! and allow top full-width rows to hit the frame top. nr should be pointer
! to two successive NSRects. Number of rects actually used is returned.
-------------------------------------------------------------------------- */
{
int n = get_glyph_string_clip_rects (s, nr, 2);
--- 2633,2648 ----
/* ==========================================================================
! Glyph drawing operations
========================================================================== */
static int
ns_get_glyph_string_clip_rect (struct glyph_string *s, NativeRectangle *nr)
/* --------------------------------------------------------------------------
! Wrapper utility to account for internal border width on full-width lines,
! and allow top full-width rows to hit the frame top. nr should be pointer
! to two successive NSRects. Number of rects actually used is returned.
-------------------------------------------------------------------------- */
{
int n = get_glyph_string_clip_rects (s, nr, 2);
***************
*** 2653,2664 ****
Draw a wavy line under glyph string s. The wave fills wave_height
pixels from y.
! x wave_length = 2
! --
! y * * * * *
! |* * * * * * * * *
! wave_height = 3 | * * * *
! --------------------------------------------------------------------- */
static void
ns_draw_underwave (struct glyph_string *s, EmacsCGFloat width, EmacsCGFloat x)
--- 2653,2664 ----
Draw a wavy line under glyph string s. The wave fills wave_height
pixels from y.
! x wave_length = 2
! --
! y * * * * *
! |* * * * * * * * *
! wave_height = 3 | * * * *
! --------------------------------------------------------------------- */
static void
ns_draw_underwave (struct glyph_string *s, EmacsCGFloat width, EmacsCGFloat x)
***************
*** 2822,2830 ****
ns_draw_box (NSRect r, CGFloat thickness, NSColor *col,
char left_p, char right_p)
/* --------------------------------------------------------------------------
! Draw an unfilled rect inside r, optionally leaving left and/or right open.
! Note we can't just use an NSDrawRect command, because of the possibility
! of some sides not being drawn, and because the rect will be filled.
-------------------------------------------------------------------------- */
{
NSRect s = r;
--- 2822,2830 ----
ns_draw_box (NSRect r, CGFloat thickness, NSColor *col,
char left_p, char right_p)
/* --------------------------------------------------------------------------
! Draw an unfilled rect inside r, optionally leaving left and/or right open.
! Note we can't just use an NSDrawRect command, because of the possibility
! of some sides not being drawn, and because the rect will be filled.
-------------------------------------------------------------------------- */
{
NSRect s = r;
***************
*** 2853,2864 ****
static void
ns_draw_relief (NSRect r, int thickness, char raised_p,
! char top_p, char bottom_p, char left_p, char right_p,
! struct glyph_string *s)
/* --------------------------------------------------------------------------
! Draw a relief rect inside r, optionally leaving some sides open.
! Note we can't just use an NSDrawBezel command, because of the possibility
! of some sides not being drawn, and because the rect will be filled.
-------------------------------------------------------------------------- */
{
static NSColor *baseCol = nil, *lightCol = nil, *darkCol = nil;
--- 2853,2864 ----
static void
ns_draw_relief (NSRect r, int thickness, char raised_p,
! char top_p, char bottom_p, char left_p, char right_p,
! struct glyph_string *s)
/* --------------------------------------------------------------------------
! Draw a relief rect inside r, optionally leaving some sides open.
! Note we can't just use an NSDrawBezel command, because of the possibility
! of some sides not being drawn, and because the rect will be filled.
-------------------------------------------------------------------------- */
{
static NSColor *baseCol = nil, *lightCol = nil, *darkCol = nil;
***************
*** 2873,2884 ****
{
newBaseCol = ns_lookup_indexed_color (s->face->box_color, s->f);
}
! /* else if (s->first_glyph->type == IMAGE_GLYPH
! && s->img->pixmap
! && !IMAGE_BACKGROUND_TRANSPARENT (s->img, s->f, 0))
! {
newBaseCol = IMAGE_BACKGROUND (s->img, s->f, 0);
! } */
else
{
newBaseCol = ns_lookup_indexed_color (s->face->background, s->f);
--- 2873,2884 ----
{
newBaseCol = ns_lookup_indexed_color (s->face->box_color, s->f);
}
! /* else if (s->first_glyph->type == IMAGE_GLYPH
! && s->img->pixmap
! && !IMAGE_BACKGROUND_TRANSPARENT (s->img, s->f, 0))
! {
newBaseCol = IMAGE_BACKGROUND (s->img, s->f, 0);
! } */
else
{
newBaseCol = ns_lookup_indexed_color (s->face->background, s->f);
***************
*** 2930,2937 ****
static void
ns_dumpglyphs_box_or_relief (struct glyph_string *s)
/* --------------------------------------------------------------------------
! Function modeled after x_draw_glyph_string_box ().
! Sets up parameters for drawing.
-------------------------------------------------------------------------- */
{
int right_x, last_x;
--- 2930,2937 ----
static void
ns_dumpglyphs_box_or_relief (struct glyph_string *s)
/* --------------------------------------------------------------------------
! Function modeled after x_draw_glyph_string_box ().
! Sets up parameters for drawing.
-------------------------------------------------------------------------- */
{
int right_x, last_x;
***************
*** 2977,2988 ****
{
ns_draw_box (r, abs (thickness),
ns_lookup_indexed_color (face->box_color, s->f),
! left_p, right_p);
}
else
{
ns_draw_relief (r, abs (thickness), s->face->box == FACE_RAISED_BOX,
! 1, 1, left_p, right_p, s);
}
}
--- 2977,2988 ----
{
ns_draw_box (r, abs (thickness),
ns_lookup_indexed_color (face->box_color, s->f),
! left_p, right_p);
}
else
{
ns_draw_relief (r, abs (thickness), s->face->box == FACE_RAISED_BOX,
! 1, 1, left_p, right_p, s);
}
}
***************
*** 2990,2997 ****
static void
ns_maybe_dumpglyphs_background (struct glyph_string *s, char force_p)
/* --------------------------------------------------------------------------
! Modeled after x_draw_glyph_string_background, which draws BG in
! certain cases. Others are left to the text rendering routine.
-------------------------------------------------------------------------- */
{
NSTRACE (ns_maybe_dumpglyphs_background);
--- 2990,2997 ----
static void
ns_maybe_dumpglyphs_background (struct glyph_string *s, char force_p)
/* --------------------------------------------------------------------------
! Modeled after x_draw_glyph_string_background, which draws BG in
! certain cases. Others are left to the text rendering routine.
-------------------------------------------------------------------------- */
{
NSTRACE (ns_maybe_dumpglyphs_background);
***************
*** 3025,3032 ****
if (s->hl != DRAW_CURSOR)
{
NSRect r = NSMakeRect (s->x, s->y + box_line_width,
! s->background_width,
! s->height-2*box_line_width);
NSRectFill (r);
}
--- 3025,3032 ----
if (s->hl != DRAW_CURSOR)
{
NSRect r = NSMakeRect (s->x, s->y + box_line_width,
! s->background_width,
! s->height-2*box_line_width);
NSRectFill (r);
}
***************
*** 3039,3045 ****
static void
ns_dumpglyphs_image (struct glyph_string *s, NSRect r)
/* --------------------------------------------------------------------------
! Renders an image and associated borders.
-------------------------------------------------------------------------- */
{
EmacsImage *img = s->img->pixmap;
--- 3039,3045 ----
static void
ns_dumpglyphs_image (struct glyph_string *s, NSRect r)
/* --------------------------------------------------------------------------
! Renders an image and associated borders.
-------------------------------------------------------------------------- */
{
EmacsImage *img = s->img->pixmap;
***************
*** 3074,3080 ****
{
face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
if (!face)
! face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
}
else
face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
--- 3074,3080 ----
{
face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
if (!face)
! face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
}
else
face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
***************
*** 3103,3110 ****
s->slice.width, s->slice.height);
[img drawInRect: dr
fromRect: ir
! operation: NSCompositeSourceOver
! fraction: 1.0
respectFlipped: YES
hints: nil];
#else
--- 3103,3110 ----
s->slice.width, s->slice.height);
[img drawInRect: dr
fromRect: ir
! operation: NSCompositeSourceOver
! fraction: 1.0
respectFlipped: YES
hints: nil];
#else
***************
*** 3115,3130 ****
if (s->hl == DRAW_CURSOR)
{
! [FRAME_CURSOR_COLOR (s->f) set];
! if (s->w->phys_cursor_type == FILLED_BOX_CURSOR)
! tdCol = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f);
! else
! /* Currently on NS img->mask is always 0. Since
! get_window_cursor_type specifies a hollow box cursor when on
! a non-masked image we never reach this clause. But we put it
! in in anticipation of better support for image masks on
! NS. */
! tdCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f);
}
else
{
--- 3115,3130 ----
if (s->hl == DRAW_CURSOR)
{
! [FRAME_CURSOR_COLOR (s->f) set];
! if (s->w->phys_cursor_type == FILLED_BOX_CURSOR)
! tdCol = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f);
! else
! /* Currently on NS img->mask is always 0. Since
! get_window_cursor_type specifies a hollow box cursor when on
! a non-masked image we never reach this clause. But we put it
! in in anticipation of better support for image masks on
! NS. */
! tdCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f);
}
else
{
***************
*** 3188,3200 ****
ns_focus (s->f, r, n);
if (s->hl == DRAW_MOUSE_FACE)
! {
! face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
! if (!face)
! face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
! }
else
! face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
bgCol = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f);
fgCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f);
--- 3188,3200 ----
ns_focus (s->f, r, n);
if (s->hl == DRAW_MOUSE_FACE)
! {
! face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
! if (!face)
! face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
! }
else
! face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
bgCol = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f);
fgCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f);
***************
*** 3215,3232 ****
leftoverrun = (WINDOW_BOX_LEFT_EDGE_X (s->w)
+ WINDOW_LEFT_FRINGE_WIDTH (s->w)) - s->x;
! if (leftoverrun > 0)
! {
! r[i].origin.x += leftoverrun;
! r[i].size.width -= leftoverrun;
! }
!
! /* XXX: Try to work between problem where a stretch glyph on
! a partially-visible bottom row will clear part of the
! modeline, and another where list-buffers headers and similar
! rows erroneously have visible_height set to 0. Not sure
! where this is coming from as other terms seem not to show. */
! r[i].size.height = min (s->height, s->row->visible_height);
}
[bgCol set];
--- 3215,3232 ----
leftoverrun = (WINDOW_BOX_LEFT_EDGE_X (s->w)
+ WINDOW_LEFT_FRINGE_WIDTH (s->w)) - s->x;
! if (leftoverrun > 0)
! {
! r[i].origin.x += leftoverrun;
! r[i].size.width -= leftoverrun;
! }
!
! /* XXX: Try to work between problem where a stretch glyph on
! a partially-visible bottom row will clear part of the
! modeline, and another where list-buffers headers and similar
! rows erroneously have visible_height set to 0. Not sure
! where this is coming from as other terms seem not to show. */
! r[i].size.height = min (s->height, s->row->visible_height);
}
[bgCol set];
***************
*** 3269,3275 ****
static void
ns_draw_glyph_string (struct glyph_string *s)
/* --------------------------------------------------------------------------
! External (RIF): Main draw-text call.
-------------------------------------------------------------------------- */
{
/* TODO (optimize): focus for box and contents draw */
--- 3269,3275 ----
static void
ns_draw_glyph_string (struct glyph_string *s)
/* --------------------------------------------------------------------------
! External (RIF): Main draw-text call.
-------------------------------------------------------------------------- */
{
/* TODO (optimize): focus for box and contents draw */
***************
*** 3307,3314 ****
}
if (!s->for_overlaps && s->face->box != FACE_NO_BOX
! && (s->first_glyph->type == CHAR_GLYPH
! || s->first_glyph->type == COMPOSITE_GLYPH))
{
n = ns_get_glyph_string_clip_rect (s, r);
ns_focus (s->f, r, n);
--- 3307,3314 ----
}
if (!s->for_overlaps && s->face->box != FACE_NO_BOX
! && (s->first_glyph->type == CHAR_GLYPH
! || s->first_glyph->type == COMPOSITE_GLYPH))
{
n = ns_get_glyph_string_clip_rect (s, r);
ns_focus (s->f, r, n);
***************
*** 3418,3424 ****
/* ==========================================================================
! Event loop
========================================================================== */
--- 3418,3424 ----
/* ==========================================================================
! Event loop
========================================================================== */
***************
*** 3426,3433 ****
static void
ns_send_appdefined (int value)
/* --------------------------------------------------------------------------
! Internal: post an appdefined event which EmacsApp-sendEvent will
! recognize and take as a command to halt the event loop.
-------------------------------------------------------------------------- */
{
/*NSTRACE (ns_send_appdefined); */
--- 3426,3433 ----
static void
ns_send_appdefined (int value)
/* --------------------------------------------------------------------------
! Internal: post an appdefined event which EmacsApp-sendEvent will
! recognize and take as a command to halt the event loop.
-------------------------------------------------------------------------- */
{
/*NSTRACE (ns_send_appdefined); */
***************
*** 3446,3453 ****
#endif
/* Only post this event if we haven't already posted one. This will end
! the [NXApp run] main loop after having processed all events queued at
! this moment. */
if (send_appdefined)
{
NSEvent *nxev;
--- 3446,3453 ----
#endif
/* Only post this event if we haven't already posted one. This will end
! the [NXApp run] main loop after having processed all events queued at
! this moment. */
if (send_appdefined)
{
NSEvent *nxev;
***************
*** 3504,3510 ****
#endif
/* GNUstep and OSX <= 10.4 does not have cancelTracking. */
! #if defined (NS_IMPL_COCOA) && \
MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
/* Check if menu open should be canceled or continued as normal. */
void
--- 3504,3510 ----
#endif
/* GNUstep and OSX <= 10.4 does not have cancelTracking. */
! #if defined (NS_IMPL_COCOA) && \
MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
/* Check if menu open should be canceled or continued as normal. */
void
***************
*** 3573,3587 ****
static int
ns_read_socket (struct terminal *terminal, struct input_event *hold_quit)
/* --------------------------------------------------------------------------
! External (hook): Post an event to ourself and keep reading events until
! we read it back again. In effect process all events which were waiting.
! From 21+ we have to manage the event buffer ourselves.
-------------------------------------------------------------------------- */
{
struct input_event ev;
int nevents;
! /* NSTRACE (ns_read_socket); */
#ifdef HAVE_NATIVE_FS
check_native_fs ();
--- 3573,3587 ----
static int
ns_read_socket (struct terminal *terminal, struct input_event *hold_quit)
/* --------------------------------------------------------------------------
! External (hook): Post an event to ourself and keep reading events until
! we read it back again. In effect process all events which were waiting.
! From 21+ we have to manage the event buffer ourselves.
-------------------------------------------------------------------------- */
{
struct input_event ev;
int nevents;
! /* NSTRACE (ns_read_socket); */
#ifdef HAVE_NATIVE_FS
check_native_fs ();
***************
*** 3619,3627 ****
}
/* Deal with pending service requests. */
else if (ns_pending_service_names && [ns_pending_service_names count] != 0
! && [(EmacsApp *)
! NSApp fulfillService: [ns_pending_service_names objectAtIndex: 0]
! withArg: [ns_pending_service_args objectAtIndex: 0]])
{
[ns_pending_service_names removeObjectAtIndex: 0];
[ns_pending_service_args removeObjectAtIndex: 0];
--- 3619,3627 ----
}
/* Deal with pending service requests. */
else if (ns_pending_service_names && [ns_pending_service_names count] != 0
! && [(EmacsApp *)
! NSApp fulfillService: [ns_pending_service_names objectAtIndex: 0]
! withArg: [ns_pending_service_args objectAtIndex: 0]])
{
[ns_pending_service_names removeObjectAtIndex: 0];
[ns_pending_service_args removeObjectAtIndex: 0];
***************
*** 3655,3661 ****
fd_set *exceptfds, struct timespec const *timeout,
sigset_t const *sigmask)
/* --------------------------------------------------------------------------
! Replacement for select, checking for events
-------------------------------------------------------------------------- */
{
int result;
--- 3655,3661 ----
fd_set *exceptfds, struct timespec const *timeout,
sigset_t const *sigmask)
/* --------------------------------------------------------------------------
! Replacement for select, checking for events
-------------------------------------------------------------------------- */
{
int result;
***************
*** 3663,3669 ****
struct input_event event;
char c;
! /* NSTRACE (ns_select); */
#ifdef HAVE_NATIVE_FS
check_native_fs ();
--- 3663,3669 ----
struct input_event event;
char c;
! /* NSTRACE (ns_select); */
#ifdef HAVE_NATIVE_FS
check_native_fs ();
***************
*** 3796,3811 ****
/* ==========================================================================
! Scrollbar handling
========================================================================== */
static void
ns_set_vertical_scroll_bar (struct window *window,
! int portion, int whole, int position)
/* --------------------------------------------------------------------------
! External (hook): Update or add scrollbar
-------------------------------------------------------------------------- */
{
Lisp_Object win;
--- 3796,3811 ----
/* ==========================================================================
! Scrollbar handling
========================================================================== */
static void
ns_set_vertical_scroll_bar (struct window *window,
! int portion, int whole, int position)
/* --------------------------------------------------------------------------
! External (hook): Update or add scrollbar
-------------------------------------------------------------------------- */
{
Lisp_Object win;
***************
*** 3826,3832 ****
if (view->scrollbarsNeedingUpdate == 0)
{
if (!windows_or_buffers_changed)
! return;
}
else
view->scrollbarsNeedingUpdate--;
--- 3826,3832 ----
if (view->scrollbarsNeedingUpdate == 0)
{
if (!windows_or_buffers_changed)
! return;
}
else
view->scrollbarsNeedingUpdate--;
***************
*** 3893,3899 ****
if (FRAME_LIVE_P (f) && !NSEqualRects (oldRect, r))
{
if (oldRect.origin.x != r.origin.x)
! ns_clear_frame_area (f, sb_left, top, width, height);
[bar setFrame: r];
}
}
--- 3893,3899 ----
if (FRAME_LIVE_P (f) && !NSEqualRects (oldRect, r))
{
if (oldRect.origin.x != r.origin.x)
! ns_clear_frame_area (f, sb_left, top, width, height);
[bar setFrame: r];
}
}
***************
*** 3906,3913 ****
static void
ns_condemn_scroll_bars (struct frame *f)
/* --------------------------------------------------------------------------
! External (hook): arrange for all frame's scrollbars to be removed
! at next call to judge_scroll_bars, except for those redeemed.
-------------------------------------------------------------------------- */
{
int i;
--- 3906,3913 ----
static void
ns_condemn_scroll_bars (struct frame *f)
/* --------------------------------------------------------------------------
! External (hook): arrange for all frame's scrollbars to be removed
! at next call to judge_scroll_bars, except for those redeemed.
-------------------------------------------------------------------------- */
{
int i;
***************
*** 3928,3935 ****
static void
ns_redeem_scroll_bar (struct window *window)
/* --------------------------------------------------------------------------
! External (hook): arrange to spare this window's scrollbar
! at next call to judge_scroll_bars.
-------------------------------------------------------------------------- */
{
id bar;
--- 3928,3935 ----
static void
ns_redeem_scroll_bar (struct window *window)
/* --------------------------------------------------------------------------
! External (hook): arrange to spare this window's scrollbar
! at next call to judge_scroll_bars.
-------------------------------------------------------------------------- */
{
id bar;
***************
*** 3945,3952 ****
static void
ns_judge_scroll_bars (struct frame *f)
/* --------------------------------------------------------------------------
! External (hook): destroy all scrollbars on frame that weren't
! redeemed after call to condemn_scroll_bars.
-------------------------------------------------------------------------- */
{
int i;
--- 3945,3952 ----
static void
ns_judge_scroll_bars (struct frame *f)
/* --------------------------------------------------------------------------
! External (hook): destroy all scrollbars on frame that weren't
! redeemed after call to condemn_scroll_bars.
-------------------------------------------------------------------------- */
{
int i;
***************
*** 3970,3976 ****
/* ==========================================================================
! Initialization
========================================================================== */
--- 3970,3976 ----
/* ==========================================================================
! Initialization
========================================================================== */
***************
*** 4007,4013 ****
static Lisp_Object ns_string_to_lispmod (const char *s)
/* --------------------------------------------------------------------------
! Convert modifier name to lisp symbol
-------------------------------------------------------------------------- */
{
if (!strncmp (SSDATA (SYMBOL_NAME (Qmeta)), s, 10))
--- 4007,4013 ----
static Lisp_Object ns_string_to_lispmod (const char *s)
/* --------------------------------------------------------------------------
! Convert modifier name to lisp symbol
-------------------------------------------------------------------------- */
{
if (!strncmp (SSDATA (SYMBOL_NAME (Qmeta)), s, 10))
***************
*** 4029,4038 ****
static void
ns_default (const char *parameter, Lisp_Object *result,
! Lisp_Object yesval, Lisp_Object noval,
! BOOL is_float, BOOL is_modstring)
/* --------------------------------------------------------------------------
! Check a parameter value in user's preferences
-------------------------------------------------------------------------- */
{
const char *value = ns_get_defaults_value (parameter);
--- 4029,4038 ----
static void
ns_default (const char *parameter, Lisp_Object *result,
! Lisp_Object yesval, Lisp_Object noval,
! BOOL is_float, BOOL is_modstring)
/* --------------------------------------------------------------------------
! Check a parameter value in user's preferences
-------------------------------------------------------------------------- */
{
const char *value = ns_get_defaults_value (parameter);
***************
*** 4254,4259 ****
--- 4254,4263 ----
selector: @selector (logNotification:)
name: nil object: nil]; */
+ [[NSDistributedNotificationCenter defaultCenter] addObserver: NSApp
+ selector: @selector (changeInputMethod:)
+ name: @"AppleSelectedInputSourcesChangedNotification" object: nil];
+
dpyinfo = xzalloc (sizeof *dpyinfo);
ns_initialize_display_info (dpyinfo);
***************
*** 4520,4525 ****
--- 4524,4545 ----
NSLog (@"notification: '%@'", [notification name]);
}
+ - (void)changeInputMethod: (NSNotification *)notification
+ {
+
+ struct frame *emacsframe = SELECTED_FRAME ();
+
+ if (mac_store_change_input_method_event())
+ {
+ if (!emacs_event)
+ return;
+ emacs_event->kind = NS_NONKEY_EVENT;
+ emacs_event->code = KEY_MAC_CHANGE_INPUT_METHOD;
+ emacs_event->modifiers = 0;
+ EV_TRAILER ((id)nil);
+ }
+ }
+
- (void)sendEvent: (NSEvent *)theEvent
/* --------------------------------------------------------------------------
***************
*** 5294,5317 ****
code, fnKeysym, flags, emacs_event->modifiers);
/* if it was a function key or had modifiers, pass it directly to emacs */
! if (fnKeysym || (emacs_event->modifiers
! && (emacs_event->modifiers != shift_modifier)
! && [[theEvent charactersIgnoringModifiers] length] > 0))
/*[[theEvent characters] length] */
! {
! emacs_event->kind = NON_ASCII_KEYSTROKE_EVENT;
! if (code < 0x20)
! code |= (1<<28)|(3<<16);
! else if (code == 0x7f)
code |= (1<<28)|(3<<16);
else if (!fnKeysym)
emacs_event->kind = code > 0xFF
? MULTIBYTE_CHAR_KEYSTROKE_EVENT : ASCII_KEYSTROKE_EVENT;
emacs_event->code = code;
! EV_TRAILER (theEvent);
! processingCompose = NO;
! return;
}
}
--- 5314,5348 ----
code, fnKeysym, flags, emacs_event->modifiers);
/* if it was a function key or had modifiers, pass it directly to emacs */
! if (mac_pass_key_directly_to_emacs ()
! ||fnKeysym || (emacs_event->modifiers
! && (emacs_event->modifiers != shift_modifier)
! && [[theEvent charactersIgnoringModifiers] length] > 0))
/*[[theEvent characters] length] */
! {
! emacs_event->kind = NON_ASCII_KEYSTROKE_EVENT;
! if (code < 0x20)
! code |= (1<<28)|(3<<16);
! else if (code == 0x7f)
code |= (1<<28)|(3<<16);
else if (!fnKeysym)
emacs_event->kind = code > 0xFF
? MULTIBYTE_CHAR_KEYSTROKE_EVENT : ASCII_KEYSTROKE_EVENT;
emacs_event->code = code;
! /* The function mac_pass_key_to_system decides
! whether it is passed directly to emacs or not. */
! if (emacs_event->kind == NON_ASCII_KEYSTROKE_EVENT
! || !mac_pass_key_to_system (code, flags
! & (NSShiftKeyMask
! | NSControlKeyMask
! | NSAlternateKeyMask
! | NSCommandKeyMask)))
! {
! EV_TRAILER (theEvent);
! processingCompose = NO;
! return;
! }
}
}
***************
*** 5411,5420 ****
(unsigned long)selRange.length,
(unsigned long)selRange.location);
- if (workingText != nil)
- [self deleteWorkingText];
if ([str length] == 0)
! return;
if (!emacs_event)
return;
--- 5442,5461 ----
(unsigned long)selRange.length,
(unsigned long)selRange.location);
if ([str length] == 0)
! {
! [self deleteWorkingText];
! return;
! }
! else
! {
! if (workingText != nil) {
! [workingText release];
! workingText = nil;
! processingCompose = NO;
! }
! }
!
if (!emacs_event)
return;
***************
*** 5424,5430 ****
ns_working_text = build_string ([workingText UTF8String]);
emacs_event->kind = NS_TEXT_EVENT;
! emacs_event->code = KEY_NS_PUT_WORKING_TEXT;
EV_TRAILER ((id)nil);
}
--- 5465,5473 ----
ns_working_text = build_string ([workingText UTF8String]);
emacs_event->kind = NS_TEXT_EVENT;
! emacs_event->code = KEY_NS_PUT_MARKED_TEXT;
! emacs_event->arg = Fcons (make_number (selRange.location),
! Fcons (make_number (selRange.length), Qnil));
EV_TRAILER ((id)nil);
}
***************
*** 5479,5493 ****
{
NSRect rect;
NSPoint pt;
! struct window *win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe));
if (NS_KEYLOG)
NSLog (@"firstRectForCharRange request");
rect.size.width = theRange.length * FRAME_COLUMN_WIDTH (emacsframe);
rect.size.height = FRAME_LINE_HEIGHT (emacsframe);
pt.x = WINDOW_TEXT_TO_FRAME_PIXEL_X (win, win->phys_cursor.x);
pt.y = WINDOW_TO_FRAME_PIXEL_Y (win, win->phys_cursor.y
! +FRAME_LINE_HEIGHT (emacsframe));
pt = [self convertPoint: pt toView: nil];
pt = [[self window] convertBaseToScreen: pt];
--- 5522,5545 ----
{
NSRect rect;
NSPoint pt;
! // struct window *win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe));
! struct window *win;
if (NS_KEYLOG)
NSLog (@"firstRectForCharRange request");
+ if (NILP (Vmac_in_echo_area))
+ win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe));
+ else if (WINDOWP (echo_area_window))
+ win = XWINDOW (echo_area_window);
+ else
+ win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe));
+
rect.size.width = theRange.length * FRAME_COLUMN_WIDTH (emacsframe);
rect.size.height = FRAME_LINE_HEIGHT (emacsframe);
pt.x = WINDOW_TEXT_TO_FRAME_PIXEL_X (win, win->phys_cursor.x);
pt.y = WINDOW_TO_FRAME_PIXEL_Y (win, win->phys_cursor.y
! +FRAME_LINE_HEIGHT (emacsframe)+2);
!
pt = [self convertPoint: pt toView: nil];
pt = [[self window] convertBaseToScreen: pt];
***************
*** 7756,7761 ****
--- 7808,7817 ----
baseline level. The default value is nil. */);
x_underline_at_descent_line = 0;
+ DEFVAR_LISP ("mac-in-echo-area", Vmac_in_echo_area,
+ doc: /* state of cursor in echo area. */);
+ Vmac_in_echo_area = Qnil;
+
/* Tell Emacs about this window system. */
Fprovide (Qns, Qnil);
diff -Nrc emacs-24.4_orig/src/termhooks.h emacs-24.4_patched/src/termhooks.h
*** emacs-24.4_orig/src/termhooks.h 2014-12-07 01:37:59.000000000 +0900
--- emacs-24.4_patched/src/termhooks.h 2014-12-07 02:09:35.000000000 +0900
***************
*** 49,54 ****
--- 49,55 ----
output_x_window,
output_msdos_raw,
output_w32,
+ output_mac,
output_ns
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment