Class: RubyCurses::HelpManager
- Defined in:
- lib/rbcurse/core/widgets/rwidget.rb
Overview
Instance Method Summary collapse
- #display_help ⇒ Object
-
#help_text(text = nil) ⇒ Object
super instance_eval &block if block_given?.
- #help_text=(text) ⇒ Object
-
#initialize(form, config = {}, &block) ⇒ HelpManager
constructor
A new instance of HelpManager.
Constructor Details
#initialize(form, config = {}, &block) ⇒ HelpManager
Returns a new instance of HelpManager.
1966 1967 1968 1969 1970 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1966 def initialize form, config={}, &block @form = form #super #instance_eval &block if block_given? end |
Instance Method Details
#display_help ⇒ Object
1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1978 def display_help filename = File.dirname(__FILE__) + "/../docs/index.txt" # defarr contains default help if File.exists?(filename) defarr = File.open(filename,'r').readlines else arr = [] arr << " NO HELP SPECIFIED FOR APP " arr << " " arr << " --- General help --- " arr << " F10 - exit application " arr << " Alt-x - select commands " arr << " : (or M-:) - select commands " arr << " ? (or M-?) - current widget key bindings " arr << " " defarr = arr end defhelp = true if @help_text defhelp = false arr = @help_text else arr = defarr end case arr when String arr = arr.split("\n") when Array end #w = arr.max_by(&:length).length h = FFI::NCurses.LINES - 4 w = FFI::NCurses.COLS - 10 require 'rbcurse/core/util/viewer' RubyCurses::Viewer.view(arr, :layout => [2, 4, h, w],:close_key => KEY_F10, :title => "[ Help ]", :print_footer => true) do |t| # you may configure textview further here. #t.suppress_borders true #t.color = :black #t.bgcolor = :white # or #t.attr = :reverse # help was provided, so default help is provided in second buffer unless defhelp t.add_content defarr, :title => ' General Help ' end end end |
#help_text(text = nil) ⇒ Object
super instance_eval &block if block_given?
1971 1972 1973 1974 1975 1976 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1971 def help_text text=nil if text @help_text = text end return @help_text end |
#help_text=(text) ⇒ Object
1977 |
# File 'lib/rbcurse/core/widgets/rwidget.rb', line 1977 def help_text=(text); help_text(text); end |