Procházet zdrojové kódy

* configure.ac:

+ Default to ncurses, not slang, because slang only has 128 colour pairs.
  * src/caca.c:
    + Disable scrolling to avoid hashmap scrolling optimization code.
  * src/graphics.c:
    + Swap fg and bg in the colour pair indexing, so that bg is always
      right.
    + Disable alt charset support to exploit my patched slang.
tags/v0.99.beta14
Sam Hocevar sam před 21 roky
rodič
revize
88359dfc90
4 změnil soubory, kde provedl 41 přidání a 15 odebrání
  1. +5
    -0
      NOTES
  2. +9
    -9
      configure.ac
  3. +4
    -0
      src/caca.c
  4. +23
    -6
      src/graphics.c

+ 5
- 0
NOTES Zobrazit soubor

@@ -117,6 +117,11 @@ $Id$

o S-Lang:

256 character pairs are definable, but only 128 can be used. This is
because slsmg.c's This_Color variable uses its 8th bit to indicate an
alternate character set. Replacing a few 0x7F with 0xFF in sldisply.c
works around the problem but gets rid of the alternate charset.

o MS-DOS: all bright colours, bright backgrounds, and bright combinations
work using <conio.h>. No need to kludge anything.


+ 9
- 9
configure.ac Zobrazit soubor

@@ -17,10 +17,10 @@ dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
dnl now otherwise it might be set in an obscure if statement.
AC_EGREP_CPP(foo,foo)

AC_ARG_ENABLE(slang,
[ --enable-slang slang graphics support (default enabled)])
AC_ARG_ENABLE(ncurses,
[ --enable-ncurses ncurses graphics support (default disabled)])
[ --enable-ncurses ncurses graphics support (default enabled)])
AC_ARG_ENABLE(slang,
[ --enable-slang slang graphics support (default disabled)])
AC_ARG_ENABLE(conio,
[ --enable-conio DOS conio.h graphics support (default disabled)])

@@ -40,16 +40,16 @@ if test "${enable_conio}" = "yes"; then
AC_MSG_RESULT(no)])
AC_DEFINE(USE_CONIO, 1, Define if the backend driver is conio.h)
USE_CONIO=:
elif test "${enable_ncurses}" = "yes"; then
AC_CHECK_HEADER(ncurses.h,:,AC_MSG_ERROR([cannot find ncurses headers]))
AC_CHECK_LIB(ncurses,initscr,:,AC_MSG_ERROR([cannot find ncurses library]))
AC_DEFINE(USE_NCURSES, 1, Define if the backend driver is ncurses)
USE_NCURSES=:
elif test "${enable_slang}" != "no"; then
elif test "${enable_slang}" = "yes"; then
AC_CHECK_HEADER(slang.h,:,AC_MSG_ERROR([cannot find slang headers]))
AC_CHECK_LIB(slang,SLkp_init,:,AC_MSG_ERROR([cannot find slang library]))
AC_DEFINE(USE_SLANG, 1, Define if the backend driver is slang)
USE_SLANG=:
elif test "${enable_ncurses}" != "no"; then
AC_CHECK_HEADER(ncurses.h,:,AC_MSG_ERROR([cannot find ncurses headers]))
AC_CHECK_LIB(ncurses,initscr,:,AC_MSG_ERROR([cannot find ncurses library]))
AC_DEFINE(USE_NCURSES, 1, Define if the backend driver is ncurses)
USE_NCURSES=:
else
AC_MSG_ERROR([could not find any terminal graphics interface])
fi


+ 4
- 0
src/caca.c Zobrazit soubor

@@ -97,6 +97,10 @@ int caca_init(void)
SLtt_set_mouse_mode(1, 0);
SLsmg_refresh();

/* Disable scrolling so that hashmap scrolling optimization code
* does not cause ugly refreshes due to slow terminals */
SLtt_Term_Cannot_Scroll = 1;

#elif defined(USE_NCURSES)
mmask_t newmask;



+ 23
- 6
src/graphics.c Zobrazit soubor

@@ -39,6 +39,10 @@
# error "no graphics library detected"
#endif

#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif

#include <stdio.h> /* BUFSIZ */
#include <string.h>
#include <stdlib.h>
@@ -64,7 +68,7 @@ void caca_set_color(enum caca_color fgcolor, enum caca_color bgcolor)
_caca_fgcolor = fgcolor;
_caca_bgcolor = bgcolor;
#if defined(USE_SLANG)
SLsmg_set_color(fgcolor + 16 * bgcolor);
SLsmg_set_color((bgcolor + 16 * fgcolor) /*% 128*/);
#elif defined(USE_NCURSES)
attrset(_caca_attr[fgcolor + 16 * bgcolor]);
#elif defined(USE_CONIO)
@@ -134,7 +138,7 @@ void caca_putstr(int x, int y, const char *s)

#if defined(USE_SLANG)
SLsmg_gotorc(y, x);
SLsmg_write_string(s);
SLsmg_write_string((char *)(intptr_t)s);
#elif defined(USE_NCURSES)
move(y, x);
addstr(s);
@@ -198,6 +202,7 @@ int _caca_init_graphics(void)
/* See SLang ref., 5.4.4. */
static char *slang_colors[16] =
{
/* Standard colours */
"black",
"blue",
"green",
@@ -206,6 +211,7 @@ int _caca_init_graphics(void)
"magenta",
"brown",
"lightgray",
/* Bright colours */
"gray",
"brightblue",
"brightgreen",
@@ -218,16 +224,20 @@ int _caca_init_graphics(void)

int fg, bg;

for(bg = 0; bg < 16; bg++)
for(fg = 0; fg < 16; fg++)
for(fg = 0; fg < 16; fg++)
for(bg = 0; bg < 16; bg++)
{
int i = fg + 16 * bg;
int i = bg + 16 * fg;
SLtt_set_color(i, NULL, slang_colors[fg], slang_colors[bg]);
}

/* Disable alt charset support so that we get all 256 colour pairs */
SLtt_Has_Alt_Charset = 0;

#elif defined(USE_NCURSES)
static int curses_colors[] =
{
/* Standard curses colours */
COLOR_BLACK,
COLOR_BLUE,
COLOR_GREEN,
@@ -252,6 +262,12 @@ int _caca_init_graphics(void)
/* Activate colour */
start_color();

/* If COLORS == 16, it means the terminal supports full bright colours
* using setab and setaf (will use \e[90m \e[91m etc. for colours >= 8),
* we can build 16*16 colour pairs.
* If COLORS == 8, it means the terminal does not know about bright
* colours and we need to get them through A_BOLD and A_BLINK (\e[1m
* and \e[5m). We can only build 8*8 colour pairs. */
max = COLORS >= 16 ? 16 : 8;

for(bg = 0; bg < max; bg++)
@@ -271,7 +287,8 @@ int _caca_init_graphics(void)
/* Simple fg on bright bg */
_caca_attr[fg + 16 * (bg + 8)] = A_BLINK | COLOR_PAIR(col);
/* Bright fg on bright bg */
_caca_attr[fg + 8 + 16 * (bg + 8)] = A_BLINK | A_BOLD | COLOR_PAIR(col);
_caca_attr[fg + 8 + 16 * (bg + 8)] = A_BLINK | A_BOLD
| COLOR_PAIR(col);
}
}



Načítá se…
Zrušit
Uložit