rbcurse 1.4.1 → 1.5.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +31 -0
- data/README.markdown +69 -11
- data/VERSION +1 -1
- data/lib/rbcurse.rb +5 -5
- metadata +10 -198
- data/Makefile +0 -21
- data/Manifest.txt +0 -91
- data/TODO +0 -372
- data/TODO2.txt +0 -118
- data/examples/README.txt +0 -67
- data/examples/abasiclist.rb +0 -33
- data/examples/alpmenu.rb +0 -42
- data/examples/app.rb +0 -859
- data/examples/app.sample +0 -10
- data/examples/appdirtree.rb +0 -75
- data/examples/appemail.rb +0 -191
- data/examples/appemaillb.rb +0 -308
- data/examples/appgcompose.rb +0 -315
- data/examples/atree.rb +0 -64
- data/examples/common/file.rb +0 -40
- data/examples/common/rmail.rb +0 -257
- data/examples/data.txt +0 -683
- data/examples/data/README.markdown +0 -9
- data/examples/data/brew.txt +0 -38
- data/examples/data/color.2 +0 -37
- data/examples/data/gemlist.txt +0 -60
- data/examples/data/lotr.txt +0 -12
- data/examples/data/ports.txt +0 -136
- data/examples/data/tasks.txt +0 -27
- data/examples/data/todocsv.csv +0 -28
- data/examples/data/unix1.txt +0 -21
- data/examples/data/unix2.txt +0 -11
- data/examples/dbdemo.rb +0 -495
- data/examples/deprecated/appgmail.rb +0 -952
- data/examples/deprecated/splitp.rb +0 -56
- data/examples/deprecated/testscrolllb.rb +0 -86
- data/examples/deprecated/testscrollp.rb +0 -88
- data/examples/deprecated/testscrollta.rb +0 -80
- data/examples/deprecated/testscrolltable.rb +0 -165
- data/examples/deprecated/testsplit.rb +0 -87
- data/examples/deprecated/testsplit2.rb +0 -123
- data/examples/deprecated/testsplit3.rb +0 -215
- data/examples/deprecated/testsplit3_1.rb +0 -244
- data/examples/deprecated/testsplit3a.rb +0 -215
- data/examples/deprecated/testsplit3b.rb +0 -237
- data/examples/deprecated/testsplitta.rb +0 -148
- data/examples/deprecated/testsplittv.rb +0 -142
- data/examples/deprecated/testsplittvv.rb +0 -144
- data/examples/deprecated/testtpane.rb +0 -215
- data/examples/deprecated/testtpane2.rb +0 -145
- data/examples/deprecated/testtpanetable.rb +0 -203
- data/examples/dirtree.rb +0 -88
- data/examples/experimental/resultsetdemo.rb +0 -280
- data/examples/experimental/testmform.rb +0 -35
- data/examples/experimental/testscroller.rb +0 -117
- data/examples/experimental/teststackflow.rb +0 -111
- data/examples/menu1.rb +0 -112
- data/examples/multispl.rb +0 -86
- data/examples/newmessagebox.rb +0 -130
- data/examples/newtabbedwindow.rb +0 -100
- data/examples/newtesttabp.rb +0 -121
- data/examples/qdfilechooser.rb +0 -68
- data/examples/rfe.rb +0 -1195
- data/examples/rfe_renderer.rb +0 -121
- data/examples/sqlc.rb +0 -454
- data/examples/sqlm.rb +0 -437
- data/examples/sqlt.rb +0 -408
- data/examples/status.txt +0 -68
- data/examples/table1.rb +0 -24
- data/examples/term2.rb +0 -84
- data/examples/test1.rb +0 -239
- data/examples/test2.rb +0 -674
- data/examples/testapp.rb +0 -44
- data/examples/testapp2.rb +0 -58
- data/examples/testchars.rb +0 -137
- data/examples/testcombo.rb +0 -91
- data/examples/testkeypress.rb +0 -66
- data/examples/testlistbox.rb +0 -113
- data/examples/testmenu.rb +0 -101
- data/examples/testmulticomp.rb +0 -70
- data/examples/testmulticontainer.rb +0 -94
- data/examples/testmultispl.rb +0 -199
- data/examples/testree.rb +0 -106
- data/examples/testtable.rb +0 -263
- data/examples/testtabp.rb +0 -107
- data/examples/testtodo.rb +0 -584
- data/examples/testvimsplit.rb +0 -112
- data/examples/testwsshortcuts.rb +0 -64
- data/examples/testwsshortcuts2.rb +0 -126
- data/examples/todo.db +0 -0
- data/examples/todo.yml +0 -191
- data/examples/viewtodo.rb +0 -574
- data/lib/rbcurse/action.rb +0 -40
- data/lib/rbcurse/app.rb +0 -1374
- data/lib/rbcurse/applicationheader.rb +0 -102
- data/lib/rbcurse/celleditor.rb +0 -112
- data/lib/rbcurse/checkboxcellrenderer.rb +0 -57
- data/lib/rbcurse/colormap.rb +0 -159
- data/lib/rbcurse/comboboxcellrenderer.rb +0 -30
- data/lib/rbcurse/common/ansiparser.rb +0 -117
- data/lib/rbcurse/common/appmethods.rb +0 -112
- data/lib/rbcurse/common/basestack.rb +0 -407
- data/lib/rbcurse/common/bordertitle.rb +0 -41
- data/lib/rbcurse/common/chunk.rb +0 -177
- data/lib/rbcurse/common/colorparser.rb +0 -71
- data/lib/rbcurse/common/keydefs.rb +0 -30
- data/lib/rbcurse/common/widgetshortcuts.rb +0 -302
- data/lib/rbcurse/defaultlistselectionmodel.rb +0 -79
- data/lib/rbcurse/deprecated/README.markdown +0 -12
- data/lib/rbcurse/deprecated/rscrollpane.rb +0 -512
- data/lib/rbcurse/deprecated/rsplitpane.rb +0 -894
- data/lib/rbcurse/deprecated/rsplitpane2.rb +0 -1009
- data/lib/rbcurse/deprecated/rviewport.rb +0 -204
- data/lib/rbcurse/experimental/README.markdown +0 -14
- data/lib/rbcurse/experimental/resultsettextview.rb +0 -585
- data/lib/rbcurse/experimental/stackflow.rb +0 -478
- data/lib/rbcurse/extras/bottomline.rb +0 -1850
- data/lib/rbcurse/extras/box.rb +0 -58
- data/lib/rbcurse/extras/directorylist.rb +0 -467
- data/lib/rbcurse/extras/directorytree.rb +0 -69
- data/lib/rbcurse/extras/divider.rb +0 -310
- data/lib/rbcurse/extras/focusmanager.rb +0 -31
- data/lib/rbcurse/extras/horizlist.rb +0 -203
- data/lib/rbcurse/extras/listselectable.rb +0 -264
- data/lib/rbcurse/extras/masterdetail.rb +0 -166
- data/lib/rbcurse/extras/menutree.rb +0 -63
- data/lib/rbcurse/extras/multiform.rb +0 -330
- data/lib/rbcurse/extras/multilinelabel.rb +0 -142
- data/lib/rbcurse/extras/newmessagebox.rb +0 -328
- data/lib/rbcurse/extras/newtabbedpane.rb +0 -612
- data/lib/rbcurse/extras/newtabbedwindow.rb +0 -68
- data/lib/rbcurse/extras/padreader.rb +0 -189
- data/lib/rbcurse/extras/rcomboedit.rb +0 -256
- data/lib/rbcurse/extras/resultsetbrowser.rb +0 -281
- data/lib/rbcurse/extras/rlink.rb +0 -27
- data/lib/rbcurse/extras/rmenulink.rb +0 -21
- data/lib/rbcurse/extras/scrollbar.rb +0 -143
- data/lib/rbcurse/extras/statusline.rb +0 -94
- data/lib/rbcurse/extras/stdscrwindow.rb +0 -309
- data/lib/rbcurse/extras/tableextended.rb +0 -40
- data/lib/rbcurse/extras/tabular.rb +0 -264
- data/lib/rbcurse/extras/tabularwidget.rb +0 -1150
- data/lib/rbcurse/extras/textpad.rb +0 -516
- data/lib/rbcurse/extras/viewer.rb +0 -136
- data/lib/rbcurse/io.rb +0 -850
- data/lib/rbcurse/keylabelprinter.rb +0 -178
- data/lib/rbcurse/listcellrenderer.rb +0 -140
- data/lib/rbcurse/listeditable.rb +0 -310
- data/lib/rbcurse/listkeys.rb +0 -37
- data/lib/rbcurse/listscrollable.rb +0 -564
- data/lib/rbcurse/listselectable.rb +0 -142
- data/lib/rbcurse/mapper.rb +0 -130
- data/lib/rbcurse/orderedhash.rb +0 -77
- data/lib/rbcurse/ractionevent.rb +0 -67
- data/lib/rbcurse/rbasiclistbox.rb +0 -768
- data/lib/rbcurse/rchangeevent.rb +0 -27
- data/lib/rbcurse/rcombo.rb +0 -238
- data/lib/rbcurse/rcommandwindow.rb +0 -587
- data/lib/rbcurse/rcontainer.rb +0 -415
- data/lib/rbcurse/rdialogs.rb +0 -451
- data/lib/rbcurse/rinputdataevent.rb +0 -47
- data/lib/rbcurse/rlistbox.rb +0 -1196
- data/lib/rbcurse/rmenu.rb +0 -939
- data/lib/rbcurse/rmessagebox.rb +0 -348
- data/lib/rbcurse/rmulticontainer.rb +0 -304
- data/lib/rbcurse/rmultisplit.rb +0 -722
- data/lib/rbcurse/rmultitextview.rb +0 -306
- data/lib/rbcurse/rpopupmenu.rb +0 -755
- data/lib/rbcurse/rprogress.rb +0 -118
- data/lib/rbcurse/rscrollform.rb +0 -418
- data/lib/rbcurse/rtabbedpane.rb +0 -1158
- data/lib/rbcurse/rtabbedwindow.rb +0 -167
- data/lib/rbcurse/rtable.rb +0 -1718
- data/lib/rbcurse/rtextarea.rb +0 -920
- data/lib/rbcurse/rtextview.rb +0 -761
- data/lib/rbcurse/rtree.rb +0 -780
- data/lib/rbcurse/rvimsplit.rb +0 -763
- data/lib/rbcurse/rwidget.rb +0 -2915
- data/lib/rbcurse/scrollable.rb +0 -301
- data/lib/rbcurse/table/tablecellrenderer.rb +0 -86
- data/lib/rbcurse/table/tabledatecellrenderer.rb +0 -98
- data/lib/rbcurse/tree/treecellrenderer.rb +0 -150
- data/lib/rbcurse/tree/treemodel.rb +0 -428
- data/lib/rbcurse/undomanager.rb +0 -188
- data/lib/rbcurse/vieditable.rb +0 -144
- data/lib/ver/keyboard.rb +0 -150
- data/lib/ver/keyboard2.rb +0 -170
- data/lib/ver/ncurses.rb +0 -218
- data/lib/ver/panel.rb +0 -162
- data/lib/ver/rpad.rb +0 -375
- data/lib/ver/window.rb +0 -882
- data/test/test_rbcurse.rb +0 -0
data/lib/ver/keyboard2.rb
DELETED
@@ -1,170 +0,0 @@
|
|
1
|
-
# Usage:
|
2
|
-
# VER::Keyboard2.focus = self
|
3
|
-
# or whatever class you have created.
|
4
|
-
# DEPENDENCIES:
|
5
|
-
# press(key) - a method that takes an int key and processes it
|
6
|
-
# stopping? returns true of false. if false, this prgram returns control
|
7
|
-
# window - gives window of caller, responding to getch
|
8
|
-
# 2008-11-24 12:41
|
9
|
-
# this differs from original in that i try to return an int so it can just replace
|
10
|
-
# existing loops without any modification
|
11
|
-
# I thus return an int not a string
|
12
|
-
module VER
|
13
|
-
module Keyboard2 # avoid initialize
|
14
|
-
ESC = 27 # keycode
|
15
|
-
@polling = false
|
16
|
-
|
17
|
-
module_function
|
18
|
-
|
19
|
-
def focus=(receiver)
|
20
|
-
@stack = []
|
21
|
-
@focus = receiver
|
22
|
-
poll unless @polling
|
23
|
-
end
|
24
|
-
|
25
|
-
def poll
|
26
|
-
@polling = true
|
27
|
-
|
28
|
-
while char = @focus.window.getch
|
29
|
-
break if @focus.stopping? # XXX
|
30
|
-
#break if VER.stopping?
|
31
|
-
$log.debug("char: #{char} stakc: #{@stack.inspect}") if char != Ncurses::ERR
|
32
|
-
if char == Ncurses::ERR # timeout or signal
|
33
|
-
#@focus.press('esc') if @stack == [ESC]
|
34
|
-
@focus.press(ESC) if @stack == [ESC]
|
35
|
-
@stack.clear
|
36
|
-
elsif ready = resolve(char)
|
37
|
-
$log.debug("char: #{char} ready: #{ready}")
|
38
|
-
@stack.clear
|
39
|
-
@focus.press(ready)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
ensure
|
44
|
-
@polling = false
|
45
|
-
end
|
46
|
-
|
47
|
-
def resolve(char)
|
48
|
-
$log.debug("char: #{char} resolve") if char == ESC
|
49
|
-
@stack << char
|
50
|
-
|
51
|
-
if @stack.first == ESC
|
52
|
-
MOD_KEYS[@stack] || SPECIAL_KEYS[@stack]
|
53
|
-
elsif (char >= 0 and char < 27) or char == 32 or char == 127
|
54
|
-
char
|
55
|
-
else
|
56
|
-
#NCURSES_KEYS[char] || CONTROL_KEYS[char] || PRINTABLE_KEYS[char]
|
57
|
-
NCURSES_KEYS[char] || PRINTABLE_KEYS[char]
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# TODO: make this section sane
|
62
|
-
|
63
|
-
ASCII = (0..255).map{|c| c.chr }
|
64
|
-
CONTROL = ASCII.grep(/[[:cntrl:]]/)
|
65
|
-
PRINTABLE = ASCII.grep(/[[:print:]]/)
|
66
|
-
|
67
|
-
SPECIAL_KEYS = {
|
68
|
-
[27, 79, 50, 81] => 'F14',
|
69
|
-
[27, 79, 50, 82] => 'F15',
|
70
|
-
[27, 79, 70] => 'end',
|
71
|
-
[27, 79, 70] => 'end',
|
72
|
-
[27, 79, 72] => 'home',
|
73
|
-
# [27, 79, 80] => 'F1',
|
74
|
-
[27, 79, 80] => Ncurses::KEY_F1,
|
75
|
-
[27, 79, 81] => 'F2',
|
76
|
-
[27, 79, 82] => 'F3',
|
77
|
-
[27, 79, 83] => 'F4',
|
78
|
-
[27, 91, 49, 126] => 'end',
|
79
|
-
[27, 91, 49, 126] => 'home',
|
80
|
-
[27, 91, 49, 49, 126] => Ncurses::KEY_F1,
|
81
|
-
[27, 91, 49, 50, 126] => 'F2',
|
82
|
-
[27, 91, 49, 51, 126] => 'F3',
|
83
|
-
[27, 91, 49, 52, 126] => 'F4',
|
84
|
-
[27, 91, 49, 52, 126] => 'F4',
|
85
|
-
[27, 91, 49, 53, 126] => 'F5',
|
86
|
-
[27, 91, 49, 55, 126] => 'F6',
|
87
|
-
[27, 91, 49, 56, 59, 50, 126] => 'F19',
|
88
|
-
[27, 91, 49, 56, 59, 51, 126] => 'F7',
|
89
|
-
[27, 91, 49, 59, 51, 65] => 'ppage',
|
90
|
-
[27, 91, 49, 59, 51, 66] => 'npage',
|
91
|
-
[27, 91, 49, 59, 53, 65] => 'ppage',
|
92
|
-
[27, 91, 49, 59, 53, 66] => 'npage',
|
93
|
-
[27, 91, 49, 59, 53, 70] => 'M-<',
|
94
|
-
[27, 91, 49, 59, 53, 72] => 'M->',
|
95
|
-
[27, 91, 50, 54, 126] => 'F14',
|
96
|
-
[27, 91, 50, 56, 126] => 'F15',
|
97
|
-
[27, 91, 51, 59, 51, 126] => 'del',
|
98
|
-
[27, 91, 52, 126] => 'end',
|
99
|
-
[27, 91, 55, 126] => 'home',
|
100
|
-
[27, 91, 55, 126] => 'home',
|
101
|
-
[27, 91, 56, 126] => 'end',
|
102
|
-
[27, 91, 56, 126] => 'end',
|
103
|
-
[27, 91, 65] => 'up',
|
104
|
-
[27, 91, 66] => 'down',
|
105
|
-
[27, 91, 67] => 'right',
|
106
|
-
[27, 91, 68] => 'left',
|
107
|
-
[27, 91, 70] => 'end',
|
108
|
-
[27, 91, 72] => 'end',
|
109
|
-
[27, 91, 72] => 'home',
|
110
|
-
[27, 91, 91, 65] => Ncurses::KEY_F1,
|
111
|
-
[27, 91, 91, 66] => 'F2',
|
112
|
-
[27, 91, 91, 67] => 'F3',
|
113
|
-
[27, 91, 91, 68] => 'F4',
|
114
|
-
[27, 91, 91, 69] => 'F5',
|
115
|
-
}
|
116
|
-
|
117
|
-
CONTROL_KEYS = {
|
118
|
-
0 => 'C-space',
|
119
|
-
1 => 'C-a',
|
120
|
-
2 => 'C-b',
|
121
|
-
3 => 'C-c',
|
122
|
-
4 => 'C-d',
|
123
|
-
5 => 'C-e',
|
124
|
-
6 => 'C-f',
|
125
|
-
7 => 'C-g',
|
126
|
-
8 => 'C-h',
|
127
|
-
9 => 'tab',
|
128
|
-
10 => 'return', # C-j
|
129
|
-
11 => 'C-k',
|
130
|
-
12 => 'C-l',
|
131
|
-
13 => 'return', # C-m
|
132
|
-
14 => 'C-n',
|
133
|
-
15 => 'C-o',
|
134
|
-
16 => 'C-p',
|
135
|
-
17 => 'C-q',
|
136
|
-
18 => 'C-r',
|
137
|
-
19 => 'C-s',
|
138
|
-
20 => 'C-t',
|
139
|
-
21 => 'C-u',
|
140
|
-
22 => 'C-v',
|
141
|
-
23 => 'C-w',
|
142
|
-
24 => 'C-x',
|
143
|
-
25 => 'C-y',
|
144
|
-
26 => 'C-z', # FIXME: is usually suspend in shell job control
|
145
|
-
# 27 => 'esc',
|
146
|
-
32 => 'space',
|
147
|
-
127 => 'backspace',
|
148
|
-
}
|
149
|
-
|
150
|
-
PRINTABLE_KEYS = {}
|
151
|
-
MOD_KEYS = {}
|
152
|
-
|
153
|
-
PRINTABLE.each do |key|
|
154
|
-
code = key.unpack('c')[0] # using unpack to be compatible with 1.9
|
155
|
-
# PRINTABLE_KEYS[code] = key
|
156
|
-
# MOD_KEYS[[ESC, code]] = "M-#{key}" unless key == '[' # don't map esc
|
157
|
-
PRINTABLE_KEYS[code] = code
|
158
|
-
MOD_KEYS[[ESC, code]] = 128 + code unless key == '[' # don't map esc
|
159
|
-
end
|
160
|
-
|
161
|
-
NCURSES_KEYS = {}
|
162
|
-
Ncurses.constants.grep(/^KEY_/).each do |const|
|
163
|
-
value = Ncurses.const_get(const)
|
164
|
-
key = const[/^KEY_(.*)/, 1]
|
165
|
-
key = key =~ /^F/ ? key : key.downcase # function keys
|
166
|
-
#NCURSES_KEYS[value] = key
|
167
|
-
NCURSES_KEYS[value] = value
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
data/lib/ver/ncurses.rb
DELETED
@@ -1,218 +0,0 @@
|
|
1
|
-
require 'ffi-ncurses'
|
2
|
-
#include FFI::NCurses # this pollutes many objects and invalidates method_missing
|
3
|
-
module VER
|
4
|
-
module_function
|
5
|
-
|
6
|
-
# Setup ncurses, nicely documented by the curses manpages
|
7
|
-
def start_ncurses
|
8
|
-
return if $ncurses_started
|
9
|
-
$ncurses_started = true
|
10
|
-
# The initscr code determines the terminal type and initializes all curses
|
11
|
-
# data structures.
|
12
|
-
# initscr also causes the first call to refresh to clear the screen.
|
13
|
-
# If errors occur, initscr writes an appropriate error message to standard
|
14
|
-
# error and exits; otherwise, a pointer is returned to stdscr.
|
15
|
-
stdscr = Ncurses.initscr ## FFI
|
16
|
-
|
17
|
-
# Color.start if Ncurses.has_colors?
|
18
|
-
Ncurses.start_color();
|
19
|
-
ColorMap.setup # added by RK 2008-11-30 00:48
|
20
|
-
# The keypad option enables the keypad of the user's terminal.
|
21
|
-
# If enabled (bf is TRUE), the user can press a function key (such as an
|
22
|
-
# arrow key) and wgetch returns a single value representing the function
|
23
|
-
# key, as in KEY_LEFT.
|
24
|
-
# If disabled (bf is FALSE), curses does not treat function keys specially
|
25
|
-
# and the program has to interpret the escape sequences itself.
|
26
|
-
# If the keypad in the terminal can be turned on (made to transmit) and off
|
27
|
-
# (made to work locally), turning on this option causes the terminal keypad
|
28
|
-
# to be turned on when wgetch is called.
|
29
|
-
# The default value for keypad is false.
|
30
|
-
Ncurses.keypad(stdscr.pointer, bf = true) # FFIWINDOW
|
31
|
-
#Ncurses.keypad(stdscr, bf = true)
|
32
|
-
#Ncurses.stdscr.keypad(true) # turn on keypad mode FFI
|
33
|
-
#Ncurses.keypad(stdscr, bf = 1)
|
34
|
-
|
35
|
-
# The nl and nonl routines control whether the underlying display device
|
36
|
-
# translates the return key into newline on input, and whether it
|
37
|
-
# translates newline into return and line-feed on output (in either case,
|
38
|
-
# the call addch('\n') does the equivalent of return and line feed on the
|
39
|
-
# virtual screen).
|
40
|
-
# Initially, these translations do occur.
|
41
|
-
# If you disable them using nonl, curses will be able to make better use of
|
42
|
-
# the line-feed capability, resulting in faster cursor motion.
|
43
|
-
# Also, curses will then be able to detect the return key.
|
44
|
-
Ncurses.nonl
|
45
|
-
|
46
|
-
# The raw and noraw routines place the terminal into or out of raw mode.
|
47
|
-
# Raw mode is similar to cbreak mode, in that characters typed are
|
48
|
-
# immediately passed through to the user program.
|
49
|
-
# The differences are that in raw mode, the interrupt, quit, suspend, and
|
50
|
-
# flow control characters are all passed through uninterpreted, instead of
|
51
|
-
# generating a signal.
|
52
|
-
# The behavior of the BREAK key depends on other bits in the tty driver
|
53
|
-
# that are not set by curses.
|
54
|
-
Ncurses.raw
|
55
|
-
|
56
|
-
# Normally, the tty driver buffers typed characters until a newline or
|
57
|
-
# carriage return is typed.
|
58
|
-
# The cbreak routine disables line buffering and
|
59
|
-
# erase/kill character-processing (interrupt and flow control characters
|
60
|
-
# are unaffected), making characters typed by the user immediately
|
61
|
-
# available to the program.
|
62
|
-
Ncurses.cbreak
|
63
|
-
|
64
|
-
# The echo and noecho routines control whether characters typed by the user
|
65
|
-
# are echoed by getch as they are typed.
|
66
|
-
# Echoing by the tty driver is always disabled, but initially getch is in
|
67
|
-
# echo mode, so characters typed are echoed.
|
68
|
-
Ncurses.noecho
|
69
|
-
|
70
|
-
# The curs_set routine sets the cursor state is set to invisible, normal,
|
71
|
-
# or very visible for visibility equal to 0, 1, or 2 respectively.
|
72
|
-
# If the terminal supports the visibility requested, the previous cursor
|
73
|
-
# state is returned; otherwise, ERR is returned.
|
74
|
-
Ncurses.curs_set(1)
|
75
|
-
|
76
|
-
# The halfdelay routine is used for half-delay mode, which is similar to
|
77
|
-
# cbreak mode in that characters typed by the user are immediately
|
78
|
-
# available to the program.
|
79
|
-
# However, after blocking for tenths tenths of seconds, ERR is returned if
|
80
|
-
# nothing has been typed.
|
81
|
-
# The value of tenths must be a number between 1 and 255.
|
82
|
-
# Use nocbreak to leave half-delay mode.
|
83
|
-
Ncurses::halfdelay(tenths = 10)
|
84
|
-
|
85
|
-
# The nodelay option causes getch to be a non-blocking call. If no input is
|
86
|
-
# ready, getch returns ERR. If disabled (bf is FALSE), getch waits until a
|
87
|
-
# key is pressed.
|
88
|
-
# Ncurses::nodelay(Ncurses::stdscr, bf = true)
|
89
|
-
end
|
90
|
-
|
91
|
-
# this should happen only in outermost program that started ncurses
|
92
|
-
# if a called program does this, the calling program can have a display freeze
|
93
|
-
def stop_ncurses
|
94
|
-
Ncurses.echo
|
95
|
-
Ncurses.nocbreak
|
96
|
-
Ncurses.nl
|
97
|
-
Ncurses.endwin
|
98
|
-
$ncurses_started = false
|
99
|
-
#puts "curses over"
|
100
|
-
ensure
|
101
|
-
return unless error = @last_error
|
102
|
-
log = Config[:logfile].value
|
103
|
-
|
104
|
-
Kernel.warn "There may have been fatal errors logged to: #{log}."
|
105
|
-
Kernel.warn "The most recent was:"
|
106
|
-
|
107
|
-
$stderr.puts ''
|
108
|
-
$stderr.puts @last_error_message if @last_error_message
|
109
|
-
$stderr.puts @last_error, *@last_error.backtrace
|
110
|
-
end
|
111
|
-
require 'rbcurse/colormap'
|
112
|
-
include ColorMap
|
113
|
-
end
|
114
|
-
module Ncurses
|
115
|
-
extend self
|
116
|
-
FALSE = 0
|
117
|
-
TRUE = 1
|
118
|
-
module NCX
|
119
|
-
def COLS
|
120
|
-
FFI::NCurses.getmaxx(FFI::NCurses.stdscr)
|
121
|
-
end
|
122
|
-
def LINES
|
123
|
-
# #FFI::NCurses.getmaxy(FFI::NCurses.stdscr)
|
124
|
-
FFI::NCurses.LINES
|
125
|
-
end
|
126
|
-
# # supposed to be picked up at runtime
|
127
|
-
def COLORS
|
128
|
-
FFI::NCurses.COLORS
|
129
|
-
end
|
130
|
-
|
131
|
-
# jsut trying this so i can do Ncurses.stdscr.getmax
|
132
|
-
def _stdscr
|
133
|
-
FFI::NCurses.stdscr
|
134
|
-
end
|
135
|
-
# this allows me to refer to them as Ncurses::A_REVERSE as is the case everywhere
|
136
|
-
A_REVERSE = FFI::NCurses::A_REVERSE
|
137
|
-
A_STANDOUT = FFI::NCurses::A_STANDOUT
|
138
|
-
A_BOLD = FFI::NCurses::A_BOLD
|
139
|
-
A_UNDERLINE = FFI::NCurses::A_UNDERLINE
|
140
|
-
A_BLINK = FFI::NCurses::A_BLINK
|
141
|
-
A_NORMAL = FFI::NCurses::A_NORMAL
|
142
|
-
KEY_F1 = FFI::NCurses::KEY_F1
|
143
|
-
end
|
144
|
-
include NCX
|
145
|
-
extend NCX
|
146
|
-
# i think we can knock this off
|
147
|
-
def method_missing meth, *args
|
148
|
-
if (FFI::NCurses.respond_to?(meth))
|
149
|
-
FFI::NCurses.send meth, *args
|
150
|
-
end
|
151
|
-
end
|
152
|
-
# FFINC.constants.each { |e| Ncurses.const_set(e, FFINC.const_get(e) ) }
|
153
|
-
def const_missing name
|
154
|
-
val = FFI::NCurses.const_get(name)
|
155
|
-
const_set(name, val)
|
156
|
-
return val
|
157
|
-
end
|
158
|
-
|
159
|
-
# This is a window pointer wrapper, to be used for stdscr and others.
|
160
|
-
# Ideally ffi-ncurses should do this, if it returns a pointer, I'll do this.
|
161
|
-
class FFIWINDOW
|
162
|
-
attr_accessor :pointer
|
163
|
-
def initialize(*args, &block)
|
164
|
-
if block_given?
|
165
|
-
@pointer = args.first
|
166
|
-
else
|
167
|
-
@pointer = FFI::NCurses.newwin(*args)
|
168
|
-
end
|
169
|
-
end
|
170
|
-
def method_missing(name, *args)
|
171
|
-
name = name.to_s
|
172
|
-
if (name[0,2] == "mv")
|
173
|
-
test_name = name.dup
|
174
|
-
test_name[2,0] = "w" # insert "w" after"mv"
|
175
|
-
if (FFI::NCurses.respond_to?(test_name))
|
176
|
-
return FFI::NCurses.send(test_name, @pointer, *args)
|
177
|
-
end
|
178
|
-
end
|
179
|
-
test_name = "w" + name
|
180
|
-
if (FFI::NCurses.respond_to?(test_name))
|
181
|
-
return FFI::NCurses.send(test_name, @pointer, *args)
|
182
|
-
end
|
183
|
-
FFI::NCurses.send(name, @pointer, *args)
|
184
|
-
end
|
185
|
-
def respond_to?(name)
|
186
|
-
name = name.to_s
|
187
|
-
if (name[0,2] == "mv" && FFI::NCurses.respond_to?("mvw" + name[2..-1]))
|
188
|
-
return true
|
189
|
-
end
|
190
|
-
FFI::NCurses.respond_to?("w" + name) || FFI::NCurses.respond_to?(name)
|
191
|
-
end
|
192
|
-
def del
|
193
|
-
FFI::NCurses.delwin(@pointer)
|
194
|
-
end
|
195
|
-
alias delete del
|
196
|
-
end
|
197
|
-
# if ffi-ncurses returns a pointer wrap it.
|
198
|
-
# or we can check for whether it responds_to? refresh and getch
|
199
|
-
def self.initscr
|
200
|
-
#@stdscr = Ncurses::FFIWINDOW.new(FFI::NCurses.initscr) { }
|
201
|
-
stdscr = FFI::NCurses.initscr
|
202
|
-
if stdscr.is_a? FFI::Pointer
|
203
|
-
@stdscr = Ncurses::FFIWINDOW.new(stdscr) { }
|
204
|
-
else
|
205
|
-
@stdscr = stdscr
|
206
|
-
end
|
207
|
-
end
|
208
|
-
def self.stdscr
|
209
|
-
@stdscr
|
210
|
-
end
|
211
|
-
# commented off on 2011-09-15 FFIWINDOW results in errors
|
212
|
-
# class << self
|
213
|
-
# def method_missing(method, *args, &block)
|
214
|
-
# FFI::NCurses.send(method, *args, &block)
|
215
|
-
# end
|
216
|
-
# end
|
217
|
-
# ---
|
218
|
-
end
|
data/lib/ver/panel.rb
DELETED
@@ -1,162 +0,0 @@
|
|
1
|
-
require "ffi-ncurses"
|
2
|
-
module Ncurses # changed on 2011-09-8
|
3
|
-
# making minimal changes as per ffi-ncurses 0.4.0 which implements panels
|
4
|
-
#module VER # too many places call Ncurses::Panel
|
5
|
-
class Panel #< Struct.new(:pointer)
|
6
|
-
# extend FFI::Library
|
7
|
-
#
|
8
|
-
# # use RUBY_FFI_NCURSES_LIB to specify exactly which lib you want, e.g.
|
9
|
-
# # ncursesw, XCurses (from PDCurses)
|
10
|
-
# if ENV["RUBY_FFI_PANEL_LIB"].to_s != ""
|
11
|
-
# LIB_HANDLE = ffi_lib( ENV["RUBY_FFI_PANEL_LIB"] ).first
|
12
|
-
# else
|
13
|
-
# # next works but not when ENV, maybe since 'panel' not in code above
|
14
|
-
# LIB_HANDLE = ffi_lib( 'panel', '/opt/local/lib/libpanelw.5.dylib' ).first
|
15
|
-
# #LIB_HANDLE = ffi_lib( 'panel', 'libpanel' ).first # this also works
|
16
|
-
# end
|
17
|
-
#
|
18
|
-
# functions = [
|
19
|
-
# [:new_panel, [:pointer], :pointer],
|
20
|
-
# [:bottom_panel, [:pointer], :int],
|
21
|
-
# [:top_panel, [:pointer], :int],
|
22
|
-
# [:show_panel, [:pointer], :int],
|
23
|
-
# [:update_panels, [], :void],
|
24
|
-
# [:hide_panel, [:pointer], :int],
|
25
|
-
# [:panel_window, [:pointer], :pointer],
|
26
|
-
# [:replace_panel, [:pointer, :pointer], :int],
|
27
|
-
# [:move_panel, [:pointer, :int, :int], :int],
|
28
|
-
# [:panel_hidden, [:pointer], :int],
|
29
|
-
# [:panel_above, [:pointer], :pointer],
|
30
|
-
# [:panel_below, [:pointer], :pointer],
|
31
|
-
# [:set_panel_userptr, [:pointer, :pointer], :int],
|
32
|
-
# [:panel_userptr, [:pointer], :pointer],
|
33
|
-
# [:del_panel, [:pointer], :int],
|
34
|
-
# ]
|
35
|
-
#
|
36
|
-
# functions.each do |function|
|
37
|
-
# attach_function(*function)
|
38
|
-
# end
|
39
|
-
|
40
|
-
def initialize(window)
|
41
|
-
if window.respond_to?(:pointer)
|
42
|
-
@pointer = FFI::NCurses.new_panel(window.pointer)
|
43
|
-
else
|
44
|
-
@pointer = FFI::NCurses.new_panel(window)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
def pointer
|
48
|
-
@pointer
|
49
|
-
end
|
50
|
-
|
51
|
-
# Puts panel below all other panels.
|
52
|
-
def bottom_panel
|
53
|
-
FFI::NCurses.bottom_panel(@pointer)
|
54
|
-
end
|
55
|
-
alias bottom bottom_panel
|
56
|
-
|
57
|
-
# Put the visible panel on top of all other panels in the stack.
|
58
|
-
#
|
59
|
-
# To ensure compatibility across platforms, use this method instead of
|
60
|
-
# {show_panel} when the panel is shown.
|
61
|
-
def top_panel
|
62
|
-
FFI::NCurses.top_panel(@pointer)
|
63
|
-
end
|
64
|
-
alias top top_panel
|
65
|
-
|
66
|
-
# Makes hidden panel visible by placing it on the top of the stack.
|
67
|
-
#
|
68
|
-
# To ensure compatibility across platforms, use this method instead of
|
69
|
-
# {top_panel} when the panel is hidden.
|
70
|
-
def show_panel
|
71
|
-
FFI::NCurses.show_panel(@pointer)
|
72
|
-
end
|
73
|
-
alias show show_panel
|
74
|
-
|
75
|
-
# Removes the given panel from the panel stack and thus hides it from
|
76
|
-
# view.
|
77
|
-
# The PANEL structure is not lost, merely removed from the stack.
|
78
|
-
def hide_panel
|
79
|
-
FFI::NCurses.hide_panel(@pointer)
|
80
|
-
end
|
81
|
-
alias hide hide_panel
|
82
|
-
|
83
|
-
# Returns a pointer to the window of the given panel.
|
84
|
-
def panel_window
|
85
|
-
FFI::NCurses.panel_window(@pointer)
|
86
|
-
end
|
87
|
-
alias window panel_window
|
88
|
-
|
89
|
-
# Replace the window of the panel with the given window.
|
90
|
-
# Useful, for example, if you want to resize a panel.
|
91
|
-
# You can call {replace_panel} on the output of {wresize}.
|
92
|
-
# It does not change the position of the panel in the stack.
|
93
|
-
def replace_panel(window)
|
94
|
-
FFI::NCurses.replace_panel(@pointer, window)
|
95
|
-
end
|
96
|
-
alias replace replace_panel
|
97
|
-
|
98
|
-
# Move the panel window so that its upper-left corner is at
|
99
|
-
# (+starty+,+startx+).
|
100
|
-
# It does not change the position of the panel in the stack.
|
101
|
-
# Be sure to use this method instead of {mvwin}, to move a panel window.
|
102
|
-
def move_panel(starty = 0, startx = 0)
|
103
|
-
FFI::NCurses.move_panel(@pointer, starty, startx)
|
104
|
-
end
|
105
|
-
alias move move_panel
|
106
|
-
|
107
|
-
# Returns true if the panel is in the panel stack, false if not.
|
108
|
-
# Returns ERR if the panel pointer is a null pointer.
|
109
|
-
def panel_hidden
|
110
|
-
FFI::NCurses.panel_hidden(@pointer) == 0
|
111
|
-
end
|
112
|
-
alias hidden? panel_hidden
|
113
|
-
|
114
|
-
# Returns pointer to the panel above.
|
115
|
-
def panel_above
|
116
|
-
FFI::NCurses.panel_above(@pointer)
|
117
|
-
end
|
118
|
-
alias above panel_above
|
119
|
-
|
120
|
-
# Return a pointer to the panel just below panel.
|
121
|
-
# If the panel argument is a pointer to 0, it returns a pointer to the
|
122
|
-
# top panel in the stack.
|
123
|
-
def panel_below
|
124
|
-
FFI::NCurses.panel_below(@pointer)
|
125
|
-
end
|
126
|
-
alias below panel_below
|
127
|
-
|
128
|
-
# Returns the user pointer for a given panel.
|
129
|
-
def panel_userptr
|
130
|
-
FFI::NCurses.panel_userptr(@pointer)
|
131
|
-
end
|
132
|
-
alias userptr panel_userptr
|
133
|
-
|
134
|
-
# sets the panel's user pointer.
|
135
|
-
def set_panel_userptr(user_pointer)
|
136
|
-
FFI::NCurses.set_panel_userptr(@pointer, user_pointer)
|
137
|
-
end
|
138
|
-
alias userptr= set_panel_userptr
|
139
|
-
|
140
|
-
# Remove the panel from the stack and deallocate the PANEL structure.
|
141
|
-
# Doesn't remove the associated window.
|
142
|
-
def del_panel
|
143
|
-
FFI::NCurses.del_panel(@pointer)
|
144
|
-
end
|
145
|
-
alias del del_panel
|
146
|
-
alias delete del_panel
|
147
|
-
|
148
|
-
class << self
|
149
|
-
# these will be used when you say Ncurses::Panel.del_panel(@panel.pointer)
|
150
|
-
# You could directly say FFI:NCurses or even @panel.del_panel.
|
151
|
-
def update_panels
|
152
|
-
FFI::NCurses.update_panels
|
153
|
-
end
|
154
|
-
def method_missing(name, *args)
|
155
|
-
if (FFI::NCurses.respond_to?(name))
|
156
|
-
return FFI::NCurses.send(name, *args)
|
157
|
-
end
|
158
|
-
raise "Panel did not respond_to #{name} "
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|