Ejemplo n.º 1
0
void Cursor_Del(ConsoleInformation *console) {
    char temp[CON_CHARS_PER_LINE+1];

    if(strlen(Topmost->RCommand) > 0) {
        strcpy(temp, Topmost->RCommand);
        strcpy(Topmost->RCommand, &temp[1]);
        Assemble_Command(console);
    }
}
Ejemplo n.º 2
0
void Cursor_BSpace(ConsoleInformation *console) {
    if(Topmost->CursorPos > 0) {
        Topmost->CursorPos--;
        Topmost->Offset--;
        if(Topmost->Offset < 0)
            Topmost->Offset = 0;
        Topmost->LCommand[strlen(Topmost->LCommand)-1] = '\0';
        Assemble_Command(console);
    }
}
Ejemplo n.º 3
0
void Cursor_Add(ConsoleInformation *console, SDL_Event *event) {
	int len = 0;

	/* Again: the commandline has to hold the command and the cursor (+1) */
	if(strlen(Topmost->Command) + 1 < CON_CHARS_PER_LINE && event->key.keysym.unicode) {
		Topmost->CursorPos++;
		len = strlen(Topmost->LCommand);
		Topmost->LCommand[len] = (char)event->key.keysym.unicode;
		Topmost->LCommand[len + sizeof(char)] = '\0';
		Assemble_Command(console);
	}
}
Ejemplo n.º 4
0
void Command_Up(ConsoleInformation *console) {
    if(console->CommandScrollBack < console->TotalCommands - 1) {
        /* move back a line in the command strings and copy the command to the current input string */
        console->CommandScrollBack++;
        /* I want to know if my string handling REALLY works :-) */
        /* memset(console->RCommand, 0, CON_CHARS_PER_LINE);
        memset(console->LCommand, 0, CON_CHARS_PER_LINE); */
        console->RCommand[0] = '\0';

        console->Offset = 0;
        strcpy(console->LCommand, console->CommandLines[console->CommandScrollBack]);
        console->CursorPos = strlen(console->CommandLines[console->CommandScrollBack]);
        Assemble_Command(console);
    }
}
Ejemplo n.º 5
0
void Cursor_Add(ConsoleInformation *console, SDL_Event *event) {
    int len = 0;

    if (event->key.keysym.sym < SDLK_SPACE || event->key.keysym.sym > SDLK_z)
    {
        return;
    }

    // Todo: keysym.unicode is obsolete
    /* Again: the commandline has to hold the command and the cursor (+1) */
    if(strlen(Topmost->Command) + 1 < CON_CHARS_PER_LINE && event->key.keysym.sym) {
        Topmost->CursorPos++;
        len = strlen(Topmost->LCommand);
        Topmost->LCommand[len] = (char)event->key.keysym.sym;
        Topmost->LCommand[len + sizeof(char)] = '\0';
        Assemble_Command(console);
    }
}
Ejemplo n.º 6
0
void Add_String_to_Console(char *text)
{

    int len = 0, textlen, i;

    textlen = (int)strlen(text);

    for ( i = 0 ; i < textlen; ++i) {
        /* Again: the commandline has to hold the command and the cursor (+1) */
        if (strlen(Topmost->Command) + 1 < CON_CHARS_PER_LINE) {
            Topmost->CursorPos++;
            len = strlen(Topmost->LCommand);
            Topmost->LCommand[len] = text[i];
            Topmost->LCommand[len + sizeof(char)] = '\0';
            Assemble_Command(Topmost);
        }
    }
}
Ejemplo n.º 7
0
void Command_Down(ConsoleInformation * console)
{
    if (console->CommandScrollBack > -1) {
        /* move forward a line in the command strings and copy the command to the current input string */
        console->CommandScrollBack--;
        /* I want to know if my string handling REALLY works :-) */
        /* memset(console->RCommand, 0, CON_CHARS_PER_LINE);
           memset(console->LCommand, 0, CON_CHARS_PER_LINE); */
        console->RCommand[0] = '\0';

        console->Offset = 0;
        if (console->CommandScrollBack > -1)
            strcpy(console->LCommand, console->CommandLines[console->CommandScrollBack]);
        else
            strcpy(console->LCommand,console->BackupCommand);
        console->CursorPos = strlen(console->LCommand);
        Assemble_Command(console);
    }
}
Ejemplo n.º 8
0
void CON_TabCompletion(ConsoleInformation * console)
{
    int i, j;
    char *command;

    if (!console)
        return;

    command = strdup(console->LCommand);
    command = console->TabFunction(command);

    if (!command)
        return;			/* no tab completion took place so return silently */

    /*      command now contains the tabcompleted string. check for correct size
       since the string has to fit into the commandline it can have a maximum length of
       CON_CHARS_PER_LINE = commandlength + space + cursor
       => commandlength = CON_CHARS_PER_LINE - 2
     */
    j = strlen(command);
    if (j + 2 > CON_CHARS_PER_LINE)
        j = CON_CHARS_PER_LINE - 2;

    memset(console->LCommand, 0, CON_CHARS_PER_LINE + 1);
    console->CursorPos = 0;

    for (i = 0; i < j; i++) {
        console->CursorPos++;
        console->LCommand[i] = command[i];
    }
    /* add a trailing space */
    console->CursorPos++;
    console->LCommand[j] = ' ';
    console->LCommand[j + 1] = '\0';

    Assemble_Command(console);
}