Ask

@param string text
@param function callback
@param string text_color
@param string bg_color

@return string
503634
public static function ask($text, $callback = null, $text_color = null, $bg_color = null)
    {
        if (null === $callback) {
            $callback = function() {
                return true;
            };
        }

        do {
            self::write($text, $text_color, $bg_color);
        } while (!$callback($answer = self::read()));

        return $answer;
    }
86146
public void showTextKerned(String text) {
        if (state.fontDetails == null)
            throw new NullPointerException("Font and size must be set before writing any text");
        BaseFont bf = state.fontDetails.getBaseFont();
        if (bf.hasKernPairs())
            showText(getKernArray(text, bf));
        else
            showText(text);
    }
341753
def colorize(text, color=None, **kwargs):
    
    style = None
    bg = None
    # ================ #
    # Keyword checking #
    # ================ #
    if 'style' in kwargs:
        if kwargs['style'] not in STYLE:
            raise WrongStyle('"{}" is wrong argument for {}'.format(kwargs['style'], 'style'))
        style = kwargs['style']

    if 'bg' in kwargs:
        if kwargs['bg'] not in BACKGROUND:
            raise WrongBackground('"{}" is wrong argument for {}'.format(kwargs['bg'], 'bg'))
        bg = kwargs['bg']

    if color not in COLOR:
        raise WrongColor('"{}" is wrong argument for {}'.format(color, 'color'))
    # ===================== #
    # Colorizing the string #
    # ===================== #
    if '\x1b[0m' not in text:
        text = '\x1b[' + ';'.join([str(STYLE[style]), str(COLOR[color]), str(BACKGROUND[bg])])\
               + 'm' + text + '\x1b[0m'
    else:
        lst = text.split('\x1b[0m')
        text = ''
        for x in lst:
            if not x.startswith('\x1b['):
                x = '\x1b[' + ';'.join([str(STYLE[style]), str(COLOR[color]), str(BACKGROUND[bg])])\
                     + 'm' + x + '\x1b[0m'
            else:
                x += '\x1b[0m'
            text += x
    return text
686571
def bgcyan(cls, string, auto=False):
        
        return cls.colorize('bgcyan', string, auto=auto)
82625
function colorize(color, str) {
  return str
      .split('\n')
      .map(part => color(part))
      .join('\n');
}
1297016
def bgwhite(cls, string, auto=False):
        
        return cls.colorize('bgwhite', string, auto=auto)
520482
public function do_text(
        $text,
        $offsetX = 0,
        $offsetY = 0,
        $opacity = 1.0,
        $color = 0x000000,
        $size = 12,
        $font_file = null
    ) {
        $textColor = imagecolorallocatealpha($this->_image, ($color >> 16) & 0xFF, ($color >> 8) & 0xFF,
            $color & 0xFF, abs(1 - $opacity) * 127);
        if ($font_file) {
            imagettftext($this->_image, $size, 0, $offsetX, $offsetY, $textColor, $this->alias->resolve($font_file), $text);
        } else {
            imagestring($this->_image, $size, $offsetX, $offsetY, $text, $textColor);
        }

        return $this;
    }
225491
function expectText(fn, res) {
  bluebird.try(fn).then(result => {
    res.set('Content-Type', 'text/plain');
    res.send(result);
  }).catch(handleError(res));
}
1321295
def bgyellow(cls, string, auto=False):
        
        return cls.colorize('bgyellow', string, auto=auto)
1252922
def _make_color_fn(color):
	""""""
	def _color(text = ""):
		return (_color_sep + color + _color_sep2 + text +
			_color_sep + "default" + _color_sep2)
	return _color
1021289
def bgmagenta(cls, string, auto=False):
        
        return cls.colorize('bgmagenta', string, auto=auto)
672440
function( input, null_text ) {
		if ( input == null || input === undefined ) return null_text || '';
		if ( typeof input === 'object' && Object.prototype.toString.call(input) === '[object Date]' ) return input.toDateString();
		if ( input.toString ) return input.toString().replace(/\n/g, '<br />').replace(/''/g, "'");
		return '';
	}
160329
function color(c, bold, msg) {
  return bold ? clic.xterm(c).bold(msg) : clic.xterm(c)(msg);
}
1353970
function ( question, callback ) {
  var domain = require( 'domain' );
  var d = domain.create();

  return new Promise( function ( resolve, reject ) {

    d.on( 'error', function ( err ) {
      if ( err.code === 'ENXIO' ) {
        // when using a graphical interface like github
        // there is no way we can create a tty stream
        // hence we assume that the user wanted to say yes
        // at least that will operate on the code
        console.error( 'could not open TTY... assuming the user wanted to say yes' );
        callback && callback( 'yes' );
        resolve();
      }
    } );

    d.run( function () {
      var readline = require( 'readline' );

      var tty = fs.createReadStream( '/dev/tty', 'utf8' );

      var r = readline.createInterface( {
        input: tty,
        output: nodeProcess.stdout,
        terminal: false
      } );

      r.question( question + '\n\n' +
          whiteString( '>> continue? ' ) +
          grayString( '(' ) +
          grayString( 'yes' ) +
          grayString( '|' ) +
          whiteString( 'NO' ) +
          grayString( ') : ' ), function ( answer ) {

          var yes = answer.trim() === 'yes';

          callback && callback( null, yes );

          if ( yes ) {
            resolve( answer );
          } else {
            reject();
          }
          tty.close();
        } );
    } );

  } );
}
1367664
public static function colorizeLines($text, $fgcolor = null, $bgcolor = null)
    {
        $lines = explode("\n", $text);
        foreach ($lines as &$line) {
            $line = self::colorize($line, $fgcolor, $bgcolor);
        }
        return implode("\n", $lines);
    }
610392
def colorize(txt, fg=None, bg=None):
    

    setting = ''
    setting += _SET_FG.format(fg) if fg else ''
    setting += _SET_BG.format(bg) if bg else ''
    return setting + str(txt) + _STYLE_RESET
684651
function (msg, colors) {

        if (!colors) {
            return msg;
        }

        if (typeof colors === 'string') {
            colors = [colors];
        }

        colors.forEach(function (color) {
            if (typeof colorsjs[color] === 'function') {
                msg = colorsjs[color](msg);
            }
        });

        return msg;
    }