Module: Curses
- Defined in:
- lib/rodo/curses_util.rb
Defined Under Namespace
Modules: WindowExtensions
Classes: Window
Constant Summary
collapse
- KEY_CTRL_RIGHT =
Curses::REQ_SCR_FCHAR
- KEY_CTRL_LEFT =
Curses::REQ_DEL_CHAR
- @@debug_win =
nil
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.abort(msg) ⇒ Object
277
278
279
280
281
282
283
284
285
|
# File 'lib/rodo/curses_util.rb', line 277
def self.abort(msg)
Curses.close_screen
puts "Traceback (most recent call last):"
puts caller.each_with_index.map { |s, i| "#{(i+1).to_s.rjust(9)}: from #{s}" }.reverse
puts msg
Kernel.exit(-1)
end
|
.bracketed_paste ⇒ Object
Switch on bracketed paste mode and reset it at end of application
27
28
29
30
31
32
|
# File 'lib/rodo/curses_util.rb', line 27
def self.bracketed_paste
print("\x1b[?2004h")
at_exit {
print("\x1b[?2004l")
}
end
|
.ch2key(ch) ⇒ Object
264
265
266
267
268
269
270
271
272
273
274
275
|
# File 'lib/rodo/curses_util.rb', line 264
def self.ch2key(ch)
if !defined?(@@map)
@@map = {}
Curses.constants(false).each { |s|
c = Curses.const_get(s)
@@map[c] ||= []
@@map[c] << s
}
end
@@map[ch]
end
|
.char_info(char) ⇒ Object
250
251
252
253
254
255
256
257
258
259
260
261
262
|
# File 'lib/rodo/curses_util.rb', line 250
def self.char_info(char)
case char
when Integer
key = Curses::ch2key(char)
return "Char: #{char} - Class Integer " + (key != nil ? "Constant: #{key}" : "To chr(): #{char.chr}")
else
return "Char: #{char.inspect} - Class: #{char.class}"
end
end
|
.cputs(string) ⇒ Object
235
236
237
238
239
240
|
# File 'lib/rodo/curses_util.rb', line 235
def self.cputs(string)
w = stdscr.inset
w.puts string
w.getch
w.close
end
|
.debug(message) ⇒ Object
18
19
20
21
22
23
|
# File 'lib/rodo/curses_util.rb', line 18
def self.debug message
if @@debug_win
@@debug_win.puts message
@@debug_win.refresh
end
end
|
.debug_win ⇒ Object
14
15
16
|
# File 'lib/rodo/curses_util.rb', line 14
def self.debug_win
@@debug_win
end
|
.debug_win=(debug_win) ⇒ Object
10
11
12
|
# File 'lib/rodo/curses_util.rb', line 10
def self.debug_win= debug_win
@@debug_win = debug_win
end
|
Instance Method Details
#bracketed_paste ⇒ Object
Enable bracketed paste mode and reset it upon exit
243
244
245
246
247
248
|
# File 'lib/rodo/curses_util.rb', line 243
def bracketed_paste
print("\x1b[?2004h")
at_exit {
print("\x1b[?2004l")
}
end
|