
#ifdef SPC_VAR

// __types += %{ vartree; %};

global SVAR = %{
// ^^^^ we have some fixed qualifiers ...
// GLOBAL/PROJECT/TEMPORARY and (CONST|HIDDEN)=INTERNAL
// but exept for const and hidden they are ignored ...


    // ---- this is the list of all possible types in this tree;
    //	    their bodies represent the names that have special
    //	    meanings and so shall be treated case insenitive
    //	    (I'll try to place the defaults into that types-definition, too)
    //	    ahhh - types are also treated case-insensitive
    __TYPES = %{
	// ---- MACRO bits - Flags that already have a macro interface!
	MBIT   = %{
	    REFERENCE;
	    SET = %[ SETF_$(@TOUPPER@$(REFERENCE)) (Ep, test_arg (value, GETF_$(@TOUPPER@$(REFERENCE)) (Ep))); %];
	    GET = %[ value = GETF_$(@TOUPPER@$(REFERENCE)) (Ep)? "1": "0"; %];
	    //SAY = %[ warn("%s switched %s", $(@IF@!?NICKNAME@spc_names[_I_$(NAME)_])$(@IF@?NICKNAME@$(NICKNAME)), GETF_$(@TOUPPER@$(REFERENCE)) (Ep)? __on: __off); %];
	    SAY = %[ warn("%s switched %s", spc_names[_I_$(NAME)_], GETF_$(@TOUPPER@$(REFERENCE)) (Ep)? __on: __off); %];
	%};

	// ---- for the case, a flag has not (yet) got its macro interface
	BIT    = %{
	    REFERENCE;
	    SET = %[ $(REFERENCE) = test_arg (value, $(REFERENCE)); %];
	    GET = %[ value = $(REFERENCE)? "1": "0"; %];
	    //SAY = %[ warn("%s switched %s", $(@IF@!$(?NICKNAME)@spc_names[_I_$(NAME)_])$(@IF@?NICKNAME@$(NICKNAME)), $(REFERENCE)? __on: __off); %];
	    SAY = %[ warn("%s switched %s", spc_names[_I_$(NAME)_], $(REFERENCE)? __on: __off); %];
	%};

	// ---- SEMI - bits: get as bit, set as Functions
	SBIT   = %{
	    REFERENCE;
	    SETTRUE;
	    SETFALSE;
	    GET = %[ value = GETF_$(@TOUPPER@$(REFERENCE)) (Ep)? "1": "0"; %];
	    SET = %[
		array[0] = test_arg(value, GETF_$(@TOUPPER@$(REFERENCE)) (Ep));
		if (array[0] != GETF_$(@TOUPPER@$(REFERENCE)) (Ep))
		    if (array[0]) $(SETTRUE)
		    else	  $(SETFALSE) %];
	    //SAY = %[ warn("%s switched %s", $(@IF@!$(?NICKNAME)@spc_names[_I_$(NAME)_])$(@IF@?NICKNAME@$(NICKNAME)), GETF_$(@TOUPPER@$(REFERENCE)) (Ep)? __on: __off); %];
	    SAY = %[ warn("%s switched %s", spc_names[_I_$(NAME)_], GETF_$(@TOUPPER@$(REFERENCE)) (Ep)? __on: __off); %];
	%};

	// ---- handling for numeric variables
	INT    = %{
	    REFERENCE;
	    SET = %[ $(REFERENCE) = atol(value); %];
	    GET = %[ value = ltostr((long)$(REFERENCE)); %];
	    SAY = %[ warn("%s set to %d", spc_names[_I_$(NAME)_], $(REFERENCE)); %];
	%};

	// ---- static strings and strings, that shall not be reallocated
	STR    = %{
	    REFERENCE;
	    SET = %[ strcpy ($(REFERENCE), value); %];
	    GET = %[ value = $(REFERENCE); %];
	    SAY = %[ warn("%s set to %s", spc_names[_I_$(NAME)_], $(REFERENCE)); %];
	%};

	// ---- dyanimcally allocated strings (using strdup/malloc/free)
	STRPTR = %{
	    REFERENCE;
	    SET = %[ $(REFERENCE) = strrep ($(REFERENCE), value); %];
	    GET = %[ value = $(REFERENCE); %];
	    SAY = %[ warn("%s set to %d", spc_names[_I_$(NAME)_], $(REFERENCE)); %];
	%};

	// ---- for the case, we need complex functions (e.g. to parse the value)
	//	the KILLSTACK is used to show, that a certain item shall be
	//	respected in the stack-cleanup function
	FNC    = %{
	    KILLSTACK;
	    SAY = "return 0;";
	%};

    %};

    // ---- that is an additional list of fixed names, which shall
    //	    be treated case insensitive; it is common to all types
    __NEEDED = %{ SET; GET; REFERENCE; %};

    // ---- following are default entries for all types, as far as
    //	    each type has any default entries.

//    MBIT __default = %{
//    %};
//    BIT __default = %{
//    %};
//    INT __default = %{
//    %};
//    STR __default = %{
//    %};
//    STRPTR __default = %{
//    %};
//    SBIT __default = %{
//    %};


    // ---- entries for the pens ...

    int fgpen = %{ reference =	"TEXT_FPEN(Ep)"; %};
    int bgpen = %{ reference =	"TEXT_BPEN(Ep)"; %};
    int hgpen = %{ reference = "BLOCK_FPEN(Ep)"; %};
    int bbpen = %{ reference = "BLOCK_BPEN(Ep)"; %};
    int tfpen = %{ reference = "TITLE_FPEN(Ep)"; %};
    int tbpen = %{ reference = "TITLE_BPEN(Ep)"; %};

    // ---- entries for the normal flags ...

    mbit activetofront	    = %{ reference = "activatetofront"; %};
    mbit autoindent	    = %{ reference = "autoindent";  %};
    mbit autosplit	    = %{ reference = "autosplit";   %};
    mbit autounblock	    = %{ reference = "autounblock"; %};
    mbit debug		    = %{ reference = "debug";       %};
    mbit dobackup	    = %{ reference = "doback";      %};
    mbit followcursor	    = %{ reference = "FollowCursor"; %};
    mbit globalsearch	    = %{ reference = "globalsearch"; %};
    mbit iconactive	    = %{ reference = "iconactive";  %};
    mbit ignorecase	    = %{ reference = "ignorecase";  %};
    mbit insertmode	    = %{ reference = "insertmode";  %};
    mbit modified	    = %{ reference = "modified";    %};
    mbit nicepaging	    = %{ reference = "nicepaging";  %};
    mbit norequest	    = %{ reference = "NoRequest";   %};
    mbit saveicons	    = %{ reference = "Saveicons";   %};
    mbit savetabs	    = %{ reference = "Savetabs";    %};
    mbit shortlines	    = %{ reference = "SLine";       %};
    mbit showtitle	    = %{ reference = "Showtitle";   %};
    mbit simpletabs	    = %{ reference = "SimpleTabs";  %};
    mbit sourcebreaks	    = %{ reference = "SourceBreaks"; %};
    mbit viewmode	    = %{ reference = "viewmode";    %};
    mbit windowcycling	    = %{ reference = "Windowcycling"; %};
    mbit windowtitles	    = %{ reference = "WindowTitles"; %};
    mbit wordwrap	    = %{ reference = "wordwrap";    %};
    const mbit comlinemode  = %{ reference = "Comlinemode"; %};
    project sbit iconmode   = %{ reference = "iconmode"; settrue = "iconify ();"; setfalse = "uniconify ();"; %};


    // ---- Pardon - references do currently not work
    // bit intuitiontitles = windowtitles;

    // ---- normal integers

    const project int ascii	= %{ reference = "Current[Ep->column]"; %};
    const project int colno	= %{ reference = "Ep->column + 1";      %};
    const project int lineno	= %{ reference = "Ep->line + 1";        %};
    const project int numlines	= %{ reference = "Ep->lines";           %}; // 02-11-94
    project int margin		= %{ reference = "Ep->config.margin";   %};
    project int parcol		= %{ reference = "Ep->config.wwcol";    %};
    project int tabstop 	= %{ reference = "Ep->config.tabstop";  %};

    // ---- strings

    strptr scanf	= %{ reference = "String";   %};
    str findstr 	= %{ reference = "Fstr";     %};
    str fname		= %{ reference = "Ep->name"; %};
    str repstr		= %{ reference = "Rstr";     %};
    const str version	= %{ reference = "version";  %};
    const str rexxport	= %{ reference = "RexxPortName"; %};
    str reqpattern	= %{ reference = "pattern"; %};
    str icontitle	= %{ reference = "icontitle_pattern"; %};
    str title		= %{ reference = "title_pattern"; %};


    // ---- where do end variables and where do start functions ?

    const project fnc currentline   = %{ get = "value = Current"; set = %[ strcpy (Current, value); Clen = strlen(Current); while (Clen < Ep->column) Current[Clen++] = ' '; Current[Clen] = '\0'; %]; %};
    const project fnc restofline    = %{ get = "value = Current + Ep->column"; %};
    const project fnc currentword   = %{ get = "value = current_word()"; %};
    const project fnc recentword    = %{ get = "value = recent_word()"; %};
    const project fnc firstnb	    = %{ get = "value = ltostr(firstns (Current) + 1);" %};



    //
    //	COPY OF THE ENTRIES IN `Src/Mod/*.c'
    //

    bit       infixmode 	 = %{ reference = "MathInfix";          %};
    const str reqresult 	 = %{ reference = "ReqString";          %};
    strptr    cmdshellname	 = %{ reference = "CMDSH_FileName";     %};
    strptr    cmdshellprompt	 = %{ reference = "CMDSH_Prompt";       %};
    bit       errorsoncmdshell	 = %{ reference = "CMDSH_ErrorsOut";    %};
    bit       warningsoncmdshell = %{ reference = "CMDSH_WarningsOut";  %};
    sbit      cmdshell		 = %{ reference = "CMDSH_Active"; settrue = "do_opencmdshell();"; setfalse = "do_closecmdshell();"; %};
    sbit      appicon		 = %{ reference = "APIC_Active";  settrue = "do_apicshow();";     setfalse = "do_apichide();";      %};
    strptr    appicontitle	 = %{ reference = "APIC_IconTitle";     %};
    strptr    appiconname	 = %{ reference = "APIC_IconFile";      %};
    strptr    appicondropaction  = %{ reference = "APIC_ActionDrop";    %};
    strptr    appiconclickaction = %{ reference = "APIC_ActionDblClick"; %};
    strptr    gtbformat 	 = %{ reference = "GTB_Format";         %};

    const project int txtfontsize= %{ reference = "(Ep->font? Ep->font->tf_YSize: (Ysize - LineDistance))"; %};
    const project str txtfontname= %{ reference = "(Ep->font? Ep->font->tf_Message.mn_Node.ln_Name: \"*Defaultfont*\")"; %};
    //const project str txtfontname= %{ reference = "(Ep->font? Ep->font: Ep->win->RPort->Font)->tf_Message.mn_Node.ln_Name"; %};

    int    menufontsize  = %{ reference = "menufont_ta.ta_YSize";
	    SET = %[
		menufont_ta.ta_YSize = atol(value);
		verify_menufont();
	    %];
    %};
    strptr menufontname  = %{ reference = "menufont_ta.ta_Name";
	    SET = %[
		$(REFERENCE) = strrep ($(REFERENCE), value);
		verify_menufont();
	    %];
    %};


    //	... So, the rest of this file represents only
    //	about 13 additional Functional variables
    //


    //temporary
    const fnc itemcheck = %{
	get = %[ if (active_menu)
		value = (((struct MenuItem *)active_menu)->Flags & CHECKED) ? "1": "0";
	%];
	set = %[ if (active_menu) {
		UWORD *flags, fv;;
		fv = *(flags = &(((struct MenuItem *)active_menu)->Flags);
		*flags = (fv & ~CHECKED) | test_arg(value, (fv & CHECKED) ? 1: 0);
		if (fv != *flags)
		    menu_strip (currentmenu(), Ep->win);
	    } /* if */
	%];
    %};

    // easy access to the prev nonblank line, if s.o. (me) wants to have fancy indenting makros
    project const fnc prevnbline = %{
	get = %[{
	    int i = Ep->line;
	    while ((--i >= 0) && !GETTEXT(Ep,i)[0]);
	    value = (i >= 0)? GETTEXT(Ep,i): "";
	}%];
    %};

    // control over the used Keytable
    project fnc keytable = %{
	get = %[
	    if ((value = (void*)currenthash()))
		value = ((struct Node *)value)->ln_Name;
	%];
	set = %[
	    av[1] = value;
	    do_use_keytable();
	    av[1] = av1_bak;
	%];
    %};

    // control over the used menustrip
    project fnc menustrip = %{
	get = %[
	    if ((value = (void *)currentmenu()))
		value = ((struct Node *)value)->ln_Name;
	%];
	set = %[
	    av[1] = value;
	    do_use_menustrip();
	    av[1] = av1_bak;
	%];
    %};

    // communtication w/ arexx
    fnc rxresult = %{
	get = %[ value = get_rexx_result(); %];
	set = %[{
	    av[1] = value;
	    put_rexx_result();
	    av[1] = av1_bak;
	}%];
    %};

    // control over the file's path and name
    project fnc filename = %{
	get = %[ if (getpathto(Ep->dirlock, Ep->name, tmp_buffer))
		value = tmp_buffer;
	%];
	set = %[
	    av[1] = value;
	    do_chfilename();
	    av[1] = av1_bak;
	%];
    %};

    // control over file's path
    project fnc currentdir = %{
	get = %[ if (NameFromLock(Ep->dirlock, tmp_buffer, sizeof(tmp_buffer)))
		value = tmp_buffer;
	%];
	set = %[
	    av[1] = value;
	    do_cd();
	    av[1] = av1_bak;
	%];
    %};




    //
    //	COPY OF THE ENTRIES IN CMD.c
    //	due to the following functions, we can drop the item-stack
    //



    FNC project pens = %{
	set = %[
	    sscanf (value, "%ld %ld %ld %ld %ld %ld", &array[0], &array[1], &array[2], &array[3], &array[4], &array[5]);

	    TEXT_FPEN(Ep) = array[0];
	    TEXT_BPEN(Ep) = array[1];
	    BLOCK_FPEN(Ep) = array[2];
	    BLOCK_BPEN(Ep) = array[3];
	    TITLE_FPEN(Ep) = array[4];
	    TITLE_BPEN(Ep) = array[5];

	    if (!GETF_ICONMODE(Ep))
		text_redisplay ();

	    SETF_MFORCETITLE(Ep,1);
	%];
	get = %[
	    array[0] =	TEXT_FPEN(Ep);
	    array[1] =	TEXT_BPEN(Ep);
	    array[2] = BLOCK_FPEN(Ep);
	    array[3] = BLOCK_BPEN(Ep);
	    array[4] = TITLE_FPEN(Ep);
	    array[5] = TITLE_BPEN(Ep);

	    sprintf (tmp_buffer, "%ld %ld %ld %ld %ld %ld", array[0], array[1], array[2], array[3], array[4], array[5]);
	    value = tmp_buffer;
	%];
    %};

    FNC project icon = %{
	set = %[
	    sscanf (value, "%ld %ld", &array[0], &array[1]);

	    Ep->config.iwinx	  = array[0];
	    Ep->config.iwiny	  = array[1];

	    if (GETF_ICONMODE(Ep)) {
		MoveWindow (Ep->win, Ep->config.winx - Ep->win->LeftEdge,
				    Ep->config.winy - Ep->win->TopEdge);
	    } /* if */
	%];
	get = %[
	    if (GETF_ICONMODE(Ep)) {
		array[0] = Ep->config.iwinx;
		array[1] = Ep->config.iwiny;
	    } else {
		array[0] = Ep->win->LeftEdge;
		array[1] = Ep->win->TopEdge;
	    } /* if */
	    sprintf (tmp_buffer, "%ld %ld", array[0], array[1]);
	    value = tmp_buffer;
	%];
    %};

    FNC project window = %{
	set = %[
	    sscanf (value, "%ld %ld %ld %ld", &array[0], &array[1], &array[2], &array[3]);

	    Ep->config.winx	 = array[0];
	    Ep->config.winy	 = array[1];
	    Ep->config.winwidth  = array[2];
	    Ep->config.winheight = array[3];

	    if (!GETF_ICONMODE(Ep)) {
		MoveWindow (Ep->win, Ep->config.winx - Ep->win->LeftEdge,
				    Ep->config.winy - Ep->win->TopEdge);
		SizeWindow (Ep->win, Ep->config.winwidth  - Ep->win->Width,
				    Ep->config.winheight - Ep->win->Height);
	    } /* if */
	%];
	get = %[
	    if (!GETF_ICONMODE(Ep)) {
		array[0] = Ep->config.winx;
		array[1] = Ep->config.winy;
		array[2] = Ep->config.winwidth;
		array[3] = Ep->config.winheight;
	    } else {
		array[0] = Ep->win->LeftEdge;
		array[1] = Ep->win->TopEdge;
		array[2] = Ep->win->Width;
		array[3] = Ep->win->Height;
	    } /* if */

	    sprintf (tmp_buffer, "%d %d %d %d", array[0], array[1], array[2], array[3]);
	    value = tmp_buffer;
	%];
    %};

    fnc ed = %{
	killstack = %[ check = strtol(value, &value, 16); %];
	set = %[
	    if (VSTK_Internal)
		sscanf (value, "%08lx", &array[0]);
	    else {
		array[0] = (long)finded (value, 0);
	    } /* if */

    /* /* **** MISSING SAFETY CHECK!!!! **** */

	    //text_cursor (1);
	    switch_ed ((void *)array[0]);
	    //text_cursor (0);

	    ActivateWindow (Ep->win);                              /// FIX
	    if (GETF_ACTIVATETOFRONT(Ep))
		WindowToFront(Ep->win);
	    //text_load ();
	    //text_adjust (FALSE);
    //////////////////////////////////////////////////////////////////
    //	For an unknown reason, SETting eds is not performed success-   FIXED
    //	fully; this is a bug in DO_POP, where I got the code from      FIXED
    //////////////////////////////////////////////////////////////////
	%];
	get = %[
	    if (VSTK_Internal)
		sprintf (value = tmp_buffer, "%08lx", Ep);
	    else
		value =  ((struct Node *)Ep)->ln_Name;
	%];
    %};

    FNC global pos = %{
	killstack = %[ check = strtol(value, &value, 16); %];
	set = %[{
	    struct TextMarker pos;
	    if (VSTK_Internal)
		sscanf (value, "%08lx %08lx %08lx", &array[0],  &array[1], &array[2]);
	    else {
		sscanf (value, "%s %ld %ld", tmp_buffer, &array[1], &array[2]);
		array[0] = (long)finded (tmp_buffer, 0);
	    } /* if */

	    pos.ep	= (void*)array[0];
	    pos.line	= array[1];
	    pos.column	= array[2];

    /* /* **** MISSING SAFETY CHECK!!!! **** */

	    text_sync ();

	    text_cursor (1);
	    switch_ed (pos.ep);
	    text_cursor (0);

	    if (IntuitionBase->ActiveWindow != Ep->win) {
		if (GETF_ACTIVATETOFRONT(Ep))
		    WindowToFront (Ep->win);
		ActivateWindow (Ep->win);
	    }

	    if (pos.line >= Ep->lines)
		Ep->line = Ep->lines - 1;
	    else
		Ep->line = pos.line;

	    Ep->column = pos.column;

	    text_load ();
	    text_adjust (FALSE);
	}%];
	get = %[
	    if (VSTK_Internal)
		sprintf (tmp_buffer, "%08lx %08lx %08lx", (long)Ep, (long)Ep->line, (long)Ep->column);
	    else
		sprintf (tmp_buffer, "%s %ld %ld", ((struct Node *)Ep)->ln_Name, (long)Ep->line, (long)Ep->column);
	    value = tmp_buffer;
	%];
    %};

    FNC global block = %{
	killstack = %[ check = strtol(value, &value, 16); %];
	set = %[{
	    Block block;
	    //int type = ActualBlock.type;

	    if (VSTK_Internal)
		sscanf (value, "%08lx %lx %08lx %08lx %08lx %08lx", &array[0], &array[1], &array[2], &array[3], &array[4], &array[5]);
	    else {
		sscanf (value, "%s %ld %ld %ld %ld %ld", tmp_buffer, &array[1], &array[2], &array[3], &array[4], &array[5]);
		array[0] = (long)finded (tmp_buffer, 0);
	    } /* if */

	    block.ep	       = (void *)array[0];
	    block.type	       = array[1];
	    block.start_line   = array[2];
	    block.start_column = array[3];
	    block.end_line     = array[4];
	    block.end_column   = array[5];

    /* /* **** MISSING SAFETY CHECK!!!! **** */

	    //do_unblock();
	    set_block (&block);

	    if (!GETF_ICONMODE(ActualBlock.ep))
		//if (ActualBlock.type == type)
		//    text_redrawblock (1);
		//else
		//    text_redisplay ();
		displayblock(1);
    //////////////////////////////////////////////////////////////////
    //	For an unknown reason, SETting non-blocks leads to redraw	FIXED
    //	problems; this is a bug in DO_POP, where I got the code from	FIXED
    //////////////////////////////////////////////////////////////////
	}%];
	get = %[{
	    Block block;
	    get_block(&block);
	    if (VSTK_Internal)
		sprintf (tmp_buffer, "%08lx %lx %08lx %08lx %08lx %08lx",
					(long)block.ep,
					(long)block.type,
					(long)block.start_line,
					(long)block.start_column,
					(long)block.end_line,
					(long)block.end_column);
	    else
		sprintf (tmp_buffer, "%s %ld %ld %ld %ld %ld",
					(long)((struct Node *)block.ep)->ln_Name,
					(long)block.type,
					(long)block.start_line,
					(long)block.start_column,
					(long)block.end_line,
					(long)block.end_column);
	    value = tmp_buffer;
	}%];
    %};


%}; // vartree SpecialVars

#endif
//#endif
//#if 0




//fnc qualifiers

//we would need a list_2_str ... better list_2_dstr
//const fnc refpaths
//const fnc textnames

// const int win-x/y/width/height
// const int iwin-x/y
// int asl-left/top/width/height
// fnc font
// fnc windowsize
// int taskpri

// useful would be:
// str tabline
// const int tableft
// const int tabright
// const bit istab
// str delimiters
// bit first_click_activates_window
// int number_max_click -> 1-4
// int dble_click_treshold



