Module: Curses

Defined in:
lib/curses-ui.rb

Defined Under Namespace

Classes: Window

Class Method Summary collapse

Class Method Details

.begin_draw(desc) ⇒ Object



72
73
74
75
# File 'lib/curses-ui.rb', line 72

def Curses.begin_draw desc
    Curses.relayout_all if desc.win.nil?
    desc.win
end

.end_it_allObject



81
82
83
84
85
# File 'lib/curses-ui.rb', line 81

def Curses.end_it_all
    Curses.close_screen
    puts "quiting, and stuff"
    exit
end

.init_color_tableObject

real curses only



93
94
95
96
97
98
99
100
101
# File 'lib/curses-ui.rb', line 93

def Curses.init_color_table
    # set up colors
    start_color
    8.times { |fg|
        8.times { |bg|
            init_pair Curses.pair_index(fg, bg), fg, bg
        }
    }
end

.int_finishObject



77
78
79
# File 'lib/curses-ui.rb', line 77

def Curses.int_finish
    Curses.close_screen
end

.int_initObject

possibly color list for completion A_NORMAL, A_BOLD, A_UNDERLINE, A_BLINK, A_REVERSE, COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW, COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/curses-ui.rb', line 32

def Curses.int_init
    Curses.init_screen
    Curses.nonl
    Curses.cbreak
    Curses.noecho
    Curses.raw
    Curses.init_color_table # ext
    # thanks to Aredridel!!!
    require 'dl/import'
    DL.dlopen("libncurses.so.5") {
        |h|
        d = h.sym('ESCDELAY')
        d[0] = [15].pack("L")
    }
    scr = Curses.stdscr
    scr.keypad true unless $win32
    Ruvi::WinDescs::instance.stdscr = scr
    Ruvi::EditorApp.perform_layout
end

.pair_index(fg, bg) ⇒ Object

TODO - make private



88
89
90
# File 'lib/curses-ui.rb', line 88

def Curses.pair_index(fg, bg)
    fg + bg * 8 + 1
end

.relayout_allObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/curses-ui.rb', line 52

def Curses.relayout_all
    # relayout *all* windows
    Ruvi::WinDescs::instance.descs.each_value {
        |d|
        Ruvi::WinDescs::instance.stdscr.clear
        begin
            win = Ruvi::WinDescs::instance.stdscr.subwin d.sy, d.sx, d.y, d.x
        rescue => e
            # some useful debugging information if our window ever fails to layout
            Curses.close_screen
            p e
            p d.to_s
            exit
        end
        win.scrollok true
        win.keypad true unless $win32
        d.win = win
    }
end