rbcurse 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +20 -0
- data/NOTES +45 -0
- data/README.markdown +47 -68
- data/TODO2.txt +29 -32
- data/VERSION +1 -1
- data/examples/abasiclist.rb +2 -0
- data/examples/app.rb +2 -2
- data/examples/app.sample +10 -0
- data/examples/appemail.rb +29 -2
- data/examples/appemaillb.rb +1 -1
- data/examples/appgcompose.rb +9 -2
- data/examples/appmethods.rb +69 -0
- data/examples/atree.rb +2 -2
- data/examples/menu1.rb +1 -1
- data/examples/newtesttabp.rb +8 -5
- data/examples/qdfilechooser.rb +6 -3
- data/examples/rfe.rb +71 -16
- data/examples/rmail.rb +76 -7
- data/examples/sqlc.rb +14 -3
- data/examples/sqlm.rb +3 -3
- data/examples/term.rb +48 -0
- data/examples/term2.rb +48 -21
- data/examples/test1.rb +2 -2
- data/examples/test2.rb +162 -71
- data/examples/testapp.rb +2 -2
- data/examples/testapp2.rb +1 -1
- data/examples/testchars.rb +47 -46
- data/examples/testcombo.rb +2 -2
- data/examples/testkeypress.rb +2 -2
- data/examples/testlistbox.rb +2 -2
- data/examples/testmenu.rb +1 -1
- data/examples/testmulticomp.rb +1 -1
- data/examples/testmultispl.rb +1 -1
- data/examples/testree.rb +1 -22
- data/examples/testscroller.rb +2 -2
- data/examples/testscrolllb.rb +2 -2
- data/examples/testscrollp.rb +2 -2
- data/examples/testscrollta.rb +2 -2
- data/examples/testscrolltable.rb +2 -2
- data/examples/testsplit.rb +2 -2
- data/examples/testsplit2.rb +2 -2
- data/examples/testsplit3.rb +2 -2
- data/examples/testsplit3_1.rb +2 -2
- data/examples/testsplit3a.rb +2 -2
- data/examples/testsplit3b.rb +2 -2
- data/examples/testsplitta.rb +2 -2
- data/examples/testsplittv.rb +2 -2
- data/examples/testsplittvv.rb +2 -2
- data/examples/testtable.rb +2 -2
- data/examples/testtabp.rb +2 -2
- data/examples/testtodo.rb +1 -1
- data/examples/testtpane.rb +2 -2
- data/examples/testtpane2.rb +2 -2
- data/examples/testtpanetable.rb +6 -5
- data/examples/testvimsplit.rb +2 -2
- data/examples/viewtodo.rb +1 -1
- data/lib/rbcurse.rb +2 -1
- data/lib/rbcurse/action.rb +1 -1
- data/lib/rbcurse/app.rb +51 -14
- data/lib/rbcurse/applicationheader.rb +1 -1
- data/lib/rbcurse/celleditor.rb +1 -1
- data/lib/rbcurse/colormap.rb +11 -11
- data/lib/rbcurse/comboboxcellrenderer.rb +1 -1
- data/lib/rbcurse/extras/bottomline.rb +22 -10
- data/lib/rbcurse/extras/directorylist.rb +14 -1
- data/lib/rbcurse/extras/divider.rb +1 -1
- data/lib/rbcurse/extras/listselectable.rb +2 -2
- data/lib/rbcurse/extras/masterdetail.rb +3 -1
- data/lib/rbcurse/extras/scrollbar.rb +1 -1
- data/lib/rbcurse/extras/stdscrwindow.rb +75 -24
- data/lib/rbcurse/extras/tabular.rb +8 -3
- data/lib/rbcurse/extras/viewer.rb +18 -2
- data/lib/rbcurse/io.rb +26 -13
- data/lib/rbcurse/keylabelprinter.rb +3 -2
- data/lib/rbcurse/listcellrenderer.rb +1 -0
- data/lib/rbcurse/listkeys.rb +3 -2
- data/lib/rbcurse/listselectable.rb +4 -3
- data/lib/rbcurse/rbasiclistbox.rb +12 -5
- data/lib/rbcurse/rcombo.rb +2 -2
- data/lib/rbcurse/rcommandwindow.rb +5 -3
- data/lib/rbcurse/rdialogs.rb +8 -2
- data/lib/rbcurse/rlistbox.rb +10 -2
- data/lib/rbcurse/rmenu.rb +4 -4
- data/lib/rbcurse/rmessagebox.rb +10 -5
- data/lib/rbcurse/rmulticontainer.rb +21 -8
- data/lib/rbcurse/rmultisplit.rb +2 -2
- data/lib/rbcurse/rmultitextview.rb +5 -3
- data/lib/rbcurse/rpopupmenu.rb +3 -3
- data/lib/rbcurse/rprogress.rb +3 -2
- data/lib/rbcurse/rscrollform.rb +2 -2
- data/lib/rbcurse/rscrollpane.rb +9 -9
- data/lib/rbcurse/rsplitpane.rb +2 -2
- data/lib/rbcurse/rsplitpane2.rb +2 -2
- data/lib/rbcurse/rtabbedpane.rb +48 -12
- data/lib/rbcurse/rtabbedwindow.rb +4 -4
- data/lib/rbcurse/rtable.rb +6 -3
- data/lib/rbcurse/rtextarea.rb +8 -8
- data/lib/rbcurse/rtextview.rb +3 -2
- data/lib/rbcurse/rtree.rb +2 -2
- data/lib/rbcurse/rviewport.rb +2 -2
- data/lib/rbcurse/rvimsplit.rb +3 -2
- data/lib/rbcurse/rwidget.rb +63 -26
- data/lib/rbcurse/scrollable.rb +1 -1
- data/lib/rbcurse/table/tablecellrenderer.rb +1 -1
- data/lib/rbcurse/table/tabledatecellrenderer.rb +1 -1
- data/lib/rbcurse/tree/treemodel.rb +1 -1
- data/lib/rbcurse/vieditable.rb +1 -0
- data/lib/ver/ncurses.rb +122 -4
- data/lib/ver/panel.rb +162 -0
- data/lib/ver/window.rb +262 -120
- metadata +19 -7
- data/examples/keytest.rb +0 -178
- data/examples/mpad2.rb +0 -156
data/lib/rbcurse/scrollable.rb
CHANGED
@@ -157,7 +157,7 @@ module Scrollable
|
|
157
157
|
list = get_content
|
158
158
|
@content_rows = list.length # rows can be added at any time
|
159
159
|
win = get_window
|
160
|
-
maxlen = @maxlen
|
160
|
+
maxlen = @maxlen || @width-2
|
161
161
|
if @bgcolor.is_a? String and @color.is_a? String
|
162
162
|
acolor = ColorMap.get_color(@color, @bgcolor)
|
163
163
|
else
|
data/lib/rbcurse/vieditable.rb
CHANGED
@@ -130,6 +130,7 @@ module ViEditable
|
|
130
130
|
# @param [int] max length of input
|
131
131
|
# @return [0, -1] return value 0 if okay, -1 if error
|
132
132
|
def input_string prompt="Insert: ", maxlen=80
|
133
|
+
#ret, str = rbgetstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config)
|
133
134
|
ret, str = rbgetstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config)
|
134
135
|
#return str if ret == 0
|
135
136
|
#return ""
|
data/lib/ver/ncurses.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require '
|
1
|
+
require 'ffi-ncurses'
|
2
|
+
#include FFI::NCurses # this pollutes many objects and invalidates method_missing
|
2
3
|
module VER
|
3
|
-
include ColorMap
|
4
4
|
module_function
|
5
5
|
|
6
6
|
# Setup ncurses, nicely documented by the curses manpages
|
@@ -12,7 +12,15 @@ include ColorMap
|
|
12
12
|
# initscr also causes the first call to refresh to clear the screen.
|
13
13
|
# If errors occur, initscr writes an appropriate error message to standard
|
14
14
|
# error and exits; otherwise, a pointer is returned to stdscr.
|
15
|
-
stdscr = Ncurses.initscr
|
15
|
+
stdscr = Ncurses.initscr ## FFI
|
16
|
+
#stdscr = FFI::NCurses.initscr
|
17
|
+
# File.open('stdscrmethrbc', 'w'){|io|
|
18
|
+
# io.puts '=' * 80
|
19
|
+
# io.puts stdscr.class
|
20
|
+
# io.puts(stdscr.public_methods)
|
21
|
+
# io.puts '=' * 80
|
22
|
+
# }
|
23
|
+
#$g_stdscr = stdscr
|
16
24
|
|
17
25
|
# Color.start if Ncurses.has_colors?
|
18
26
|
Ncurses.start_color();
|
@@ -27,7 +35,10 @@ include ColorMap
|
|
27
35
|
# (made to work locally), turning on this option causes the terminal keypad
|
28
36
|
# to be turned on when wgetch is called.
|
29
37
|
# The default value for keypad is false.
|
30
|
-
Ncurses.keypad(stdscr, bf = true)
|
38
|
+
Ncurses.keypad(stdscr.pointer, bf = true) # FFIWINDOW
|
39
|
+
#Ncurses.keypad(stdscr, bf = true)
|
40
|
+
#Ncurses.stdscr.keypad(true) # turn on keypad mode FFI
|
41
|
+
#Ncurses.keypad(stdscr, bf = 1)
|
31
42
|
|
32
43
|
# The nl and nonl routines control whether the underlying display device
|
33
44
|
# translates the return key into newline on input, and whether it
|
@@ -105,4 +116,111 @@ include ColorMap
|
|
105
116
|
$stderr.puts @last_error_message if @last_error_message
|
106
117
|
$stderr.puts @last_error, *@last_error.backtrace
|
107
118
|
end
|
119
|
+
require 'rbcurse/colormap'
|
120
|
+
include ColorMap
|
121
|
+
end
|
122
|
+
module Ncurses
|
123
|
+
extend self
|
124
|
+
FALSE = 0
|
125
|
+
TRUE = 1
|
126
|
+
module NCX
|
127
|
+
def COLS
|
128
|
+
FFI::NCurses.getmaxx(FFI::NCurses.stdscr)
|
129
|
+
end
|
130
|
+
def LINES
|
131
|
+
# #FFI::NCurses.getmaxy(FFI::NCurses.stdscr)
|
132
|
+
FFI::NCurses.LINES
|
133
|
+
end
|
134
|
+
# # supposed to be picked up at runtime
|
135
|
+
def COLORS
|
136
|
+
FFI::NCurses.COLORS
|
137
|
+
end
|
138
|
+
|
139
|
+
# jsut trying this so i can do Ncurses.stdscr.getmax
|
140
|
+
def _stdscr
|
141
|
+
FFI::NCurses.stdscr
|
142
|
+
end
|
143
|
+
# this allows me to refer to them as Ncurses::A_REVERSE as is the case everywhere
|
144
|
+
A_REVERSE = FFI::NCurses::A_REVERSE
|
145
|
+
A_STANDOUT = FFI::NCurses::A_STANDOUT
|
146
|
+
A_BOLD = FFI::NCurses::A_BOLD
|
147
|
+
A_UNDERLINE = FFI::NCurses::A_UNDERLINE
|
148
|
+
A_BLINK = FFI::NCurses::A_BLINK
|
149
|
+
A_NORMAL = FFI::NCurses::A_NORMAL
|
150
|
+
KEY_F1 = FFI::NCurses::KEY_F1
|
151
|
+
end
|
152
|
+
include NCX
|
153
|
+
extend NCX
|
154
|
+
# i think we can knock this off
|
155
|
+
def method_missing meth, *args
|
156
|
+
if (FFI::NCurses.respond_to?(meth))
|
157
|
+
FFI::NCurses.send meth, *args
|
158
|
+
end
|
159
|
+
end
|
160
|
+
# FFINC.constants.each { |e| Ncurses.const_set(e, FFINC.const_get(e) ) }
|
161
|
+
def const_missing name
|
162
|
+
val = FFI::NCurses.const_get(name)
|
163
|
+
const_set(name, val)
|
164
|
+
return val
|
165
|
+
end
|
166
|
+
|
167
|
+
# This is a window pointer wrapper, to be used for stdscr and others.
|
168
|
+
# Ideally ffi-ncurses should do this, if it returns a pointer, I'll do this.
|
169
|
+
class FFIWINDOW
|
170
|
+
attr_accessor :pointer
|
171
|
+
def initialize(*args, &block)
|
172
|
+
if block_given?
|
173
|
+
@pointer = args.first
|
174
|
+
else
|
175
|
+
@pointer = FFI::NCurses.newwin(*args)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
def method_missing(name, *args)
|
179
|
+
name = name.to_s
|
180
|
+
if (name[0,2] == "mv")
|
181
|
+
test_name = name.dup
|
182
|
+
test_name[2,0] = "w" # insert "w" after"mv"
|
183
|
+
if (FFI::NCurses.respond_to?(test_name))
|
184
|
+
return FFI::NCurses.send(test_name, @pointer, *args)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
test_name = "w" + name
|
188
|
+
if (FFI::NCurses.respond_to?(test_name))
|
189
|
+
return FFI::NCurses.send(test_name, @pointer, *args)
|
190
|
+
end
|
191
|
+
FFI::NCurses.send(name, @pointer, *args)
|
192
|
+
end
|
193
|
+
def respond_to?(name)
|
194
|
+
name = name.to_s
|
195
|
+
if (name[0,2] == "mv" && FFI::NCurses.respond_to?("mvw" + name[2..-1]))
|
196
|
+
return true
|
197
|
+
end
|
198
|
+
FFI::NCurses.respond_to?("w" + name) || FFI::NCurses.respond_to?(name)
|
199
|
+
end
|
200
|
+
def del
|
201
|
+
FFI::NCurses.delwin(@pointer)
|
202
|
+
end
|
203
|
+
alias delete del
|
204
|
+
end
|
205
|
+
# if ffi-ncurses returns a pointer wrap it.
|
206
|
+
# or we can check for whether it responds_to? refresh and getch
|
207
|
+
def self.initscr
|
208
|
+
#@stdscr = Ncurses::FFIWINDOW.new(FFI::NCurses.initscr) { }
|
209
|
+
stdscr = FFI::NCurses.initscr
|
210
|
+
if stdscr.is_a? FFI::Pointer
|
211
|
+
@stdscr = Ncurses::FFIWINDOW.new(stdscr) { }
|
212
|
+
else
|
213
|
+
@stdscr = stdscr
|
214
|
+
end
|
215
|
+
end
|
216
|
+
def self.stdscr
|
217
|
+
@stdscr
|
218
|
+
end
|
219
|
+
# commented off on 2011-09-15 FFIWINDOW results in errors
|
220
|
+
# class << self
|
221
|
+
# def method_missing(method, *args, &block)
|
222
|
+
# FFI::NCurses.send(method, *args, &block)
|
223
|
+
# end
|
224
|
+
# end
|
225
|
+
# ---
|
108
226
|
end
|
data/lib/ver/panel.rb
ADDED
@@ -0,0 +1,162 @@
|
|
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
|
data/lib/ver/window.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'ver/ncurses'
|
2
|
+
require 'ver/panel'
|
2
3
|
module VER
|
3
4
|
class Window
|
4
5
|
attr_reader :width, :height, :top, :left
|
@@ -13,12 +14,15 @@ module VER
|
|
13
14
|
@visible = true
|
14
15
|
reset_layout(layout)
|
15
16
|
|
16
|
-
|
17
|
-
|
17
|
+
#@window = Ncurses::WINDOW.new(height, width, top, left)
|
18
|
+
#@window = Ncurses.newwin(height, width, top, left) # added FFI 2011-09-6
|
19
|
+
@window = FFI::NCurses.newwin(height, width, top, left) # added FFI 2011-09-6
|
20
|
+
#@panel = Ncurses::Panel.new_panel(@window)
|
21
|
+
@panel = Ncurses::Panel.new(@window) # added FFI 2011-09-6
|
18
22
|
## eeks XXX next line will wreak havoc when multiple windows opened like a mb or popup
|
19
23
|
#$error_message_row = $status_message_row = Ncurses.LINES-1
|
20
24
|
$error_message_row ||= Ncurses.LINES-1
|
21
|
-
$error_message_col ||= 1
|
25
|
+
$error_message_col ||= 1 # ask (bottomline) uses 0 as default so you can have mismatch. XXX
|
22
26
|
init_vars
|
23
27
|
|
24
28
|
|
@@ -56,9 +60,13 @@ module VER
|
|
56
60
|
def resize_with(layout)
|
57
61
|
$log.debug " DARN ! This awready duz a resize!! if h or w or even top or left changed!!! XXX"
|
58
62
|
reset_layout(layout)
|
59
|
-
|
63
|
+
#@window.wresize(height, width)
|
64
|
+
wresize(height, width)
|
65
|
+
#FFI::NCurses.wresize(@window,height, width)
|
60
66
|
# this is dicey since we often change top and left in pads only for panning !! XXX
|
61
|
-
|
67
|
+
#@window.mvwin(top, left)
|
68
|
+
mvwin(top, left)
|
69
|
+
#FFI::NCurses.mvwin(@window, top, left)
|
62
70
|
end
|
63
71
|
|
64
72
|
%w[width height top left].each do |side|
|
@@ -70,6 +78,21 @@ module VER
|
|
70
78
|
end"
|
71
79
|
)
|
72
80
|
end
|
81
|
+
# ADDED DUE TO FFI
|
82
|
+
def wrefresh
|
83
|
+
Ncurses.wrefresh(@window)
|
84
|
+
end
|
85
|
+
def delwin # 2011-09-7
|
86
|
+
Ncurses.delwin(@window)
|
87
|
+
end
|
88
|
+
def attron *args
|
89
|
+
FFI::NCurses.wattron @window, *args
|
90
|
+
end
|
91
|
+
def attroff *args
|
92
|
+
FFI::NCurses.wattroff @window, *args
|
93
|
+
end
|
94
|
+
#
|
95
|
+
# ## END FFI
|
73
96
|
|
74
97
|
def resize
|
75
98
|
resize_with(@layout)
|
@@ -92,16 +115,64 @@ module VER
|
|
92
115
|
def x=(n) move(y, n) end
|
93
116
|
def y=(n) move(n, x) end
|
94
117
|
|
95
|
-
def move(y, x)
|
96
|
-
return unless @visible
|
97
|
-
|
98
|
-
|
118
|
+
#def move(y, x)
|
119
|
+
#return unless @visible
|
120
|
+
## Log.debug([y, x] => caller[0,4])
|
121
|
+
##@window.wmove(y, x) # bombing since ffi-ncurses 0.4.0 (maybe it was never called
|
122
|
+
##earlier. was crashing in appemail.rb testchoose.
|
123
|
+
#wmove y,x # can alias it
|
124
|
+
#end
|
125
|
+
# since include FFI is taking over, i need to force it here. not going into
|
126
|
+
# method_missing
|
127
|
+
def wmove y,x
|
128
|
+
#Ncurses.wmove @window, y, x
|
129
|
+
FFI::NCurses.wmove @window, y, x
|
130
|
+
end
|
131
|
+
alias :move :wmove
|
132
|
+
|
133
|
+
# while moving from ncurses-ruby to FFI need to pass window pointer
|
134
|
+
# for w methods as well as mvw - NOT COMING HERE due to include FFI
|
135
|
+
def OLDmethod_missing(meth, *args)
|
136
|
+
$log.debug " WWWW method missing #{meth} "
|
137
|
+
if meth[0,1]=="w" || meth[0,3] == "mvw"
|
138
|
+
$log.debug " WWWW method missing #{meth} adding window in call "
|
139
|
+
#return @window.send(meth, @window, *args)
|
140
|
+
return FFI::NCurses.send(meth, @window, *args)
|
141
|
+
else
|
142
|
+
end
|
143
|
+
if @window
|
144
|
+
if @window.respond_to? meth
|
145
|
+
@window.send(meth, *args)
|
146
|
+
else
|
147
|
+
FFI::NCurses.send( meth, *args)
|
148
|
+
end
|
149
|
+
else
|
150
|
+
FFI::NCurses.send( meth, *args)
|
151
|
+
end
|
99
152
|
end
|
100
153
|
|
101
|
-
def method_missing(
|
102
|
-
|
154
|
+
def method_missing(name, *args)
|
155
|
+
name = name.to_s
|
156
|
+
if (name[0,2] == "mv")
|
157
|
+
test_name = name.dup
|
158
|
+
test_name[2,0] = "w" # insert "w" after"mv"
|
159
|
+
if (FFI::NCurses.respond_to?(test_name))
|
160
|
+
return FFI::NCurses.send(test_name, @window, *args)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
test_name = "w" + name
|
164
|
+
if (FFI::NCurses.respond_to?(test_name))
|
165
|
+
return FFI::NCurses.send(test_name, @window, *args)
|
166
|
+
end
|
167
|
+
FFI::NCurses.send(name, @window, *args)
|
168
|
+
end
|
169
|
+
def respond_to?(name)
|
170
|
+
name = name.to_s
|
171
|
+
if (name[0,2] == "mv" && FFI::NCurses.respond_to?("mvw" + name[2..-1]))
|
172
|
+
return true
|
173
|
+
end
|
174
|
+
FFI::NCurses.respond_to?("w" + name) || FFI::NCurses.respond_to?(name)
|
103
175
|
end
|
104
|
-
|
105
176
|
def print(string, width = width)
|
106
177
|
return unless visible?
|
107
178
|
@window.waddnstr(string.to_s, width)
|
@@ -132,7 +203,7 @@ module VER
|
|
132
203
|
print(strings.join("\n") << "\n")
|
133
204
|
end
|
134
205
|
|
135
|
-
def
|
206
|
+
def _refresh
|
136
207
|
return unless visible?
|
137
208
|
@window.refresh
|
138
209
|
end
|
@@ -156,7 +227,8 @@ module VER
|
|
156
227
|
end
|
157
228
|
|
158
229
|
def getch
|
159
|
-
c = @window.getch
|
230
|
+
#c = @window.getch
|
231
|
+
c = Ncurses.getch
|
160
232
|
#if c == Ncurses::KEY_RESIZE
|
161
233
|
|
162
234
|
rescue Interrupt => ex
|
@@ -170,7 +242,8 @@ module VER
|
|
170
242
|
def getchar
|
171
243
|
while 1
|
172
244
|
ch = getch
|
173
|
-
|
245
|
+
$log.debug "window getchar() GOT: #{ch}" if ch != -1
|
246
|
+
sf = @stack.first
|
174
247
|
if ch == -1
|
175
248
|
# the returns escape 27 if no key followed it, so its SLOW if you want only esc
|
176
249
|
if @stack.first == 27
|
@@ -184,12 +257,30 @@ module VER
|
|
184
257
|
@stack.clear
|
185
258
|
return ch
|
186
259
|
when 3
|
187
|
-
$log.
|
260
|
+
$log.warn " SHOULD NOT COME HERE getchar():#{@stack}"
|
188
261
|
end
|
262
|
+
#elsif [181, 179, 178].include? @stack.first
|
263
|
+
elsif @stack == [181] || @stack == [179] || @stack == [178]
|
264
|
+
ch = @stack.first
|
265
|
+
@stack.clear
|
266
|
+
return ch
|
267
|
+
elsif @stack == [179,49] # someone trying to spoof S-F9 with M3, 1
|
268
|
+
ch = @stack.shift
|
269
|
+
return ch
|
270
|
+
end
|
271
|
+
# possibly a 49 left over from M3-1
|
272
|
+
unless @stack.empty?
|
273
|
+
if @stack.size == 1
|
274
|
+
@stack.clear
|
275
|
+
return sf
|
276
|
+
end
|
277
|
+
$log.warn "something on stack getchar(): #{@stack} "
|
189
278
|
end
|
279
|
+
# comemnt after testing keys since this will be called a lot, even stack.clear is called a lot
|
280
|
+
$log.warn "ERROR CLEARING STACK WITH STUFF ON IT getchar():#{@stack}" if ($log.debug? && !@stack.empty?)
|
190
281
|
@stack.clear
|
191
282
|
next
|
192
|
-
end
|
283
|
+
end # -1
|
193
284
|
# this is the ALT combination
|
194
285
|
if @stack.first == 27
|
195
286
|
# experimental. 2 escapes in quick succession to make exit faster
|
@@ -198,7 +289,7 @@ module VER
|
|
198
289
|
return ch
|
199
290
|
end
|
200
291
|
# possible F1..F3 on xterm-color
|
201
|
-
if ch == 79
|
292
|
+
if ch == 79 || ch == 91
|
202
293
|
#$log.debug " got 27, #{ch}, waiting for one more"
|
203
294
|
@stack << ch
|
204
295
|
next
|
@@ -227,16 +318,52 @@ module VER
|
|
227
318
|
# the usual Meta combos. (alt)
|
228
319
|
ch = 128 + ch
|
229
320
|
@stack.clear
|
321
|
+
# these correspond to M-5, M2 and M3 but can also be C-left. C-rt. S-F5-S-F10
|
322
|
+
if ch == 181 || ch == 178 || ch == 179
|
323
|
+
@stack << ch
|
324
|
+
next
|
325
|
+
end
|
230
326
|
return ch
|
231
|
-
|
327
|
+
elsif @stack.first == 181
|
328
|
+
if ch == 68
|
329
|
+
ch = C_LEFT
|
330
|
+
@stack.clear; return ch
|
331
|
+
elsif ch == 67
|
332
|
+
ch = C_RIGHT
|
333
|
+
@stack.clear; return ch
|
334
|
+
else
|
335
|
+
$log.error "We ate a key 181 M-5 expecting C-L or C-r, but got #{ch}. I can only return one "
|
336
|
+
@stack.clear; # should we ungetch the ch FIXME
|
337
|
+
return 181
|
338
|
+
end
|
339
|
+
elsif @stack == [179, 49]
|
340
|
+
if ch == 126
|
341
|
+
@stack.clear;
|
342
|
+
return S_F9
|
343
|
+
else
|
344
|
+
# FIXME
|
345
|
+
$log.error "getchar: We ate 2 keys 179 M-?, 49 expecting S-F9, but got #{ch}. I can only return one "
|
346
|
+
end
|
347
|
+
elsif sf == 179
|
348
|
+
if ch == 49
|
349
|
+
@stack << ch
|
350
|
+
next
|
351
|
+
else
|
352
|
+
#@stack.clear; # should i ungetch FIXME
|
353
|
+
@stack.shift # some combination like M-3 2
|
354
|
+
@stack << ch
|
355
|
+
return 179
|
356
|
+
end
|
357
|
+
elsif sf == 178
|
358
|
+
end # stack.first == 27
|
232
359
|
# append a 27 to stack, actually one can use a flag too
|
233
360
|
if ch == 27
|
234
361
|
@stack << 27
|
235
362
|
next
|
236
363
|
end
|
237
364
|
return ch
|
238
|
-
end
|
239
|
-
end
|
365
|
+
end # while
|
366
|
+
end # def
|
240
367
|
|
241
368
|
def clear
|
242
369
|
# return unless visible?
|
@@ -247,13 +374,19 @@ module VER
|
|
247
374
|
# setup and reset
|
248
375
|
|
249
376
|
def reset_layout(layout)
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
377
|
+
case layout
|
378
|
+
when Array
|
379
|
+
@height, @width, @top, @left = *layout
|
380
|
+
when Hash
|
381
|
+
@layout = layout
|
382
|
+
|
383
|
+
[:height, :width, :top, :left].each do |name|
|
384
|
+
instance_variable_set("@#{name}", layout_value(name))
|
385
|
+
end
|
254
386
|
end
|
255
387
|
end
|
256
388
|
|
389
|
+
# removed ref to default_for since giving error in FFI 2011-09-8
|
257
390
|
def layout_value(name)
|
258
391
|
value = @layout[name]
|
259
392
|
default = default_for(name)
|
@@ -262,12 +395,15 @@ module VER
|
|
262
395
|
return (value || default).to_i
|
263
396
|
end
|
264
397
|
|
398
|
+
# this gives error since stdscr is only a pointer at this time
|
265
399
|
def default_for(name)
|
266
400
|
case name
|
267
401
|
when :height, :top
|
268
|
-
Ncurses.stdscr.getmaxy
|
402
|
+
#Ncurses.stdscr.getmaxy(stdscr)
|
403
|
+
FFI::NCurses.LINES
|
269
404
|
when :width, :left
|
270
|
-
Ncurses.stdscr.getmaxx
|
405
|
+
#Ncurses.stdscr.getmaxx(stdscr)
|
406
|
+
FFI::NCurses.COLS
|
271
407
|
else
|
272
408
|
0
|
273
409
|
end
|
@@ -276,19 +412,19 @@ module VER
|
|
276
412
|
# Ncurses panel
|
277
413
|
|
278
414
|
def hide
|
279
|
-
Ncurses::Panel.hide_panel @panel
|
415
|
+
Ncurses::Panel.hide_panel @panel.pointer
|
280
416
|
Ncurses.refresh # wnoutrefresh
|
281
417
|
@visible = false
|
282
418
|
end
|
283
419
|
|
284
420
|
def show
|
285
|
-
Ncurses::Panel.show_panel @panel
|
421
|
+
Ncurses::Panel.show_panel @panel.pointer
|
286
422
|
Ncurses.refresh # wnoutrefresh
|
287
423
|
@visible = true
|
288
424
|
end
|
289
425
|
|
290
426
|
def on_top
|
291
|
-
Ncurses::Panel.top_panel @panel
|
427
|
+
Ncurses::Panel.top_panel @panel.pointer
|
292
428
|
wnoutrefresh
|
293
429
|
end
|
294
430
|
|
@@ -306,8 +442,10 @@ module VER
|
|
306
442
|
$log.debug "win destroy start"
|
307
443
|
|
308
444
|
#@panel = @window.panel if @window
|
309
|
-
Ncurses::Panel
|
310
|
-
@
|
445
|
+
# changed Ncurses::Panel to Ncurses::Panel on 2011-09-8 when moved to FFI
|
446
|
+
Ncurses::Panel.del_panel(@panel.pointer) if !@panel.nil? # ADDED FFI pointer 2011-09-7
|
447
|
+
#@window.delwin(@window) if !@window.nil? # added FFI 2011-09-7
|
448
|
+
delwin() if !@window.nil? # added FFI 2011-09-7
|
311
449
|
$log.debug "win destroy end"
|
312
450
|
end
|
313
451
|
##
|
@@ -320,7 +458,7 @@ module VER
|
|
320
458
|
# @ param att - ncurses attribute: normal, bold, reverse, blink,
|
321
459
|
# underline
|
322
460
|
def printstring(r,c,string, color, att = Ncurses::A_NORMAL)
|
323
|
-
|
461
|
+
prv_printstring(r,c,string, color, att )
|
324
462
|
end
|
325
463
|
|
326
464
|
## name changed from printstring to prv_prinstring
|
@@ -341,15 +479,15 @@ module VER
|
|
341
479
|
att = Ncurses::A_REVERSE
|
342
480
|
end
|
343
481
|
|
344
|
-
|
482
|
+
wattron(Ncurses.COLOR_PAIR(color) | att)
|
345
483
|
# we should not print beyond window coordinates
|
346
484
|
# trying out on 2009-01-03 19:29
|
347
|
-
width = Ncurses.COLS
|
485
|
+
#width = Ncurses.COLS
|
348
486
|
# the next line won't ensure we don't write outside some bounds like table
|
349
487
|
#string = string[0..(width-c)] if c + string.length > width
|
350
488
|
#$log.debug "PRINT len:#{string.length}, #{Ncurses.COLS}, #{r}, #{c} w: #{@window} "
|
351
|
-
|
352
|
-
|
489
|
+
mvwprintw(r, c, "%s", :string, string);
|
490
|
+
wattroff(Ncurses.COLOR_PAIR(color) | att)
|
353
491
|
end
|
354
492
|
# added by rk 2008-11-29 19:01
|
355
493
|
# Since these methods write directly to window they are not advised
|
@@ -358,7 +496,7 @@ module VER
|
|
358
496
|
# 2010-09-13 00:22 WE should not use these any longer.
|
359
497
|
# Application should create a label and map a Variable named
|
360
498
|
# $errormessage to it. We should only update the Variable
|
361
|
-
def print_error_message text=$error_message
|
499
|
+
def print_error_message text=$error_message.get_value
|
362
500
|
r = $error_message_row || Ncurses.LINES-1
|
363
501
|
c = $error_message_col || (Ncurses.COLS-text.length)/2
|
364
502
|
|
@@ -388,15 +526,15 @@ module VER
|
|
388
526
|
##
|
389
527
|
# CAUTION : FOR MESSAGEBOXES ONLY !!!! XXX
|
390
528
|
def print_border_mb row, col, height, width, color, attr
|
391
|
-
mvwaddch row, col, ACS_ULCORNER
|
392
|
-
mvwhline( row, col+1, ACS_HLINE, width-6)
|
529
|
+
mvwaddch row, col, Ncurses::ACS_ULCORNER
|
530
|
+
mvwhline( row, col+1, Ncurses::ACS_HLINE, width-6)
|
393
531
|
mvwaddch row, col+width-5, Ncurses::ACS_URCORNER
|
394
|
-
mvwvline( row+1, col, ACS_VLINE, height-4)
|
532
|
+
mvwvline( row+1, col, Ncurses::ACS_VLINE, height-4)
|
395
533
|
|
396
534
|
mvwaddch row+height-3, col, Ncurses::ACS_LLCORNER
|
397
|
-
mvwhline(row+height-3, col+1, ACS_HLINE, width-6)
|
535
|
+
mvwhline(row+height-3, col+1, Ncurses::ACS_HLINE, width-6)
|
398
536
|
mvwaddch row+height-3, col+width-5, Ncurses::ACS_LRCORNER
|
399
|
-
mvwvline( row+1, col+width-5, ACS_VLINE, height-4)
|
537
|
+
mvwvline( row+1, col+width-5, Ncurses::ACS_VLINE, height-4)
|
400
538
|
end
|
401
539
|
##
|
402
540
|
# prints a border around a widget, CLEARING the area.
|
@@ -422,9 +560,9 @@ module VER
|
|
422
560
|
end
|
423
561
|
|
424
562
|
|
425
|
-
|
426
|
-
|
427
|
-
|
563
|
+
## print just the border, no cleanup
|
564
|
+
#+ Earlier, we would clean up. Now in some cases, i'd like
|
565
|
+
#+ to print border over what's been done.
|
428
566
|
# XXX this reduces 1 from width but not height !!! FIXME
|
429
567
|
def prv_print_border_only row, col, height, width, color, att=Ncurses::A_NORMAL
|
430
568
|
att ||= Ncurses::A_NORMAL
|
@@ -440,20 +578,20 @@ module VER
|
|
440
578
|
when 'reverse'
|
441
579
|
att = Ncurses::A_REVERSE
|
442
580
|
end
|
443
|
-
|
444
|
-
mvwaddch
|
445
|
-
mvwhline( row, col+1, ACS_HLINE, width-2)
|
581
|
+
wattron(Ncurses.COLOR_PAIR(color) | att)
|
582
|
+
mvwaddch row, col, Ncurses::ACS_ULCORNER
|
583
|
+
mvwhline( row, col+1, Ncurses::ACS_HLINE, width-2)
|
446
584
|
mvwaddch row, col+width-1, Ncurses::ACS_URCORNER
|
447
|
-
mvwvline( row+1, col, ACS_VLINE, height-1)
|
585
|
+
mvwvline( row+1, col, Ncurses::ACS_VLINE, height-1)
|
448
586
|
|
449
587
|
mvwaddch row+height-0, col, Ncurses::ACS_LLCORNER
|
450
|
-
mvwhline(row+height-0, col+1, ACS_HLINE, width-2)
|
588
|
+
mvwhline(row+height-0, col+1, Ncurses::ACS_HLINE, width-2)
|
451
589
|
mvwaddch row+height-0, col+width-1, Ncurses::ACS_LRCORNER
|
452
|
-
mvwvline( row+1, col+width-1, ACS_VLINE, height-1)
|
453
|
-
|
590
|
+
mvwvline( row+1, col+width-1, Ncurses::ACS_VLINE, height-1)
|
591
|
+
wattroff(Ncurses.COLOR_PAIR(color) | att)
|
454
592
|
end
|
455
|
-
|
456
|
-
|
593
|
+
# added RK 2009-10-08 23:57 for tabbedpanes
|
594
|
+
# THIS IS EXPERIMENTAL -
|
457
595
|
# Acco to most sources, derwin and subwin are not thoroughly tested, avoid usage
|
458
596
|
# subwin moving and resizing not functioning.
|
459
597
|
def derwin(layout)
|
@@ -472,6 +610,9 @@ module VER
|
|
472
610
|
$log.debug " #{self} EXP: returning a subwin in derwin: #{v} "
|
473
611
|
return v
|
474
612
|
end
|
613
|
+
# This used to return an Ncurses window object, and you could call methods on it
|
614
|
+
# Now it returns a FFI::NCurses.window pointer which you cannot call methods on.
|
615
|
+
# You have to pass it to FFI::NCurses.<method>
|
475
616
|
def get_window; @window; end
|
476
617
|
def to_s; @name || self; end
|
477
618
|
# use in place of mvwhline if your widget could be using a pad or window
|
@@ -493,42 +634,42 @@ module VER
|
|
493
634
|
unless @bottomline
|
494
635
|
require 'forwardable'
|
495
636
|
require 'rbcurse/extras/bottomline'
|
496
|
-
@bottomline = Bottomline.new self, $error_message_row
|
637
|
+
@bottomline = RubyCurses::Bottomline.new self, $error_message_row
|
497
638
|
@bottomline.name = "window.rb"
|
498
639
|
extend Forwardable
|
499
640
|
def_delegators :@bottomline, :ask, :say, :agree, :choose
|
500
641
|
end
|
501
642
|
end
|
502
643
|
end
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
def initialize(parent, layout)
|
517
|
-
@visible = true
|
518
|
-
reset_layout(layout)
|
519
|
-
|
520
|
-
@parent = parent
|
521
|
-
#@subwin = @parent.get_window().derwin(@height, @width, @top, @left)
|
522
|
-
@subwin = @parent.get_window().subwin(@height, @width, @top, @left)
|
523
|
-
$log.debug "SUBWIN init #{@height} #{@width} #{@top} #{@left} "
|
524
|
-
#$log.debug "SUBWIN init #{@subwin.getbegx} #{@subwin.getbegy} #{@top} #{@left} "
|
525
|
-
@panel = Ncurses::Panel.new_panel(@subwin)
|
526
|
-
|
527
|
-
@window = @subwin # makes more mthods available
|
528
|
-
init_vars
|
644
|
+
##
|
645
|
+
# added RK 2009-10-08 23:57 for tabbedpanes
|
646
|
+
# THIS IS EXPERIMENTAL -
|
647
|
+
# I have not called super in the initializer so any methods you try on subwin
|
648
|
+
# that exist in the superclass which use @window will bomb
|
649
|
+
# @since 0.1.3
|
650
|
+
class SubWindow < VER::Window
|
651
|
+
attr_reader :width, :height, :top, :left
|
652
|
+
attr_accessor :layout
|
653
|
+
attr_reader :panel # XXX reader requires so he can del it in end
|
654
|
+
attr_reader :subwin #
|
655
|
+
attr_reader :parent #
|
529
656
|
|
530
|
-
|
531
|
-
|
657
|
+
def initialize(parent, layout)
|
658
|
+
@visible = true
|
659
|
+
reset_layout(layout)
|
660
|
+
|
661
|
+
@parent = parent
|
662
|
+
#@subwin = @parent.get_window().derwin(@height, @width, @top, @left)
|
663
|
+
@subwin = @parent.get_window().subwin(@height, @width, @top, @left)
|
664
|
+
$log.debug "SUBWIN init #{@height} #{@width} #{@top} #{@left} "
|
665
|
+
#$log.debug "SUBWIN init #{@subwin.getbegx} #{@subwin.getbegy} #{@top} #{@left} "
|
666
|
+
@panel = Ncurses::Panel.new_panel(@subwin)
|
667
|
+
|
668
|
+
@window = @subwin # makes more mthods available
|
669
|
+
init_vars
|
670
|
+
|
671
|
+
end
|
672
|
+
# no need really now
|
532
673
|
def reset_layout layout
|
533
674
|
@layout = layout # 2010-02-13 22:23
|
534
675
|
@height = layout[:height]
|
@@ -541,11 +682,12 @@ module VER
|
|
541
682
|
# or should window do it for all subwins, or would we want to wait that long ?
|
542
683
|
$log.debug "subwin destroy"
|
543
684
|
|
544
|
-
Ncurses::Panel.del_panel(
|
545
|
-
|
685
|
+
Ncurses::Panel.del_panel(panel.pointer) if !panel.nil? # FFI
|
686
|
+
#@window.delwin(@window) if !@window.nil? # added FFI 2011-09-7
|
687
|
+
delwin if !@window.nil? # added FFI 2011-09-7
|
546
688
|
end
|
547
689
|
end
|
548
|
-
|
690
|
+
|
549
691
|
##
|
550
692
|
# Pad
|
551
693
|
# This is EXPERIMENTAL
|
@@ -652,7 +794,7 @@ module VER
|
|
652
794
|
|
653
795
|
## added user setting screens max row and col (e.g splitpanes first component)
|
654
796
|
def set_screen_max_row_col mr, mc
|
655
|
-
|
797
|
+
$log.debug "#{@name} set_screen_max_row_col #{mr},#{mc}. earlier #{@screen_maxrow}, #{@screen_maxcol} "
|
656
798
|
# added || check on 2010-01-09 18:39 since crashing if mr > sh + top ..
|
657
799
|
# I removed the check, since it results in a blank area on screen since the
|
658
800
|
# widget has not expanded itself. Without the check it will crash on copywin so you
|
@@ -685,7 +827,7 @@ module VER
|
|
685
827
|
def smaxcol
|
686
828
|
#$log.debug " ... niside smaxcol #{@swidth} + #{@left} -1 "
|
687
829
|
#@swidth + @left -1
|
688
|
-
# $log.debug " ... niside smaxcol #{@swidth} + #{@left} -1 - #{@pmincol} "
|
830
|
+
# $log.debug " ... niside smaxcol #{@swidth} + #{@left} -1 - #{@pmincol} "
|
689
831
|
@screen_maxcol || @swidth + @left -1 - @pmincol
|
690
832
|
end
|
691
833
|
##
|
@@ -725,12 +867,12 @@ module VER
|
|
725
867
|
osmr = @otherwin.smaxrow() rescue osh # TRYING for windows
|
726
868
|
osmc = @otherwin.smaxcol() rescue osw
|
727
869
|
if smr >= osmr
|
728
|
-
|
870
|
+
$log.debug " adjusted smr from #{smr} to #{osmr} -1 causing issues in viewfooter"
|
729
871
|
smr = osmr-1 # XXX causing issues in viewport, wont print footer with this
|
730
872
|
end
|
731
873
|
if smr > @sheight + @top -1 -@pminrow # 2010-01-17 13:27
|
732
|
-
|
733
|
-
|
874
|
+
smr = @sheight + @top -1 -@pminrow
|
875
|
+
$log.debug " adjusted smr to #{smr} to prevent crash "
|
734
876
|
end
|
735
877
|
smc = smaxcol()
|
736
878
|
$log.debug " SMC original = #{smc} "
|
@@ -746,44 +888,44 @@ module VER
|
|
746
888
|
# dang, this is coming up a lot. 2010-01-16 20:34
|
747
889
|
# the second scrollpane was one row too large in testsplit3a.rb
|
748
890
|
if smr - @top > @padheight
|
749
|
-
|
750
|
-
|
891
|
+
$log.debug " fixing smr to padheight 2010-01-16 20:35 HOPE THIS DOESNT BREAK ANYTHING"
|
892
|
+
smr = @padheight
|
751
893
|
end
|
752
894
|
@pminrow = 0 if @pminrow < 0
|
753
895
|
@pmincol = 0 if @pmincol < 0
|
754
896
|
$log.debug " COPYING #{self.name} to #{@otherwin.name} "
|
755
897
|
$log.debug " calling copy pad #{@pminrow} #{@pmincol}, #{@top} #{@left}, #{smr} #{smc} self #{self.name} "
|
756
898
|
$log.debug " calling copy pad H: #{@height} W: #{@width}, PH #{@padheight} PW #{@padwidth} WIN:#{@window} "
|
757
|
-
# $log.debug " -otherwin target copy pad #{@otherwin.pminrow} #{@otherwin.pmincol}, #{@otherwin.top} #{@otherwin.left}, #{osmr} #{osmc} OTHERWIN:#{@otherwin.name} "
|
899
|
+
# $log.debug " -otherwin target copy pad #{@otherwin.pminrow} #{@otherwin.pmincol}, #{@otherwin.top} #{@otherwin.left}, #{osmr} #{osmc} OTHERWIN:#{@otherwin.name} "
|
758
900
|
ret="-"
|
759
901
|
#if ret == -1
|
760
|
-
#x XXX $log.debug " #{ret} otherwin copy pad #{@otherwin.pminrow} #{@otherwin.pmincol}, #{@otherwin.top} #{@otherwin.left}, #{osmr} #{osmc} "
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
902
|
+
#x XXX $log.debug " #{ret} otherwin copy pad #{@otherwin.pminrow} #{@otherwin.pmincol}, #{@otherwin.top} #{@otherwin.left}, #{osmr} #{osmc} "
|
903
|
+
$log.debug " #{ret} otherwin copy pad H: #{osh} W: #{osw}"
|
904
|
+
if @top >= osh
|
905
|
+
$log.debug " #{ret} ERROR top exceeds other ht #{@top} H: #{osh} "
|
906
|
+
end
|
907
|
+
if @left >= osw
|
908
|
+
$log.debug " #{ret} ERROR left exceeds other wt #{@left} W: #{osw} "
|
909
|
+
end
|
910
|
+
if smr >= osh
|
911
|
+
$log.debug " #{ret} ERROR smrow exceeds other ht #{smr} H: #{osh} "
|
912
|
+
smr = osh() -1 # testing 2010-01-31 21:47 , again 2010-02-05 20:22
|
913
|
+
end
|
914
|
+
if smc >= osw
|
915
|
+
$log.debug " #{ret} ERROR smcol exceeds other wt #{smc} W: #{osw} "
|
916
|
+
end
|
917
|
+
if smc - @left > @padwidth
|
918
|
+
$log.debug " #{ret} ERROR smcol - left exceeds padwidth #{smc}- #{@left} PW: #{@padwidth} "
|
919
|
+
end
|
920
|
+
if smr - @top > @padheight
|
921
|
+
$log.debug " #{ret} ERROR smr - top exceeds padheight #{smr}- #{@top} PH: #{@padheight} "
|
922
|
+
end
|
781
923
|
ret = @window.copywin(@otherwin.get_window,@pminrow,@pmincol, @top, @left, smr, smc, 0)
|
782
924
|
$log.debug " copywin ret #{ret} "
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
925
|
+
# 2010-01-11 19:42 one more cause of -1 coming is that padheight (actual height which never
|
926
|
+
# changes unless pad increases) or padwidth is smaller than area being printed. Solution: increase
|
927
|
+
# buffer by increasing widgets w or h. smc - left should not exceed padwidth. smr-top should not
|
928
|
+
# exceed padheight
|
787
929
|
#end
|
788
930
|
@modified = false
|
789
931
|
return ret
|