
-- this file replaces the old kernel.cdefs and musekernel.cdefs

-- =========== first part is from old kernel.cdefs ===============

environment MuseDefs
{

	Cfunc	printf( Cstr );

	Cfunc	StringWidth( Cstr, Cint ) returns Cint;
	Cfunc	StringNWidth( Cstr, Cint, Cint ) returns Cint;
	Cfunc	WarpMouse( Cint, Cint, Cint );
	Cfunc	CreateCursor( Cint ) returns Cint;
	Cfunc	DefineCursor( Cint, Cint ) returns Cint;	

	Cfunc	DrawXLine(Cint,Cint,Cint,Cint,Cint,Cint,Cint,Cint,Cint);
	Cfunc	DrawOutlinedBox(Cint,Cint,Cint,Cint,Cint,Cint,Cint,Cint,Cint);
	Cfunc	DrawFilledBox  (Cint,Cint,Cint,Cint,Cint,Cint,Cint,Cint);

	Cfunc	GetBox(Cint,Cstr,Cstr,Cstr,Cstr,Cint) returns Cint;
	Cfunc	GetLine(Cint,Cstr,Cstr,Cstr,Cstr,Cint) returns Cint;
	Cfunc	GetWindow(Cint) returns Cint;

	Cfunc	SetWindowBorderColor( Cint, Cint );
	Cfunc	SetWindowBackgroundColor( Cint, Cint );
	Cfunc	SetWindowBorderWidth( Cint, Cint );
	Cfunc	SetWindowBackingStore( Cint, Cstr ) returns Cint;
	Cfunc	SetWindowSaveUnder( Cint, Cint );
	Cfunc	SetWindowGeometry(Cint,Cint,Cint,Cint,Cint,Cint);
	Cfunc	RaiseWindow(Cint);
	Cfunc	LowerWindow(Cint);
	Cfunc	CirculateSubwindowsDown(Cint);
	Cfunc	CirculateSubwindowsUp(Cint);

	Cfunc	theObj() returns Cstr;
	Cfunc	theEnv() returns Cstr;
	Cfunc	theCode() returns Cstr;
	Cfunc	GXCOPY() returns Cint;
	Cfunc	GXXOR() returns Cint;
	Cfunc	ALLPLANES() returns Cint;
	Cfunc	myWindow() returns Cint;
	Cfunc	myWindowEventMask() returns Cint;
	Cfunc	GetAFont( Cstr ) returns Cint;
	Cfunc	ShowText( Cint, Cint, Cint, Cstr, Cint, Cint, Cint, Cint );
	Cfunc	theRoot() returns Cint;	
	Cfunc	White() returns Cint;
	Cfunc	Black() returns Cint;
	Cfunc	MakeWindow( Cint, Cint, Cint, Cint, 
			Cint, Cint, Cint, Cint ) returns Cint;

	Cfunc	WindowFromName( Cstr ) returns Cint;
	Cfunc	NameFromWindow( Cint, Cstr ) returns Cint;

	Cfunc	GetParent( Cint ) returns Cint;
	Cfunc	GetMouse( Cint, Cstr, Cstr, Cstr ) returns Cint;
	Cfunc	RegisterWindow( Cint, Cstr );
	Cfunc	MapWindow( Cint );
	Cfunc	MapChildren( Cint );
	Cfunc	UnMap( Cint );
	Cfunc	ClearWindow( Cint );
	Cfunc	strlen( Cstr ) returns Cint;
	Cfunc	QueryFont( Cint, Cstr, Cstr ) returns Cint;

	Cfunc	QueryWindow( Cint, Cstr, Cstr, Cstr, Cstr, 
			Cstr, Cstr, Cstr, Cstr ) returns Cint;
	Cfunc	FlushEvents();
	Cfunc	Beep();
	Cfunc	MoveWindow( Cint, Cint, Cint );
	Cfunc	ChangeWindow( Cint, Cint, Cint );
	Cfunc	Quit();

-- RMS mod 3/8/90; CloneObj now takes a flag; if true, means
-- the state is copied from the parent obj; 0 means everything
-- is initially set to 0

	Cfunc	CloneObj( Cstr, Cstr, Cint ) returns Cint;

	Cfunc	GetColor( Cstr ) returns Cint;

	Cfunc	substr( Cstr, Cint, Cint, Cstr ) returns Cstr;

-- ======== old musekernel.cdefs follows ===============================

-- Functions used to dynamically allocate packages, etc. in readfile.c

-- misc

Cfunc	system(Cstr) returns Cint;

Cfunc	ProcessMuseEvents();		-- handles any pending X events
					-- BUT ... screws up timers
-- PARSING

-- these are completely untested so far
Cfunc	ParseMuseString(Cstr) returns Cint;
Cfunc	ParseMuseFile(Cstr) returns Cint;

-- WINDOWS

Cfunc	WindowFromScreen( Cint ) returns Cint;
Cfunc	DragWindow( Cint ) returns Cint;
Cfunc	SizeWindow( Cint ) returns Cint;

-- WIDGETS

Cfunc 	EnableDragWidget();
Cfunc 	EnableSizeWidget();

Cfunc	SetTextSelectMessage(Cint,Cstr,Cstr) returns Cint;
Cfunc	SetTextLineSelection(Cint,Cint) returns Cint;

--  PACKAGES

Cfunc 	set_position( Cint );	-- packpos
Cfunc	rset_position( Cint );	-- packpos
Cfunc   CreatePackage(Cstr) returns Cint; --Pck * .. (name)
Cfunc   GetPackageID( Cstr ) returns Cint;    -- packname
Cfunc   PackageAddDimension(Cint,Cint);  -- (PckId, DimID)
Cfunc   PackageAddElement(Cint,Cint);  -- (PckId, EleID)
Cfunc   Copy_package(Cint) returns Cint; --(PckID)->PckId
Cfunc   PackagePositionSpec( Cstr ) returns Cint ; --(packpos spec)->PckPosID
Cfunc   activate (Cint);  --(packpos)
Cfunc   expire (Cint);  --(packpos)
Cfunc   GetPackageAttribute (Cint,Cstr,Cstr); --(PckID,"attrib","res")
Cfunc   SetPackageAttribute (Cint,Cstr,Cstr); --(PckID,"attrib","val")
--These are the dimension attributes that can be used with set and get
--package attribs:

--	active
--	name
--	ndims (number of dimensions)
--	on_open
--	on_close
--	screen_name

--  DIMENSIONS
Cfunc   CreateDimension(Cstr) returns Cint; -- (name) ->DimID
Cfunc   Copy_dimension(Cint) returns Cint; --(DimID)->DimID
Cfunc   GetDimensionID(Cint, Cstr ) returns Cint;  -- (PckID,"dimname")
Cfunc   GetDimensionID2( Cstr ) returns Cint;  -- ("packname->dimname")
Cfunc   GetDimensionAttribute( Cint,Cstr ) returns Cint; --dimID,attribute
Cfunc   SetDimensionAttribute( Cint,Cstr,Cstr);
--These are the dimension attributes that can be used with set and get
--dim attribs:

--	current
--	initial
--	max
--	min
--	range
--	rate

--  ELEMENTS
Cfunc   GetElementID(Cint,Cstr) returns Cint; -- (PckID, name) -> EleID
Cfunc   Copy_element(Cint,Cint) returns Cint; -- (EleID,PckID) -> EleID
Cfunc   CreateElement(Cstr) returns Cint; -- (name) -> EleID
Cfunc   ElementAddMap(Cint,Cint); -- (EleID,MapID)
Cfunc   ElementAddScreenName(Cint,Cstr); -- (EleID,name)
Cfunc   ElementAddLocalScreen(Cint,Cint); -- (EleID,ScrnID)
Cfunc   activate_element(Cint); -- (EleID)
Cfunc   refresh( Cint ); -- (EleID)
Cfunc   SetElementAttribute(Cint,Cstr,Cstr);
--These are the dimension attributes that can be used with set and get
--element attribs: 

--	active
--	script
--	type


--  MAPS
Cfunc   CreateMap(Cstr,Cint) returns Cint; -- (map_type, widget)
Cfunc   Copy_map(Cint) returns Cint; -- (MapID)->MapID
Cfunc   SetMapAttribute(Cint,Cstr,Cstr); -- (MapID, attr, val )
Cfunc	SetWidgetAttribute(Cint,Cstr,Cstr); -- (MapID, attr, val )
Cfunc   ScreenToVirtual (Cint,Cint,Cint,Cint) returns Cint; --EleID,dim,x/y,pos
Cfunc   GetCurrentMap(Cint) returns Cint; --(ElementID) -> MapID
Cfunc   SetMapPosIn (Cint,Cint,Cint); --(MapID, dim, val)
Cfunc   SetMapPosOut  (Cint,Cint,Cint);
Cfunc   GetMapPosIn (Cint,Cint) returns Cint;
Cfunc   GetMapPosOut  (Cint,Cint) returns Cint;
Cfunc   evsetxy( Cint,Cint,Cint,Cint,Cint );   -- packID,xdim,x,ydim,y
Cfunc   evsetrate( Cint, Cint, Cint);          -- packID,rdim,rate

--  SCREENS

Cfunc	GetScreenID( Cint, Cstr ) returns Cint;

Cfunc 	DragScreen( Cint ) returns Cint;	-- convenience function
Cfunc 	SizeScreen( Cint ) returns Cint;	-- convenience function

       		   -- (name,type,parent,x, y,   w,   h,   bw,  bd
Cfunc   CreateScreen(Cstr,Cstr,Cstr,Cint,Cint,Cint,Cint,Cint,Cint,
			Cint,Cint,Cint) returns Cint;
 		  --     bg,  vx,  vy 		ScrnID
Cfunc   ScreenSetAdd(Cint,Cint,Cint); -- (pScrnID,ScrnID,new_screen_set)
	 --new_screen_set is a flag; 0->add to current set, 1 -> start new set
Cfunc   GetScreenAttribute(Cint,Cstr,Cstr); -- (ScrnID,att,result)
Cfunc   SetScreenAttribute(Cint,Cstr,Cstr); -- (ScrnID,att,value)

Cfunc   create_window(Cint); -- given a ScrnID, creates X window

-- ==================== last are new or experimental ===========

Cfunc kill(Cint,Cint) returns Cint;
Cfunc sleep(Cint);
Cfunc popen(Cstr,Cstr) returns Cint;
Cfunc pclose(Cint);
Cfunc fgets(Cstr,Cint,Cint) returns Cint;
Cfunc SetMuseParserObject(Cstr);

--			shell-command	text-pointer
Cfunc CreateStringFromPipe(Cstr) returns Cint;

Cfunc GetTextStringPointer(Cint) returns Cint;
Cfunc StringFromFile(Cstr) returns Cint;

Cfunc write_all_scriptfiles_from_to(Cint,Cint,Cint) returns Cint;
Cfunc write_screenset(Cint,Cint) returns Cint;
Cfunc write_package(Cint,Cint) returns Cint;

Cfunc strlen_ptr(Cint) returns Cint;
Cfunc fprintf_ptr(Cint,Cint) returns Cint;

Cfunc fopen(Cstr,Cstr) returns Cint;
Cfunc fwrite(Cint,Cint,Cint,Cint);
Cfunc fclose(Cint) returns Cint;
Cfunc fprintf(Cint,Cstr);
Cfunc ScreenFromWindow(Cint) returns Cint;

Cfunc GetElementAttribute(Cint,Cstr,Cstr);

Cfunc verify_window_mapped(Cint);

Cfunc CreatePackageList(Cstr) returns Cint;
Cfunc CreateElementList(Cstr,Cstr) returns Cint;

Cfunc CreateObjectList(Cstr) returns Cint;

Cfunc   MakeScreen(Cstr,Cstr,Cstr,Cint,Cint,Cint,Cint,Cint,Cint,
			Cint,Cint,Cint) returns Cint;

Cfunc TextDisplayCaret(Cint, Cint) returns Cint;

--		      eleID,string-from-above  success-code
Cfunc FillTextWithString(Cint,Cint) returns Cint;

Cfunc EvStringToPointer(Cstr) returns Cint;
Cfunc EvPointerToString(Cint,Cstr) returns Cint;
Cfunc SendToChildren(Cstr,Cstr) returns Cint;
--           prompt default answer no-cancel win   x   y    fg    bg
Cfunc AskFor(Cstr,  Cstr,   Cstr,  Cint,     Cint,Cint,Cint,Cint,Cint) 
	returns Cint;

Cfunc ScreenSetOfScreen(Cint) returns Cint;
Cfunc ScreenFromName(Cstr) returns Cint;

Cfunc MuseGetBox(Cint,Cstr,Cstr,Cstr,Cstr,Cint) returns Cint;
Cfunc MuseGetLine(Cint,Cstr,Cstr,Cstr,Cstr,Cint) returns Cint;
Cfunc MuseGetWindow(Cint) returns Cint;

Cfunc theObjectDict() returns Cint;
Cfunc dict_lookup(Cint,Cstr) returns Cint;

Cint u_Display;
Cfunc XFlush(Cint);
Cfunc XSync(Cint,Cint);

Cfunc PutVar(Cstr,Cstr,Cstr);
Cfunc GetVar(Cstr,Cstr) returns Cstr;

Cfunc IsClone(Cstr) returns Cint;
Cfunc HasChildren(Cstr) returns Cint;

Cfunc ScreenExists(Cstr,Cint) returns Cint;
Cfunc PackageExists(Cstr) returns Cint;
Cfunc ElementExists(Cstr,Cstr) returns Cint;

Cfunc getenv(Cstr) returns Cstr;
Cfunc getpid() returns Cint;
Cfunc strsave(Cstr) returns Cint;

Cfunc GetPackageDimID(Cint,Cint) returns Cint;
Cfunc GetDimensionName(Cint,Cstr) returns Cint;

Cstr theCurrentMessage;
Cint NumScriptFiles;

Cfunc MuseShellCommand(Cstr);

Cfunc ZoomOnWindow(Cint);
Cfunc ZoomOff();

}



