-
Notifications
You must be signed in to change notification settings - Fork 0
/
glcshell.m
91 lines (66 loc) · 1.69 KB
/
glcshell.m
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
% Gleemex shell.
%
function glcshell(data)
global GL glc
glc_checkextract();
glc = glcall();
GL = glconstants();
glcsh = GLCShellData();
% create the window!
winid = glcall(glc.newwindow, [20 20], glcsh.wh, 'Gleemex shell');
GLCApplicationData.register(winid, glcsh);
nset = GLCApplicationData.setCallbacks('sh_');
assert(nset == 4);
glcall(glc.entermainloop);
end
function sh_reshape(w, h)
global GL glc
glcsh = glc_appdata();
glcsh.updateWindowPos(w, h, true);
end
function sh_display()
global GL glc
glcsh = glc_appdata();
glcall(glc.clear, 1-[0 0 0]);
w = glcsh.wh(1);
glcsh.el.display([20 w-20], 20+16, struct('lineheight',16, 'colors',[.9 .9 .9]));
end
function sh_keyboard(key, x, y, mods)
global GL glc
glcsh = glc_appdata();
doquit = false;
enter = glcsh.el.handleKey(key, mods);
while (enter) % if, really
enter = false;
% Issue entered command.
cmd = strtrim(glcsh.el.getLine());
if (isempty(cmd))
break
end
if (any(strcmp(cmd, {'quit', 'exit', 'quit!', 'exit!'})))
doquit = 1 + (numel(cmd)==5);
break
end
try
evalin('base', cmd);
catch
fprintf('%s\n', lasterr());
end
glcsh.el.clearLine();
end
if (doquit)
if (doquit == 1)
glcall(glc.closewindow);
else
glcall(glc.leavemainloop);
end
return
end
glcall(glc.redisplay);
end
function sh_motion(buttonsdown, x, y)
global GL glc
glcsh = glc_appdata();
glcsh.updateMousePos(buttonsdown, x, y);
glcall(glc.redisplay);
end