Project

General

Profile

Actions

Feature #8121

closed

updated Curses::Window example

Added by hramrach (Michal Suchanek) about 11 years ago. Updated almost 11 years ago.

Status:
Closed
Assignee:
-
Target version:
[ruby-core:53520]

Description

The example on http://ruby-doc.org/stdlib-2.0/libdoc/curses/rdoc/Curses/Window.html produces somewhat garbled output. Subwindow can be used to avoid that:

require 'curses'

Curses.init_screen()

my_str = "LOOK! PONIES!"
bwin = Curses::Window.new( 10, (my_str.length + 10),
(Curses.lines - 10) / 2,
(Curses.cols - (my_str.length + 10)) / 2 )
bwin.box("\", "/")
bwin.refresh
win = bwin.subwin( 6, my_str.length + 6,
(Curses.lines - 6) / 2,
(Curses.cols - (my_str.length + 6)) / 2 )
win.setpos(2,3)
win.addstr(my_str)

or even

win << "\nORLY"
win << "\nYES!! " + my_str
win.refresh
win.getch
win.close

Actions

Also available in: Atom PDF

Like0
Like0Like0