Added a basic input example. Really messy right now.
[nfoiled.git] / examples / multiple_terminals.rb
blobfcc5ada36529475d8f6177357a0af05ff99bc122
1 ($:.unshift File.expand_path(File.join( File.dirname(__FILE__), '..', 'lib' ))).uniq!
2 require 'nfoiled'
4 ##
5 # This example deals with utilizing multiple `Terminal` instances in Nfoiled.
7 # Creating our first `Terminal` will take care of initializing the Nfoiled
8 # system for us.
9 term1 = Nfoiled::Terminal.new
11 # Rembmer that creating a new `Terminal` also activates it, so `term1` is
12 # active right now!
13 Nfoiled::update!
15 # Let's print some content to show that the terminal exists.
16 term1_win = Nfoiled::Window.new
17 term1_win.print "This appears in `term1`."
18 Nfoiled::update!
20 sleep 2.5
22 # Now let's switch to `term2`.
23 # TODO: Figure out why this prints a slew of constant re-definition warnings.
24 term2 = Nfoiled::Terminal.new
25 Nfoiled::update!
27 # Let's print some content to show that the terminal exists.
28 term2_win = Nfoiled::Window.new
29 term2_win.print "This appears in `term2`."
30 Nfoiled::update!
32 sleep 2.5
34 # Finally, let's switch back to `term1` to show that it, also, still exists.
35 # TODO: Figure out why this doesn't work.
36 term1.activate!
37 Nfoiled::update!
39 sleep 2.5