examples/form.rb in ncursesw-1.4.10 vs examples/form.rb in ncursesw-1.4.11
- old
+ new
@@ -3,13 +3,13 @@
# Example from the NCurses Programming HOWTO
# This example uses module functions that are documented in the ncurses man page.
# For a more rubyish approach that uses Ruby objects see form2.rb
#
# The original example contained the following copyright:
-# Copyright (c) 2001 by Pradeep Padala. This document may be distributed
+# Copyright (c) 2001 by Pradeep Padala. This document may be distributed
# under the terms set forth in the LDP license at linuxdoc.org/COPYRIGHT.html.
-
+
require 'ncursesw.rb'
begin
scr = Ncurses.initscr()
Ncurses.cbreak()
@@ -18,20 +18,20 @@
#create some fields
fields = Array.new
fields.push(Ncurses::Form.new_field(1,10,4,18,0,0))
fields.push(Ncurses::Form.new_field(1,10,6,18,0,0))
-
+
# set field options
Ncurses::Form.set_field_back(fields[0], Ncurses::A_UNDERLINE)
Ncurses::Form.field_opts_off(fields[0], Ncurses::Form::O_AUTOSKIP)
Ncurses::Form.set_field_back(fields[1], Ncurses::A_UNDERLINE)
Ncurses::Form.field_opts_off(fields[1], Ncurses::Form::O_AUTOSKIP)
- # create a form
+ # create a form
form = Ncurses::Form.new_form(fields)
# post the form and refresh the screen
Ncurses::Form.post_form(form)
scr.refresh()
@@ -47,27 +47,27 @@
# Go to next field
Ncurses::Form.form_driver(form, Ncurses::Form::REQ_NEXT_FIELD)
# Go to the end of the present buffer
# Leaves nicely at the last character
Ncurses::Form.form_driver(form, Ncurses::Form::REQ_END_LINE)
-
+
when Ncurses::KEY_UP
#Go to previous field
Ncurses::Form.form_driver(form, Ncurses::Form::REQ_PREV_FIELD)
Ncurses::Form.form_driver(form, Ncurses::Form::REQ_END_LINE);
- else
+ else
# If this is a normal character, it gets Printed
Ncurses::Form.form_driver(form, ch)
end
end
-
+
# unpost and free form
Ncurses::Form.unpost_form(form);
Ncurses::Form.free_form(form)
Ncurses::Form.free_field(fields[0]);
Ncurses::Form.free_field(fields[1]);
-
+
#using class methods this time
# form = Ncurses::Form::FORM.new(fields)
# puts "Created form: #{form.inspect}\n"
# form.free()