Class: StatusWindow
Overview
TODO: add option of putting progress_bar
Instance Attribute Summary collapse
- 
  
    
      #color_pair  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute color_pair. 
- 
  
    
      #h  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    height, width, top row, left col of window. 
- 
  
    
      #left  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    height, width, top row, left col of window. 
- 
  
    
      #top  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    height, width, top row, left col of window. 
- 
  
    
      #w  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    height, width, top row, left col of window. 
- 
  
    
      #win  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute win. 
Instance Method Summary collapse
- #create_window(h = 2, w = Ncurses.COLS-0, t = Ncurses.LINES-2, l = 0) ⇒ Object
- 
  
    
      #destroy  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    caller must destroy after he’s finished printing messages, unless user calls linger. 
- #hide ⇒ Object
- 
  
    
      #initialize(config = {}, &block)  ⇒ StatusWindow 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of StatusWindow. 
- 
  
    
      #linger(caller_window = nil)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    pauses with the message, but doesn’t ask the user to press a key. 
- #pause ⇒ Object
- 
  
    
      #print(*textarray)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    print given strings from first first column onwards. 
- 
  
    
      #printstring(r, c, text, color_pair = @color_pair)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    creates a color pair based on given bg and fg colors as strings def set_colors bgcolor, fgcolor=‘white’ end prints a string on given row (0 or 1). 
- #show ⇒ Object
Constructor Details
#initialize(config = {}, &block) ⇒ StatusWindow
Returns a new instance of StatusWindow.
| 291 292 293 294 295 296 | # File 'lib/rbcurse/core/util/rdialogs.rb', line 291 def initialize config={}, &block @color_pair = config[:color_pair] @row_offset = config[:row_offset] || 0 @col_offset = config[:col_offset] || 0 create_window *config[:layout] end | 
Instance Attribute Details
#color_pair ⇒ Object
Returns the value of attribute color_pair.
| 290 291 292 | # File 'lib/rbcurse/core/util/rdialogs.rb', line 290 def color_pair @color_pair end | 
#h ⇒ Object (readonly)
height, width, top row, left col of window
| 288 289 290 | # File 'lib/rbcurse/core/util/rdialogs.rb', line 288 def h @h end | 
#left ⇒ Object (readonly)
height, width, top row, left col of window
| 288 289 290 | # File 'lib/rbcurse/core/util/rdialogs.rb', line 288 def left @left end | 
#top ⇒ Object (readonly)
height, width, top row, left col of window
| 288 289 290 | # File 'lib/rbcurse/core/util/rdialogs.rb', line 288 def top @top end | 
#w ⇒ Object (readonly)
height, width, top row, left col of window
| 288 289 290 | # File 'lib/rbcurse/core/util/rdialogs.rb', line 288 def w @w end | 
#win ⇒ Object (readonly)
Returns the value of attribute win.
| 289 290 291 | # File 'lib/rbcurse/core/util/rdialogs.rb', line 289 def win @win end | 
Instance Method Details
#create_window(h = 2, w = Ncurses.COLS-0, t = Ncurses.LINES-2, l = 0) ⇒ Object
| 297 298 299 300 301 302 303 304 | # File 'lib/rbcurse/core/util/rdialogs.rb', line 297 def create_window h = 2 , w = Ncurses.COLS-0, t = Ncurses.LINES-2, l = 0 return @win if @win @win = VER::Window.new(h, w , t, l) @h = h ; @w = w; @top = t ; @left = l @color_pair ||= get_color($promptcolor, 'white','black') @win.bkgd(Ncurses.COLOR_PAIR(@color_pair)); @win end | 
#destroy ⇒ Object
caller must destroy after he’s finished printing messages, unless user calls linger
| 348 | # File 'lib/rbcurse/core/util/rdialogs.rb', line 348 def destroy; @win.destroy if @win; @win = nil; end | 
#hide ⇒ Object
| 349 350 351 352 | # File 'lib/rbcurse/core/util/rdialogs.rb', line 349 def hide @win.hide @visible = false end | 
#linger(caller_window = nil) ⇒ Object
pauses with the message, but doesn’t ask the user to press a key. If he does, the key should be used by underlying window. Do not call destroy if you call linger, it does the destroy.
| 334 335 336 337 338 339 340 341 342 343 344 345 | # File 'lib/rbcurse/core/util/rdialogs.rb', line 334 def linger caller_window=nil begin if caller_window ch = @win.getchar caller_window.ungetch(ch) # will this be available to underlying window XXX i think not !! else sleep 1 end ensure destroy end end | 
#pause ⇒ Object
| 330 | # File 'lib/rbcurse/core/util/rdialogs.rb', line 330 def pause; @win.getchar; end | 
#print(*textarray) ⇒ Object
print given strings from first first column onwards
| 321 322 323 324 325 326 327 328 329 | # File 'lib/rbcurse/core/util/rdialogs.rb', line 321 def print *textarray create_window unless @win show unless @visible c = 1 textarray.each_with_index { |s, i| @win.printstring i+@row_offset, c+@col_offset, "%-*s" % [@w-(@col_offset*2)-c, s], @color_pair } @win.wrefresh end | 
#printstring(r, c, text, color_pair = @color_pair) ⇒ Object
creates a color pair based on given bg and fg colors as strings def set_colors bgcolor, fgcolor=‘white’ end prints a string on given row (0 or 1)
| 310 311 312 313 314 315 316 317 318 319 | # File 'lib/rbcurse/core/util/rdialogs.rb', line 310 def printstring r, c, text, color_pair=@color_pair create_window unless @win show unless @visible r = @h-1 if r > @h-1 #@win.printstring r, c, ' '*@w, @color_pair # FIXME this padding overwrites the border and the offset means next line wiped # However, now it may now totally clear a long line. @win.printstring r+@row_offset, c+@col_offset, "%-*s" % [@w-(@col_offset*2)-c, text], color_pair @win.wrefresh end | 
#show ⇒ Object
| 353 354 355 356 | # File 'lib/rbcurse/core/util/rdialogs.rb', line 353 def show @win.show unless @visible @visible = true end |