//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// CommonHelpers satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Text;

namespace CommonHelpers {

//**************************************************************************************************
partial class HConsole {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public void Output(bool insertBlankLine,object obj)
{
   Output(insertBlankLine,obj.ToString());
}
public void Output(bool insertBlankLine,string str)
{
   Output(insertBlankLine,null,str);
}
public void Output(bool insertBlankLine,string format,params object[] parameters)
{
   Output(insertBlankLine,null,format,parameters);
}

//--------------------------------------------------------------------------------------------------

public void Output(bool insertBlankLine,ConsoleColor? color,object obj)
{
   Output(insertBlankLine,color,obj.ToString());
}
public void Output(bool insertBlankLine,ConsoleColor? color,string str)
{
   if ( insertBlankLine )
      str = "\n"+str;
   lock (_InstanceSyncRoot_)
      using (new HConsoleColorRetention( this, color.HasValue ? color.Value : NormalColor.Value ))
      {
         var sb = new StringBuilder();
         char? prevChar = null;
         foreach (char ch in str)
            if ( ch == '\n' )
            {
               if ( prevChar == '\r' )
                  sb.Length--;
               PerformOutput( sb, true );
               sb.Length = 0;
               prevChar = null;
            }
            else
               sb.Append( prevChar = ch );
         PerformOutput( sb, false );
      }
}
public void Output( bool insertBlankLine, ConsoleColor? color,
                    string format, params object[] parameters )
{
   Output(insertBlankLine,color,string.Format(format,parameters));
}

//--------------------------------------------------------------------------------------------------

public void OutputDefault(bool insertBlankLine,object obj)
{
   Output(insertBlankLine,ForegroundColor,obj);
}
public void OutputDefault(bool insertBlankLine,string str)
{
   Output(insertBlankLine,ForegroundColor,str);
}
public void OutputDefault(bool insertBlankLine,string format,params object[] parameters)
{
   Output(insertBlankLine,ForegroundColor,string.Format(format,parameters));
}

//--------------------------------------------------------------------------------------------------

public void OutputIntensive(bool insertBlankLine,object obj)
{
   Output(insertBlankLine,IntensiveColor,obj);
}
public void OutputIntensive(bool insertBlankLine,string str)
{
   Output(insertBlankLine,IntensiveColor,str);
}
public void OutputIntensive(bool insertBlankLine,string format,params object[] parameters)
{
   Output(insertBlankLine,IntensiveColor,format,parameters);
}

//--------------------------------------------------------------------------------------------------

public void OutputFaint(bool insertBlankLine,object obj)
{
   Output(insertBlankLine,FaintColor,obj);
}

public void OutputFaint(bool insertBlankLine,string str)
{
   Output(insertBlankLine,FaintColor,str);
}

public void OutputFaint(bool insertBlankLine,string format,params object[] parameters)
{
   Output(insertBlankLine,FaintColor,format,parameters);
}

//--------------------------------------------------------------------------------------------------

public void OutputExpressive(bool insertBlankLine,object obj)
{
   Output(insertBlankLine,ExpressiveColor,obj);
}
public void OutputExpressive(bool insertBlankLine,string str)
{
   Output(insertBlankLine,ExpressiveColor,str);
}
public void OutputExpressive(bool insertBlankLine,string format,params object[] parameters)
{
   Output(insertBlankLine,ExpressiveColor,format,parameters);
}

//--------------------------------------------------------------------------------------------------

public void OutputImportant(bool insertBlankLine,object obj)
{
   Output(insertBlankLine,ImportantColor,obj);
}
public void OutputImportant(bool insertBlankLine,string str)
{
   Output(insertBlankLine,ImportantColor,str);
}
public void OutputImportant(bool insertBlankLine,string format,params object[] parameters)
{
   Output(insertBlankLine,ImportantColor,format,parameters);
}

//--------------------------------------------------------------------------------------------------

public void OutputExclamation(bool insertBlankLine,object obj)
{
   Output(insertBlankLine,ExclamationColor,obj);
}
public void OutputExclamation(bool insertBlankLine,string str)
{
   Output(insertBlankLine,ExclamationColor,str);
}
public void OutputExclamation(bool insertBlankLine,string format,params object[] parameters)
{
   Output(insertBlankLine,ExclamationColor,format,parameters);
}

//--------------------------------------------------------------------------------------------------

public void OutputInformation(bool insertBlankLine,object obj)
{
   Output(insertBlankLine,InformationColor,obj);
}
public void OutputInformation(bool insertBlankLine,string str)
{
   Output(insertBlankLine,InformationColor,str);
}
public void OutputInformation(bool insertBlankLine,string format,params object[] parameters)
{
   Output(insertBlankLine,InformationColor,format,parameters);
}

//--------------------------------------------------------------------------------------------------

public void OutputWarning(bool insertBlankLine,object obj)
{
   Output(insertBlankLine,WarningColor,obj);
}
public void OutputWarning(bool insertBlankLine,string str)
{
   Output(insertBlankLine,WarningColor,str);
}
public void OutputWarning(bool insertBlankLine,string format,params object[] parameters)
{
   Output(insertBlankLine,WarningColor,format,parameters);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // HConsole
//**************************************************************************************************

} // CommonHelpers
