#include "cs.h"
                                                /*    winFLTK.c         */
                                                /* Csound FLTK/X graphs */
                                                /*   jpff,06Oct02       */
#include <stdio.h>
#ifndef MYFLT
#include "sysdep.h"
#endif
#include "cwindow.h"
#include "text.h"

extern long MakeWindow(char *);
extern void kill_graph(int);
extern   int myFLwait(void);
extern void *XOpenDisplay(char *);

int Graphable_(void)     /* called during program initialisation */
{               /* decides whether to use X or not; initializes X if so */
    int         rc = 0;         /* default : don't use X, use tty ascii */

    if (XOpenDisplay(NULL)) rc = 1;  /*       so set return code  */
    return(rc);
}

void MakeGraph_(WINDAT *wdptr, char *name)
{
    wdptr->windid = MakeWindow(name);
}

void KillGraph_(WINDAT *wdptr)
{
    kill_graph(wdptr->windid);
}

int ExitGraph_(void) /* print click-Exit message in most recently active window */
{
    char *env = getenv("CSNOSTOP");
    if (env==NULL || strcmp(env,"yes")==0)
      myFLwait();
    return 0;
}



