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

namespace CommonHelpers {

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

public void PrintWithNewLineInBuffer(string str)
{
   PrintWithNewLineInBuffer( false, str );
}

public void PrintWithNewLineInBuffer(string stringFmt,params object[] parameters)
{
   PrintWithNewLineInBuffer( false, stringFmt, parameters );
}

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

public void PrintWithNewLineInBuffer(bool flushPrevious,string str)
{
   PrintWithNewLineInBuffer( flushPrevious, null, str );
}

public void PrintWithNewLineInBuffer( bool flushPrevious,
                                      string stringFmt,
                                      params object[] parameters )
{
   PrintWithNewLineInBuffer( flushPrevious, null, stringFmt, parameters );
}

//==================================================================================================

public void PrintWithNewLineInBuffer(ConsoleColor? color,string str)
{
   PrintWithNewLineInBuffer( false, color, str );
}

public void PrintWithNewLineInBuffer( ConsoleColor? color,
                                      string stringFmt,
                                      params object[] parameters )
{
   PrintWithNewLineInBuffer( false, color, stringFmt, parameters );
}

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

public void PrintWithNewLineInBuffer(bool flushPrevious,ConsoleColor? color,string str)
{
   HArgChecking.VerifyNotNull( str );
   lock ( _InstanceSyncRoot_ )
   {
      if ( !UsePendingNewLine )
      {
         Print( color, str ); return;
      }
      _IgnoreFlushPendingNewLine_ = !flushPrevious;
      try
      {
         Output( color, str );
         _PendingNewLine_ = !( IsInNativeVisualMode && Console.CursorLeft==0 );
      }
      finally
      {
         _IgnoreFlushPendingNewLine_ = false;
      }
   }
}

public void PrintWithNewLineInBuffer( bool flushPrevious, ConsoleColor? color,
                                      string stringFmt, params object[] parameters )
{
   PrintWithNewLineInBuffer( flushPrevious, color, string.Format(stringFmt,parameters) );
}

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

} // CommonHelpers
