unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ehud Karni" <ehud@unix.mvs.co.il>
Cc: larsh@math.ku.dk, emacs-devel@gnu.org
Subject: Re: cua-mode: cursor types
Date: Mon, 3 May 2004 18:44:21 +0300	[thread overview]
Message-ID: <200405031544.i43FiLg6020849@beta.mvs.co.il> (raw)
In-Reply-To: <m3pt9nrg9k.fsf@kfs-l.imdomain.dk> (storm@cua.dk)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01 May 2004 23:25:59 +0200, storm@cua.dk (Kim F. Storm) wrote:
>
> Lars Hansen <larsh@math.ku.dk> 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-----

  parent reply	other threads:[~2004-05-03 15:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-01  7:11 cua-mode: cursor types Lars Hansen
2004-05-01 21:25 ` Kim F. Storm
2004-05-03  9:24   ` Juanma Barranquero
2004-05-03 15:44   ` Ehud Karni [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-02-24  3:20 Michael Mauger
2004-04-30 20:56 ` Kim F. Storm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200405031544.i43FiLg6020849@beta.mvs.co.il \
    --to=ehud@unix.mvs.co.il \
    --cc=emacs-devel@gnu.org \
    --cc=larsh@math.ku.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).