aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-10-13 15:17:42 +0200
committerThomas White <taw@physics.org>2021-10-13 15:19:04 +0200
commit8f4b2d8249fad3f8d05099b76de698a9f7db64a4 (patch)
tree63ae856fcfa9a46d97f22edd8ef621227129f619
parent00831dc3cae2fd4df8ed13bdb8d2fa8bece7ceae (diff)
Remove NCurses dependency
It's only used once, to get background colours for 'indexamajig --int-diag', itself a rarely used feature. The dependency itself seems to cause problems for some people, particularly those not using system libraries for everything. So I think it's better just to remove it, and use ANSI escape codes directly.
-rw-r--r--INSTALL.md5
-rw-r--r--libcrystfel/CMakeLists.txt7
-rw-r--r--libcrystfel/libcrystfel-config.h.cmake.in1
-rw-r--r--libcrystfel/libcrystfel-config.h.meson.in1
-rw-r--r--libcrystfel/meson.build7
-rw-r--r--libcrystfel/src/integration.c64
6 files changed, 23 insertions, 62 deletions
diff --git a/INSTALL.md b/INSTALL.md
index 7001b7a8..ca1bd869 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -49,7 +49,6 @@ roughly in order of importance:
* [PinkIndexer](https://stash.desy.de/users/gevorkov/repos/pinkindexer) \[\*\] (for indexing electron or wide bandwidth diffraction patterns)
* [FFTW](http://fftw.org/) 3.0 or later (required for `asdf` indexing)
* [FDIP](https://stash.desy.de/users/gevorkov/repos/fastdiffractionimageprocessing/) \[\*\] (for `peakFinder9` peak search algorithm)
-* NCurses (for integration diagnostics: `indexamajig --int-diag`)
Most of the dependencies mentioned above should be available from your Linux
distribution's package manager, or from [Homebrew](https://brew.sh/) on Mac OS.
@@ -108,14 +107,14 @@ later (for CentOS, replace `dnf` with `yum`):
```
$ sudo dnf group install 'Development Tools'
$ sudo dnf install hdf5-devel gsl-devel gtk3-devel cairo-devel pango-devel gdk-pixbuf2-devel meson cmake gcc-c++
-$ sudo dnf install fftw-devel ncurses-devel zeromq-devel msgpack-devel libccp4-devel
+$ sudo dnf install fftw-devel zeromq-devel msgpack-devel libccp4-devel
```
Here are the commands for Ubuntu and Debian:
```
$ sudo apt install build-essential
$ sudo apt install libhdf5-dev libgsl-dev gtk3-devel cairo-devel pango-devel gdk-pixbuf2-devel meson cmake gcc-c++
-$ sudo apt install fftw-devel ncurses-devel libmsgpack-dev libzmq3-dev libccp4-dev
+$ sudo apt install fftw-devel libmsgpack-dev libzmq3-dev libccp4-dev
```
For Mac OS X, first install [Homebrew](https://brew.sh/), which will also cause
diff --git a/libcrystfel/CMakeLists.txt b/libcrystfel/CMakeLists.txt
index 83f1e983..aea75b27 100644
--- a/libcrystfel/CMakeLists.txt
+++ b/libcrystfel/CMakeLists.txt
@@ -1,6 +1,5 @@
project(libcrystfel VERSION ${CRYSTFEL_SHORT_VERSION} LANGUAGES C)
-find_package(Curses)
pkg_check_modules(XGANDALF xgandalf)
pkg_check_modules(PINKINDEXER pinkIndexer)
pkg_check_modules(FDIP fdip)
@@ -13,7 +12,6 @@ pkg_check_modules(LIBCCP4 libccp4c)
configure_file(src/libcrystfel-version.c.cmake.in libcrystfel-version.c)
-set(HAVE_CURSES ${CURSES_FOUND})
set(HAVE_FFTW ${FFTW_FOUND})
set(HAVE_XGANDALF ${XGANDALF_FOUND})
set(HAVE_PINKINDEXER ${PINKINDEXER_FOUND})
@@ -150,11 +148,6 @@ if (FFTW_FOUND)
target_link_libraries(${PROJECT_NAME} PRIVATE ${FFTW_LINK_LIBRARIES})
endif (FFTW_FOUND)
-if (CURSES_FOUND)
- target_include_directories(${PROJECT_NAME} PRIVATE ${CURSES_INCLUDE_DIRS})
- target_link_libraries(${PROJECT_NAME} PRIVATE ${CURSES_LIBRARIES})
-endif (CURSES_FOUND)
-
if (LIBCCP4_FOUND)
target_include_directories(${PROJECT_NAME} PRIVATE ${LIBCCP4_INCLUDES})
target_link_libraries(${PROJECT_NAME} PRIVATE ${LIBCCP4_LIBRARIES})
diff --git a/libcrystfel/libcrystfel-config.h.cmake.in b/libcrystfel/libcrystfel-config.h.cmake.in
index 1a81ffde..a7aaaf8f 100644
--- a/libcrystfel/libcrystfel-config.h.cmake.in
+++ b/libcrystfel/libcrystfel-config.h.cmake.in
@@ -5,7 +5,6 @@
#cmakedefine HAVE_XGANDALF
#cmakedefine HAVE_PINKINDEXER
#cmakedefine HAVE_FDIP
-#cmakedefine HAVE_CURSES
#cmakedefine HAVE_GZBUFFER
#cmakedefine HAVE_GDKPIXBUF
#cmakedefine HAVE_LIBCCP4
diff --git a/libcrystfel/libcrystfel-config.h.meson.in b/libcrystfel/libcrystfel-config.h.meson.in
index 1cadfd02..ede17ab8 100644
--- a/libcrystfel/libcrystfel-config.h.meson.in
+++ b/libcrystfel/libcrystfel-config.h.meson.in
@@ -4,7 +4,6 @@
#mesondefine HAVE_XGANDALF
#mesondefine HAVE_PINKINDEXER
#mesondefine HAVE_FDIP
-#mesondefine HAVE_CURSES
#mesondefine HAVE_GZBUFFER
#mesondefine HAVE_LIBCCP4
#mesondefine HAVE_MSGPACK
diff --git a/libcrystfel/meson.build b/libcrystfel/meson.build
index 35893115..dc0fe2bf 100644
--- a/libcrystfel/meson.build
+++ b/libcrystfel/meson.build
@@ -12,11 +12,6 @@ if fftwdep.found()
conf_data.set10('HAVE_FFTW', 1)
endif
-ncursesdep = dependency('ncurses', required: false)
-if ncursesdep.found()
- conf_data.set10('HAVE_CURSES', 1)
-endif
-
xgandalfdep = dependency('xgandalf',
required: false,
fallback: ['xgandalf', 'xgandalf_dep'])
@@ -139,7 +134,7 @@ libcrystfel = library('crystfel', [libcrystfel_sources, libcrystfel_versionc],
include_directories: [libcrystfel_includes,
libcrystfel_conf_inc],
dependencies: [mdep, utildep, fftwdep, gsldep, zlibdep,
- hdf5dep, pthreaddep, ncursesdep,
+ hdf5dep, pthreaddep,
xgandalfdep, pinkindexerdep, fdipdep,
ccp4dep, msgpackdep],
install: true)
diff --git a/libcrystfel/src/integration.c b/libcrystfel/src/integration.c
index 04524274..9c38f608 100644
--- a/libcrystfel/src/integration.c
+++ b/libcrystfel/src/integration.c
@@ -36,10 +36,6 @@
#include <gsl/gsl_linalg.h>
#include <gsl/gsl_eigen.h>
-#ifdef HAVE_CURSES
-#include <ncurses.h>
-#endif
-
#include "reflist.h"
#include "reflist-utils.h"
#include "cell.h"
@@ -178,21 +174,20 @@ static float boxi(struct intcontext *ic, struct peak_box *bx, int p, int q)
}
-#ifdef HAVE_CURSES
static void colour_on(enum boxmask_val b)
{
switch ( b ) {
case BM_BG :
- attron(COLOR_PAIR(1));
+ printf("\e[44m\e[37m");
break;
case BM_PK :
- attron(COLOR_PAIR(2));
+ printf("\e[41m\e[37m");
break;
case BM_BH :
- attron(COLOR_PAIR(3));
+ printf("\e[46m\e[30m");
break;
default:
@@ -207,15 +202,15 @@ static void colour_off(enum boxmask_val b)
switch ( b ) {
case BM_BG :
- attroff(COLOR_PAIR(1));
+ printf("\e[49m\e[39m");
break;
case BM_PK :
- attroff(COLOR_PAIR(2));
+ printf("\e[49m\e[39m");
break;
case BM_BH :
- attroff(COLOR_PAIR(3));
+ printf("\e[49m\e[39m");
break;
default:
@@ -223,15 +218,13 @@ static void colour_off(enum boxmask_val b)
}
}
-#endif
-#ifdef HAVE_CURSES
static void show_reference_profile(struct intcontext *ic, int i)
{
int q;
- printw("Reference profile number %i (%i contributions):\n", i,
+ printf("Reference profile number %i (%i contributions):\n", i,
ic->n_profiles_in_reference[i]);
for ( q=ic->w-1; q>=0; q-- ) {
@@ -241,40 +234,32 @@ static void show_reference_profile(struct intcontext *ic, int i)
for ( p=0; p<ic->w; p++ ) {
colour_on(ic->bm[p+q*ic->w]);
- printw("%4.0f ", ic->reference_profiles[i][p+ic->w*q]);
+ printf("%4.0f ", ic->reference_profiles[i][p+ic->w*q]);
colour_off(ic->bm[p+q*ic->w]);
}
- printw("\n");
+ printf("\n");
}
}
-#endif
static void show_peak_box(struct intcontext *ic, struct peak_box *bx,
pthread_mutex_t *term_lock)
{
-#ifdef HAVE_CURSES
int q;
signed int h, k, l;
double fs, ss;
if ( term_lock != NULL ) pthread_mutex_lock(term_lock);
- initscr();
- clear();
- start_color();
- init_pair(1, COLOR_WHITE, COLOR_BLUE) ; /* Background */
- init_pair(2, COLOR_WHITE, COLOR_RED); /* Peak */
- init_pair(3, COLOR_BLACK, COLOR_CYAN); /* Blackhole */
-
get_indices(bx->refl, &h, &k, &l);
get_detector_pos(bx->refl, &fs, &ss);
- printw("Indices %i %i %i\nPanel %s\nPosition fs = %.1f, ss = %.1f\n\n",
+ printf("-------- Start of integration diagnostics\n");
+ printf("Indices %i %i %i\nPanel %s\nPosition fs = %.1f, ss = %.1f\n\n",
h, k, l, bx->p->name, fs, ss);
- printw("Pixel values:\n");
+ printf("Pixel values:\n");
for ( q=ic->w-1; q>=0; q-- ) {
int p;
@@ -282,15 +267,15 @@ static void show_peak_box(struct intcontext *ic, struct peak_box *bx,
for ( p=0; p<ic->w; p++ ) {
colour_on(bx->bm[p+q*ic->w]);
- printw("%5.0f ", boxi(ic, bx, p, q));
+ printf("%5.0f ", boxi(ic, bx, p, q));
colour_off(bx->bm[p+q*ic->w]);
}
- printw("\n");
+ printf("\n");
}
- printw("\nFitted background (parameters a=%.2f, b=%.2f, c=%.2f)\n",
+ printf("\nFitted background (parameters a=%.2f, b=%.2f, c=%.2f)\n",
bx->a, bx->b, bx->c);
for ( q=ic->w-1; q>=0; q-- ) {
@@ -299,33 +284,24 @@ static void show_peak_box(struct intcontext *ic, struct peak_box *bx,
for ( p=0; p<ic->w; p++ ) {
colour_on(bx->bm[p+q*ic->w]);
- printw("%5.0f ", bx->a*p + bx->b*q + bx->c);
+ printf("%5.0f ", bx->a*p + bx->b*q + bx->c);
colour_off(bx->bm[p+q*ic->w]);
}
- printw("\n");
+ printf("\n");
}
if ( ic->meth & INTEGRATION_PROF2D ) {
- printw("\n");
+ printf("\n");
show_reference_profile(ic, bx->rp);
}
- printw("\nIntensity = %.2f +/- %.2f\n", get_intensity(bx->refl),
+ printf("\nIntensity = %.2f +/- %.2f\n", get_intensity(bx->refl),
get_esd_intensity(bx->refl));
-
- printw("\n\nPress any key to continue processing...\n\n");
-
- refresh();
- getch();
- endwin();
+ printf("-------- End of integration diagnostics\n");
if ( term_lock != NULL ) pthread_mutex_unlock(term_lock);
-#else
- STATUS("Not showing peak box because CrystFEL was compiled without "
- "ncurses.\n");
-#endif
}