Ejemplo n.º 1
0
main()
{
    cmdScannerADT cs;

    printf("Test program for the symbol table package\n");
    cs = NewCommandScanner();
    SetCommandData(cs, NewSymbolTable());
    InitCommandTable(cs);
    CommandLoop(cs, "-> ");
    FreeSymbolTable(GetCommandData(cs));
    FreeCommandScanner(cs);
}
Ejemplo n.º 2
0
static void EnterCmdFn(cmdScannerADT cs)
{
    symtabADT table;
    string key, token, value;

    table = GetCommandData(cs);
    key = ReadCommandToken(cs);
    token = ReadCommandToken(cs);
    if (!StringEqual(token, "=")) Error("Enter: Missing =");
    value = ReadCommandToken(cs);
    CheckForExtraTokens(cs);
    Enter(table, key, value);
}
Ejemplo n.º 3
0
static void ListCmdFn(cmdScannerADT cs)
{
    scannerADT scanner;
    symtabADT nodeTable;
    graphADT graph;
    nodeADT node, target;

    graph = GetCommandData(cs);
    foreach (node in Nodes(graph)) {
        printf("%s:", (string) GetNodeData(node));
        foreach (target in ConnectedNodes(node)) {
            printf(" %s", (string) GetNodeData(target));
        }
Ejemplo n.º 4
0
static void ListCmdFn(cmdScannerADT cs)
{
    symtabADT table;
    string key, value;
    iteratorADT iterator;

    CheckForExtraTokens(cs);
    table = GetCommandData(cs);
    iterator = NewIterator(table);
    while (StepIterator(iterator, &key)) {
        value = Lookup(table, key);
        printf("%s = %s\n", key, value);
    }
    FreeIterator(iterator);
}
Ejemplo n.º 5
0
static void LookupCmdFn(cmdScannerADT cs)
{
    symtabADT table;
    string key, value;

    table = GetCommandData(cs);
    key = ReadCommandToken(cs);
    CheckForExtraTokens(cs);
    value = Lookup(table, key);
    if (value == UNDEFINED) {
        printf("'%s' is undefined.\n", key);
    } else {
        printf("%s\n", value);
    }
}
Ejemplo n.º 6
0
static void NodeCmdFn(cmdScannerADT cs)
{
    scannerADT scanner;
    symtabADT nodeTable;
    graphADT graph;
    nodeADT node;
    string label;

    scanner = GetTokenScanner(cs);
    graph = GetCommandData(cs);
    nodeTable = GetGraphData(graph);
    label = ReadToken(scanner);
    if (Lookup(nodeTable, label) != UNDEFINED) {
        printf("That node already exists\n");
    } else {
        node = NewNode(graph);
        SetNodeData(node, label);
        Enter(nodeTable, label, node);
    }
}
Ejemplo n.º 7
0
// Adds the columns to the controls
void CScreenConfigure::InitControlList()
{

	LTIntPt pos(m_ListRect.left,m_ListRect.top);


	for (int i=0; i < g_kNumCommands; i++)
	{
		const CommandData *pData = GetCommandData(i);

		//check to see that this is a TO2 command
		if (pData->nCommandID < FIRST_TRON_COMMAND)
		{
			// The initial column (contains the action)
			CLTGUIColumnCtrl *pCtrl=CreateColumnCtrl(CMD_CHANGE_CONTROL, IDS_HELP_SETCONTROL);
			pCtrl->SetFont(LTNULL,m_nListFontSize);

			// The "action" column
			char szTmp[64];
			FormatString(pData->nStringID,szTmp,sizeof(szTmp));
			pCtrl->AddColumn(szTmp, m_nActionWidth);

			// The equals column.  Changes from "" to "=" when the user is binding the key
			pCtrl->AddColumn(" ", m_nEqualsWidth);

			// The column that contains the key which is assigned to the control!
			FormatString(IDS_CONTROL_UNASSIGNED,szTmp,sizeof(szTmp));
			pCtrl->AddColumn(szTmp, m_nCommandWidth);

			pCtrl->SetParam1(i);

			m_pList[pData->nCommandType]->AddControl(pCtrl);
		}

	}
}
Ejemplo n.º 8
0
static void ClearCmdFn(cmdScannerADT cs)
{
    CheckForExtraTokens(cs);
    FreeSymbolTable(GetCommandData(cs));
    SetCommandData(cs, NewSymbolTable());
}
Ejemplo n.º 9
0
LTBOOL CScreenConfigure::KeyRemappable (DeviceInput* pInput)
{

	if (pInput->m_DeviceType != DEVICETYPE_KEYBOARD) return LTTRUE;

	uint16 nDIK = pInput->m_ControlCode;
	if (nDIK == DIK_ESCAPE)
        return LTFALSE;
	if (nDIK == DIK_PAUSE)
        return LTFALSE;
	if (nDIK >= DIK_F1 && nDIK <= DIK_F10)
        return LTFALSE;
	if (nDIK >= DIK_F11 && nDIK <= DIK_F15)
        return LTFALSE;


    DeviceBinding* pBindings = g_pLTClient->GetDeviceBindings (DEVICETYPE_KEYBOARD);
    if (!pBindings) return LTTRUE;

	// see if this input object is already bound to something...

	DeviceBinding* ptr = pBindings;
	while (ptr)
	{
		if( ptr->m_nObjectId == pInput->m_nObjectId )
		{
			// see if this binding is in the list of mappable ones
			GameAction* pAction = ptr->pActionHead;
			while (pAction)
			{
                LTBOOL bFound = LTFALSE;
				for (int i = 0; i < g_kNumCommands; i++)
				{
					const CommandData *pData = GetCommandData(i);
					if (pData->nCommandID == pAction->nActionCode)
					{
                        bFound = LTTRUE;
						break;
					}
				}

				if (!bFound)
				{
					// this key is already bound to something but is not remappable
                    g_pLTClient->FreeDeviceBindings (pBindings);
                    return LTFALSE;
				}

				pAction = pAction->pNext;
			}

			// binding must already exist in the folders...
			break;
		}
		ptr = ptr->pNext;
	}

	// either the binding exists in the folders or this key is not currently bound...therefore it's remappable

    g_pLTClient->FreeDeviceBindings (pBindings);
    return LTTRUE;
}