diff options
| author | Kim F. Storm | 2004-04-30 22:47:38 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2004-04-30 22:47:38 +0000 |
| commit | 2ed2415d6d393f8212dcf105d933d67ebd350c1e (patch) | |
| tree | 0a1560f3ce1451254616970816bf65039e969a0a | |
| parent | 4bf6af929cb03d1af406bd0a5cfba456fd7c6239 (diff) | |
| download | emacs-2ed2415d6d393f8212dcf105d933d67ebd350c1e.tar.gz emacs-2ed2415d6d393f8212dcf105d933d67ebd350c1e.zip | |
* emulation/cua-base.el: Add support for changing cursor types;
based on patch from Michael Mauger.
(cua-normal-cursor-color, cua-read-only-cursor-color)
(cua-overwrite-cursor-color, cua-global-mark-cursor-color):
Customization cursor type and/or cursor color.
(cua--update-indications): Handle cursor type changes.
(cua-mode): Update cursor indications if enabled.
| -rw-r--r-- | lisp/emulation/cua-base.el | 132 |
1 files changed, 106 insertions, 26 deletions
diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el index 0dbfce78870..c32624fe7b7 100644 --- a/lisp/emulation/cua-base.el +++ b/lisp/emulation/cua-base.el | |||
| @@ -413,29 +413,101 @@ Can be toggled by [M-p] while the rectangle is active," | |||
| 413 | "red") | 413 | "red") |
| 414 | "Normal (non-overwrite) cursor color. | 414 | "Normal (non-overwrite) cursor color. |
| 415 | Also used to indicate that rectangle padding is not in effect. | 415 | Also used to indicate that rectangle padding is not in effect. |
| 416 | Default is to load cursor color from initial or default frame parameters." | 416 | Default is to load cursor color from initial or default frame parameters. |
| 417 | |||
| 418 | If the value is a COLOR name, then only the `cursor-color' attribute will be | ||
| 419 | affected. If the value is a cursor TYPE (one of: box, block, bar, or hbar), | ||
| 420 | then only the `cursor-type' property will be affected. If the value is | ||
| 421 | a cons (TYPE . COLOR), then both properties are affected." | ||
| 417 | :initialize 'custom-initialize-default | 422 | :initialize 'custom-initialize-default |
| 418 | :type 'color | 423 | :type '(choice |
| 424 | (color :tag "Color") | ||
| 425 | (choice :tag "Type" | ||
| 426 | (const :tag "Filled box" box) | ||
| 427 | (const :tag "Vertical bar" bar) | ||
| 428 | (const :tag "Horisontal bar" hbar) | ||
| 429 | (const :tag "Hollow box" block)) | ||
| 430 | (cons :tag "Color and Type" | ||
| 431 | (choice :tag "Type" | ||
| 432 | (const :tag "Filled box" box) | ||
| 433 | (const :tag "Vertical bar" bar) | ||
| 434 | (const :tag "Horisontal bar" hbar) | ||
| 435 | (const :tag "Hollow box" block)) | ||
| 436 | (color :tag "Color"))) | ||
| 419 | :group 'cua) | 437 | :group 'cua) |
| 420 | 438 | ||
| 421 | (defcustom cua-read-only-cursor-color "darkgreen" | 439 | (defcustom cua-read-only-cursor-color "darkgreen" |
| 422 | "*Cursor color used in read-only buffers, if non-nil. | 440 | "*Cursor color used in read-only buffers, if non-nil. |
| 423 | Only used when `cua-enable-cursor-indications' is non-nil." | 441 | Only used when `cua-enable-cursor-indications' is non-nil. |
| 424 | :type 'color | 442 | |
| 443 | If the value is a COLOR name, then only the `cursor-color' attribute will be | ||
| 444 | affected. If the value is a cursor TYPE (one of: box, block, bar, or hbar), | ||
| 445 | then only the `cursor-type' property will be affected. If the value is | ||
| 446 | a cons (TYPE . COLOR), then both properties are affected." | ||
| 447 | :type '(choice | ||
| 448 | (color :tag "Color") | ||
| 449 | (choice :tag "Type" | ||
| 450 | (const :tag "Filled box" box) | ||
| 451 | (const :tag "Vertical bar" bar) | ||
| 452 | (const :tag "Horisontal bar" hbar) | ||
| 453 | (const :tag "Hollow box" block)) | ||
| 454 | (cons :tag "Color and Type" | ||
| 455 | (choice :tag "Type" | ||
| 456 | (const :tag "Filled box" box) | ||
| 457 | (const :tag "Vertical bar" bar) | ||
| 458 | (const :tag "Horisontal bar" hbar) | ||
| 459 | (const :tag "Hollow box" block)) | ||
| 460 | (color :tag "Color"))) | ||
| 425 | :group 'cua) | 461 | :group 'cua) |
| 426 | 462 | ||
| 427 | (defcustom cua-overwrite-cursor-color "yellow" | 463 | (defcustom cua-overwrite-cursor-color "yellow" |
| 428 | "*Cursor color used when overwrite mode is set, if non-nil. | 464 | "*Cursor color used when overwrite mode is set, if non-nil. |
| 429 | Also used to indicate that rectangle padding is in effect. | 465 | Also used to indicate that rectangle padding is in effect. |
| 430 | Only used when `cua-enable-cursor-indications' is non-nil." | 466 | Only used when `cua-enable-cursor-indications' is non-nil. |
| 431 | :type 'color | 467 | |
| 468 | If the value is a COLOR name, then only the `cursor-color' attribute will be | ||
| 469 | affected. If the value is a cursor TYPE (one of: box, block, bar, or hbar), | ||
| 470 | then only the `cursor-type' property will be affected. If the value is | ||
| 471 | a cons (TYPE . COLOR), then both properties are affected." | ||
| 472 | :type '(choice | ||
| 473 | (color :tag "Color") | ||
| 474 | (choice :tag "Type" | ||
| 475 | (const :tag "Filled box" box) | ||
| 476 | (const :tag "Vertical bar" bar) | ||
| 477 | (const :tag "Horisontal bar" hbar) | ||
| 478 | (const :tag "Hollow box" block)) | ||
| 479 | (cons :tag "Color and Type" | ||
| 480 | (choice :tag "Type" | ||
| 481 | (const :tag "Filled box" box) | ||
| 482 | (const :tag "Vertical bar" bar) | ||
| 483 | (const :tag "Horisontal bar" hbar) | ||
| 484 | (const :tag "Hollow box" block)) | ||
| 485 | (color :tag "Color"))) | ||
| 432 | :group 'cua) | 486 | :group 'cua) |
| 433 | 487 | ||
| 434 | (defcustom cua-global-mark-cursor-color "cyan" | 488 | (defcustom cua-global-mark-cursor-color "cyan" |
| 435 | "*Indication for active global mark. | 489 | "*Indication for active global mark. |
| 436 | Will change cursor color to specified color if string. | 490 | Will change cursor color to specified color if string. |
| 437 | Only used when `cua-enable-cursor-indications' is non-nil." | 491 | Only used when `cua-enable-cursor-indications' is non-nil. |
| 438 | :type 'color | 492 | |
| 493 | If the value is a COLOR name, then only the `cursor-color' attribute will be | ||
| 494 | affected. If the value is a cursor TYPE (one of: box, block, bar, or hbar), | ||
| 495 | then only the `cursor-type' property will be affected. If the value is | ||
| 496 | a cons (TYPE . COLOR), then both properties are affected." | ||
| 497 | :type '(choice | ||
| 498 | (color :tag "Color") | ||
| 499 | (choice :tag "Type" | ||
| 500 | (const :tag "Filled box" box) | ||
| 501 | (const :tag "Vertical bar" bar) | ||
| 502 | (const :tag "Horisontal bar" hbar) | ||
| 503 | (const :tag "Hollow box" block)) | ||
| 504 | (cons :tag "Color and Type" | ||
| 505 | (choice :tag "Type" | ||
| 506 | (const :tag "Filled box" box) | ||
| 507 | (const :tag "Vertical bar" bar) | ||
| 508 | (const :tag "Horisontal bar" hbar) | ||
| 509 | (const :tag "Hollow box" block)) | ||
| 510 | (color :tag "Color"))) | ||
| 439 | :group 'cua) | 511 | :group 'cua) |
| 440 | 512 | ||
| 441 | 513 | ||
| @@ -946,23 +1018,29 @@ If ARG is the atom `-', scroll upward by nearly full screen." | |||
| 946 | ;;; Cursor indications | 1018 | ;;; Cursor indications |
| 947 | 1019 | ||
| 948 | (defun cua--update-indications () | 1020 | (defun cua--update-indications () |
| 949 | (let ((cursor | 1021 | (let* ((cursor |
| 950 | (cond | 1022 | (cond |
| 951 | ((and cua--global-mark-active | 1023 | ((and cua--global-mark-active |
| 952 | (stringp cua-global-mark-cursor-color)) | 1024 | cua-global-mark-cursor-color) |
| 953 | cua-global-mark-cursor-color) | 1025 | cua-global-mark-cursor-color) |
| 954 | ((and buffer-read-only | 1026 | ((and buffer-read-only |
| 955 | (stringp cua-read-only-cursor-color)) | 1027 | cua-read-only-cursor-color) |
| 956 | cua-read-only-cursor-color) | 1028 | cua-read-only-cursor-color) |
| 957 | ((and (stringp cua-overwrite-cursor-color) | 1029 | ((and cua-overwrite-cursor-color |
| 958 | (or overwrite-mode | 1030 | (or overwrite-mode |
| 959 | (and cua--rectangle (cua--rectangle-padding)))) | 1031 | (and cua--rectangle (cua--rectangle-padding)))) |
| 960 | cua-overwrite-cursor-color) | 1032 | cua-overwrite-cursor-color) |
| 961 | (t cua-normal-cursor-color)))) | 1033 | (t cua-normal-cursor-color))) |
| 962 | (if (and cursor | 1034 | (color (if (consp cursor) (cdr cursor) cursor)) |
| 963 | (not (equal cursor (frame-parameter nil 'cursor-color)))) | 1035 | (type (if (consp cursor) (car cursor) cursor))) |
| 964 | (set-cursor-color cursor)) | 1036 | (if (and color |
| 965 | cursor)) | 1037 | (stringp color) |
| 1038 | (not (equal color (frame-parameter nil 'cursor-color)))) | ||
| 1039 | (set-cursor-color color)) | ||
| 1040 | (if (and type | ||
| 1041 | (symbolp type) | ||
| 1042 | (not (eq type (frame-parameter nil 'cursor-type)))) | ||
| 1043 | (setq default-cursor-type type)))) | ||
| 966 | 1044 | ||
| 967 | 1045 | ||
| 968 | ;;; Pre-command hook | 1046 | ;;; Pre-command hook |
| @@ -1233,7 +1311,9 @@ paste (in addition to the normal emacs bindings)." | |||
| 1233 | (add-hook 'post-command-hook 'cua--post-command-handler) | 1311 | (add-hook 'post-command-hook 'cua--post-command-handler) |
| 1234 | (if (and cua-enable-modeline-indications (not (assoc 'cua-mode minor-mode-alist))) | 1312 | (if (and cua-enable-modeline-indications (not (assoc 'cua-mode minor-mode-alist))) |
| 1235 | (setq minor-mode-alist (cons '(cua-mode cua--status-string) minor-mode-alist))) | 1313 | (setq minor-mode-alist (cons '(cua-mode cua--status-string) minor-mode-alist))) |
| 1236 | ) | 1314 | (if cua-enable-cursor-indications |
| 1315 | (cua--update-indications))) | ||
| 1316 | |||
| 1237 | (remove-hook 'pre-command-hook 'cua--pre-command-handler) | 1317 | (remove-hook 'pre-command-hook 'cua--pre-command-handler) |
| 1238 | (remove-hook 'post-command-hook 'cua--post-command-handler)) | 1318 | (remove-hook 'post-command-hook 'cua--post-command-handler)) |
| 1239 | 1319 | ||