Exemplo n.º 1
0
void consoleDraw(char *sd, int row, int col, int len)
{
    /* <SY>This function is used to display a text field containing
    the string 'sd' on the screen.*/
    int i;

    if(sd && row>=0 && col>=0) {
        consoleMove(row,col);               //set position

        if(len<=0) {
            consolePutS((char*)sd);

        } else {

            for(i=0; i<len && sd[i]!='\0'; i++) {
                consolePutC(sd[i]);
            }
            for(; i<len; i++) {
                consolePutC(' ');
            }

        }
    }

}
Exemplo n.º 2
0
int consoleBox(int row, int col, int l, int h, char edge, char top_btm, char ls_rs)
{
	int i, j; // For-loop counters
	int fit = 0; // Return value

	// Checks if box can fit
	if ((row + h) <= consoleGetRows() && (col + l) <= consoleGetCols())
	{
		consoleMove(row, col); // Moves the cursor to starting position

		for (i = 1; i <= h; i++) // Box rows
		{
			for (j = 1; j <= l; j++) // Box columns
			{
				if ((j == 1) || (j == l)) // If we're at the beginning or the end
				{
					if ((i == 1) || (i == h)) // If we're at the top or the bottom
					{
						consolePutC(edge); // Put edge character
					}
					else
					{
						consolePutC(ls_rs); // Put left-right side character
					}
				}
				else
				{
					if ((i == 1) || (i == h)) // If we're at the top or the bottom
					{
						consolePutC(top_btm); // Put top-bottom character
					}
					else
					{
						consolePutC(' '); // Put a blank space
					}
				}
			}

			consoleMove((row + i), col); // Move the cursor to the next row starting position
		}

		fit = 1; // Box fits
	}

	return fit;
}
Exemplo n.º 3
0
void consoleDraw(char *sd, int row, int col, int len) 
{
	int i; // For-loop counter
	int l; // # of characters of the string that will be printed

	// Gets correct length to fit in a field
	l = len < strlen(sd) ? len : strlen(sd);
	l = (col + l) < consoleGetCols() ? 
		l : (l - ((col + l) - consoleGetCols()));

	consoleMove(row, col); // Moves the cursor to starting position

	// Puts character on screen by the determined max length
	for (i = 0; i < l; i++) 
	{
		consolePutC(sd[i]);
	}

	consoleFlush(); // Flushes buffer
}