-
Notifications
You must be signed in to change notification settings - Fork 2
/
panel.go
121 lines (98 loc) · 2.21 KB
/
panel.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package curses
// struct ldat{};
// struct _win_st{};
// #define _Bool int
// #define NCURSES_OPAQUE 1
// #include <ncurses/panel.h>
// #include <stdlib.h>
import "C"
import (
// "fmt"
"os"
//
"unsafe"
)
var panelByPtr = make( map[ uintptr ] *Panel )
type Panel struct {
panel *C.PANEL
hidden bool
}
/*
extern NCURSES_EXPORT(PANEL*) new_panel (WINDOW *);
extern NCURSES_EXPORT(PANEL*) panel_above (const PANEL *);
extern NCURSES_EXPORT(PANEL*) panel_below (const PANEL *);
extern NCURSES_EXPORT(int) set_panel_userptr (PANEL *, NCURSES_CONST void *);
extern NCURSES_EXPORT(NCURSES_CONST void*) panel_userptr (const PANEL *);
extern NCURSES_EXPORT(int) move_panel (PANEL *, int, int);
extern NCURSES_EXPORT(int) replace_panel (PANEL *,WINDOW *);
extern NCURSES_EXPORT(int) panel_hidden (const PANEL *);
*/
func (p *Panel) Window () (w *Window, err os.Error) {
in()
defer out()
w=(*Window)(C.panel_window( p.panel ))
if w==nil { err = CursesError{ "No Window" } }
return
}
func UpdatePanels() {
in()
defer out()
C.update_panels()
}
func (p *Panel) Hide (b bool) {
in()
defer out()
if b {
C.hide_panel( p.panel )
} else {
C.show_panel( p.panel )
}
p.hidden = b
}
func (p *Panel) Delete() {
in()
defer out()
C.del_panel( p.panel )
}
func (p *Panel) ToTop() {
in()
defer out()
C.top_panel( p.panel )
}
func (p *Panel) ToBottom() {
in()
defer out()
C.bottom_panel( p.panel )
}
func NewPanel( w *Window ) (p *Panel, err os.Error ) {
in()
defer out()
p = new(Panel)
p.panel = C.new_panel( (*C.WINDOW)(w) )
if p.panel == nil {
err = CursesError{ "Could not allocate PANEL" }
p = nil
} else {
panelByPtr[uintptr(unsafe.Pointer(p.panel) )] = p
p.hidden = false
}
return
}
func (p *Panel) Above() *Panel {
in(); defer out()
return panelByPtr[ uintptr(unsafe.Pointer(C.panel_above( p.panel ))) ]
}
func (p *Panel) Below() *Panel {
in(); defer out()
return panelByPtr[ uintptr(unsafe.Pointer(C.panel_below( p.panel ))) ]
}
func (p *Panel) Move(x,y int) ( err os.Error ) {
in(); defer out()
if (int)(C.move_panel( p.panel, C.int( y ), C.int( x ) )) == C.ERR {
err = CursesError{ "Can't move PANEL" }
}
return
}
func (p *Panel) Hidden() bool {
return p.hidden
}