Id: To index
Original: Legend
Status:
Mutant: Show

Testcases to display

Filter by kind

Filter by status

1:
#
ifndef
 
window_hpp
2:
#
define
 
window_hpp
3:
4:
#
include
 
"termbox.h"
5:
#
include
 
"util.h"
6:
7:
enum
 
class
 
WindowEvent
 
{
8:    
Unknown
,
9:    
ArrowUp
,
10:    
ArrowDown
,
11:    
ArrowLeft
,
12:    
ArrowRight
,
13:
}
;
14:
15:
inline
 
std
:
:
string
 
to_string
(
WindowEvent
 
ev
)
 
{
16:    
switch
 
(
ev
)
 
{
17:    
case
 
WindowEvent
:
:
Unknown
:
18:    
default
:
19:        
return
 
"Unknown"
;
20:
21:    
case
 
WindowEvent
:
:
ArrowUp
:
22:        
return
 
"ArrowUp"
;
23:    
case
 
WindowEvent
:
:
ArrowDown
:
24:        
return
 
"ArrowDown"
;
25:    
case
 
WindowEvent
:
:
ArrowLeft
:
26:        
return
 
"ArrowLeft"
;
27:    
case
 
WindowEvent
:
:
ArrowRight
:
28:        
return
 
"ArrowRight"
;
29:    
}
30:
}
31:
32:
struct
 
Pos
 
{
33:    
int
 
x
{
0
}
;
34:    
int
 
y
{
0
}
;
35:    
char
 
c
{
0
}
;
36:
}
;
37:
38:
class
 
Window
 
{
39:
public
:
40:    
Window
(
)
;
41:    
~
Window
(
)
;
42:    
int32_t
 
width
(
)
 
const
;
43:    
int32_t
 
height
(
)
 
const
;
44:
45:    
bool
 
handleEvents
(
)
;
 
// returns false on quit
46:    
const
 
std
:
:
vector
<
WindowEvent
>
&
 
events
(
)
 
const
 
{
 
return
 
events_
;
 
}
47:    
void
 
render
(
)
;
48:
49:    
void
 
clear
(
)
;
50:    
void
 
set
(
int
 
x
,
 
int
 
y
,
 
char
 
c
,
 
uint16_t
 
fg
,
 
uint16_t
 
bg
)
;
51:
52:    
/// Testing interface where events are synthetically injected.
53:    
void
 
inject
(
WindowEvent
 
ev
)
 
{
 
events_
.
push_back
(
ev
)
;
 
}
54:
55:    
/// The position updates that has been generated. Used for testing purpose.
56:    
std
:
:
vector
<
Pos
>
 
layoutEvents
;
57:
58:
private
:
59:    
std
:
:
vector
<
WindowEvent
>
 
events_
;
60:
}
;
61:
62:
#
endif