Skip to content

Commit

Permalink
strip out slang
Browse files Browse the repository at this point in the history
  • Loading branch information
flatcap committed Oct 15, 2021
1 parent 6879c34 commit 23c300f
Show file tree
Hide file tree
Showing 19 changed files with 47 additions and 400 deletions.
8 changes: 0 additions & 8 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@ task:
build_script: make
version_script: ./neomutt -v

- name: FreeBSD / S-Lang
install_script:
- ${PKG_UPDATE}
- ${PKG_INSTALL} ${PKG_COMMON} libslang2
configure_script: ./configure ${CONFIGURE_COMMON} --with-ui=slang
build_script: make
version_script: ./neomutt -v

- name: FreeBSD / pkgconf
install_script:
- ${PKG_UPDATE}
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ jobs:
options:
- name: disabled
options: --disable-idn --disable-nls --disable-pgp --disable-smime
- name: slang
options: --fmemopen --homespool --locales-fix --mixmaster --ssl --with-domain=example.com --with-lock=flock --with-ui=slang
- name: everything
options: --autocrypt --bdb --disable-idn --full-doc --gdbm --gnutls --gpgme --gss --idn2 --kyotocabinet --lmdb --lua --lz4 --notmuch --qdbm --sasl --tdb --tokyocabinet --with-lock=fcntl --with-ui=ncurses --zlib --zstd
options: --autocrypt --bdb --disable-idn --full-doc --gdbm --gnutls --gpgme --gss --idn2 --kyotocabinet --lmdb --lua --lz4 --notmuch --qdbm --sasl --tdb --tokyocabinet --with-lock=fcntl --zlib --zstd

steps:
- name: Checkout Code
Expand Down
1 change: 0 additions & 1 deletion .lgtm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ extraction:
- libnotmuch-dev
- libqdbm-dev
- libsasl2-dev
- libslang2-dev
- libssl-dev
- libtokyocabinet-dev
- libxml2-utils
Expand Down
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ addons:
- libqdbm-dev
- librocksdb-dev
- libsasl2-dev
- libslang2-dev
- libssl-dev
- libtdb-dev
- libtokyocabinet-dev
Expand Down
4 changes: 1 addition & 3 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ See [Signing Releases](https://neomutt.org/dev/signing#source-example) for detai
To build NeoMutt, you will need, at the very minimum:

- A C99 compiler such as gcc or clang
- SysV-compatible curses library: ncurses or slang
- SysV-compatible curses library: ncurses
- Some common libraries, such as iconv and regex
- DocBook XSL stylesheets and DTDs (for building the docs)

Expand All @@ -55,9 +55,7 @@ For a list of the currently supported options and a brief help text, run:

| Configure option | Path | Notes |
| :---------------------- | :--- | :------------------------------------------- |
| `--with-ui=CHOICE` | | Select 'ncurses' or 'slang' |
| `--with-ncurses=path` | | Location of ncurses |
| `--with-slang=path` | | Location of S-Lang |
| | | |
| `--gpgme` | Path | GPG Made Easy |
| `--gnutls` | Path | Gnu TLS (SSL) |
Expand Down
96 changes: 36 additions & 60 deletions auto.def
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ set subdirs {po docs contrib}
###############################################################################
# Add any user options here
options {
# Curses / S-Lang
with-ui:=ncurses => "Select ncurses or slang for the UI"
# Curses
with-ncurses:path => "Location of ncurses"
with-slang:path => "Location of S-Lang"
# Features w/o 3rd party dependencies
doc=1 => "Disable building the documentation"
full-doc=0 => "Build the full documentation set"
Expand Down Expand Up @@ -152,9 +150,9 @@ if {1} {
# relative --enable-opt to true. This allows "--with-opt=/usr" to be used as
# a shortcut for "--opt --with-opt=/usr".
foreach opt {
bdb gdbm gnutls gpgme gss homespool idn idn2 kyotocabinet lmdb lua lz4
mixmaster ncurses nls notmuch pcre2 qdbm rocksdb sasl slang sqlite ssl tdb
tokyocabinet zlib zstd
bdb gdbm gnutls gpgme gss homespool idn idn2 kyotocabinet lmdb lua lz4
mixmaster nls notmuch pcre2 qdbm rocksdb sasl sqlite ssl tdb tokyocabinet
zlib zstd
} {
if {[opt-val with-$opt] ne {}} {
define want-$opt 1
Expand Down Expand Up @@ -707,72 +705,50 @@ if {[get-define want-fmemopen]} {
}

###############################################################################
# Ncurses / S-Lang
switch [opt-val with-ui ncurses] {
ncurses {
define-append CFLAGS -DNCURSES_WIDECHAR
set ncurses_prefix [opt-val with-ncurses $prefix]
# Ncurses
define-append CFLAGS -DNCURSES_WIDECHAR
set ncurses_prefix [opt-val with-ncurses $prefix]

cc-with [list -libs -L$ncurses_prefix/$::libdir_tail] {
cc-with [list -libs -L$ncurses_prefix/$::libdir_tail] {

set tinfo_libs {tinfow tinfo}
set ncurses_libs {ncursesw ncurses curses}
set tinfo_libs {tinfow tinfo}
set ncurses_libs {ncursesw ncurses curses}

# Locate the library defining tgetent()
# This must be done *before* checking for ncurses functions, see
# https://github.com/neomutt/neomutt/issues/1118
foreach tinfo_lib [concat $tinfo_libs $ncurses_libs] {
if {[cc-check-function-in-lib tgetent $tinfo_lib]} {
break
}
}

# Locate the library defining waddnwstr()
foreach ncurses_lib $ncurses_libs {
if {[cc-check-function-in-lib waddnwstr $ncurses_lib]} {
break
}
}

if {![have-feature waddnwstr] || ![have-feature tgetent]} {
user-error "Unable to find ncursesw library"
}
# Locate the library defining tgetent()
# This must be done *before* checking for ncurses functions, see
# https://github.com/neomutt/neomutt/issues/1118
foreach tinfo_lib [concat $tinfo_libs $ncurses_libs] {
if {[cc-check-function-in-lib tgetent $tinfo_lib]} {
break
}

# Locate the directory containing ncurses.h
# See https://github.com/neomutt/neomutt/pull/679
apply {{ncurses_prefix} {
cc-with [list -cflags -I$ncurses_prefix/include] {
foreach ncurses_inc {ncursesw/ ncurses/ curses/ {}} {
if {[cc-check-includes ${ncurses_inc}ncurses.h] ||
[cc-check-includes ${ncurses_inc}curses.h]} {
return
}
}
user-error "Unable to find ncurses headers"
}
}} $ncurses_prefix
}

slang {
cc-with {-includes sys/param.h} {
if {[cc-check-defines BSD]} {
cc-check-function-in-lib initscr termlib
}
# Locate the library defining waddnwstr()
foreach ncurses_lib $ncurses_libs {
if {[cc-check-function-in-lib waddnwstr $ncurses_lib]} {
break
}
if {![check-inc-and-lib slang [opt-val with-slang $prefix] \
slcurses.h SLtt_get_terminfo slang]} {
user-error "Unable to find S-Lang"
}
define USE_SLANG_CURSES
}

default {
user-error "Invalid value for --with-ui=[opt-val with-ui], select ncurses\
or slang"
if {![have-feature waddnwstr] || ![have-feature tgetent]} {
user-error "Unable to find ncursesw library"
}
}

# Locate the directory containing ncurses.h
# See https://github.com/neomutt/neomutt/pull/679
apply {{ncurses_prefix} {
cc-with [list -cflags -I$ncurses_prefix/include] {
foreach ncurses_inc {ncursesw/ ncurses/ curses/ {}} {
if {[cc-check-includes ${ncurses_inc}ncurses.h] ||
[cc-check-includes ${ncurses_inc}curses.h]} {
return
}
}
user-error "Unable to find ncurses headers"
}
}} $ncurses_prefix

###############################################################################
# Iconv - try to mimic AM_ICONV by preferring an installed libiconv
if {![check-iconv $prefix]} {
Expand Down
82 changes: 0 additions & 82 deletions color/color.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@
#include "init.h"
#include "mutt_globals.h"
#include "options.h"
#ifdef USE_SLANG_CURSES
#include <assert.h>
#endif

#define COLOR_UNSET UINT32_MAX
/// Ten colours, quoted0..quoted9 (quoted and quoted0 are equivalent)
Expand Down Expand Up @@ -413,56 +410,6 @@ static struct ColorLine *color_line_new(void)
return cl;
}

#ifdef USE_SLANG_CURSES
/**
* get_color_name - Get a colour's name from its ID
* @param dest Buffer for the result
* @param destlen Length of buffer
* @param val Colour ID to look up
* @retval ptr Pointer to the results buffer
*/
static char *get_color_name(char *dest, size_t destlen, uint32_t val)
{
static const char *const missing[3] = { "brown", "lightgray", "default" };

if (val & RGB24)
{
assert(snprintf(dest, destlen, "#%06X", val & 0xffffff) == 7);
return dest;
}

switch (val)
{
case COLOR_YELLOW:
mutt_str_copy(dest, missing[0], destlen);
return dest;

case COLOR_WHITE:
mutt_str_copy(dest, missing[1], destlen);
return dest;

case COLOR_DEFAULT:
mutt_str_copy(dest, missing[2], destlen);
return dest;
}

for (int i = 0; ColorNames[i].name; i++)
{
if (ColorNames[i].value == val)
{
mutt_str_copy(dest, ColorNames[i].name, destlen);
return dest;
}
}

/* Sigh. If we got this far, the color is of the form 'colorN'
* Slang can handle this itself, so just return 'colorN' */
snprintf(dest, destlen, "color%d", val);

return dest;
}
#endif

/**
* mutt_color_alloc - Allocate a colour pair
* @param fg Foreground colour ID
Expand All @@ -471,9 +418,6 @@ static char *get_color_name(char *dest, size_t destlen, uint32_t val)
*/
int mutt_color_alloc(uint32_t fg, uint32_t bg)
{
#ifdef USE_SLANG_CURSES
char fgc[128], bgc[128];
#endif
struct ColorList *p = Colors.user_colors;

/* check to see if this color is already allocated to save space */
Expand Down Expand Up @@ -516,21 +460,11 @@ int mutt_color_alloc(uint32_t fg, uint32_t bg)
p->bg = bg;
p->fg = fg;

#ifdef USE_SLANG_CURSES
/*
* If using s-lang always use SLtt_set_color which allows using truecolor
* values. Note that I couldn't figure out if s-lang somehow reports
* truecolor support.
*/
SLtt_set_color(i, NULL, get_color_name(fgc, sizeof(fgc), fg),
get_color_name(bgc, sizeof(bgc), bg));
#else
if (fg == COLOR_DEFAULT)
fg = COLOR_UNSET;
if (bg == COLOR_DEFAULT)
bg = COLOR_UNSET;
init_pair(i, fg, bg);
#endif

mutt_debug(LL_DEBUG3, "Color pairs used so far: %d\n", Colors.num_user_colors);

Expand Down Expand Up @@ -630,20 +564,6 @@ static enum CommandResult parse_color_name(const char *s, uint32_t *col, int *at
return MUTT_CMD_ERROR;
}
}
#ifdef USE_SLANG_CURSES
else if (*s == '#')
{
s += 1;
*col = strtoul(s, &eptr, 16);
if ((*s == '\0') || (*eptr != '\0') ||
((*col == COLOR_UNSET) && !OptNoCurses && has_colors()))
{
snprintf(err->data, err->dsize, _("%s: color not supported by term"), s);
return MUTT_CMD_ERROR;
}
*col |= RGB24;
}
#endif
else if ((*col = mutt_map_get_value(s, ColorNames)) == -1)
{
mutt_buffer_printf(err, _("%s: no such color"), s);
Expand Down Expand Up @@ -1243,7 +1163,6 @@ static enum CommandResult parse_color(struct Buffer *buf, struct Buffer *s,
return MUTT_CMD_SUCCESS;
}

#ifdef NCURSES_VERSION
if (!OptNoCurses &&
has_colors()
/* delay use_default_colors() until needed, since it initializes things */
Expand All @@ -1256,7 +1175,6 @@ static enum CommandResult parse_color(struct Buffer *buf, struct Buffer *s,
mutt_buffer_strcpy(err, _("default colors not supported"));
return MUTT_CMD_ERROR;
}
#endif

if (object == MT_COLOR_ATTACH_HEADERS)
rc = add_pattern(mutt_color_attachments(), buf->data, true, fg, bg, attr,
Expand Down
Loading

0 comments on commit 23c300f

Please sign in to comment.