*BSD News Article 33026


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!yeshua.marcam.com!MathWorks.Com!panix!not-for-mail
From: wpaul@panix.com (Bill Paul)
Newsgroups: comp.os.386bsd.misc
Subject: non-flashing cursor for syscons
Date: 20 Jul 1994 15:47:52 -0400
Organization: The M00se Illuminati (bl00p!)
Lines: 238
Message-ID: <30jv18$jep@panix3.panix.com>
NNTP-Posting-Host: panix3.panix.com
X-Newsreader: TIN [version 1.2 PL2]


Greetings:

I've got a bit of hackery I'd like to share with you, which I created as
a result of a fierce dislike of the PC's standard blinking cursor. I can't
stand the thing. Always annoyed the heck out of me. Back when I had (steady
boys) Linux installed on my system, I went to great lengths to convince
the console driver to generate a non-flashing block cursor, and in the
end it actually worked out quite well. 

Well, now I'm using syscons in FreeBSD, and I decided to do the same
thing. Turned out to be quite a bit easier to do with syscons that with
the Linux console driver, though in retrospect that may have been because
I went about it the wrong way the first time.

Anyway, this is a small hack so I'm just going to append the diffs for it
to this post. Apply them to /usr/src/sys/i386/isa/syscons.c, then edit your 
host config file: if you have 'options FAT_CURSOR' defined, take it out, 
and insert 'options NOBLINK_CURSOR.' You know the drill from there.

This will disable the blinking cursor (by stuffing impossible values in
where the cursor shape would normally be defined, and getting rid of the
code that normally moves it around) and cause syscons to generate a 
non-flashing block cursor by applying the currently defined 'reverse' 
attributes to the cursor location. By default, this means you'll get a 
white block cursor and chatacters beneath the cursor will be displayed
in black. This will change depending on how you set the 'reverse' 
forground and background colors with vidcontrol.

Well, anyway, here it is. I'm running this with FreeBSD 1.1.5, but it ought
to work with syscons from 1.1 as well (don't quote me on that: I don't have
the sources handy). I have a VGA display, but the changes I made should
work equally well with CGA or mono. If they don't let me know and maybe
I'll be able to work out what I did wrong.

Share and enjoy!

-Bill

------------------------------BEGIN INCLUDE TEXT------------------------------

--- syscons.c	Tue Jul 19 18:33:45 1994
+++ syscons.c.orig	Mon Jul 18 20:19:28 1994
@@ -43,16 +43,6 @@
 #define FAT_CURSOR
 #endif
 
-/* NOBLINK and FAT are mutually exclusive */
-
-#ifdef NOBLINK_CURSOR
-#undef FAT_CURSOR
-#endif
-
-#ifdef FAT_CURSOR
-#undef NOBLINK_CURSOR
-#endif
-
 #include "param.h"
 #include "conf.h"
 #include "ioctl.h"
@@ -150,9 +140,6 @@
 	u_short 	*crt_base;		/* address of screen memory */
 	u_short 	*scr_buf;		/* buffer when off screen */
 	u_short 	*crtat;			/* cursor address */
-#ifdef NOBLINK_CURSOR
-	u_short		cur_cursor_attr;	/* cursor attributes */
-#endif
 	int 		xpos;			/* current X position */
 	int 		ypos;			/* current Y position */
 	int 		xsize;			/* X size */
@@ -202,9 +189,7 @@
 static  int		fonts_loaded = 0;
 static	char		palette[3*256];
 static 	const u_int 	n_fkey_tab = sizeof(fkey_tab) / sizeof(*fkey_tab);
-#ifndef NOBLINK_CURSOR
 static	int 		cur_cursor_pos = -1;
-#endif
 static	char 		in_putc = 0;
 static	char	 	polling = 0;
 #if ASYNCH
@@ -387,12 +372,6 @@
 		printf(" <%d virtual consoles>\n", NCONS);
 	else
 		printf("\n");
-
-#ifdef NOBLINK_CURSOR
-                start = -1;
-                end = -1;
-	if (crtc_vga) {
-#else
 #if defined(FAT_CURSOR)
                 start = 0;
                 end = 18;
@@ -401,8 +380,6 @@
 	if (crtc_vga) {
 		get_cursor_shape(&start, &end);
 #endif
-#endif
-
 #if defined(HARDFONTS)
 		font_8 = font_8x8;
 		font_14 = font_8x14;
@@ -448,7 +425,7 @@
 		}
 	}
 	/* get cursor going */
-#if defined(FAT_CURSOR) || defined(NOBLINK_CURSOR)
+#if defined(FAT_CURSOR)
         cursor_shape(console[0].cursor_start,
                      console[0].cursor_end);
 #endif
@@ -1214,7 +1191,6 @@
 	if (c == '\n')
 		scput('\r');
 	scput(c);
-#ifndef NOBLINK_CURSOR
 	if (cur_console == &console[0]) {
 	int 	pos = cur_console->crtat - cur_console->crt_base;
 		if (pos != cur_cursor_pos) {
@@ -1225,7 +1201,6 @@
 			outb(crtc_addr+1,pos&0xff);
 		}
 	}
-#endif
 }
 
 
@@ -1344,9 +1319,7 @@
 	else {
 		if (scrn_blanked) {
 			bcopy(scp->scr_buf, Crtat, scp->xsize*scp->ysize*2);
-#ifndef NOBLINK_CURSOR
 			cur_cursor_pos = -1;
-#endif
 			set_border(scp->border);
 			scrn_blanked = 0;
 		}
@@ -1406,9 +1379,7 @@
 		if (scrn_blanked) {
 			bcopy(scp->scr_buf, Crtat,
 			      scp->xsize * scp->ysize * 2);
-#ifndef NOBLINK_CURSOR
 			cur_cursor_pos = -1;
-#endif
 			set_border(scp->border);
 			scrn_blanked = 0;
 		}
@@ -1444,7 +1415,6 @@
 		return;
 	if (scrn_blank_time && (time.tv_sec > scrn_time_stamp+scrn_blank_time))
 		SCRN_SAVER(1);
-#ifndef NOBLINK_CURSOR
 	pos = cur_console->crtat - cur_console->crt_base;
 	if (force || (!scrn_blanked && pos != cur_cursor_pos)) {
 		cur_cursor_pos = pos;
@@ -1453,7 +1423,6 @@
 		outb(crtc_addr, 15);
 		outb(crtc_addr+1, pos&0xff);
 	}
-#endif
 	timeout((timeout_t)cursor_pos, 0, hz/20);
 }
 
@@ -1967,13 +1936,11 @@
 
 		case 'C': 	/* set cursor shape (start & end line) */
 			if (scp->term.num_param == 2) {
-#ifndef NOBLINK_CURSOR
 				scp->cursor_start = scp->term.param[0] & 0x1F; 
 				scp->cursor_end = scp->term.param[1] & 0x1F; 
 				if (scp == cur_console)
 					cursor_shape(scp->cursor_start,
 						     scp->cursor_end);
-#endif
 			}
 			break;
 
@@ -2014,10 +1981,7 @@
 {
 	if (scp->status & UNKNOWN_MODE) 
 		return;
-#ifdef NOBLINK_CURSOR
-	/* undraw cursor */
-	*scp->crtat = scp->cur_cursor_attr;
-#endif
+
 	/* make screensaver happy */
 	if (scp == cur_console) {
 		scrn_time_stamp = time.tv_sec;
@@ -2080,14 +2044,6 @@
 		scp->crtat -= scp->xsize;
 		scp->ypos--;
 	}
-#ifdef NOBLINK_CURSOR
-	/* draw cursor */
-	scp->cur_cursor_attr = *scp->crtat;
-	if (scp->term.cur_attr == scp->term.std_attr)
-		*scp->crtat = scp->term.rev_attr | (*scp->crtat & 0x00FF);
-	else
-		*scp->crtat = scp->term.std_attr | (*scp->crtat & 0x00FF);
-#endif
 	in_putc--;
 	if (delayed_next_scr)
 		switch_scr(delayed_next_scr - 1);
@@ -2159,9 +2115,6 @@
 	for (i=0; i<sizeof(scr_map); i++)
 		scr_map[i] = i;
 	clear_screen(&console[0]);
-#ifdef NOBLINK_CURSOR
-	cursor_shape (-1,-1);
-#endif
 }
 
 
@@ -2655,12 +2608,11 @@
 	/* (re)activate cursor */
 	untimeout((timeout_t)cursor_pos, 0);
 	cursor_pos(1);
-
-#ifndef NOBLINK_CURSOR	
+	
 	/* change cursor type if set */
 	if (scp->cursor_start != -1 && scp->cursor_end != -1)
 		cursor_shape(scp->cursor_start, scp->cursor_end);
-#endif
+
 	/* mode change only on VGA's */
 	if (!crtc_vga) 
 		return;

-------------------------------END INCLUDED TEXT------------------------------
--
 _      /\      _            Join the
/ \_/\_/  \_/\_/ \  .----.   M00se Illuminati   Bill Paul 
\_____/ () \_____/ (bl00p!)  Face it: wouldn't  <Big City M00se>
     /      \       `----'   you feel much      wpaul@panix.com   -or-
    /  \__/  \    --'        safer?             ghod@drycas.club.cc.cmu.edu
   /__________\