#include #include #include #include #include "frame.h" #include "common.h" void allocate_frame(struct frame **frame) { if (!(*frame = malloc(sizeof(**frame)))) { fprintf(stderr, tty_solitaire_error_message(errno, __FILE__, __LINE__)); exit(errno); } (*frame)->window = newwin(FRAME_HEIGHT, FRAME_WIDTH, 0, 0); } void initialize_frame(struct frame *frame) { frame->begin_y = 0; frame->begin_x = 0; } void free_frame(struct frame *frame) { delwin(frame->window); free(frame); } void set_frame(struct frame *frame, int begin_y, int begin_x) { frame->begin_y = begin_y; frame->begin_x = begin_x; mvwin(frame->window, begin_y, begin_x); } struct frame *duplicate_frame(struct frame *frame) { struct frame *new_frame; allocate_frame(&new_frame); set_frame(new_frame, frame->begin_y, frame->begin_x); return(new_frame); }