Class: Ncurses::Panel
Overview
making minimal changes as per ffi-ncurses 0.4.0 which implements panels module VER # too many places call Ncurses::Panel
Class Method Summary collapse
- .method_missing(name, *args) ⇒ Object
-
.update_panels ⇒ Object
these will be used when you say Ncurses::Panel.del_panel(@panel.pointer) You could directly say FFI:NCurses or even @panel.del_panel.
Instance Method Summary collapse
-
#bottom_panel ⇒ Object
(also: #bottom)
Puts panel below all other panels.
-
#del_panel ⇒ Object
(also: #del, #delete)
Remove the panel from the stack and deallocate the PANEL structure.
-
#hide_panel ⇒ Object
(also: #hide)
Removes the given panel from the panel stack and thus hides it from view.
-
#initialize(window) ⇒ Panel
constructor
extend FFI::Library.
-
#move_panel(starty = 0, startx = 0) ⇒ Object
(also: #move)
Move the panel window so that its upper-left corner is at (
starty
,startx
). -
#panel_above ⇒ Object
(also: #above)
Returns pointer to the panel above.
-
#panel_below ⇒ Object
(also: #below)
Return a pointer to the panel just below panel.
-
#panel_hidden ⇒ Object
(also: #hidden?)
Returns true if the panel is in the panel stack, false if not.
-
#panel_userptr ⇒ Object
(also: #userptr)
Returns the user pointer for a given panel.
-
#panel_window ⇒ Object
(also: #window)
Returns a pointer to the window of the given panel.
- #pointer ⇒ Object
-
#replace_panel(window) ⇒ Object
(also: #replace)
Replace the window of the panel with the given window.
-
#set_panel_userptr(user_pointer) ⇒ Object
(also: #userptr=)
sets the panel’s user pointer.
-
#show_panel ⇒ Object
(also: #show)
Makes hidden panel visible by placing it on the top of the stack.
-
#top_panel ⇒ Object
(also: #top)
Put the visible panel on top of all other panels in the stack.
Constructor Details
#initialize(window) ⇒ Panel
extend FFI::Library
# use RUBY_FFI_NCURSES_LIB to specify exactly which lib you want, e.g.
# ncursesw, XCurses (from PDCurses)
if ENV["RUBY_FFI_PANEL_LIB"].to_s != ""
LIB_HANDLE = ffi_lib( ENV["RUBY_FFI_PANEL_LIB"] ).first
else
# next works but not when ENV, maybe since 'panel' not in code above
LIB_HANDLE = ffi_lib( 'panel', '/opt/local/lib/libpanelw.5.dylib' ).first
#LIB_HANDLE = ffi_lib( 'panel', 'libpanel' ).first # this also works
end
functions = [
[:new_panel, [:pointer], :pointer],
[:bottom_panel, [:pointer], :int],
[:top_panel, [:pointer], :int],
[:show_panel, [:pointer], :int],
[:update_panels, [], :void],
[:hide_panel, [:pointer], :int],
[:panel_window, [:pointer], :pointer],
[:replace_panel, [:pointer, :pointer], :int],
[:move_panel, [:pointer, :int, :int], :int],
[:panel_hidden, [:pointer], :int],
[:panel_above, [:pointer], :pointer],
[:panel_below, [:pointer], :pointer],
[:set_panel_userptr, [:pointer, :pointer], :int],
[:panel_userptr, [:pointer], :pointer],
[:del_panel, [:pointer], :int],
]
functions.each do |function|
attach_function(*function)
end
40 41 42 43 44 45 46 |
# File 'lib/rbcurse/core/system/panel.rb', line 40 def initialize(window) if window.respond_to?(:pointer) @pointer = FFI::NCurses.new_panel(window.pointer) else @pointer = FFI::NCurses.new_panel(window) end end |
Class Method Details
.method_missing(name, *args) ⇒ Object
154 155 156 157 158 159 |
# File 'lib/rbcurse/core/system/panel.rb', line 154 def method_missing(name, *args) if (FFI::NCurses.respond_to?(name)) return FFI::NCurses.send(name, *args) end raise "Panel did not respond_to #{name} " end |
.update_panels ⇒ Object
these will be used when you say Ncurses::Panel.del_panel(@panel.pointer) You could directly say FFI:NCurses or even @panel.del_panel.
151 152 153 |
# File 'lib/rbcurse/core/system/panel.rb', line 151 def update_panels FFI::NCurses.update_panels end |
Instance Method Details
#bottom_panel ⇒ Object Also known as: bottom
Puts panel below all other panels.
52 53 54 |
# File 'lib/rbcurse/core/system/panel.rb', line 52 def bottom_panel FFI::NCurses.bottom_panel(@pointer) end |
#del_panel ⇒ Object Also known as: del, delete
Remove the panel from the stack and deallocate the PANEL structure. Doesn’t remove the associated window.
142 143 144 |
# File 'lib/rbcurse/core/system/panel.rb', line 142 def del_panel FFI::NCurses.del_panel(@pointer) end |
#hide_panel ⇒ Object Also known as: hide
Removes the given panel from the panel stack and thus hides it from view. The PANEL structure is not lost, merely removed from the stack.
78 79 80 |
# File 'lib/rbcurse/core/system/panel.rb', line 78 def hide_panel FFI::NCurses.hide_panel(@pointer) end |
#move_panel(starty = 0, startx = 0) ⇒ Object Also known as: move
Move the panel window so that its upper-left corner is at (starty
,startx
). It does not change the position of the panel in the stack. Be sure to use this method instead of mvwin, to move a panel window.
102 103 104 |
# File 'lib/rbcurse/core/system/panel.rb', line 102 def move_panel(starty = 0, startx = 0) FFI::NCurses.move_panel(@pointer, starty, startx) end |
#panel_above ⇒ Object Also known as: above
Returns pointer to the panel above.
115 116 117 |
# File 'lib/rbcurse/core/system/panel.rb', line 115 def panel_above FFI::NCurses.panel_above(@pointer) end |
#panel_below ⇒ Object Also known as: below
Return a pointer to the panel just below panel. If the panel argument is a pointer to 0, it returns a pointer to the top panel in the stack.
123 124 125 |
# File 'lib/rbcurse/core/system/panel.rb', line 123 def panel_below FFI::NCurses.panel_below(@pointer) end |
#panel_hidden ⇒ Object Also known as:
Returns true if the panel is in the panel stack, false if not. Returns ERR if the panel pointer is a null pointer.
109 110 111 |
# File 'lib/rbcurse/core/system/panel.rb', line 109 def panel_hidden FFI::NCurses.panel_hidden(@pointer) == 0 end |
#panel_userptr ⇒ Object Also known as: userptr
Returns the user pointer for a given panel.
129 130 131 |
# File 'lib/rbcurse/core/system/panel.rb', line 129 def panel_userptr FFI::NCurses.panel_userptr(@pointer) end |
#panel_window ⇒ Object Also known as: window
Returns a pointer to the window of the given panel.
84 85 86 |
# File 'lib/rbcurse/core/system/panel.rb', line 84 def panel_window FFI::NCurses.panel_window(@pointer) end |
#pointer ⇒ Object
47 48 49 |
# File 'lib/rbcurse/core/system/panel.rb', line 47 def pointer @pointer end |
#replace_panel(window) ⇒ Object Also known as: replace
Replace the window of the panel with the given window. Useful, for example, if you want to resize a panel. You can call #replace_panel on the output of wresize. It does not change the position of the panel in the stack.
93 94 95 |
# File 'lib/rbcurse/core/system/panel.rb', line 93 def replace_panel(window) FFI::NCurses.replace_panel(@pointer, window) end |
#set_panel_userptr(user_pointer) ⇒ Object Also known as: userptr=
sets the panel’s user pointer.
135 136 137 |
# File 'lib/rbcurse/core/system/panel.rb', line 135 def set_panel_userptr(user_pointer) FFI::NCurses.set_panel_userptr(@pointer, user_pointer) end |
#show_panel ⇒ Object Also known as: show
Makes hidden panel visible by placing it on the top of the stack.
To ensure compatibility across platforms, use this method instead of #top_panel when the panel is hidden.
70 71 72 |
# File 'lib/rbcurse/core/system/panel.rb', line 70 def show_panel FFI::NCurses.show_panel(@pointer) end |
#top_panel ⇒ Object Also known as: top
Put the visible panel on top of all other panels in the stack.
To ensure compatibility across platforms, use this method instead of #show_panel when the panel is shown.
61 62 63 |
# File 'lib/rbcurse/core/system/panel.rb', line 61 def top_panel FFI::NCurses.top_panel(@pointer) end |