// Windows GWW.SR copysdnww rgsdoc bubblingww

get "BRAVO.DF"

// Incoming procedures

external
	[
	establishww
	errhlt
 	]

// Incoming statics

external
	[
	dcb;
	cdcb;
// ** GYPSY ADDED:
	rgdirpage
	rgsdoc;
	rgview;
	vwwcurrent;
	selection;
	selaux;
	sww;
	]

// Outgoing procedures

external
	[
	enww;
	makeroomww;
	copydnww;
	bubblingww; // **
	]

// Outgoing statics

external
	[
	macww
	rgdoc
	rgcpfdispl
	rgyfirst
	rgylast
	rgdlfirst
	rgdllast
	rgmaxdl
	vdlhint;
	pbmfirstfree;
	fcp;
	rghpused;
	macdl;
	rgccomp;
	rgcdlblank;
	]

// Local statics

static
	[
	macww
	rgdoc
	rgcpfdispl
	rgyfirst
	rgylast
	rgdlfirst
	rgdllast
	rgmaxdl
	vdlhint;
	pbmfirstfree;
	fcp;
	rghpused;
	macdl;
	rgccomp;
	rgcdlblank;
	]

// E N W W

let enww(proc,doc) be
for ww = 0 to macww-1 do
	if rgdoc ! ww eq doc then 
		[ 
		establishww(ww);
		proc(ww);
		] 

// M A K E R O O M W W 
// catalogue no. = 122
and makeroomww(wwparam) be
[ if macww eq maxww then errhlt("wwo");
for ww = macww-1 to wwparam by -1 do
	copydnww(ww+1,ww);
macww = macww+1;
] 

// C O P Y D N W W
//
and copydnww(ww1,ww2) be
[
rgdoc ! ww1 = rgdoc ! ww2;
rgsdoc ! ww1 = rgsdoc ! ww2; // ** GYPSY
rgview ! ww1 = rgview ! ww2; // ** GYPSY
rgdirpage ! ww1 = rgdirpage ! ww2; // ** GYPSY
rgcpfdispl ! ww1 = rgcpfdispl ! ww2;
rgyfirst ! ww1 = rgyfirst ! ww2;
rgylast ! ww1 = rgylast ! ww2;
rgdlfirst ! ww1 = rgdlfirst ! ww2;
rgdllast ! ww1 = rgdllast ! ww2;
rgmaxdl ! ww1 = rgmaxdl ! ww2;
]

// ** GYPSY ADDED:

and bubblingww(ww, dir) be
[
if vwwcurrent ge ww then vwwcurrent = vwwcurrent + dir
if vwwcurrent le 1 then vwwcurrent = 2
if selection >> SEL.ww ge ww then
	selection >> SEL.ww = selection >> SEL.ww + dir
if selaux >> SEL.ww ge ww then
	selaux >> SEL.ww = selaux >> SEL.ww + dir
sww = sww + dir
]