snowleopard-ncurses 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +515 -0
- data/Changes +53 -0
- data/MANIFEST +28 -0
- data/Makefile +194 -0
- data/README +355 -0
- data/THANKS +15 -0
- data/TODO +15 -0
- data/VERSION +1 -0
- data/examples/LICENSES_for_examples +26 -0
- data/examples/example.rb +129 -0
- data/examples/form.rb +82 -0
- data/examples/form2.rb +184 -0
- data/examples/hello_ncurses.rb +57 -0
- data/examples/rain.rb +219 -0
- data/examples/read_line.rb +67 -0
- data/examples/tclock.rb +227 -0
- data/examples/test_scanw.rb +27 -0
- data/extconf.rb +138 -0
- data/form_wrap.c +1450 -0
- data/form_wrap.h +61 -0
- data/lib/ncurses.rb +344 -0
- data/make_dist.rb +45 -0
- data/menu_wrap.c +1144 -0
- data/menu_wrap.h +49 -0
- data/ncurses_wrap.c +2769 -0
- data/ncurses_wrap.h +101 -0
- data/panel_wrap.c +256 -0
- data/panel_wrap.h +32 -0
- metadata +91 -0
data/THANKS
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$Id: THANKS,v 1.9 2009/05/03 10:37:54 t-peters Exp $
|
2
|
+
|
3
|
+
A list of people that helped me with ncurses-ruby
|
4
|
+
|
5
|
+
Akinori MUSHA (knu at idaemons dot org)
|
6
|
+
Jan Becvar (jan dot becvar at solnet dot cz)
|
7
|
+
Juergen Daubert
|
8
|
+
Doug Kearns
|
9
|
+
Simon Kaczor (skaczor at cox dut net)
|
10
|
+
Hiroshi Sainohira
|
11
|
+
Andreas Schwarz
|
12
|
+
Simon Strandgaard
|
13
|
+
Paul Duncan
|
14
|
+
Tim Sutherland
|
15
|
+
Earle Clubb
|
data/TODO
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$Id: TODO,v 1.6 2003/03/22 22:55:27 t-peters Exp $
|
2
|
+
|
3
|
+
This is the complete list of functions present in ncurses that have not yet
|
4
|
+
been wrapped by ncurses-ruby:
|
5
|
+
|
6
|
+
terminfo functions: setupterm, setterm, set_curterm, del_curterm, restartterm,
|
7
|
+
tparm, tputs, vidputs
|
8
|
+
|
9
|
+
termcap fuctions: tgetent, tgetflag, tgetnum, tgetstr, tgoto
|
10
|
+
|
11
|
+
ncurses
|
12
|
+
kernel functions: ripoffline
|
13
|
+
|
14
|
+
No sense in
|
15
|
+
wrapping these: vw_printw, vwprintw, vwscanw
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.2.4
|
@@ -0,0 +1,26 @@
|
|
1
|
+
$Id: LICENSES_for_examples,v 1.6 2004/05/13 21:55:17 t-peters Exp $
|
2
|
+
|
3
|
+
Ideally, an example program on how to use a library should be in the public
|
4
|
+
domain.
|
5
|
+
|
6
|
+
Some of the example programs contained in this dircectory have not been put in
|
7
|
+
the public domain, however.
|
8
|
+
|
9
|
+
The reason is because I did not write all programs completely myself -- I've
|
10
|
+
adapted the following example programs from ncurses programs in other
|
11
|
+
programming languages, or I have included example programs contributed by
|
12
|
+
other authors, and I have to respect their original licenses:
|
13
|
+
- rain.rb is adapted from rain.c from the ncurses library distribution.
|
14
|
+
- example.rb is adapted from an example program for the python ncurses binding.
|
15
|
+
- tclock.rb is adapted from tclock.c from the ncurses library distribution.
|
16
|
+
- form.rb anf form2.rb have been written by Simon Kaczor, who has adapted them
|
17
|
+
from sample code from the NCurses Programming HOWTO.
|
18
|
+
|
19
|
+
See the comments in the source files for restrictions imposed on copying and
|
20
|
+
modifying these.
|
21
|
+
|
22
|
+
That said, I suppose you may still look at their source code and learn how
|
23
|
+
ncurses programs generally work, as long as you dont start your own programs
|
24
|
+
by loading the example program into your editor and modify it to your needs.
|
25
|
+
|
26
|
+
Tobias Peters <t-peters@users.berlios.de>
|
data/examples/example.rb
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# $Id: example.rb,v 1.4 2002/03/04 13:24:29 t-peters Exp $
|
4
|
+
|
5
|
+
# This file provides an example for the usage of the ncurses-ruby module.
|
6
|
+
# Copyright (C) 2002 Tobias Peters <t-peters@users.berlios.de>
|
7
|
+
#
|
8
|
+
# The following license applys only to this file. It is less restrictive
|
9
|
+
# than the license for the rest of the ncurses-ruby distribution.
|
10
|
+
# I've adapted this file from someone else, see below.
|
11
|
+
#
|
12
|
+
# Permission is hereby granted, free of charge, to any person
|
13
|
+
# obtaining a copy of this file
|
14
|
+
# (the "Software"), to deal in the Software without restriction,
|
15
|
+
# including without limitation the rights to use, copy, modify, merge,
|
16
|
+
# publish, distribute, sublicense, and/or sell copies of the Software,
|
17
|
+
# and to permit persons to whom the Software is furnished to do so,
|
18
|
+
# subject to the following conditions:
|
19
|
+
#
|
20
|
+
# The above copyright notice and this permission notice shall be
|
21
|
+
# included in all copies or substantial portions of the Software.
|
22
|
+
#
|
23
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
24
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
25
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
26
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
27
|
+
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
28
|
+
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
29
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
30
|
+
# SOFTWARE.
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
# this file is adapted from an example of the python ncurses binding
|
35
|
+
# pyncurses (http://pyncurses.sf.net/), which has the following copyright
|
36
|
+
# statement:
|
37
|
+
|
38
|
+
# Copyright (c) 2000 by Harry Henry Gebel
|
39
|
+
#
|
40
|
+
# Permission is hereby granted, free of charge, to any person
|
41
|
+
# obtaining a copy of this software and associated documentation files
|
42
|
+
# (the "Software"), to deal in the Software without restriction,
|
43
|
+
# including without limitation the rights to use, copy, modify, merge,
|
44
|
+
# publish, distribute, sublicense, and/or sell copies of the Software,
|
45
|
+
# and to permit persons to whom the Software is furnished to do so,
|
46
|
+
# subject to the following conditions:
|
47
|
+
#
|
48
|
+
# The above copyright notice and this permission notice shall be
|
49
|
+
# included in all copies or substantial portions of the Software.
|
50
|
+
#
|
51
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
52
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
53
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
54
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
55
|
+
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
56
|
+
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
57
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
58
|
+
# SOFTWARE.
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
require "ncurses"
|
63
|
+
|
64
|
+
def moving(scr)
|
65
|
+
scr.clear() # clear screen
|
66
|
+
scr.move(5,5) # move cursor
|
67
|
+
scr.addstr("move(5,5)")
|
68
|
+
scr.refresh() # update screen
|
69
|
+
sleep(2)
|
70
|
+
scr.move(2,2)
|
71
|
+
scr.addstr("move(2,2)")
|
72
|
+
scr.refresh()
|
73
|
+
sleep(2)
|
74
|
+
scr.move(10, 2)
|
75
|
+
scr.addstr("Press a key to continue")
|
76
|
+
scr.getch()
|
77
|
+
end
|
78
|
+
|
79
|
+
def border(scr)
|
80
|
+
scr.clear()
|
81
|
+
scr.border(*([0]*8)) # calls WINDOW#border(0, 0, 0, 0, 0, 0, 0, 0)
|
82
|
+
scr.move(3,3)
|
83
|
+
scr.addstr("Press a key to continue")
|
84
|
+
scr.getch()
|
85
|
+
end
|
86
|
+
|
87
|
+
def two_borders()
|
88
|
+
# make a new window as tall as the screen and half as wide, in the left half
|
89
|
+
# of the screen
|
90
|
+
one = Ncurses::WINDOW.new(0, Ncurses.COLS() / 2, 0, 0)
|
91
|
+
# make one for the right half
|
92
|
+
two = Ncurses::WINDOW.new(0, Ncurses.COLS() - (Ncurses.COLS() / 2),
|
93
|
+
0, Ncurses.COLS() / 2)
|
94
|
+
one.border(*([0]*8))
|
95
|
+
two.border(*([0]*8))
|
96
|
+
one.move(3,3)
|
97
|
+
two.move(2,5)
|
98
|
+
one.addstr("move(3,3)")
|
99
|
+
two.addstr("move(2,5)")
|
100
|
+
two.move(5,3)
|
101
|
+
two.addstr("Press a key to continue")
|
102
|
+
one.noutrefresh() # copy window to virtual screen, don't update real screen
|
103
|
+
two.noutrefresh()
|
104
|
+
Ncurses.doupdate() # update read screen
|
105
|
+
two.getch()
|
106
|
+
end
|
107
|
+
|
108
|
+
begin
|
109
|
+
# initialize ncurses
|
110
|
+
Ncurses.initscr
|
111
|
+
Ncurses.cbreak # provide unbuffered input
|
112
|
+
Ncurses.noecho # turn off input echoing
|
113
|
+
Ncurses.nonl # turn off newline translation
|
114
|
+
Ncurses.stdscr.intrflush(false) # turn off flush-on-interrupt
|
115
|
+
Ncurses.stdscr.keypad(true) # turn on keypad mode
|
116
|
+
|
117
|
+
Ncurses.stdscr.addstr("Press a key to continue") # output string
|
118
|
+
Ncurses.stdscr.getch # get a charachter
|
119
|
+
|
120
|
+
moving(Ncurses.stdscr) # demo of moving cursor
|
121
|
+
border(Ncurses.stdscr) # demo of borders
|
122
|
+
two_borders() # demo of two windows with borders
|
123
|
+
|
124
|
+
ensure
|
125
|
+
Ncurses.echo
|
126
|
+
Ncurses.nocbreak
|
127
|
+
Ncurses.nl
|
128
|
+
Ncurses.endwin
|
129
|
+
end
|
data/examples/form.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# Copyright (c) 2004 by Simon Kaczor <skaczor@cox.net>
|
3
|
+
# Example from the NCurses Programming HOWTO
|
4
|
+
# This example uses module functions that are documented in the ncurses man page.
|
5
|
+
# For a more rubyish approach that uses Ruby objects see form2.rb
|
6
|
+
#
|
7
|
+
# The original example contained the following copyright:
|
8
|
+
# Copyright (c) 2001 by Pradeep Padala. This document may be distributed
|
9
|
+
# under the terms set forth in the LDP license at linuxdoc.org/COPYRIGHT.html.
|
10
|
+
|
11
|
+
require 'ncurses.rb'
|
12
|
+
|
13
|
+
begin
|
14
|
+
scr = Ncurses.initscr()
|
15
|
+
Ncurses.cbreak()
|
16
|
+
Ncurses.noecho()
|
17
|
+
Ncurses.keypad(scr, true)
|
18
|
+
|
19
|
+
#create some fields
|
20
|
+
fields = Array.new
|
21
|
+
fields.push(Ncurses::Form.new_field(1,10,4,18,0,0))
|
22
|
+
fields.push(Ncurses::Form.new_field(1,10,6,18,0,0))
|
23
|
+
|
24
|
+
# set field options
|
25
|
+
Ncurses::Form.set_field_back(fields[0], Ncurses::A_UNDERLINE)
|
26
|
+
Ncurses::Form.field_opts_off(fields[0], Ncurses::Form::O_AUTOSKIP)
|
27
|
+
|
28
|
+
Ncurses::Form.set_field_back(fields[1], Ncurses::A_UNDERLINE)
|
29
|
+
Ncurses::Form.field_opts_off(fields[1], Ncurses::Form::O_AUTOSKIP)
|
30
|
+
|
31
|
+
|
32
|
+
# create a form
|
33
|
+
form = Ncurses::Form.new_form(fields)
|
34
|
+
|
35
|
+
# post the form and refresh the screen
|
36
|
+
Ncurses::Form.post_form(form)
|
37
|
+
scr.refresh()
|
38
|
+
|
39
|
+
Ncurses.mvprintw(4, 10, "Value 1:")
|
40
|
+
Ncurses.mvprintw(6, 10, "Value 2:")
|
41
|
+
scr.refresh()
|
42
|
+
|
43
|
+
# Loop through to get user requests
|
44
|
+
while((ch = scr.getch()) != Ncurses::KEY_F1) do
|
45
|
+
case(ch)
|
46
|
+
when Ncurses::KEY_DOWN
|
47
|
+
# Go to next field
|
48
|
+
Ncurses::Form.form_driver(form, Ncurses::Form::REQ_NEXT_FIELD)
|
49
|
+
# Go to the end of the present buffer
|
50
|
+
# Leaves nicely at the last character
|
51
|
+
Ncurses::Form.form_driver(form, Ncurses::Form::REQ_END_LINE)
|
52
|
+
|
53
|
+
when Ncurses::KEY_UP
|
54
|
+
#Go to previous field
|
55
|
+
Ncurses::Form.form_driver(form, Ncurses::Form::REQ_PREV_FIELD)
|
56
|
+
Ncurses::Form.form_driver(form, Ncurses::Form::REQ_END_LINE);
|
57
|
+
else
|
58
|
+
# If this is a normal character, it gets Printed
|
59
|
+
Ncurses::Form.form_driver(form, ch)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# unpost and free form
|
64
|
+
Ncurses::Form.unpost_form(form);
|
65
|
+
Ncurses::Form.free_form(form)
|
66
|
+
Ncurses::Form.free_field(fields[0]);
|
67
|
+
Ncurses::Form.free_field(fields[1]);
|
68
|
+
|
69
|
+
|
70
|
+
#using class methods this time
|
71
|
+
# form = Ncurses::Form::FORM.new(fields)
|
72
|
+
# puts "Created form: #{form.inspect}\n"
|
73
|
+
# form.free()
|
74
|
+
|
75
|
+
ensure
|
76
|
+
# put the screen back in its normal state
|
77
|
+
Ncurses.echo()
|
78
|
+
Ncurses.nocbreak()
|
79
|
+
Ncurses.nl()
|
80
|
+
Ncurses.endwin()
|
81
|
+
end
|
82
|
+
|
data/examples/form2.rb
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# Copyright (c) 2004 by Simon Kaczor <skaczor@cox.net>
|
3
|
+
# Simple example of a form in action, based on the NCURSES Programming HOWTO:
|
4
|
+
# http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/
|
5
|
+
#
|
6
|
+
# All standard field types are created in the form.
|
7
|
+
# Additionnally a custom field is created to illustrate
|
8
|
+
# custom field validation using Ruby Proc objects, as shown in the example.
|
9
|
+
#
|
10
|
+
# The original example contained the following copyright:
|
11
|
+
# Copyright (c) 2001 by Pradeep Padala. This document may be distributed
|
12
|
+
# under the terms set forth in the LDP license at linuxdoc.org/COPYRIGHT.html.
|
13
|
+
|
14
|
+
require 'ncurses'
|
15
|
+
|
16
|
+
include Ncurses
|
17
|
+
include Ncurses::Form
|
18
|
+
|
19
|
+
def print_in_middle(win, starty, startx, width, string, color)
|
20
|
+
|
21
|
+
if(win == nil)
|
22
|
+
win = stdscr;
|
23
|
+
end
|
24
|
+
x = Array.new
|
25
|
+
y = Array.new
|
26
|
+
Ncurses.getyx(win, y, x);
|
27
|
+
if(startx != 0)
|
28
|
+
x[0] = startx;
|
29
|
+
end
|
30
|
+
if(starty != 0)
|
31
|
+
y[0] = starty;
|
32
|
+
end
|
33
|
+
if(width == 0)
|
34
|
+
width = 80;
|
35
|
+
end
|
36
|
+
length = string.length;
|
37
|
+
temp = (width - length)/ 2;
|
38
|
+
x[0] = startx + temp.floor;
|
39
|
+
win.attron(color);
|
40
|
+
win.mvprintw(y[0], x[0], "%s", string);
|
41
|
+
win.attroff(color);
|
42
|
+
Ncurses.refresh();
|
43
|
+
end
|
44
|
+
|
45
|
+
fields = Array.new
|
46
|
+
|
47
|
+
states = {"MI" => "Michigan",
|
48
|
+
"VA" => "Virginia",
|
49
|
+
"VE" => "Vermont"}
|
50
|
+
fieldcheck = proc { |afield|
|
51
|
+
val = afield.field_buffer(0)
|
52
|
+
val.strip!
|
53
|
+
if (states[val] != nil)
|
54
|
+
afield.set_field_buffer(0,states[val])
|
55
|
+
return true
|
56
|
+
else
|
57
|
+
return false
|
58
|
+
end
|
59
|
+
}
|
60
|
+
charcheck = proc { |ch|
|
61
|
+
if (('A'..'Z').include?(ch))
|
62
|
+
return true
|
63
|
+
else
|
64
|
+
return false
|
65
|
+
end
|
66
|
+
}
|
67
|
+
|
68
|
+
# Initialize curses
|
69
|
+
begin
|
70
|
+
stdscr = Ncurses.initscr();
|
71
|
+
Ncurses.start_color();
|
72
|
+
Ncurses.cbreak();
|
73
|
+
Ncurses.noecho();
|
74
|
+
Ncurses.keypad(stdscr, true);
|
75
|
+
|
76
|
+
# Initialize few color pairs
|
77
|
+
Ncurses.init_pair(1, COLOR_RED, COLOR_BLACK);
|
78
|
+
Ncurses.init_pair(2, COLOR_BLACK, COLOR_WHITE);
|
79
|
+
Ncurses.init_pair(3, COLOR_BLACK, COLOR_BLUE);
|
80
|
+
stdscr.bkgd(Ncurses.COLOR_PAIR(2));
|
81
|
+
|
82
|
+
# Initialize the fields
|
83
|
+
(1..9).each { |i|
|
84
|
+
field = FIELD.new(1, 10, i*2, 1, 0, 0)
|
85
|
+
field.set_field_back(A_UNDERLINE)
|
86
|
+
fields.push(field)
|
87
|
+
}
|
88
|
+
|
89
|
+
customtype = FIELDTYPE.new(fieldcheck, charcheck);
|
90
|
+
|
91
|
+
fields[1].set_field_type(TYPE_ALNUM, 0);
|
92
|
+
fields[2].set_field_type(TYPE_ALPHA, 0);
|
93
|
+
fields[3].set_field_type(TYPE_INTEGER, 0, 0, 1000);
|
94
|
+
fields[4].set_field_type(TYPE_NUMERIC, 2, 0, 1000);
|
95
|
+
fields[5].set_field_type(TYPE_ENUM, ["one","two","three"], false, false);
|
96
|
+
fields[6].set_field_type(TYPE_REGEXP, "^ *[0-9]* *$");
|
97
|
+
fields[7].set_field_type(TYPE_IPV4);
|
98
|
+
fields[8].set_field_type(customtype);
|
99
|
+
|
100
|
+
|
101
|
+
# Create the form and post it
|
102
|
+
my_form = FORM.new(fields);
|
103
|
+
|
104
|
+
my_form.user_object = "My identifier"
|
105
|
+
|
106
|
+
# Calculate the area required for the form
|
107
|
+
rows = Array.new()
|
108
|
+
cols = Array.new()
|
109
|
+
my_form.scale_form(rows, cols);
|
110
|
+
|
111
|
+
# Create the window to be associated with the form
|
112
|
+
my_form_win = WINDOW.new(rows[0] + 3, cols[0] + 14, 1, 1);
|
113
|
+
my_form_win.bkgd(Ncurses.COLOR_PAIR(3));
|
114
|
+
my_form_win.keypad(TRUE);
|
115
|
+
|
116
|
+
# Set main window and sub window
|
117
|
+
my_form.set_form_win(my_form_win);
|
118
|
+
my_form.set_form_sub(my_form_win.derwin(rows[0], cols[0], 2, 12));
|
119
|
+
|
120
|
+
# Print a border around the main window and print a title */
|
121
|
+
my_form_win.box(0, 0);
|
122
|
+
print_in_middle(my_form_win, 1, 0, cols[0] + 14, "My Form", Ncurses.COLOR_PAIR(1));
|
123
|
+
|
124
|
+
my_form.post_form();
|
125
|
+
|
126
|
+
# Print field types
|
127
|
+
my_form_win.mvaddstr(4, 2, "No Type")
|
128
|
+
my_form_win.mvaddstr(6, 2, "Alphanum")
|
129
|
+
my_form_win.mvaddstr(8, 2, "Alpha")
|
130
|
+
my_form_win.mvaddstr(10, 2, "Integer")
|
131
|
+
my_form_win.mvaddstr(12, 2, "Numeric")
|
132
|
+
my_form_win.mvaddstr(14, 2, "Enum")
|
133
|
+
my_form_win.mvaddstr(16, 2, "Regexp")
|
134
|
+
my_form_win.mvaddstr(18, 2, "IP")
|
135
|
+
my_form_win.mvaddstr(20, 2, "Custom")
|
136
|
+
|
137
|
+
my_form_win.wrefresh();
|
138
|
+
|
139
|
+
stdscr.mvprintw(Ncurses.LINES - 2, 28, "Use UP, DOWN arrow keys to switch between fields");
|
140
|
+
stdscr.mvprintw(Ncurses.LINES - 1, 28, "Press F1 to quit");
|
141
|
+
stdscr.refresh();
|
142
|
+
|
143
|
+
# Loop through to get user requests
|
144
|
+
while((ch = my_form_win.getch()) != KEY_F1)
|
145
|
+
case ch
|
146
|
+
when KEY_DOWN
|
147
|
+
# Go to next field */
|
148
|
+
my_form.form_driver(REQ_VALIDATION);
|
149
|
+
my_form.form_driver(REQ_NEXT_FIELD);
|
150
|
+
# Go to the end of the present buffer
|
151
|
+
# Leaves nicely at the last character
|
152
|
+
my_form.form_driver(REQ_END_LINE);
|
153
|
+
|
154
|
+
when KEY_UP
|
155
|
+
# Go to previous field
|
156
|
+
my_form.form_driver(REQ_VALIDATION);
|
157
|
+
my_form.form_driver(REQ_PREV_FIELD);
|
158
|
+
my_form.form_driver(REQ_END_LINE);
|
159
|
+
|
160
|
+
when KEY_LEFT
|
161
|
+
# Go to previous field
|
162
|
+
my_form.form_driver(REQ_PREV_CHAR);
|
163
|
+
|
164
|
+
when KEY_RIGHT
|
165
|
+
# Go to previous field
|
166
|
+
my_form.form_driver(REQ_NEXT_CHAR);
|
167
|
+
|
168
|
+
when KEY_BACKSPACE
|
169
|
+
my_form.form_driver(REQ_DEL_PREV);
|
170
|
+
else
|
171
|
+
# If this is a normal character, it gets Printed
|
172
|
+
my_form.form_driver(ch);
|
173
|
+
end
|
174
|
+
end
|
175
|
+
# Un post form and free the memory
|
176
|
+
my_form.unpost_form();
|
177
|
+
my_form.free_form();
|
178
|
+
fields.each {|f| f.free_field()}
|
179
|
+
|
180
|
+
|
181
|
+
ensure
|
182
|
+
Ncurses.endwin();
|
183
|
+
end
|
184
|
+
|