comparison lisp/term/ns-win.el @ 96870:30f1368d9cf6

* term/ns-win.el: Rename ns- functions/variables to the corresponding x- versions. (x-select-text, x-cut-buffer-or-selection-value) (x-disown-selection-internal, x-get-selection-internal) (x-own-selection-internal, x-defined-colors, xw-defined-colors) (x-display-mm-width, x-display-mm-height) (x-display-backing-store, x-display-save-under) (x-display-visual-class, x-display-screens, x-focus-frame): Remove defaliases. * image.c: * nsfns.m: * nsselect.m: * nsterm.h: * nsterm.m: Rename ns prefixed functions/variables to the corresponding x versions. Update references.
author Dan Nicolaescu <dann@ics.uci.edu>
date Mon, 21 Jul 2008 17:47:25 +0000
parents 2e1af3a60ab7
children 71ed3159f616
comparison
equal deleted inserted replaced
96869:8cb5d45989af 96870:30f1368d9cf6
59 ;; nsterm.m 59 ;; nsterm.m
60 (defvar ns-version-string) 60 (defvar ns-version-string)
61 (defvar ns-expand-space) 61 (defvar ns-expand-space)
62 (defvar ns-cursor-blink-rate) 62 (defvar ns-cursor-blink-rate)
63 (defvar ns-alternate-modifier) 63 (defvar ns-alternate-modifier)
64
65 (declare-function ns-server-vendor "nsfns.m" (&optional display))
66 (declare-function ns-server-version "nsfns.m" (&optional display))
67 64
68 ;;;; Command line argument handling. 65 ;;;; Command line argument handling.
69 66
70 (defvar ns-invocation-args nil) 67 (defvar ns-invocation-args nil)
71 (defvar ns-command-line-resources nil) 68 (defvar ns-command-line-resources nil)
96 (error "%s: missing argument to `%s' option" (invocation-name) switch)) 93 (error "%s: missing argument to `%s' option" (invocation-name) switch))
97 (setq initial-frame-alist (cons (cons 'name (pop ns-invocation-args)) 94 (setq initial-frame-alist (cons (cons 'name (pop ns-invocation-args))
98 initial-frame-alist))) 95 initial-frame-alist)))
99 96
100 ;; Set (but not used?) in frame.el. 97 ;; Set (but not used?) in frame.el.
101 (defvar ns-display-name nil 98 (defvar x-display-name nil
102 "The name of the Nextstep display on which Emacs was started.") 99 "The name of the Nextstep display on which Emacs was started.")
103 100
104 ;; nsterm.m. 101 ;; nsterm.m.
105 (defvar ns-input-file) 102 (defvar ns-input-file)
106 103
321 (defvaralias 'mac-command-modifier 'ns-command-modifier) 318 (defvaralias 'mac-command-modifier 'ns-command-modifier)
322 (defvaralias 'mac-control-modifier 'ns-control-modifier) 319 (defvaralias 'mac-control-modifier 'ns-control-modifier)
323 (defvaralias 'mac-option-modifier 'ns-option-modifier) 320 (defvaralias 'mac-option-modifier 'ns-option-modifier)
324 (defvaralias 'mac-function-modifier 'ns-function-modifier) 321 (defvaralias 'mac-function-modifier 'ns-function-modifier)
325 322
326 ;; alt-up/down scrolling a la Stuart.app
327 ;; only activated if ns-extended-platform-support is on
328 (defun up-one () (interactive) (scroll-up 1))
329 (defun down-one () (interactive) (scroll-down 1))
330 (defun left-one () (interactive) (scroll-left 1))
331 (defun right-one () (interactive) (scroll-right 1))
332
333 (defvar menu-bar-ns-file-menu) ; below 323 (defvar menu-bar-ns-file-menu) ; below
334 324
335 ;; Toggle some additional Nextstep-like features that may interfere 325 ;; Toggle some additional Nextstep-like features that may interfere
336 ;; with users' expectations coming from emacs on other platforms. 326 ;; with users' expectations coming from emacs on other platforms.
337 (define-minor-mode ns-extended-platform-support-mode 327 (define-minor-mode ns-extended-platform-support-mode
373 363
374 (defun x-setup-function-keys (frame) 364 (defun x-setup-function-keys (frame)
375 "Set up function Keys for Nextstep for frame FRAME." 365 "Set up function Keys for Nextstep for frame FRAME."
376 (unless (terminal-parameter frame 'x-setup-function-keys) 366 (unless (terminal-parameter frame 'x-setup-function-keys)
377 (with-selected-frame frame 367 (with-selected-frame frame
378 (setq interprogram-cut-function 'ns-select-text 368 (setq interprogram-cut-function 'x-select-text
379 interprogram-paste-function 'ns-pasteboard-value) 369 interprogram-paste-function 'x-cut-buffer-or-selection-value)
380 ;; (let ((map (copy-keymap x-alternatives-map))) 370 ;; (let ((map (copy-keymap x-alternatives-map)))
381 ;; (set-keymap-parent map (keymap-parent local-function-key-map)) 371 ;; (set-keymap-parent map (keymap-parent local-function-key-map))
382 ;; (set-keymap-parent local-function-key-map map)) 372 ;; (set-keymap-parent local-function-key-map map))
383 (setq system-key-alist 373 (setq system-key-alist
384 (list 374 (list
1385 (if (not (stringp string)) (error "Nonstring given to pasteboard")) 1375 (if (not (stringp string)) (error "Nonstring given to pasteboard"))
1386 (ns-store-cut-buffer-internal 'PRIMARY string)) 1376 (ns-store-cut-buffer-internal 'PRIMARY string))
1387 1377
1388 ;; We keep track of the last text selected here, so we can check the 1378 ;; We keep track of the last text selected here, so we can check the
1389 ;; current selection against it, and avoid passing back our own text 1379 ;; current selection against it, and avoid passing back our own text
1390 ;; from ns-pasteboard-value. 1380 ;; from x-cut-buffer-or-selection-value.
1391 (defvar ns-last-selected-text nil) 1381 (defvar ns-last-selected-text nil)
1392 1382
1393 (defun ns-select-text (text &optional push) 1383 (defun x-select-text (text &optional push)
1394 "Put TEXT, a string, on the pasteboard." 1384 "Put TEXT, a string, on the pasteboard."
1395 ;; Don't send the pasteboard too much text. 1385 ;; Don't send the pasteboard too much text.
1396 ;; It becomes slow, and if really big it causes errors. 1386 ;; It becomes slow, and if really big it causes errors.
1397 (ns-set-pasteboard text) 1387 (ns-set-pasteboard text)
1398 (setq ns-last-selected-text text)) 1388 (setq ns-last-selected-text text))
1399 1389
1400 ;; Return the value of the current Nextstep selection. For 1390 ;; Return the value of the current Nextstep selection. For
1401 ;; compatibility with older Nextstep applications, this checks cut 1391 ;; compatibility with older Nextstep applications, this checks cut
1402 ;; buffer 0 before retrieving the value of the primary selection. 1392 ;; buffer 0 before retrieving the value of the primary selection.
1403 (defun ns-pasteboard-value () 1393 (defun x-cut-buffer-or-selection-value ()
1404 (let (text) 1394 (let (text)
1405 1395
1406 ;; Consult the selection, then the cut buffer. Treat empty strings 1396 ;; Consult the selection, then the cut buffer. Treat empty strings
1407 ;; as if they were unset. 1397 ;; as if they were unset.
1408 (or text (setq text (ns-get-pasteboard))) 1398 (or text (setq text (ns-get-pasteboard)))
1427 (interactive) 1417 (interactive)
1428 (insert (ns-get-cut-buffer-internal 'SECONDARY))) 1418 (insert (ns-get-cut-buffer-internal 'SECONDARY)))
1429 1419
1430 ;; PENDING: not sure what to do here.. for now interprog- are set in 1420 ;; PENDING: not sure what to do here.. for now interprog- are set in
1431 ;; init-fn-keys, and unsure whether these x- settings have an effect. 1421 ;; init-fn-keys, and unsure whether these x- settings have an effect.
1432 ;;(setq interprogram-cut-function 'ns-select-text 1422 ;;(setq interprogram-cut-function 'x-select-text
1433 ;; interprogram-paste-function 'ns-pasteboard-value) 1423 ;; interprogram-paste-function 'x-cut-buffer-or-selection-value)
1434 ;; These only needed if above not working. 1424 ;; These only needed if above not working.
1435 (defalias 'x-select-text 'ns-select-text)
1436 (defalias 'x-cut-buffer-or-selection-value 'ns-pasteboard-value)
1437 (defalias 'x-disown-selection-internal 'ns-disown-selection-internal)
1438 (defalias 'x-get-selection-internal 'ns-get-selection-internal)
1439 (defalias 'x-own-selection-internal 'ns-own-selection-internal)
1440 1425
1441 (set-face-background 'region "ns_selection_color") 1426 (set-face-background 'region "ns_selection_color")
1442 1427
1443 1428
1444 1429
1506 (defvar x-colors (ns-list-colors) 1491 (defvar x-colors (ns-list-colors)
1507 "The list of colors defined in non-PANTONE color files.") 1492 "The list of colors defined in non-PANTONE color files.")
1508 (defvar colors x-colors 1493 (defvar colors x-colors
1509 "The list of colors defined in non-PANTONE color files.") 1494 "The list of colors defined in non-PANTONE color files.")
1510 1495
1511 (defun ns-defined-colors (&optional frame) 1496 (defun xw-defined-colors (&optional frame)
1512 "Return a list of colors supported for a particular frame. 1497 "Return a list of colors supported for a particular frame.
1513 The argument FRAME specifies which frame to try. 1498 The argument FRAME specifies which frame to try.
1514 The value may be different for frames on different Nextstep displays." 1499 The value may be different for frames on different Nextstep displays."
1515 (or frame (setq frame (selected-frame))) 1500 (or frame (setq frame (selected-frame)))
1516 (let ((all-colors x-colors) 1501 (let ((all-colors x-colors)
1520 (setq this-color (car all-colors) 1505 (setq this-color (car all-colors)
1521 all-colors (cdr all-colors)) 1506 all-colors (cdr all-colors))
1522 ;; (and (face-color-supported-p frame this-color t) 1507 ;; (and (face-color-supported-p frame this-color t)
1523 (setq defined-colors (cons this-color defined-colors))) ;;) 1508 (setq defined-colors (cons this-color defined-colors))) ;;)
1524 defined-colors)) 1509 defined-colors))
1525 (defalias 'x-defined-colors 'ns-defined-colors)
1526 (defalias 'xw-defined-colors 'ns-defined-colors)
1527 1510
1528 (declare-function ns-set-alpha "nsfns.m" (color alpha)) 1511 (declare-function ns-set-alpha "nsfns.m" (color alpha))
1529 1512
1530 ;; Convenience and work-around for fact that set color fns now require named. 1513 ;; Convenience and work-around for fact that set color fns now require named.
1531 (defun ns-set-background-alpha (alpha) 1514 (defun ns-set-background-alpha (alpha)
1605 (modify-frame-parameters frame (list (cons 'background-color 1588 (modify-frame-parameters frame (list (cons 'background-color
1606 ns-input-color)))) 1589 ns-input-color))))
1607 (t 1590 (t
1608 (set-face-background face ns-input-color frame))))) 1591 (set-face-background face ns-input-color frame)))))
1609 1592
1610
1611
1612 ;; Misc aliases.
1613 (defalias 'x-display-mm-width 'ns-display-mm-width)
1614 (defalias 'x-display-mm-height 'ns-display-mm-height)
1615 (defalias 'x-display-backing-store 'ns-display-backing-store)
1616 (defalias 'x-display-save-under 'ns-display-save-under)
1617 (defalias 'x-display-visual-class 'ns-display-visual-class)
1618 (defalias 'x-display-screens 'ns-display-screens)
1619 (defalias 'x-focus-frame 'ns-focus-frame)
1620
1621 ;; Set some options to be as Nextstep-like as possible. 1593 ;; Set some options to be as Nextstep-like as possible.
1622 (setq frame-title-format t 1594 (setq frame-title-format t
1623 icon-title-format t) 1595 icon-title-format t)
1624 1596
1625 ;; Set up browser connectivity. 1597 ;; Set up browser connectivity.
1633 1605
1634 1606
1635 (defvar ns-initialized nil 1607 (defvar ns-initialized nil
1636 "Non-nil if Nextstep windowing has been initialized.") 1608 "Non-nil if Nextstep windowing has been initialized.")
1637 1609
1638 (declare-function ns-open-connection "nsfns.m"
1639 (display &optional resource_string must_succeed))
1640
1641 (declare-function ns-list-services "nsfns.m" ()) 1610 (declare-function ns-list-services "nsfns.m" ())
1642 1611
1643 ;; Do the actual Nextstep Windows setup here; the above code just 1612 ;; Do the actual Nextstep Windows setup here; the above code just
1644 ;; defines functions and variables that we use now. 1613 ;; defines functions and variables that we use now.
1645 (defun ns-initialize-window-system () 1614 (defun ns-initialize-window-system ()
1646 "Initialize Emacs for Nextstep (Cocoa / GNUstep) windowing." 1615 "Initialize Emacs for Nextstep (Cocoa / GNUstep) windowing."
1647 1616
1648 ;; PENDING: not needed? 1617 ;; PENDING: not needed?
1649 (setq command-line-args (ns-handle-args command-line-args)) 1618 (setq command-line-args (ns-handle-args command-line-args))
1650 1619
1651 (ns-open-connection (system-name) nil t) 1620 (x-open-connection (system-name) nil t)
1652 1621
1653 (dolist (service (ns-list-services)) 1622 (dolist (service (ns-list-services))
1654 (if (eq (car service) 'undefined) 1623 (if (eq (car service) 'undefined)
1655 (ns-define-service (cdr service)) 1624 (ns-define-service (cdr service))
1656 (define-key global-map (vector (car service)) 1625 (define-key global-map (vector (car service))