Exemplo n.º 1
0
void LabelManager::CreateLabels()
{
    void *file = LCOpen(NULL);
    
    if (file)
    {
        TCHAR line[MAX_LINE_LENGTH];
        
        // Read all the *Tutorial lines from the configuration file
        while (LCReadNextConfig(file, "*Tutorial", line, MAX_LINE_LENGTH))
        {
            TCHAR key[MAX_LINE_LENGTH];
            TCHAR value[MAX_LINE_LENGTH];
            LPTSTR buffers[2];
            
            buffers[0] = key;
            buffers[1] = value;
            
            // LCReadNextConfig returns the entire line, so we have to parse it
            // to get the label name
            if (LCTokenize(line, buffers, 2, NULL) >= 2)
            {
                CreateLabel(value);
            }
        }
        
        LCClose(file);
    }
}
Exemplo n.º 2
0
Arquivo: hotkey.c Projeto: now/purels
void loadHotkeys()
{
    FILE *f;
	int i;

	f = LCOpen(NULL);
	if (f)
	{
		char	buffer[4096];
		char	token1[4096], token2[4096], token3[4096], token4[4096], extra_text[4096];
		char*	tokens[4];
		
		tokens[0] = token1;
		tokens[1] = token2;
		tokens[2] = token3;
		tokens[3] = token4;

		buffer[0] = 0;

		while (LCReadNextConfig (f, "*Hotkey", buffer, sizeof (buffer)))
		{
			int count;

			token1[0] = token2[0] = token3[0] = token4[0] = extra_text[0] = '\0';

			count = LCTokenize (buffer, tokens, 4, extra_text);
			
			switch(count)
			{
			case 4:
				{
					char *tmp;

					if (!hotkeys)
						hotkeys = (hotkeyType *)malloc(sizeof(hotkeyType));
					else
						hotkeys = realloc(hotkeys, (numHotkeys+1)*sizeof(hotkeyType));

					hotkeys[numHotkeys].sub = 0;
					tmp = strtok(token2, "+");
					while (tmp)
					{
						if (!strcmpi(tmp, "Win"))
							hotkeys[numHotkeys].sub |= MOD_WIN;
						if (!strcmpi(tmp, "Alt"))
							hotkeys[numHotkeys].sub |= MOD_ALT;
						if (!strcmpi(tmp, "Ctrl"))
							hotkeys[numHotkeys].sub |= MOD_CONTROL;
						if (!strcmpi(tmp, "Shift"))
							hotkeys[numHotkeys].sub |= MOD_SHIFT;
						tmp = strtok(NULL, "+");
					}
					if (lstrlen(token3) == 1)
					{
						hotkeys[numHotkeys].ch = token3[0];
					} else {
						for (i = 0; i < MAX_VKEYS; i++)
						{
							if (!strcmpi(VKTable[i].key, token3))
							{
								hotkeys[numHotkeys].ch = VKTable[i].vkey;
							}
						}
					}

					strcpy(hotkeys[numHotkeys].szCommand, token4);
					strcpy(hotkeys[numHotkeys].szParameters, extra_text);
					numHotkeys++;
				}
			}
		}
		LCClose(f);
	}
}