/****************************************************************************
** PROJECT  **                          TAB2SPCS                           **
*****************************************************************************
** FUNCTION ** A MACRO TO CONVERT TABS TO SPACES USING THE CURRENT TAB     **
**          ** SETTINGS.                                                   **
*****************************************************************************
**  AUTHOR  ** WARREN D HUMPHREYS                                          **
*****************************************************************************
**   DATE   ** MONDAY 15TH OCTOBER 1990                                    **
*****************************************************************************
** COMMENTS **                                                             **
*****************************************************************************
**                          MODIFICATION HISTORY                           **
*****************************************************************************
**   DATE   ** WHO **                     CHANGED WHAT                     **
*****************************************************************************
**          **     **                                                      **
****************************************************************************/

/****************************************************************************
**                           FUNCTION PROTOTYPES                           **
****************************************************************************/

void	Tab2Spcs(void);

/****************************************************************************
**                            GLOBAL VARIABLES                             **
****************************************************************************/

/****************************************************************************
**                            ACTUAL FUNCTIONS                             **
****************************************************************************/

void	Tab2Spcs()
{
	int			XT;
	int			Count;
	int			Loop;
	string	Reply;
	string	Spaces;

	get_parm(NULL,Reply,"Expand all tabs to spaces [Y|N]? ",1,"N");
	if (upper(Reply)=="Y")
	{
		save_position();
		message("Converting tabs to spaces");
		top_of_buffer();
		XT=0;
		while (search_fwd("\t",1,0,0,0)!=0)
		{
			Count=distance_to_tab();
			delete_char(1);
			Spaces="";
			for (Loop=0;Loop<Count;Loop++)
				Spaces+=" ";
			insert(Spaces);
			XT++;
			message("Expanded %d tabs",XT);
		}
		restore_position();
		if (XT==0)
			message("No tab characters were found");
		else
			message("%d tab character%s expanded",XT,(XT==1) ? " was" : "s were");
	}
}
