Feature #8121

updated Curses::Window example

Added by Michal Suchanek about 1 year ago. Updated 12 months ago.

[ruby-core:53520]
Status:Closed
Priority:Normal
Assignee:-
Category:doc
Target version:2.1.0

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()

mystr = "LOOK! PONIES!"
bwin = Curses::Window.new( 10, (my
str.length + 10),
(Curses.lines - 10) / 2,
(Curses.cols - (mystr.length + 10)) / 2 )
bwin.box("\", "/")
bwin.refresh
win = bwin.subwin( 6, my
str.length + 6,
(Curses.lines - 6) / 2,
(Curses.cols - (mystr.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

Associated revisions

Revision 40506
Added by Zachary Scott 12 months ago

  • ext/curses/curses.c: Update Curses::Window example for nicer output Patch by Michal Suchanek [Bug #8121]

History

#1 Updated by Eric Hodel about 1 year ago

  • Category set to doc
  • Target version set to 2.1.0

#2 Updated by Zachary Scott 12 months ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r40506.
Michal, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • ext/curses/curses.c: Update Curses::Window example for nicer output Patch by Michal Suchanek [Bug #8121]

Also available in: Atom PDF