Пример #1
0
static inline void window_set_bounds(struct window *win, int x, int y, int w, int h) {
    // check if bounds_x_1 ... y_2 are -1.
    // if so, do calculation. otherwise, do nothing
    win->bounds_x_1 = x < 0 ? 0 : x;
    win->bounds_x_2 = x + w >= graphics_width() ? graphics_width() - 1 : x + w;
    win->bounds_y_1 = y < 0 ? 0 : y;
    win->bounds_y_2 = y + h >= graphics_height() ? graphics_height() - 1 : y + h;
}
Пример #2
0
void console_init()
{
	xsize = graphics_width()/8;
	ysize = graphics_height()/8;
	console_reset();
	console_putstring("\nconsole: initialized\n");
}
Пример #3
0
void font_puts(font_t* font, graphics_t* graphics, graphics_pos_t x, graphics_pos_t y, const char* s)
{
    if(x >= (graphics_pos_t)graphics_width(graphics) ||
            y >= (graphics_pos_t)graphics_height(graphics)) return;
    
    uint8_t tabs_count = 0;
    graphics_pos_t orig_x = x;
    while(*s){
        switch(*s){
            case '\r':
                x = orig_x;
                s ++;
                break;
            case '\n':
                x = orig_x;
                y += font->symbol_height + font->vspace;
                s ++;
                break;
            case '\t':
                font_putc(font, graphics, x, y, 0x20);
                x += font->symbol_width + font->hspace;
                if(++ tabs_count == FONT_TAB_SIZE){
                    tabs_count = 0;
                    s ++;
                }
                break;
            default:
                font_putc(font, graphics, x, y, *s);
                x += font->symbol_width + font->hspace;
                s ++;
                break;
        }
        if(y >= (graphics_pos_t)graphics_width(graphics)) break;
    }
}