library/src/utility/BP-StringFormattingSessions.cc
// Generate an output data from string entry.  The data is stored directly within
// the string entry itself.
Generate an output data from string entry.  The data is stored directly within
the string entry itself.
Generate an output data from string entry . The data is stored directly within the string entry itself .
BP_ERROR_T BP_GenerateOutputStringArrayFromStringEntrySFSession(P_BP_SF_SESSION sfs, P_BP_SFS_STRING_ENTRY entry, BP_BOOL enable_colorization)
{
	if(!sfs)
		return ERR_FAILURE;
	if(!sfs->tq)
		return ERR_FAILURE;
	if(!entry)
		return ERR_FAILURE;
	if(!entry->string || !entry->string_length)
		return ERR_FAILURE;
	char * initial_string = (char *) NULL;
	P_BP_COLOR_CODE_SET_T * colors = NULL;
	if(entry->string_length > entry->display_max_width)
	{
		initial_string        = (char *) bpcalloc(entry->string_length+1, 1);
		colors = (P_BP_COLOR_CODE_SET_T *) bpcalloc
		(
			sizeof(P_BP_COLOR_CODE_SET_T *) * (entry->string_length + 1),
			1
		);
	}
	else
	{
		initial_string        = (char *) bpcalloc(entry->display_max_width+1, 1);
		memset(initial_string, 0x20, entry->display_max_width);
		colors = (P_BP_COLOR_CODE_SET_T *) bpcalloc
		(
			sizeof(P_BP_COLOR_CODE_SET_T *) * (entry->display_max_width+1),
			1
		);
	}
	if(!initial_string)
		return ERR_FAILURE;
	if(!colors)
		return ERR_FAILURE;
	size_t n = 0;
	for(; n < entry->string_length; n++)
	{
		initial_string[n] =   entry->string[n].character;
		colors[n]         =  &entry->string[n].color_info;
	}
	size_t j = 0;
	size_t i = 0;
	P_BP_GENERIC_STRING_COLUMNIZATION tmp_lines_colorized_columnization = NULL;
	P_BP_GENERIC_STRING_COLUMNIZATION tmp_lines_columnization           = NULL;
	if(enable_colorization == BP_TRUE)
	{
		if(entry->auto_calculate_max_width_by_newlines == BP_TRUE)
		{
			tmp_lines_colorized_columnization = BP_SplitStringIntoEqualWidthColumnsByDeliniation
			(
				 initial_string,
				 bpstrlen(initial_string),
				 '\n',
				 0,
				 colors
			 );
			entry->final_columnization_colorized = tmp_lines_colorized_columnization;
		}
		else
		{
			tmp_lines_colorized_columnization = BP_SplitStringIntoEqualWidthColumns
			(
				initial_string,
				bpstrlen(initial_string),
				entry->display_max_width,
				BP_TRUE,
				entry->pad_lines_below,
				colors
			);
			entry->final_columnization_colorized = tmp_lines_colorized_columnization;
		}
	}
	if(entry->auto_calculate_max_width_by_newlines == BP_TRUE)
	{
		tmp_lines_columnization = BP_SplitStringIntoEqualWidthColumnsByDeliniation
		(
			 initial_string,
			 bpstrlen(initial_string),
			 '\n',
			 0
		 );
		entry->final_columnization = tmp_lines_columnization;
	}
	else
	{
		tmp_lines_columnization = BP_SplitStringIntoEqualWidthColumns
		(
			initial_string,
			bpstrlen(initial_string),
			entry->display_max_width,
			BP_TRUE,
			entry->pad_lines_below
		);
		entry->final_columnization = tmp_lines_columnization;
	}
	if(initial_string)
		bpfree(initial_string);
	if(colors)
		bpfree(colors);
	return ERR_SUCCESS;
}
BP_ERROR_T BP_GenerateOutputStringArrayFromStringEntrySFSession ( P_BP_SF_SESSION sfs , P_BP_SFS_STRING_ENTRY entry , BP_BOOL enable_colorization ) { if ( ! sfs ) return ERR_FAILURE ; if ( ! sfs -> tq ) return ERR_FAILURE ; if ( ! entry ) return ERR_FAILURE ; if ( ! entry -> string || ! entry -> string_length ) return ERR_FAILURE ; char * initial_string = ( char * ) NULL ; P_BP_COLOR_CODE_SET_T * colors = NULL ; if ( entry -> string_length > entry -> display_max_width ) { initial_string = ( char * ) bpcalloc ( entry -> string_length + 1 , 1 ) ; colors = ( P_BP_COLOR_CODE_SET_T * ) bpcalloc ( sizeof ( P_BP_COLOR_CODE_SET_T * ) * ( entry -> string_length + 1 ) , 1 ) ; } else { initial_string = ( char * ) bpcalloc ( entry -> display_max_width + 1 , 1 ) ; memset ( initial_string , 0x20 , entry -> display_max_width ) ; colors = ( P_BP_COLOR_CODE_SET_T * ) bpcalloc ( sizeof ( P_BP_COLOR_CODE_SET_T * ) * ( entry -> display_max_width + 1 ) , 1 ) ; } if ( ! initial_string ) return ERR_FAILURE ; if ( ! colors ) return ERR_FAILURE ; size_t n = 0 ; for ( ; n < entry -> string_length ; n ++ ) { initial_string [ n ] = entry -> string [ n ] . character ; colors [ n ] = & entry -> string [ n ] . color_info ; } size_t j = 0 ; size_t i = 0 ; P_BP_GENERIC_STRING_COLUMNIZATION tmp_lines_colorized_columnization = NULL ; P_BP_GENERIC_STRING_COLUMNIZATION tmp_lines_columnization = NULL ; if ( enable_colorization == BP_TRUE ) { if ( entry -> auto_calculate_max_width_by_newlines == BP_TRUE ) { tmp_lines_colorized_columnization = BP_SplitStringIntoEqualWidthColumnsByDeliniation ( initial_string , bpstrlen ( initial_string ) , ' \n ' , 0 , colors ) ; entry -> final_columnization_colorized = tmp_lines_colorized_columnization ; } else { tmp_lines_colorized_columnization = BP_SplitStringIntoEqualWidthColumns ( initial_string , bpstrlen ( initial_string ) , entry -> display_max_width , BP_TRUE , entry -> pad_lines_below , colors ) ; entry -> final_columnization_colorized = tmp_lines_colorized_columnization ; } } if ( entry -> auto_calculate_max_width_by_newlines == BP_TRUE ) { tmp_lines_columnization = BP_SplitStringIntoEqualWidthColumnsByDeliniation ( initial_string , bpstrlen ( initial_string ) , ' \n ' , 0 ) ; entry -> final_columnization = tmp_lines_columnization ; } else { tmp_lines_columnization = BP_SplitStringIntoEqualWidthColumns ( initial_string , bpstrlen ( initial_string ) , entry -> display_max_width , BP_TRUE , entry -> pad_lines_below ) ; entry -> final_columnization = tmp_lines_columnization ; } if ( initial_string ) bpfree ( initial_string ) ; if ( colors ) bpfree ( colors ) ; return ERR_SUCCESS ; }
Generate an output data from string entry.
Generate an output data from string entry .
// ensure relevant data portions are set // allocate a simple buffer to hold the initial string // color set to use for painting the buffer // the initial buffer should be the string length, but only in the // case that the string length is longer than the specified display length.  If // this is not the case, we'll have to padd the entry with spaces to ensure that // display buffers line up correctly. // allocate memory // allocate space for colors REFERENCE array (do not free individual elements, // only free the entire array) // allocate space for initial string // set buffer to all spaces except for terminator (allows buffers to become // the correct depth with regard to padding) // allocate space for colors REFERENCE array (do not free individual elements, // only free the entire array) // ensure we could create the initial string // walk the entries in the string to generate a complete buffer // colorization index // normalization index // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Generate Colorized Data %%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // generate colorized data first // allocate space for the colors // if we're splitting by newlines, do so here // set entry // if we're not splitting by deliniation, split by width (enable hyphenation) /* some debug statements if you need them at a later date

			if(tmp_lines_colorized_columnization)
				printf("\n [%s] WATTT", tmp_lines_colorized_columnization->columns[0]);
			else
				printf("\n [%s] FAILED", initial_string);
			*/ // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Generate Non-Colorized Data %%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // if we're splitting by newlines, do so here // set uncolored final columnization // if we're not splitting by deliniation, split by width (enable hyphenation) // set uncolored final columnization // return the filled in array