Пример #1
0
/**
Redraws the window.

Draws the custom interface.

@param win The window to redraw.
@return OK if successful and ERR otherwise.
**/
int OVERLOAD(wrefresh)(WINDOW * const win) {
	if (options.roll_on) {
		return OK;
	}

	log_call("wrefresh(" PTRF ").", PTRS(win));

	/*
	Stores the state of the window,
	 draws the interface
	 and restores the state.

	Pointers are used to suppress a warning about a bug in a library.
	<pre>
	the comparison will always evaluate as 'true' for the address of 'attrs' will never be NULL [-Waddress]
	</pre>
	*/
	int y, x;
	attr_t attrs; attr_t * const attrs_ptr = &attrs;
	short int pair; short int * const pair_ptr = &pair;
	wattr_get(win, attrs_ptr, pair_ptr, NULL);
	getyx(win, y, x);
	wattrset(win, A_NORMAL);
	const int result = orig_wrefresh(win);
	gui_draw(win);
	orig_wrefresh(win);
	wmove(win, y, x);
	wattr_set(win, attrs, pair, NULL);

	return result;
}
Пример #2
0
/**
Returns the current system time.

Replaces the system time with a fixed time.

@param t The fixed time to return.
@return The fixed time.
**/
time_t OVERLOAD(time)(time_t * const t) {
	log_call("time(" PTRF ").", PTRS(t));

	if (t != NULL) {
		*t = cfg_timestamp;
	}
	return cfg_timestamp;//reduces entropy
}
Пример #3
0
/**
Controls the terminal.

Intercepts <code>TIOCGWINSZ</code> to always report a fixed size.
Resizing the terminal causes spurious calls and prints garbage on the screen.

@param fildes An open file descriptor.
@param request A request conforming to <code>ioctl_list</code>.
@param ... A single pointer.
@return 0 if successful and -1 otherwise.
**/
int OVERLOAD(ioctl)(const int fildes, const unsigned long request, ...) {
	va_list	argp;
	va_start(argp, request);
	void * arg = va_arg(argp, void *);

	log_call("ioctl(" PTRF ", " PTRF ", " PTRF ").",
			PTRS(fildes), PTRS(request), PTRS(arg));

	const int result = orig_ioctl(fildes, request, arg);
	if (request == TIOCGWINSZ) {
		struct winsize * size = (struct winsize * )arg;
		size->ws_row = (unsigned short int )cfg_rows;
		size->ws_col = (unsigned short int )cfg_cols;
	}
	va_end(argp);
	return result;
}
Пример #4
0
void  coup_mu_mesag( const short *message )
{
	GRECT *rect ;
	short dummy ;

	switch( message[0] )
	{
		case WM_REDRAW :
			form_redraw( message, &coup_form ) ;
			break ;
		case WM_MOVED :
			rect = (GRECT *) &(message[4]) ;
			wind_set( coup_form.fm_handle, WF_CURRXYWH, PTRS( rect ) ) ;
			coup_form.fm_box = *rect ;
			wind_calc( WC_WORK, wind_form_kind, ELTS( coup_form.fm_box ),
					&coup_form.fm_ptr[ROOT].ob_x, &coup_form.fm_ptr[ROOT].ob_y,
					&dummy, &dummy ) ;
			break ;
		case WM_TOPPED :
			if( message[3] == coup_form.fm_handle )
				wind_set( coup_form.fm_handle, WF_TOP ) ;
			break ;
		case WM_BOTTOM :
			wind_set( coup_form.fm_handle, WF_BOTTOM ) ;
			break ;
		case WM_CLOSED :
			save_couple( edit_coup_ref, edit_coup_block, edit_coup_cptr ) ;
			close_couple() ;
			break ;
		case WM_ALLICONIFY :
			iconify_all( coup_form.fm_box.g_x ) ;
			break ;
		case WM_ICONIFY :
			wind_set( coup_form.fm_handle, WF_UNICONIFYXYWH, ELTS( coup_form.fm_box ) ) ;
			coup_form.fm_box = *(GRECT *)&message[4] ;
			coup_form.iconified = TRUE ;
			wind_set( coup_form.fm_handle, WF_ICONIFY, ELTS( coup_form.fm_box ) ) ;
			wind_title( coup_form.fm_handle, coup_form.icon_title ) ;
			send_redraw_message( &coup_form.fm_box, coup_form.fm_handle ) ;
			break ;
		case WM_UNICONIFY :
			wind_get( coup_form.fm_handle, WF_UNICONIFY, REFS( coup_form.fm_box ) ) ;
			wind_calc( WC_WORK, wind_form_kind, ELTS( coup_form.fm_box ),
					&coup_form.fm_ptr[ROOT].ob_x, &coup_form.fm_ptr[ROOT].ob_y,
					&dummy, &dummy ) ;
			wind_set( coup_form.fm_handle, WF_UNICONIFY, ELTS( coup_form.fm_box ) ) ;
			wind_title( coup_form.fm_handle, coup_form.title_str ) ;
			coup_form.iconified = FALSE ;
			break ;
		default :
			break ;
	}
}
Пример #5
0
void  set_footers( void )
{
	BOOLEAN done = FALSE ;
	short button ;
	short old_footer_lines = footer_lines() ;
	
	copy_footers_to_form() ;
	app_modal_init( footers_ptr, footer_help, TITLED ) ;

	while( !done )
	{
		button = app_modal_do() ;
		button &= ~DOUBLE_CLICK ;

		if( button && button != APP_MODAL_TERM )
		{
			footers_ptr[button].ob_state &= ~SELECTED ;
			objc_draw( footers_ptr, button, 0, PTRS( app_modal_box() ) ) ;
		}

		switch( button )
		{
			case FOOTER_OK :
				copy_form_to_footers() ;
				done = TRUE ;
				break ;
			case FOOTER_CANCEL :
			case APP_MODAL_TERM :
				done = TRUE ;
				break ;
			case FOOTER_SAVE :
				copy_form_to_footers() ;
				saved_footers = footers ;
				save_defaults() ;
				done = TRUE ;
				break ;
			case FOOTER_HELP :
				help( footer_help ) ;
				break ;
			default :
				break ; 
		}
	}

	if( footer_lines() != old_footer_lines )  gdos_params_valid = FALSE ;
							/* This will force draw_custom_pages	*/
							/* to get a correct value				*/

	app_modal_end() ;
}
Пример #6
0
/**
Prints a string to a window.

Draws the custom interface.

@param win The window to print to.
@param str The string to print.
@param n The length of the string.
@return OK if successful and ERR otherwise.
**/
int OVERLOAD(waddnstr)(WINDOW * const win, const char * const str, const int n) {
	if (options.progress == PRINTF) {
		options.progress = WADDNSTR;
		if (gui_init() == -1) {
			uninit(FALSE);
			exit(probno);
		}
		if (init_fork() == -1) {
			uninit(FALSE);
			exit(probno);
		}
	}

	char * const buf = astresc(str);
	if (buf == NULL) {
		probno = log_error(MALLOC_PROBLEM);
		uninit(FALSE);
		exit(probno);
	}
	log_call("waddnstr(" PTRF ", \"%s\", %d).", PTRS(win), buf, n);
	free(buf);

	return orig_waddnstr(win, str, n);
}
Пример #7
0
/**
Reads a key code from a window.

@param win The window to read from.
@return The key code.
**/
int OVERLOAD(wgetch)(WINDOW * const win) {
	log_call("wgetch(" PTRF ").", PTRS(win));

	if (options.play_on) {
		int key = play_key(win);
		if (key == KEY_EOF) {
			options.play_on = FALSE;
		}
		else {
			return key;
		}
	}
	if (options.roll_on) {
		int key = play_key(win);
		if (key == KEY_EOF) {
			options.roll_on = FALSE;
		}
		else {
			return key;
		}
	}

	/*
	Keeps track of the actual turn count.
	*/
	if (*exec_turns < previous_turns) {
		negative_turns++;
	}
	else if (*exec_turns > previous_turns) {
		options.k_on = TRUE;
	}
	else {
		options.k_on = FALSE;
	}
	previous_turns = *exec_turns;
	turns = *exec_turns + negative_turns;

	/*
	Waits for a key.
	*/
	const int key = orig_wgetch(win);

	/*
	Handles a key.
	*/
	if (key == cfg_save_key) {
		put_fwrite(cfg_output_paths[current_save]);
		save_state(current_save);
	}
	else if (key == cfg_load_key) {
		load_state(current_save);
	}
	else if (key == cfg_next_save_key) {
		INC(current_save, 1, cfg_saves);
	}
	else if (key == cfg_prev_save_key) {
		DEC(current_save, 1, cfg_saves);
	}
	else if (key == cfg_longer_duration_key) {
		if (current_duration < frame_rate * frame_rate) {
			current_duration *= 2;
		}
	}
	else if (key == cfg_shorter_duration_key) {
		if (current_duration > frame_rate / frame_rate) {
			current_duration /= 2;
		}
	}
	else if (key == cfg_more_time_key) {
		if (cfg_timestamp - record.timestamp < LONG_MAX) {
			cfg_timestamp++;
		}
	}
	else if (key == cfg_less_time_key) {
		if (cfg_timestamp - record.timestamp > 0) {
			cfg_timestamp--;
		}
	}
	else if (key == cfg_menu_key) {
		options.gui_menu = !options.gui_menu;
		options.gui_info = FALSE;
	}
	else if (key == cfg_info_key) {
		options.gui_menu = FALSE;
		options.gui_info = !options.gui_info;
	}
	else if (key == cfg_condense_key) {
		options.gui_condensed = !options.gui_condensed;
	}
	else if (key == cfg_hide_key) {
		options.gui_hidden = !options.gui_hidden;
	}
	else if (key == cfg_play_key) {
		if (options.play_on) {
			options.play_on = !options.play_on;
		}
		else if (record.frames == 0) {
			options.play_on = TRUE;
			put_fread(cfg_input_path);
			record.current = record.first;
		}
	}
	else if (key == cfg_stop_key) {
		options.play_on = FALSE;
		record.current = NULL;
	}
	else if (key == cfg_quit_key) {
		options.progress = EXIT;
		*shared.state = HAD_ENOUGH;
		shared.pids[0] = 0;
		uninit(FALSE);
		exit(NO_PROBLEM);
	}
	else {
		if (record.frames == 0 && key != ' ') {
			return KEY_NULL;
		}
		else {
			const size_t inputs = sizeof previous_inputs / sizeof *previous_inputs - 1;
			for (size_t input = 0; input < inputs; input++) {//shifts the array left
				previous_inputs[input] = previous_inputs[input + 1];
			}
			previous_inputs[inputs] = key;

			rec_add_key_frame(current_duration, key);
		}
	}
	wrefresh(win);

	return key;
}
Пример #8
0
/**
Converts a <code>time_t</code> to a broken-down <code>struct tm</code>.

Replaces <code>localtime</code> with <code>gmtime</code> to disregard timezones.

@param timep The <code>time_t</code> to convert.
@return The <code>struct tm</code>.
**/
struct tm * OVERLOAD(localtime)(const time_t * const timep) {
	log_call("localtime(" PTRF ").", PTRS(timep));

	return gmtime(timep);//reduces entropy
}
Пример #9
0
short  select_exports( short *type_ptr )
{
	int oset = 0 ;				/* slider offset in numbers of people	*/
	short done = FALSE ;
	short fdone ;
	short export = FALSE ;
	short button ;
	short m_x, m_y ;
	short dummy ;
	short obj_x, obj_y ;
	Filter filter ;
	short i, flag ;

	match_refs = (int *) pmalloc( sizeof (int) * next_person ) ;
	pcross_refs = (int *) pmalloc( sizeof (int) * next_person ) ;
	ccross_refs = (int *) pmalloc( sizeof (int) * next_couple ) ;

	total_people = 0 ;
	for( i=1; i<next_person; i++ )
	{
		if( people[i].birth_date != DELETED_DATE )
			matches[total_people++] = i ;
	}

	exp_selected = (char *) pmalloc( total_people ) ;

	if( !exp_selected || !match_refs || !pcross_refs || !ccross_refs )
	{	
		rsrc_form_alert( 1, NO_MEMORY ) ;
		if( exp_selected )  free( exp_selected ) ;
		if( match_refs )  free( match_refs ) ;
		if( pcross_refs )  free( pcross_refs ) ;
		if( ccross_refs ) free( ccross_refs ) ;
		return FALSE ;
	}

	qsort( matches, (size_t) total_people, (size_t) 4, pidx_compare ) ;

				/* initialise match_refs as not all of array is used	*/
	for( i=0; i<next_person; i++ )  match_refs[i] = -1 ;
				/* load array to get from reference to match position	*/
	for( i=0; i<total_people; i++ )  match_refs[matches[i]] = i ;

	for( i=0; i<total_people; i++ )  exp_selected[i] = FALSE ;

	if( total_people > 16 )
	{
		if( total_people < 256 )
			esel_ptr[ES_SLIDER].ob_height
					= esel_ptr[ES_SLIDE_RANGE].ob_height * 16 / total_people ;
		else
			esel_ptr[ES_SLIDER].ob_height
					= esel_ptr[ES_SLIDE_RANGE].ob_height / 16 ;
		set_slide( 0, total_people-16, esel_ptr,
										ES_SLIDER, ES_SLIDE_RANGE, app_modal_box() ) ;
	}
	else
	{
		esel_ptr[ES_SLIDER].ob_height = esel_ptr[ES_SLIDE_RANGE].ob_height ;
		set_slide( 0, 1, esel_ptr, ES_SLIDER, ES_SLIDE_RANGE, app_modal_box() ) ;
	}

	list_exportees( oset ) ;

	app_modal_init( esel_ptr, "Export", TITLED ) ;

	while( !done )
	{
		button = app_modal_do() ;
		button &= ~DOUBLE_CLICK ;

		if( button  && button != APP_MODAL_TERM )  esel_ptr[button].ob_state &= ~SELECTED ;

		switch( button )
		{
			case ES_SLIDER :
				if( total_people > 16 )
				{
					oset = move_slide( esel_ptr,
										ES_SLIDER, ES_SLIDE_RANGE, app_modal_box() ) ;
					oset = ( total_people - 16 ) * oset / 1000 ;
				}
				list_exportees( oset ) ;
				objc_draw( esel_ptr, ES_LIST, MAX_DEPTH, PTRS( app_modal_box() ) ) ;
				break ;
			case ES_UP :
				if( total_people > 16 && oset > 0 )
				{
					oset-- ;
					set_slide( oset, total_people-16, esel_ptr,
										ES_SLIDER, ES_SLIDE_RANGE, app_modal_box() ) ;
				}
				list_exportees( oset ) ;
				objc_draw( esel_ptr, ES_LIST, MAX_DEPTH, PTRS( app_modal_box() ) ) ;
				break ;
			case ES_DOWN :
				if( total_people > 16 && oset < total_people - 16 )
				{
					oset++ ;
					set_slide( oset, total_people - 16, esel_ptr,
										ES_SLIDER, ES_SLIDE_RANGE, app_modal_box() ) ;
				}
				list_exportees( oset ) ;
				objc_draw( esel_ptr, ES_LIST, MAX_DEPTH, PTRS( app_modal_box() ) ) ;
				break ;
			case ES_SLIDE_RANGE :
				if( total_people > 16 )
				{
					graf_mkstate( &m_x, &m_y, &dummy, &dummy ) ;
					objc_offset( esel_ptr, ES_SLIDER, &obj_x, &obj_y ) ;
					if( m_y > obj_y )
					{
						oset += 15 ;
						if( oset > total_people - 16 )  oset = total_people - 16 ;
					}
					else
					{
						oset -= 15 ;
						if( oset < 0 )  oset = 0 ;
					}
					set_slide( oset, total_people-16, esel_ptr,
									ES_SLIDER, ES_SLIDE_RANGE, app_modal_box() ) ;
				}
				list_exportees( oset ) ;
				objc_draw( esel_ptr, ES_LIST, MAX_DEPTH, PTRS( app_modal_box() ) ) ;
				break ;
			case ESEL0 :
			case ESEL1 :
			case ESEL2 :
			case ESEL3 :
			case ESEL4 :
			case ESEL5 :
			case ESEL6 :
			case ESEL7 :
			case ESEL8 :
			case ESEL9 :
			case ESEL10 :
			case ESEL11 :
			case ESEL12 :
			case ESEL13 :
			case ESEL14 :
			case ESEL15 :
				if( esel_ptr[ANCESTORS].ob_state & SELECTED )
				{
					ancestor_select( matches[button-ESEL0 + oset] ) ;
					esel_ptr[ANCESTORS].ob_state &= ~SELECTED ;
					esel_ptr[DESCENDANTS].ob_state &= ~SELECTED ;
					list_exportees( oset ) ;
					objc_draw( esel_ptr, ROOT, MAX_DEPTH, PTRS( app_modal_box() ) ) ;
				}
				else if( esel_ptr[DESCENDANTS].ob_state & SELECTED )
				{
					descendant_select( matches[button-ESEL0 + oset], 0, 0 ) ;
					esel_ptr[DESCENDANTS].ob_state &= ~SELECTED ;
					list_exportees( oset ) ;
					objc_draw( esel_ptr, ROOT, MAX_DEPTH, PTRS( app_modal_box() ) ) ;
				}
				else
				{
					if( !exp_selected[button-ESEL0 + oset] )
					{
						exp_selected[button-ESEL0 + oset] = TRUE ;
						esel_ptr[button].ob_state |= CHECKED ;
					}
					else
					{
						exp_selected[button-ESEL0 + oset] = FALSE ;
						esel_ptr[button].ob_state &= ~CHECKED ;
					}
					objc_draw( esel_ptr, button, MAX_DEPTH, PTRS( app_modal_box() ) ) ;
				}
				break ;
			case ES_SEL_ALL :
				for( i=0; i<total_people; i++ )  exp_selected[i] = TRUE ;
				list_exportees( oset ) ;
				objc_draw( esel_ptr, ES_LIST, MAX_DEPTH, PTRS( app_modal_box() ) ) ;
				objc_draw( esel_ptr, ES_SEL_ALL, MAX_DEPTH, PTRS( app_modal_box() ) ) ;
				break ;
			case ES_DSEL_ALL :
				for( i=0; i<total_people; i++ )  exp_selected[i] = FALSE ;
				list_exportees( oset ) ;
				objc_draw( esel_ptr, ES_LIST, MAX_DEPTH, PTRS( app_modal_box() ) ) ;
				objc_draw( esel_ptr, ES_DSEL_ALL, MAX_DEPTH, PTRS( app_modal_box() ) ) ;
				break ;
			case ES_FILTER :
				clear_efil_form() ;
				clear_form_flags() ;
				for( i = 0 ; i <= FL_NOT8 - FL_NOT1 ; i+= FL_NOT2 - FL_NOT1 )
				{
					set_to_ignore(FL_NOT1+i) ;
					flags_ptr[FL_NOT1+i].ob_state |= SELECTED ;
				}
				fdone = FALSE ;				/* loop until filter done	*/
				while( !fdone )
				{
					button = do_sub_form( efil_ptr, "Export Filter", EXP_HELP, TITLED ) ;
					switch( button )
					{
						case EXP_SEL :
						case EXP_DESEL :
							busy( BUSY_MORE ) ;
							update_filter( &filter, efil_form_addrs.efam_name,
								efil_form_addrs.eforename, efil_form_addrs.ebefore,
								efil_form_addrs.eafter, efil_form_addrs.eplace ) ;
							if( button == EXP_DESEL )  flag = FALSE ;
							else  flag = TRUE ;
							for( i=0; i<total_people; i++ )
							{
								if( test_match( &filter, matches[i] ) )
									exp_selected[i] = flag ;
							}
							busy( BUSY_LESS ) ;
						case EXP_CANCEL :
							fdone = TRUE ;
							break ;
						case EXP_FLAGS :
							do_sub_form( flags_ptr, "Filter Flags", FL_HELP, TITLED ) ;
							break ;
					}
				}
				list_exportees( oset ) ;
				break ;
			case ES_CANCEL :
			case APP_MODAL_TERM :
				done = TRUE ;
				break ;
			case ES_OK :
				export = TRUE ;
				done = TRUE ;
				break ;
			case ES_HELP :
				help( export_help ) ;
				objc_draw( esel_ptr, ES_HELP, 0, PTRS( app_modal_box() ) ) ;
				break ;
			default :
				break ;
		}
	}
	esel_ptr[ANCESTORS].ob_state &= ~SELECTED ;
	esel_ptr[DESCENDANTS].ob_state &= ~SELECTED ;

	if( esel_ptr[GEDCOM].ob_state & SELECTED )
		*type_ptr = GEDCOM_TYPE ;
	else if( esel_ptr[CSV].ob_state & SELECTED )
		*type_ptr = CSV_TYPE ;
	else  *type_ptr = FAMTREE_TYPE ;
	
	app_modal_end() ;

	return export ;
}