class Object

Constants

ACTIVATE
BG
BOLD
CLICKED

Constants for the Gtk-Interface EVENTS

COLORS

Functions to apply colors to terminal output. This is stolen from the Internet and I have lost track of my own additions and modifications.

ENTER
FG
LEAVE
NEUTRAL
REGULAR
STYLES
SUMMARY
SWAP
TOGGLED
UNDERLINE
VERSION

/******************************************************************************

*   Copyright © 2021-2021, Michael Uplawski <michael.uplawski@uplawski.eu>   *
*                                                                            *
*   This program is free software; you can redistribute it and/or modify     *
*   it under the terms of the GNU General Public License as published by     *
*   the Free Software Foundation; either version 3 of the License, or        *
*   (at your option) any later version.                                      *
*                                                                            *
*   This program is distributed in the hope that it will be useful,          *
*   but WITHOUT ANY WARRANTY; without even the implied warranty of           *
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
*   GNU General Public License for more details.                             *
*                                                                            *
*   You should have received a copy of the GNU General Public License        *
*   along with this program; if not, write to the                            *
*   Free Software Foundation, Inc.,                                          *
*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                *
******************************************************************************/

Public Instance Methods

black_on_white(text) click to toggle source
# File lib/color_output.rb, line 68
def black_on_white(text); colorize(colorize(text, "\033[30m"), "\033[47m");end
blue(text) click to toggle source
# File lib/color_output.rb, line 65
def blue(text); colorize(text, "\033[34m"); end
bold(text) click to toggle source
# File lib/color_output.rb, line 71
def bold(text); style(text, "\033[01m");end
colored_output(output_text, fg_color = :default, bg_color = :default, style = :regular , mode = :neutral ) click to toggle source

a function which allows to manipulate every known aspect of the ansi-output.

# File lib/color_output.rb, line 55
def colored_output(output_text, fg_color = :default, bg_color = :default, style = :regular , mode = :neutral )
  "\033[%i;%i;%i%i;%i%im%s\033[0m" %[STYLES[mode.to_sym], STYLES[style.to_sym], FG, COLORS[fg_color.to_sym], BG, COLORS[bg_color.to_sym], output_text]
end
colorize(text, color_code) click to toggle source

Colorizes the given text. Color-code is either an escape-sequence or one of the symbols representing color-names in the COLORS hash.

# File lib/color_output.rb, line 43
def colorize(text, color_code)
  if (COLORS.keys.include?(color_code) )
    "\033[3#{COLORS[color_code]}m#{text}\033[0m"
  else
    "#{color_code}#{text}\033[0m"
  end
end
cyan(text) click to toggle source
# File lib/color_output.rb, line 64
def cyan(text); colorize(text, "\033[36m"); end
green(text) click to toggle source
# File lib/color_output.rb, line 61
def green(text); colorize(text, "\033[32m"); end
purple(text) click to toggle source
# File lib/color_output.rb, line 63
def purple(text); colorize(text, "\033[35m"); end
red(text) click to toggle source

convenience functions

# File lib/color_output.rb, line 60
def red(text); colorize(text, "\033[31m"); end
style(text, style_code) click to toggle source
# File lib/color_output.rb, line 51
def style(text, style_code)
  "#{style_code}#{text}\033[0m"
end
underline(text) click to toggle source
# File lib/color_output.rb, line 72
def underline(text); style(text, "\033[04m");end
white(text) click to toggle source
# File lib/color_output.rb, line 66
def white(text); colorize(text, "\033[37m"); end
white_on_black(text) click to toggle source
# File lib/color_output.rb, line 69
def white_on_black(text); colorize(colorize(text, "\033[37m"), "\033[40m");end
yellow(text) click to toggle source
# File lib/color_output.rb, line 62
def yellow(text); colorize(text, "\033[33m"); end