147
147
H = gs:read(Win, height),
150
Bu1==close, Bu2==open ->
150
Bu1 =:= close, Bu2 =:= open ->
151
151
resize_button_area(open, width, W-4),
152
152
gs:config('ButtonArea', {height, 30}),
154
Bu1==open, Bu2==close ->
154
Bu1 =:= open, Bu2 =:= close ->
155
155
gs:config('ButtonArea', [{width, 0}, {height, 0}]),
160
Ev1==close, Ev2==open, Bi1==open ->
160
Ev1 =:= close, Ev2 =:= open, Bi1 =:= open ->
161
161
Wnew1 = round((W-10-4)/2), % W = window/2 - rb - pads
162
162
Hbi1 = gs:read('BindArea', height), % H = bind area h
163
163
resize_eval_area(open, width, Wnew1),
167
167
resize_bind_area(open, width,
168
168
Wnew1-gs:read('BindArea', width)),
170
Ev1==close, Ev2==open, Bi1==close ->
170
Ev1 =:= close, Ev2 =:= open, Bi1 =:= close ->
171
171
resize_eval_area(open, width, W-4),
172
172
resize_eval_area(open, height, 200),
174
Ev1==open, Ev2==close, Bi1==open ->
174
Ev1 =:= open, Ev2 =:= close, Bi1 =:= open ->
175
175
gs:config('EvalArea', [{width,0}, {height,0}]),
176
176
gs:config('RB3', [{width, 0}, {height, 0}]),
178
178
resize_bind_area(open, width,
179
179
Wnew2-gs:read('BindArea', width)),
181
Ev1==open, Ev2==close, Bi1==close ->
181
Ev1 =:= open, Ev2 =:= close, Bi1 =:= close ->
182
182
Hs1 = gs:read('EvalArea', height),
183
183
gs:config('EvalArea', [{width, 0}, {height, 0}]),
188
Bi1==close, Bi2==open, Ev2==open ->
188
Bi1 =:= close, Bi2 =:= open, Ev2 =:= open ->
189
189
Wnew3 = round((W-10-4)/2), % W = window/2 - rb - pads
190
190
Hs2 = gs:read('EvalArea', height), % H = eval area h
191
191
resize_bind_area(open, width, Wnew3),
194
194
resize_eval_area(open, width,
195
195
Wnew3-gs:read('EvalArea', width)),
197
Bi1==close, Bi2==open, Ev2==close ->
197
Bi1 =:= close, Bi2 =:= open, Ev2 =:= close ->
198
198
resize_bind_area(open, width, W-4),
199
199
resize_bind_area(open, height, 200),
201
Bi1==open, Bi2==close, Ev2==open ->
201
Bi1 =:= open, Bi2 =:= close, Ev2 =:= open ->
202
202
gs:config('BindArea', [{width, 0}, {height, 0}]),
203
203
gs:config('RB3', [{width, 0}, {height, 0}]),
205
205
resize_eval_area(open, width,
206
206
Wnew4-gs:read('EvalArea', width)),
208
Bi1==open, Bi2==close, Ev2==close ->
208
Bi1 =:= open, Bi2 =:= close, Ev2 =:= close ->
209
209
Hbi2 = gs:read('BindArea', height),
210
210
gs:config('BindArea', [{width, 0}, {height, 0}]),
215
Tr1==close, Tr2==open ->
215
Tr1 =:= close, Tr2 =:= open ->
216
216
resize_trace_area(open, width, W-4),
217
217
resize_trace_area(open, height, 200),
219
Tr1==open, Tr2==close ->
219
Tr1 =:= open, Tr2 =:= close ->
220
220
Hf = gs:read('TraceArea', height),
221
221
gs:config('TraceArea', [{width, 0}, {height, 0}]),
227
227
RB1old = rb1(OldFlags), RB1new = rb1(NewFlags),
229
RB1old==close, RB1new==open ->
229
RB1old =:= close, RB1new =:= open ->
230
230
gs:config('RB1', [{width, W-4}, {height, 10}]),
231
231
gs:config(Win, {height, gs:read(Win, height)+10});
232
RB1old==open, RB1new==close ->
232
RB1old =:= open, RB1new =:= close ->
233
233
gs:config('RB1', [{width, 0}, {height, 0}, lower]),
234
234
gs:config(Win, {height, gs:read(Win, height)-10});
238
238
RB2old = rb2(OldFlags), RB2new = rb2(NewFlags),
240
RB2old==close, RB2new==open ->
240
RB2old =:= close, RB2new =:= open ->
241
241
gs:config('RB2', [{width, W-4}, {height, 10}]),
242
242
gs:config(Win, {height,gs:read(Win, height)+10});
243
RB2old==open, RB2new==close ->
243
RB2old =:= open, RB2new =:= close ->
244
244
gs:config('RB2', [{width, 0}, {height, 0}, lower]),
245
245
gs:config(Win, {height, gs:read(Win, height)-10});
301
301
%% Cond = null | {Mod, Func}
302
302
%%--------------------------------------------------------------------
303
303
add_break(WinInfo, Menu, {{Mod,Line},[Status|_Options]}=Break) ->
304
case lists:keysearch(Mod, 1, WinInfo#winInfo.editors) of
305
{value, {Mod, Editor}} ->
304
case lists:keyfind(Mod, 1, WinInfo#winInfo.editors) of
306
306
add_break_to_code(Editor, Line, Status);
309
309
add_break_to_menu(WinInfo, Menu, Break).
311
311
add_break_to_code(Editor, Line, Status) ->
312
Color = if Status==active -> red; Status==inactive -> blue end,
312
Color = if Status =:= active -> red; Status =:= inactive -> blue end,
313
313
config_editor(Editor, [{overwrite,{{Line,0},"-@- "}},
314
314
{fg,{{{Line,0},{Line,lineend}}, Color}}]).
460
460
show_code(WinInfo, Mod, Contents) ->
461
461
Editors = WinInfo#winInfo.editors,
462
{Flag, Editor} = case lists:keysearch(Mod, 1, Editors) of
463
{value, {Mod, Ed}} -> {existing, Ed};
462
{Flag, Editor} = case lists:keyfind(Mod, 1, Editors) of
463
{Mod, Ed} -> {existing, Ed};
464
464
false -> {new, code_editor()}
467
466
%% Insert code and update breakpoints, if any
468
467
config_editor(Editor, [raise, clear]),
469
468
show_code(Editor, Contents),
470
469
lists:foreach(fun(BreakInfo) ->
471
470
case BreakInfo#breakInfo.point of
472
{Mod2, Line} when Mod2==Mod ->
471
{Mod2, Line} when Mod2 =:= Mod ->
473
472
Status = BreakInfo#breakInfo.status,
474
473
add_break_to_code(Editor, Line,Status);
478
477
WinInfo#winInfo.breaks),
482
480
WinInfo#winInfo{editor={Mod, Editor}};
494
492
config_editor(Editor, {insert,{'end',Text}}).
496
494
show_no_code(WinInfo) ->
497
{value, {'$top', Editor}} =
498
lists:keysearch('$top', 1, WinInfo#winInfo.editors),
495
{'$top', Editor} = lists:keyfind('$top', 1, WinInfo#winInfo.editors),
499
496
gs:config(Editor, raise),
500
497
WinInfo#winInfo{editor={'$top', Editor}}.
502
499
remove_code(WinInfo, Mod) ->
503
500
Editors = WinInfo#winInfo.editors,
504
case lists:keysearch(Mod, 1, Editors) of
505
{value, {Mod, Editor}} ->
501
case lists:keyfind(Mod, 1, Editors) of
506
503
gs:destroy(Editor),
507
504
WinInfo#winInfo{editors=lists:keydelete(Mod, 1, Editors)};
513
509
%%--------------------------------------------------------------------
514
510
%% mark_line(WinInfo, Line, How) -> WinInfo
1144
1140
%% No Shell or Bind frame, larger window
1145
{T,0,0} when NewW>OldW -> {T,0,0};
1141
{T,0,0} when NewW > OldW -> {T,0,0};
1147
1143
%% No Shell or Bind frame, smaller window
1148
{T,0,0} when OldW>NewW -> {-T,0,0};
1144
{T,0,0} when OldW > NewW -> {-T,0,0};
1150
1146
%% Window larger; divide Diff among the frames and return result
1151
{_,Sf,B} when NewW>OldW ->
1147
{_,Sf,B} when NewW > OldW ->
1152
1148
{_,Sf2,B2} = divide([{0,0},{0,Sf},{0,B}],Diff),
1153
1149
{Sf2+B2,Sf2,B2};
1167
1163
%% Difference between old and new height, considering min win height
1168
1164
MinH = min_height(Flags),
1169
Diff = abs(max(OldH,MinH)-max(NewH,MinH)),
1165
Diff = abs(erlang:max(OldH,MinH)-erlang:max(NewH,MinH)),
1171
1167
%% Check how much the frames can be resized in reality
1173
1169
%% Window larger
1177
Ev==close, Bi==close -> 0;
1173
Ev =:= close, Bi =:= close -> 0;
1177
Tr =:= open -> Diff;
1185
1181
%% Window smaller; get difference between min size
1186
1182
%% and current size
1188
1184
{gs:read('CodeArea',height)-100,
1190
Ev==close, Bi==close -> 0;
1186
Ev =:= close, Bi =:= close -> 0;
1194
1190
gs:read('EvalArea',height)-100;
1196
1192
gs:read('BindArea',height)-100
1200
Tr==open -> gs:read('TraceArea',height)-100;
1196
Tr =:= open -> gs:read('TraceArea',height)-100;
1296
1290
rblimits('RB2',W,H),
1297
1291
rblimits('RB3',W,H)).
1299
resizeloop(WI, RB, Prev, {Min1,Max1},{Min2,Max2},{Min3,Max3}) ->
1293
resizeloop(WI, RB, Prev, {Min1,Max1}, {Min2,Max2}, {Min3,Max3}) ->
1301
{gs,_,motion,_,[_,Y]} when RB=='RB1', Y>Min1,Y<Max1 ->
1295
{gs,_,motion,_,[_,Y]} when RB =:= 'RB1', Y > Min1, Y < Max1 ->
1302
1296
gs:config('RB1', {y,Y}),
1303
resizeloop(WI, RB, Y, {Min1,Max1},{Min2,Max2},{Min3,Max3});
1304
{gs,_,motion,_,_} when RB=='RB1' ->
1305
resizeloop(WI, RB, Prev,{Min1,Max1},{Min2,Max2},{Min3,Max3});
1297
resizeloop(WI, RB, Y, {Min1,Max1}, {Min2,Max2}, {Min3,Max3});
1298
{gs,_,motion,_,_} when RB =:= 'RB1' ->
1299
resizeloop(WI, RB, Prev, {Min1,Max1}, {Min2,Max2}, {Min3,Max3});
1307
{gs,_,motion,_,[_,Y]} when RB=='RB2', Y>Min2,Y<Max2 ->
1301
{gs,_,motion,_,[_,Y]} when RB =:= 'RB2', Y > Min2, Y < Max2 ->
1308
1302
gs:config('RB2', {y,Y}),
1309
resizeloop(WI, RB, Y, {Min1,Max1},{Min2,Max2},{Min3,Max3});
1310
{gs,_,motion,_,_} when RB=='RB2' ->
1311
resizeloop(WI, RB, Prev,{Min1,Max1},{Min2,Max2},{Min3,Max3});
1303
resizeloop(WI, RB, Y, {Min1,Max1}, {Min2,Max2}, {Min3,Max3});
1304
{gs,_,motion,_,_} when RB =:= 'RB2' ->
1305
resizeloop(WI, RB, Prev, {Min1,Max1}, {Min2,Max2}, {Min3,Max3});
1313
{gs,_,motion,_,[X,_]} when RB=='RB3', X>Min3,X<Max3 ->
1307
{gs,_,motion,_,[X,_]} when RB =:= 'RB3', X > Min3, X < Max3 ->
1314
1308
gs:config('RB3', {x,X}),
1315
resizeloop(WI, RB, X, {Min1,Max1},{Min2,Max2},{Min3,Max3});
1316
{gs,_,motion,_,_} when RB=='RB3' ->
1317
resizeloop(WI, RB, Prev,{Min1,Max1},{Min2,Max2},{Min3,Max3});
1309
resizeloop(WI, RB, X, {Min1,Max1}, {Min2,Max2}, {Min3,Max3});
1310
{gs,_,motion,_,_} when RB =:= 'RB3' ->
1311
resizeloop(WI, RB, Prev, {Min1,Max1}, {Min2,Max2}, {Min3,Max3});
1319
1313
{gs,_,buttonrelease,_,_} ->
1320
1314
resize_win(WI, RB, Prev)