Skip to content

Commit

Permalink
'picsview', 'mbrot' demos now work with ncurses. The locale needed to…
Browse files Browse the repository at this point in the history
… be set, and attr_set() used instead of attrset(). Unnecessary distinctions between PDCurses* and ncurses removed.
  • Loading branch information
Bill-Gray committed Jun 12, 2023
1 parent 2f01b46 commit 8972791
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
2 changes: 2 additions & 0 deletions demos/mbrot.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <curses.h>
#include <stdlib.h>
#include <locale.h>
#include <assert.h>
#include <locale.h>

Expand Down Expand Up @@ -202,6 +203,7 @@ int main( const int argc, const char **argv)
int results[5], rval;
#endif

setlocale(LC_ALL, "");
for( i = 1; i < argc; i++)
if( argv[i][0] == '-')
switch( argv[i][1])
Expand Down
14 changes: 3 additions & 11 deletions demos/picsview.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <stdlib.h>
#include <locale.h>
#include <stdio.h>
#include <string.h>

Expand Down Expand Up @@ -220,6 +221,7 @@ int main( const int argc, const char *argv[])
double scale = 0., xpix = 0., ypix = 0.;
bool show_help = TRUE;

setlocale(LC_ALL, "");
for( i = 1; i < argc; i++)
if( argv[i][0] == '-')
switch( argv[i][1])
Expand Down Expand Up @@ -340,27 +342,17 @@ int main( const int argc, const char *argv[])
{
int low_rgb = (pptr ? get_rgb_value( pptr + xloc[i] * 3) : 0);
int low_idx = find_in_palette( low_rgb, calc_dither( i, j));
#ifndef __PDCURSES__
wchar_t bblock_char = ACS_BBLOCK;
#endif

if( low_idx != prev_low_idx || idxs[i] != prev_idx)
{
#ifdef __PDCURSES__
init_extended_pair( pair_num, low_idx, idxs[i]);
#else
init_pair( pair_num, low_idx, idxs[i]);
#endif
attrset( COLOR_PAIR( pair_num));
attr_set( A_NORMAL, pair_num, 0);
pair_num++;
prev_low_idx = low_idx;
prev_idx = idxs[i];
}
#ifdef __PDCURSES__
addch( ACS_BBLOCK);
#else
addnwstr( &bblock_char, 1);
#endif
}
}
}
Expand Down

0 comments on commit 8972791

Please sign in to comment.