[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cua-mode: cursor types
From: |
Ehud Karni |
Subject: |
Re: cua-mode: cursor types |
Date: |
Mon, 3 May 2004 18:44:21 +0300 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 01 May 2004 23:25:59 +0200, address@hidden (Kim F. Storm) wrote:
>
> Lars Hansen <address@hidden> writes:
>
> > Nice feature! My eyes are on the cursor rather than on the mode line.
> >
> > 3. If you don't use cua-mode but just set
> > cua-enable-cursor-indications to t, the feature does not work. Is
> > that intended?
>
> It only works with cua-mode as the name suggests.
>
> It would be nice to separate it, but it is tied in with cua's global-mark
> feature, so it is a bit tricky to do right. Maybe in 22.x
I have the following code that does that independently of cua-mode
(which I don't use). This code allows you to change the cursor size
for terminals that support it. The MS-DOS code is quite old (I have
not used Emacs on MS-DOS for more than 5 years).
Ehud.
(defvar cursor-string nil "Last cursor string used")
(defvar cursor-string-over "\033[4l\033[20;10W"
"Overwrite: underline cursor in TTY/MS-DOS, Yellow color for non terminals")
(defvar cursor-string-ins "\033[90;10W"
"Block cursor in TTY/MS-DOS, Green color for non terminals")
(defvar xterm-on (or (eq 'x window-system)
(eq 'w32 window-system) ;; Windows NT/95 system
(20.x)
(eq system-type 'ms-dos)) ;; PC (MSDOS) (old)
"xterm/regular terminal switch nil=regular") ;; xterm or windowed
system
(if (eq system-type 'ms-dos) ; MSDOS is not really X
terminal
(progn
(setq cursor-string-over (concat [11] [13])) ; overwrite mode
under-line
(setq cursor-string-ins (concat [01] [11]))) ; insert mode - block
cursor
(if xterm-on
(progn
(setq cursor-string-over "yellow") ; overwrite mode
(setq cursor-string-ins "green") ; insert mode
(set-cursor-color cursor-string-over)))) ; start as overwrite
cursor
(defun ins-cursor-set-init () "set cursor-string to empty string"
(setq cursor-string "")
(ins-cursor-set))
(defun ins-cursor-set () "set cursor type according to insertion mode
(insert=block)"
(let ((sv-crs-str cursor-string))
(setq cursor-string (if overwrite-mode
cursor-string-over ; under-line cursor
/ yellow
cursor-string-ins)) ; block cursor /
green
(or (string= sv-crs-str cursor-string)
(cond
((eq system-type 'ms-dos)
; MSDOS
(set-cursor-mode (aref cursor-string 0) (aref
cursor-string 1)))
(xterm-on
(set-cursor-color cursor-string))
; X terminal
(sw-tty-on
; MVS TTY emulator
(if (>= emacs-major-version 21)
; internal show cursor appeared
(internal-show-cursor nil nil))
; in emacs 21 and must be used
(send-string-to-terminal cursor-string))))))
; MVS TTY by Alex Ofek
(add-hook 'post-command-hook 'ins-cursor-set)
(add-hook 'suspend-resume-hook 'ins-cursor-set-init)
(add-hook 'minibuffer-exit-hook 'ins-cursor-set-init)
(add-hook 'minibuffer-setup-hook 'ins-cursor-set-init)
(add-hook 'mouse-leave-buffer-hook 'ins-cursor-set-init)
;; A function for MS-DOS only, should be loaded only when `system-type' is
ms-dos
(defun set-cursor-mode (start-line end-line &optional blink-mode)
"Set cursor shape for DOS machine, scan lines from START-LINE to END-LINE,
Optional third arg non-nil means cursor blinks."
(and (numberp start-line)
(numberp end-line)
(let ((regs (make-register))) ; union REGS regs
(set-register-value regs 'ah 1) ; regs.h.ah = 0x01
(set-register-value regs 'ch start-line)
(set-register-value regs 'cl end-line)
(int86 16 regs)) ; int86 (0x10 /* 16 */,...)
nil))
- --
Ehud Karni Tel: +972-3-7966-561 /"\
Mivtach - Simon Fax: +972-3-7966-667 \ / ASCII Ribbon Campaign
Insurance agencies (USA) voice mail and X Against HTML Mail
http://www.mvs.co.il FAX: 1-815-5509341 / \
GnuPG: 98EA398D <http://www.keyserver.net/> Better Safe Than Sorry
-----BEGIN PGP SIGNATURE-----
Comment: use http://www.keyserver.net/ to get my key (and others)
iD8DBQFAlmjTLFvTvpjqOY0RAuscAJ9G5YhDxNaHRLfj7pefggjJ73iCdwCeKhYH
uziYmUFe0jbvXqWsJdljbnU=
=z6Ve
-----END PGP SIGNATURE-----