0.0
No commit activity in last 3 years
No release in over 3 years
Allows developers to give programs a vim-esq splash screen
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

console_splash¶ ↑

Console Splash is a ruby gem that allows you to have a vim-esq splash screen before your ruby program. It uses the command line tool stty to get the size of the console, but you can define your own console size.

Setup¶ ↑

To install console_splash, simply install using rubygems

gem install console_splash

Usage¶ ↑

To use, first require the gem, and create a new splash object

require 'console_splash'
splash = ConsoleSplash.new()

The initializer can take in the number of lines and number of columns, but will autogenerate them with stty otherwise.

splash = ConsoleSplash.new(35, 88) #=> 35 lines, 88 columns

After that, there are a series of methods you can use to setup the splash screen. write_header takes in a name, author, and version to display program information.

splash.write_header("ConsoleSplash", "JRJurman", "0.3.0")

You can also insert your own lines into ConsoleSplash using the write_center method, which takes in a line number, and text (the line number can be negative for going from the bottom up).

splash.write_center(-3, "Splash Screens are awesome")

If you want to add a border you can use the write_horizontal_pattern and write_vertical_pattern.

splash.write_horizontal_pattern("=")
splash.write_vertical_pattern("|")

Or, if you want more control, you can use the write_top_pattern, write_bottom_pattern, write_left_pattern, and write_right_pattern

splash.write_top_pattern("^")
splash.write_bottom_pattern("v")
splash.write_left_pattern("<")
splash.write_right_pattern(">")

The write_*_pattern methods can also take more than one character!

splash.write_horizontal_pattern("v^")

Finally, call the .splash method to print your new splash screen!

splash.splash

You’re in charge of holding it there, so call the gets method, or use the sleep method to hold the screen in place. You’ll also want to clear the screen to remove previous console artifacts.

`clear`
sleep(3) #=> holds the command line in place
gets() #=> waits until user input

VERSION 2 - Now with Colorize!¶ ↑

You can now add color by passing a table of symbols, the symbols for most operations use :fg (foreground color) and :bg (background color).

splash.write_top_pattern("^", {:fg=>:white, :bg=>:green})

For the write_line method, you can also pass at what position the line starts with the :start key

splash.write_line(0, "Hello World!", {:start => 10})

There is now a write_pixel method, which takes in a line, column, and a single character, ( it also takes in a hash with the :fg and :bg keys ).

splash.write_pixel( 5, 5, "H" )

Also included in the new version is a write_left and write_right method which act like the write_center method.

splash.write_right( 4, "Splash Screens" )

For the write_header method, pass in the :nameFg and :nameBg to color the name line, :authorFg and :authorBg to color the author lines, and :versionFg and versionBg to color the version line.

splash.write_header("splash_console", "JRJurman", "2.0.0", 
        {:nameFg=>:red, :authorFg=>:green, :versionFg=>:yellow})