summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2006-11-29 19:11:18 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2006-11-29 19:11:18 +0000
commit50ee386b64c347a1453fc676e2725e0613e8c24a (patch)
treef9907f64ea3f674ebdfb026d21947be5b588ed6f
parentf1383d2d04a9e6ec1da4df59ac0ff1478bb10f9b (diff)
Change the getchar wsdisplay_accessops function to not return a
display-dependent value, but instead fill a structure with the chaarcter and a valid attribute, suitable for use with unpack_attr. Adapt the wsmoused code to these changes, and remove all knowledge of the text-mode style pc video attributes in it. This will eventually allow wsmoused to be used on non-pcdisplay devices.
-rw-r--r--sys/dev/ic/pcdisplay_subr.c18
-rw-r--r--sys/dev/ic/pcdisplayvar.h5
-rw-r--r--sys/dev/ic/vga.c11
-rw-r--r--sys/dev/pcmcia/cfxga.c24
-rw-r--r--sys/dev/wscons/wsdisplay.c60
-rw-r--r--sys/dev/wscons/wsdisplayvar.h12
-rw-r--r--sys/dev/wscons/wsmoused.h35
7 files changed, 95 insertions, 70 deletions
diff --git a/sys/dev/ic/pcdisplay_subr.c b/sys/dev/ic/pcdisplay_subr.c
index f615dfd73a6..8eefcb84a4f 100644
--- a/sys/dev/ic/pcdisplay_subr.c
+++ b/sys/dev/ic/pcdisplay_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcdisplay_subr.c,v 1.6 2006/09/29 19:46:02 miod Exp $ */
+/* $OpenBSD: pcdisplay_subr.c,v 1.7 2006/11/29 19:11:15 miod Exp $ */
/* $NetBSD: pcdisplay_subr.c,v 1.16 2000/06/08 07:01:19 cgd Exp $ */
/*
@@ -174,23 +174,31 @@ pcdisplay_putchar(id, row, col, c, attr)
scr->mem[off] = c | (attr << 8);
}
-u_int16_t
-pcdisplay_getchar(id, row, col)
+int
+pcdisplay_getchar(id, row, col, cell)
void *id;
int row, col;
+ struct wsdisplay_charcell *cell;
{
struct pcdisplayscreen *scr = id;
bus_space_tag_t memt = scr->hdl->ph_memt;
bus_space_handle_t memh = scr->hdl->ph_memh;
int off;
+ u_int16_t data;
off = row * scr->type->ncols + col;
+ /* XXX bounds check? */
if (scr->active)
- return (bus_space_read_2(memt, memh,
+ data = (bus_space_read_2(memt, memh,
scr->dispoffset + off * 2));
else
- return (scr->mem[off]);
+ data = (scr->mem[off]);
+
+ cell->uc = data & 0xff;
+ cell->attr = data >> 8;
+
+ return (0);
}
void
diff --git a/sys/dev/ic/pcdisplayvar.h b/sys/dev/ic/pcdisplayvar.h
index 314ed8b8aca..4d5044ca7d9 100644
--- a/sys/dev/ic/pcdisplayvar.h
+++ b/sys/dev/ic/pcdisplayvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcdisplayvar.h,v 1.7 2006/09/29 19:46:02 miod Exp $ */
+/* $OpenBSD: pcdisplayvar.h,v 1.8 2006/11/29 19:11:15 miod Exp $ */
/* $NetBSD: pcdisplayvar.h,v 1.8 2000/01/25 02:44:03 ad Exp $ */
/*
@@ -89,7 +89,8 @@ unsigned int pcdisplay_mapchar_simple(void *, int);
#endif
int pcdisplay_mapchar(void *, int, unsigned int *);
void pcdisplay_putchar(void *, int, int, u_int, long);
-u_int16_t pcdisplay_getchar(void *, int, int);
+struct wsdisplay_charcell;
+int pcdisplay_getchar(void *, int, int, struct wsdisplay_charcell *);
void pcdisplay_copycols(void *, int, int, int,int);
void pcdisplay_erasecols(void *, int, int, int, long);
void pcdisplay_copyrows(void *, int, int, int);
diff --git a/sys/dev/ic/vga.c b/sys/dev/ic/vga.c
index d6a58b4b81d..a1560921ecc 100644
--- a/sys/dev/ic/vga.c
+++ b/sys/dev/ic/vga.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vga.c,v 1.41 2006/11/29 19:08:22 miod Exp $ */
+/* $OpenBSD: vga.c,v 1.42 2006/11/29 19:11:15 miod Exp $ */
/* $NetBSD: vga.c,v 1.28.2.1 2000/06/30 16:27:47 simonb Exp $ */
/*
@@ -238,7 +238,7 @@ int vga_show_screen(void *, void *, int,
int vga_load_font(void *, void *, struct wsdisplay_font *);
void vga_scrollback(void *, void *, int);
void vga_burner(void *v, u_int on, u_int flags);
-u_int16_t vga_getchar(void *, int, int);
+int vga_getchar(void *, int, int, struct wsdisplay_charcell *);
void vga_doswitch(struct vga_config *);
@@ -1319,14 +1319,15 @@ vga_burner(v, on, flags)
splx(s);
}
-u_int16_t
-vga_getchar(c, row, col)
+int
+vga_getchar(c, row, col, cell)
void *c;
int row, col;
+ struct wsdisplay_charcell *cell;
{
struct vga_config *vc = c;
- return (pcdisplay_getchar(vc->active, row, col));
+ return (pcdisplay_getchar(vc->active, row, col, cell));
}
struct cfdriver vga_cd = {
diff --git a/sys/dev/pcmcia/cfxga.c b/sys/dev/pcmcia/cfxga.c
index 66f20ef08bd..5cce96617fb 100644
--- a/sys/dev/pcmcia/cfxga.c
+++ b/sys/dev/pcmcia/cfxga.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cfxga.c,v 1.13 2006/11/29 19:08:22 miod Exp $ */
+/* $OpenBSD: cfxga.c,v 1.14 2006/11/29 19:11:17 miod Exp $ */
/*
* Copyright (c) 2005, 2006, Matthieu Herrb and Miodrag Vallat
@@ -130,16 +130,6 @@ struct wsdisplay_accessops cfxga_accessops = {
};
/*
- * Backing memory cells for emulation mode.
- * We could theoretically hijack 8 bits from the rasops attribute, but this
- * will not accomodate font with more than 256 characters.
- */
-struct charcell {
- u_int uc;
- u_int32_t attr;
-};
-
-/*
* Per-screen structure
*/
@@ -147,7 +137,7 @@ struct cfxga_screen {
LIST_ENTRY(cfxga_screen) scr_link;
struct cfxga_softc *scr_sc; /* parent reference */
struct rasops_info scr_ri; /* raster op glue */
- struct charcell *scr_mem; /* backing memory */
+ struct wsdisplay_charcell *scr_mem; /* backing memory */
};
void cfxga_copycols(void *, int, int, int, int);
@@ -515,7 +505,7 @@ cfxga_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
* Allocate backing store to remember non-visible screen contents in
* emulation mode.
*/
- scrsize = ri->ri_rows * ri->ri_cols * sizeof(struct charcell);
+ scrsize = ri->ri_rows * ri->ri_cols * sizeof(struct wsdisplay_charcell);
scr->scr_mem = malloc(scrsize, M_DEVBUF, cold ? M_NOWAIT : M_WAITOK);
if (scr->scr_mem == NULL) {
free(scr, M_DEVBUF);
@@ -944,7 +934,7 @@ fail:
int
cfxga_repaint_screen(struct cfxga_screen *scr)
{
- struct charcell *cell = scr->scr_mem;
+ struct wsdisplay_charcell *cell = scr->scr_mem;
struct rasops_info *ri = &scr->scr_ri;
int x, y, cx, cy, lx, ly;
int fg, bg;
@@ -1068,7 +1058,7 @@ cfxga_copycols(void *cookie, int row, int src, int dst, int num)
/* Copy columns in backing store. */
ovbcopy(scr->scr_mem + row * ri->ri_cols + src,
scr->scr_mem + row * ri->ri_cols + dst,
- num * sizeof(struct charcell));
+ num * sizeof(struct wsdisplay_charcell));
if (scr != scr->scr_sc->sc_active)
return;
@@ -1091,7 +1081,7 @@ cfxga_copyrows(void *cookie, int src, int dst, int num)
/* Copy rows in backing store. */
ovbcopy(scr->scr_mem + src * ri->ri_cols,
scr->scr_mem + dst * ri->ri_cols,
- num * ri->ri_cols * sizeof(struct charcell));
+ num * ri->ri_cols * sizeof(struct wsdisplay_charcell));
if (scr != scr->scr_sc->sc_active)
return;
@@ -1162,7 +1152,7 @@ cfxga_eraserows(void *cookie, int row, int num, long attr)
for (y = 1; y < num; y++)
ovbcopy(scr->scr_mem + row * ri->ri_cols,
scr->scr_mem + (row + y) * ri->ri_cols,
- ri->ri_cols * sizeof(struct charcell));
+ ri->ri_cols * sizeof(struct wsdisplay_charcell));
if (scr != scr->scr_sc->sc_active)
return;
diff --git a/sys/dev/wscons/wsdisplay.c b/sys/dev/wscons/wsdisplay.c
index 4e71d61d85a..14dca81e87f 100644
--- a/sys/dev/wscons/wsdisplay.c
+++ b/sys/dev/wscons/wsdisplay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsdisplay.c,v 1.71 2006/11/29 12:13:55 miod Exp $ */
+/* $OpenBSD: wsdisplay.c,v 1.72 2006/11/29 19:11:17 miod Exp $ */
/* $NetBSD: wsdisplay.c,v 1.82 2005/02/27 00:27:52 perry Exp $ */
/*
@@ -2403,18 +2403,16 @@ mouse_moverel(char dx, char dy)
void
inverse_char(unsigned short pos)
{
- u_int16_t uc;
- u_int16_t attr;
+ struct wsdisplay_charcell cell;
+ int fg, bg, ul;
- uc = GET_FULLCHAR(pos);
- attr = uc;
+ GETCHAR(pos, &cell);
+ UNPACKATTR(cell.attr, &fg, &bg, &ul);
- if ((attr >> 8) == 0)
- attr = (FG_LIGHTGREY << 8);
+ ALLOCATTR(bg, fg, WSATTR_WSCOLORS | (ul ? WSATTR_UNDERLINE : 0),
+ &cell.attr);
- attr = (((attr >> 8) & 0x88) | ((((attr >> 8) >> 4) |
- ((attr >> 8) << 4)) & 0x77)) ;
- PUTCHAR(pos, (u_int) (uc & 0x00FF), (long) attr);
+ PUTCHAR(pos, cell.uc, cell.attr);
}
void
@@ -2440,12 +2438,14 @@ inverse_region(unsigned short start, unsigned short end)
unsigned char
skip_spc_right(char border)
{
+ struct wsdisplay_charcell cell;
unsigned short current = CPY_END;
unsigned short mouse_col = (CPY_END % N_COLS);
unsigned short limit = current + (N_COLS - mouse_col - 1);
unsigned char res = 0;
- while ((GETCHAR(current) == ' ') && (current <= limit)) {
+ while (GETCHAR(current, &cell) == 0 && cell.uc == ' ' &&
+ current <= limit) {
current++;
res++;
}
@@ -2469,12 +2469,14 @@ skip_spc_right(char border)
unsigned char
skip_spc_left(void)
{
+ struct wsdisplay_charcell cell;
short current = CPY_START;
unsigned short mouse_col = (MOUSE % N_COLS);
unsigned short limit = current - mouse_col;
unsigned char res = 0;
- while ((GETCHAR(current) == ' ') && (current >= limit)) {
+ while (GETCHAR(current, &cell) == 0 && cell.uc == ' ' &&
+ current >= limit) {
current--;
res++;
}
@@ -2561,13 +2563,16 @@ static const int charClass[256] = {
unsigned char
skip_char_right(unsigned short offset)
{
+ struct wsdisplay_charcell cell;
unsigned short current = offset;
unsigned short limit = current + (N_COLS - (MOUSE % N_COLS) - 1);
- unsigned char class = charClass[GETCHAR(current)];
+ unsigned char class;
unsigned char res = 0;
- while ((charClass[GETCHAR(current)] == class)
- && (current <= limit)) {
+ GETCHAR(current, &cell);
+ class = charClass[cell.uc & 0xff];
+ while (GETCHAR(current, &cell) == 0 &&
+ charClass[cell.uc & 0xff] == class && current <= limit) {
current++;
res++;
}
@@ -2582,12 +2587,16 @@ skip_char_right(unsigned short offset)
unsigned char
skip_char_left(unsigned short offset)
{
+ struct wsdisplay_charcell cell;
short current = offset;
unsigned short limit = current - (MOUSE % N_COLS);
- unsigned char class = charClass[GETCHAR(current)];
+ unsigned char class;
unsigned char res = 0;
- while ((charClass[GETCHAR(current)] == class) && (current >= limit)) {
+ GETCHAR(current, &cell);
+ class = charClass[cell.uc & 0xff];
+ while (GETCHAR(current, &cell) == 0 &&
+ charClass[cell.uc & 0xff] == class && current >= limit) {
current--;
res++;
}
@@ -2602,11 +2611,16 @@ skip_char_left(unsigned short offset)
unsigned char
class_cmp(unsigned short first, unsigned short second)
{
+ struct wsdisplay_charcell cell;
unsigned char first_class;
unsigned char second_class;
- first_class = charClass[GETCHAR(first)];
- second_class = charClass[GETCHAR(second)];
+ if (GETCHAR(first, &cell) != 0)
+ return (1);
+ first_class = charClass[cell.uc & 0xff];
+ if (GETCHAR(second, &cell) != 0)
+ return (1);
+ second_class = charClass[cell.uc & 0xff];
if (first_class != second_class)
return (1);
@@ -2659,6 +2673,7 @@ mouse_copy_start(void)
void
mouse_copy_word()
{
+ struct wsdisplay_charcell cell;
unsigned char right;
unsigned char left;
@@ -2671,7 +2686,7 @@ mouse_copy_word()
CPY_START = MOUSE;
CPY_END = MOUSE;
- if (IS_ALPHANUM(MOUSE)) {
+ if (GETCHAR(MOUSE, &cell) == 0 && IS_ALPHANUM(cell.uc)) {
right = skip_char_right(CPY_END);
left = skip_char_left(CPY_START);
} else {
@@ -3074,6 +3089,7 @@ remove_selection(struct wsdisplay_softc *sc)
void
mouse_copy_selection(void)
{
+ struct wsdisplay_charcell cell;
unsigned short current = 0;
unsigned short blank = current;
unsigned short buf_end = ((N_COLS + 1) * N_ROWS);
@@ -3084,7 +3100,9 @@ mouse_copy_selection(void)
sel_end = CPY_END;
while (sel_cur <= sel_end && current < buf_end - 1) {
- Copybuffer[current] = (GETCHAR(sel_cur));
+ if (GETCHAR(sel_cur, &cell) != 0)
+ break;
+ Copybuffer[current] = cell.uc;
if (!IS_SPACE(Copybuffer[current]))
blank = current + 1; /* first blank after non-blank */
current++;
diff --git a/sys/dev/wscons/wsdisplayvar.h b/sys/dev/wscons/wsdisplayvar.h
index c514e942638..15138079c99 100644
--- a/sys/dev/wscons/wsdisplayvar.h
+++ b/sys/dev/wscons/wsdisplayvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsdisplayvar.h,v 1.20 2006/11/29 19:08:23 miod Exp $ */
+/* $OpenBSD: wsdisplayvar.h,v 1.21 2006/11/29 19:11:17 miod Exp $ */
/* $NetBSD: wsdisplayvar.h,v 1.30 2005/02/04 02:10:49 perry Exp $ */
/*
@@ -102,6 +102,14 @@ struct wsscreen_descr {
#define WSSCREEN_UNDERLINE 16 /* can underline */
};
+/*
+ * Character cell description (for emulation mode).
+ */
+struct wsdisplay_charcell {
+ u_int uc;
+ long attr;
+};
+
struct wsdisplay_font;
/*
* Display access functions, invoked by user-land programs which require
@@ -121,7 +129,7 @@ struct wsdisplay_accessops {
void (*) (void *, int, int), void *);
int (*load_font)(void *, void *, struct wsdisplay_font *);
void (*scrollback)(void *, void *, int);
- u_int16_t (*getchar)(void *, int, int);
+ int (*getchar)(void *, int, int, struct wsdisplay_charcell *);
void (*burn_screen)(void *, u_int, u_int);
void (*pollc)(void *, int);
};
diff --git a/sys/dev/wscons/wsmoused.h b/sys/dev/wscons/wsmoused.h
index fd2c441d15d..1f04bec24c6 100644
--- a/sys/dev/wscons/wsmoused.h
+++ b/sys/dev/wscons/wsmoused.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsmoused.h,v 1.5 2006/02/12 19:55:39 miod Exp $ */
+/* $OpenBSD: wsmoused.h,v 1.6 2006/11/29 19:11:17 miod Exp $ */
/*
* Copyright (c) 2001 Jean-Baptiste Marchand, Julien Montagne and Jerome Verdon
@@ -105,25 +105,24 @@ extern char Paste_avail; /* flag, to indicate whether a selection is in the
#define POS_TO_X(pos) ((pos) % (N_COLS))
#define POS_TO_Y(pos) ((pos) / (N_COLS))
-#define GET_FULLCHAR(pos)\
-((*sc->sc_accessops->getchar)\
- (sc->sc_accesscookie,\
- ((pos) / N_COLS), ((pos) % N_COLS)))
-
-#define GETCHAR(pos)\
-(((*sc->sc_accessops->getchar)\
- (sc->sc_accesscookie,\
- ((pos) / N_COLS), ((pos) % N_COLS)))\
- & 0x000000FF)
-
-#define PUTCHAR(pos, uc, attr)\
-((*sc->sc_focus->scr_dconf->emulops->putchar)\
-(sc->sc_focus->scr_dconf->emulcookie, ((pos) / N_COLS),\
- ((pos) % N_COLS), (uc), (attr)));
+/* Shortcuts to the various display operations */
+#define GETCHAR(pos, cellp) \
+ ((*sc->sc_accessops->getchar) \
+ (sc->sc_accesscookie, (pos) / N_COLS, (pos) % N_COLS, cellp))
+#define PUTCHAR(pos, uc, attr) \
+ ((*sc->sc_focus->scr_dconf->emulops->putchar) \
+ (sc->sc_focus->scr_dconf->emulcookie, ((pos) / N_COLS), \
+ ((pos) % N_COLS), (uc), (attr)))
+#define UNPACKATTR(attr, fgp, bgp, ulp) \
+ ((*sc->sc_focus->scr_dconf->emulops->unpack_attr) \
+ (sc->sc_focus->scr_dconf->emulcookie, attr, fgp, bgp, ulp))
+#define ALLOCATTR(fg, bg, flags, attrp) \
+ ((*sc->sc_focus->scr_dconf->emulops->alloc_attr) \
+ (sc->sc_focus->scr_dconf->emulcookie, fg, bg, flags, attrp))
#define MOUSE_COPY_BUTTON 0
-#define MOUSE_PASTE_BUTTON 1
+#define MOUSE_PASTE_BUTTON 1
#define MOUSE_EXTEND_BUTTON 2
-#define IS_ALPHANUM(pos) (GETCHAR((pos)) != ' ')
+#define IS_ALPHANUM(c) ((c) != ' ')
#define IS_SPACE(c) ((c) == ' ')