Class: Nutils
- Inherits:
-
Object
- Object
- Nutils
- Defined in:
- lib/ncurses_ui.rb
Class Method Summary collapse
- .print(scr, row, col, text, color, width = (Curses.cols)) ⇒ Object
- .scroll(text, width, offset = 0) ⇒ Object
- .timestr(sec) ⇒ Object
Class Method Details
.print(scr, row, col, text, color, width = (Curses.cols)) ⇒ Object
210 211 212 213 214 215 216 217 |
# File 'lib/ncurses_ui.rb', line 210 def self.print(scr, row, col, text, color, width = (Curses.cols)) width = [Curses.cols, col+width].min - col t = "%-#{width}s" % [scroll(text, width)] scr.attron(Colors.map(color)) if color scr.setpos row, col scr.addstr t scr.attroff(Colors.map(color)) if color end |
.scroll(text, width, offset = 0) ⇒ Object
219 220 221 222 223 224 225 226 227 |
# File 'lib/ncurses_ui.rb', line 219 def self.scroll(text, width, offset=0) return unless text ellipsis = "*" t = text if t.size+offset > width t = t[offset..(width-ellipsis.size-1)] << ellipsis end t end |
.timestr(sec) ⇒ Object
229 230 231 232 |
# File 'lib/ncurses_ui.rb', line 229 def self.timestr(sec) sec = sec.to_i "%02d:%02d" % [sec/60, sec%60] end |