Last changed: 1995-06-24 01:43:18

Introduction:
------------

Greetings:


This distribution contains an updated version of Bill Paul's software
cursor patch for Linux version 1.0 and 1.1.54 and up. This patch provides
modifications for the Linux console driver that allow it to generate a
non-blinking software cursor to replace the sometimes irritating
blinking cursor generated by the PC's video hardware. The software
cursor can be any one of eight colors (sixteen colors if you have a
VGA display) and each virtual console's cursor color can be different,
if desired. Support is provided for switching from software to
hardware cursors on the fly, and as well as changing the hardware
cursor from the usual flashing underline to a flashing block.

New in noblink 1.6:
------------------

- No new features/bug fixes, just an updated patch for Linux 1.3.3 and
  later.

New in noblink 1.5:
------------------

- No new features/bug fixes, just an updated patch for Linux 1.1.92
  and later.

New in noblink 1.4:
------------------

- All known bugs with vga cards fixed; all thanks to Davor Jadrijevic
  <davor@emard.pub.hr>. The patch is reported to work with hercules cards.
  Also thanks to Joe George <jgeorge@twiglet.nbi.com> and all others who
  gave usefull input.


New in noblink 1.3:
------------------

- This patch is now being maintained by Sander van Malssen
  <svm@kozmix.xs4all.nl>

- Updated for Linux version 1.1.54 (meaning it should patch right into
  1.2 once it's released)


Note:
----

Version 1.3 of this patch has only been tested with VGA. I would
appreciate feedback from people with other types of monitors.


New in noblink 1.0:
------------------

- Finally fixed code to properly reinstate the hardware 'blinking
  underline' cursor correctly for all SVGA modes. (Should work
  correctly for all cards and modes now.)
  (Thanks to Joakim Rosqvist  <dvljrt@cs.umu.se>)

- Changed escape codes for underline/block selection to avoid silly
  conflict with my Dorio (DEC) terminal.

- Added support for resetting of cursor mode to bootup defaults using
  the reset_terminal() function. (Thanks to Davor Jadrijevic
  <davj@ds5000.irb.hr>)

- Added support for 16 cursor colors. (Also thanks to Joakim)


Features:
--------

- With this patch, the standard hardware-generated 'blinking underline'
  cursor can be replaced with a software-generated non-blinking block
  cursor. This is meant to help people who:

	* Have laptops/portables with LCD screens that make
	  it hard to find the cursor

	* Want to add an extra touch of color to their consoles

	* Can't stand blinking cursors

- The software cursor color on a given VC can be changed on the fly using
  VT-200 style escape codes.

- Each VC's cursor type is maintained seperately: you can have half of them
  using the software generated cursor, half of them using the hardware
  cursor, or any combination in between. Each VC's software cursor color
  is also maintained seperately: you can have a blue cursor on VC #1, red
  on VC #2, green on VC #3, and so on.

- The software cursor color on a given VC can be changed at any time
  using VT-200 style escape codes. To make things simple, I've included
  a small C program that can generate all the cursor control codes for
  you.

- The hardware cursor can be switched from a blinking underline to
  blinking block at run time using escape codes. The hardware cursor
  state is also maintained for each VC: half of them can be set to
  use underlines, the other half blocks, or any combination in between.

- The software cursor color remains unchanged even if the foreground or
  background screen colors change. The exception is if you make the
  background color the same as the cursor color: this would render the
  cursor 'invisible', so the cursor will shift to a complement color
  to avoid this condition.

- Can be safely used with selection 1.7, dosemu, XFree86 and the
  setfont utility without problems. (At least, I haven't found any. :)

- Offers the use of 16 background colors, and hence 16 cursor colors,
  if desired.

System requirements:
-------------------

- Linux 1.0 or 1.1.54 kernel sources
- gcc 2.4.5 or higher (preferably higher)
- Some manner of video hardware

This is meant to work with any VGA/SVGA hardware in any resolution. It
is known to work with monochrome Hercules adpapters, though I have no
idea what happens when you try to change cursor colors. It *should*
also work with CGA displays, though this has not been tested. If you
have a CGA adapter, try it and let me know how it works.

Note: With VGA hardware, you normally only get 8 distinct background
      colors, plus 8 'flashing' versions of the same colors. It is
      possible to change this such that you get 16 distinct background
      colors instead. I've added yet another function to set_mode()
      that will toggle this behavior on and off, thus allowing people
      with VGA hardware to have 16 cursor colors. It is important to
      note that this changes the behavior of the 'setterm' command
      somewhat: setterm -blink doesn't produce blinking text anymore.
      Typing 'cursor 16color' will enable the 16 color mode and
      'cursor 8color' will turn it off again. Like all the other
      cursor features, the color mode is maintained seperately for each
      virtual console.

Configuration:
-------------

Since this is a fairly simple patch, I haven't made an entry for it in
the config.in. However, there are 2 #defines incorporated into
linux/drivers/char/concole.c that control default cursor behavior:

#define NOBLINK 1
#define SCURSCOLOR 112

If NOBLINK is #defined to be 1, all VCs will default to software
generated cursors at boot time. If it is #defined to be 0, they'll
default to the usual hardware cursors instead.

SCURSCOLOR sets the default software cursor color for all virtual
consoles. Legal values are:

  0     16   32    48   64  80      96     112
  black blue green cyan red magenta orange white

If you have a VGA/SVGA card, you can add 8 extra colors to that list:

  128   144    160    176    192    208  224    240
  grey  bright bright bright bright pink yellow bright
        blue   green  cyan   red                white

Normally, the VGA hardware allows for 8 normal background colors plus
8 'flashing' versions of the same. However, this behavior can be
changed such that you can have 16 normal background colors instead. A
seperate function and escape code are provided to set the behavior,
which is only active when running on color VGA hardware.

Note that setting the cursor color to black will actually work, only
it will appear white on a black background since the code is smart
enough to prevent the cursor from accidentally becoming 'invisible'
due to a bad choice of screen colors. Where other colors are
concerned, conflicts will be avoided by shifting either the cursor or
the text beneath it to its complement color. The complement of black
is obviously white. The complement of blue is yellow (which looks more
orange that it does yellow, but it's called yellow in all the
references I have so we'll stick with it), the complement of green is
magenta, and so forth.

The values listed above for NOBLINK and SCURSCOLOR are the
defaults. If you elect to leave them unchanged, your kernel will boot
with white non-blinking cursors on all of your virtual consoles. You
can use the 'cursor' program later to change them however you want.


Escape codes:
------------

You can switch from software to hardware generated cursors on the fly
using a VT-200 style escape code as follows:

	<ESC>[?33h     switch to hardware cursor
	<ESC>[?33l     switch to software cursor
	<ESC>[?32h     switch hardware cursor to block mode
	<ESC>[?32l     switch hardware cursor to underline mode
	<ESC>[?31h     switch to 16 background color mode
	<ESC>[?31l     switch to 8 background color mode

Note that the two codes that control the hardware cursor
characteristics may not appear to have any effect if you issue them
while in software cursor mode. If you are already in hardware cursor
mode, then you can use them to change the hardware cursor's
characteristics and see the results immediately. Using them while in
software cursor mode will work, but you won't notice the effect until
you switch to the hardware cursor.

Previously, I used the value <ESC>[?34h and <ESC>[?34l to switch the
block/underline modes. I discovered recently that these codes are in
fact used by some terminals (in particular the Dorio terminal which I
won in a contest at UNIX Expo '93 and am now using on my Linux box :)
to switch the direction on which characters are displayed on the
screen. By that I mean that one code causes characters to be printed
on the screen from right to left, while the other changes it back to
left to right. No, really. It's true. You wouldn't believe the shock I
got when I typed 'cursor block' at the terminal and everything started
coming out backwards. Anyway, I changed the codes to avoid this
conflict. For those of you who actually enjoy reading from right to
left, sorry: you're out of luck.

You can change the software cursor color using these additional codes:

          Standard colors                Extended colors
          ---------------                ---------------

        <ESC>[100m    black		<ESC>[228m   grey
        <ESC>[116m    blue              <ESC>[244m   bright blue
        <ESC>[132m    green             <ESC>[260m   bright green
        <ESC>[148m    cyan              <ESC>[276m   bright cyan
        <ESC>[164m    red               <ESC>[292m   bright red
        <ESC>[180m    magenta           <ESC>[308m   pink
        <ESC>[196m    orange            <ESC>[324m   yellow
        <ESC>[212m    white             <ESC>[340m   bright white

Note that the number values in the color codes are the same as those
listed previously, except that they are offset by 100. I did this to
make these codes sufficiently bogus that they would not conflict with
any existing codes that I don't know about. I don't think there are
any applications that go anywhere near these values.

To switch to 'extended color mode', you must use the command 'cursor
16color' or otherwise generate the code <ESC>[?31h. You can then use
the 'cursor' program to select one of the additional 8 colors from the
'extended' table. Note that these colors are only available if Linux
detects your console as a color, 'EGA+' device.  Trying to select one
of the extended colors while in 8 color mode will have no effect.

Installation:
------------

This distribution includes the following three files:

README
cursor.c
noblink-for-1.0.diff
noblink-for-1.1.54.diff

The diff files are unified context diffs against
linux/drivers/char/console.c and can be applied as follows:

# cd .../linux/drivers/char
# patch < noblink-for-1.0.diff		# for Linux 1.0 or later
# patch < noblink-for-1.1.54.diff	# for Linux 1.1.54 or later

Check for rejects. Once you're sure the patch has been properly
installed, you can go ahead and build your new kernel. If you still
have the objects from a previous build around, all you have to do is
cd to .../linux and type 'make.' If you are compiling for the first
time, configure and build according to the kernel README file.

Note that you may wish to change the #defines mentioned above to suit
your tastes, though the defaults are fairly sane and should work for
any display, including monocrhome.

Once the kernel is finished compiling, you can build the 'cursor'
program.

***NOTE***: if you have a previous version of the 'cursor' program installed
            you MUST replace it with this one. There: I've said it.

All this program does is generate the cursor control codes for you so
you won't have to memorize them. With it, you can change the software
cursor color, switch from the software cursor back to the default
hardware cursor *and* change the hardware cursor from a flashing
underline to a flashing block or vice-versa.

'cursor' simply prints the escape codes on the standard output. If you
want, you can redirect its output to another tty device, as in:

% cursor blue > /dev/tty2

This will change VC #2's cursor blue. (You must have write permission
to /dev/tty2 to do this, of course.) The cursor will remain blue until
another escape code is used to change it back.

Compile it with the following command:

# cc -O -s -N -o cursor cursor.c

/usr/local/bin is probably the best place for it to be installed. It
does not require any special privileges.


Schmoozing:
----------

As always, questions, comments, complaints, flames, suggestions, bug
reports, bug fixes, or large sums of cash are welcomed and encouraged.

Share and enjoy!

Current maintainer:

	Sander van Malssen
	Internet : svm@kozmix.xs4all.nl

Original author:

	Bill Paul
	Internet : ghod@drycas.club.cc.cmu.edu
	Bitnet   : GHOD@DRYCAS
