Beispiel #1
0
static void console_out_character(console_private_t *pcp, const unsigned char ch)
{
    cursor(pcp, CS_SUSPEND);

    if (!pcp->bMarkMode) {
        if (pcp->bIsMarked) {
            unmark_window(pcp);
            pcp->bIsMarked = FALSE;
        }
    }

    if (ch >= 32) {
        pcp->pchWindowBuffer[CALC_POS(pcp, pcp->xPos, pcp->yPos)] = ch;
        draw_current_character(pcp);
        move_forwards(pcp);
    } else {
        /* do we have a backspace? */
        if (ch == 8) {
            move_backwards(pcp);
            pcp->pchWindowBuffer[CALC_POS(pcp, pcp->xPos, pcp->yPos)] = ' ';
            draw_current_character(pcp);
        }

        /* do we have a return? */
        if ( (ch == 13) || (ch == '\n')) {
            pcp->xPos = 0;
            move_downwards(pcp);
        }
    }

    cursor(pcp, CS_RESUME);
}
Beispiel #2
0
static void console_out_printables_only(console_private_t *pcp, const unsigned char *buffer, unsigned int length)
{
    cursor(pcp, CS_SUSPEND);

    if (!pcp->bMarkMode && pcp->bIsMarked) {
        unmark_window(pcp);
        pcp->bIsMarked = FALSE;
    }

    /* output line by line, until everything is output */

    while (length > 0) {
        unsigned int partlength = min(pcp->pConsole->console_xres - pcp->xPos, length);

        memcpy(&pcp->pchWindowBuffer[CALC_POS(pcp, pcp->xPos, pcp->yPos)], buffer, partlength);

        /* draw the current line */
        TextOut(pcp->hdc, pcp->xPos * pcp->xCharDimension, pcp->yPos * pcp->yCharDimension, &(pcp->pchWindowBuffer[CALC_POS(pcp, pcp->xPos, pcp->yPos)]), partlength);

        /* advance the buffer by the output part */
        buffer += partlength;
        length -= partlength;

        /* advance the current screen position */
        pcp->xPos += partlength;

        /* handle wrap-around, if necessary */
        if (pcp->xPos == pcp->pConsole->console_xres) {
            pcp->xPos = 0;
            move_downwards(pcp);
        }
    }

    cursor(pcp, CS_RESUME);
}
Beispiel #3
0
static console_private_t *reallocate_window_memory(console_private_t* pcp, unsigned xDim, unsigned yDim)
{
    unsigned xOldDim = pcp->xMax;
    unsigned yOldDim = pcp->yMax;
    char *pOldBuffer = pcp->pchWindowBuffer;

    unsigned y;

    /* get new memory buffer */
    pcp->pchWindowBuffer = NULL;
    pcp->xMax = max(xDim, pcp->xMax + RESIZE_INCREMENT_X);
    pcp->yMax = max(yDim, pcp->yMax + RESIZE_INCREMENT_Y);

    allocate_window_memory(pcp);

    /* now, copy the contents of the old buffer into the new one */
    for (y = 0; y < yOldDim; y++) {
        memmove(&pcp->pchWindowBuffer[CALC_POS(pcp, 0, y)], &pOldBuffer[xOldDim * y], xOldDim);
    }

    /* we're done, release the old buffer */
    lib_free(pOldBuffer);

    return pcp;
}
int cuboid (mc_connection *mc, int type, int x1, int y1, int z1, int x2, int y2, int z2) 
{
	int xp, yp, zp;
	CHECK_ORDER(x1, x2);
	CHECK_ORDER(y1, y2);
	CHECK_ORDER(z1, z2);
	
	printf("%d %d %d %d %d %d | %d\n",x1,y1,z1,x2,y2,z2,type);

	for (int bx = x1; bx <= x2+1; bx+=9) {
		for (int by = y1; by <= y2+1; by+=9) {
			for (int bz = z1; bz <= z2+1; bz+=9) {
				if (!cuboid_check_square(mc, type, bx, by, bz, x2, y2, z2))
					continue;
				xp = CALC_POS(bx, x2);
				yp = CALC_POS(by, y2);
				zp = CALC_POS(bz, z2);
				mc_proto_send_pos(mc, xp, yp, zp, 130, 130);
				mc_proto_send_pos(mc, xp, yp, zp, 130, 130);
				for (int x = bx; x <= (MIN(bx+8, x2));x++) {
					for (int y = by; y <= (MIN(by+8, y2));y++) {
						for (int z = bz; z <= (MIN(bz+8, z2));z++) {
							int block = get_block_at_coords(mc, x, y, z);
							if (type == 0 && block != 0) {
								mc_proto_send_block(mc,x,y,z,0,1);
								usleep(1000);
							} else if (type != 0 && block != 0) {
								mc_proto_send_block(mc,x,y,z,0,1);
								mc_proto_send_block(mc,x,y,z,1,type);
								usleep(1000);
							} else if (type != 0 && block == 0) {
								mc_proto_send_block(mc,x,y,z,1,type);
								usleep(1000);
							}
						}
					}
				}
				usleep(10000);
			}
		}
	}
	 // la 17 33 121 47 24 126
	return 0;
}
Beispiel #5
0
static void scroll_up(console_private_t *pcp)
{
    cursor(pcp, CS_SUSPEND);

    /* mark that we scrolled up by one line */
    ++pcp->scroll_up;

    /* move all lines one line up */
    memmove(pcp->pchWindowBuffer, &pcp->pchWindowBuffer[pcp->xMax], CALC_POS(pcp, 0, pcp->yMax - 1));

    /* clear the last line */
    memset(&pcp->pchWindowBuffer[CALC_POS(pcp, 0, pcp->yMax - 1)], ' ', pcp->xMax);

    move_upwards(pcp);

    /* force repainting of the whole window */
#if 0
    /*
     @SRT this variant takes less processor time because
     hopefully, the window needs not to be updated with
     every single scroll.
    */
    InvalidateRect(pcp->hwndConsole, NULL, FALSE );
#else
    /*
     @SRT this variant looks more realistic since every
     single scroll can be seen by the user
    */
    redraw_window(pcp, NULL);
#endif

    /* Adjust the line where the input begins */
    pcp->yPosInputLineStart--;

    cursor(pcp, CS_RESUME);
}
Beispiel #6
0
static void draw_current_character(console_private_t *pcp)
{
    TextOut(pcp->hdc, pcp->xPos * pcp->xCharDimension, pcp->yPos * pcp->yCharDimension, &pcp->pchWindowBuffer[CALC_POS(pcp, pcp->xPos, pcp->yPos)], 1);
}
Beispiel #7
0
static void redraw_window(console_private_t *pcp, LPPAINTSTRUCT pps)
{
    unsigned row;

    unsigned yMin = 0;
    unsigned yMax = pcp->pConsole->console_yres;

    unsigned xMin = 0;
    unsigned xMax = pcp->pConsole->console_xres;

    cursor(pcp, CS_SUSPEND);

    unmark_window(pcp);

#if 0
    if (pps)
    {
        /* we have an update region, so update only necessary parts */
        xMin = pps->rcPaint.left / pcp->xCharDimension;
        yMin = pps->rcPaint.top / pcp->yCharDimension;

        /*
         the "+ ..." force a rounding up.
        */
        xMax = (pps->rcPaint.right + pcp->xCharDimension-1) / pcp->xCharDimension;
        yMax = (pps->rcPaint.bottom + pcp->yCharDimension-1) / pcp->yCharDimension;
    }
#endif 

    for (row = yMin; row < yMax; row++) {
        /* draw a single line */
        TextOut(pcp->hdc, xMin * pcp->xCharDimension, row * pcp->yCharDimension, &(pcp->pchWindowBuffer[CALC_POS(pcp, xMin, row)]), xMax);
    }

    mark_window(pcp);

    cursor(pcp, CS_RESUME);
}