/* * print_buf * FUNCTION: Prints the terminal buffer to screen * INPUT: None * OUTPUT: Prints to screen * RETURN VALUE: None * SIDE EFFECTS: None */ void print_buf(){ int screen_x = get_screen_x(); int screen_y = get_screen_y(); int i; int j = 0; for(i = 0; i<1024; i++){ j++; if(terminal_buffer[i] == '\0'){ break; } putc(terminal_buffer[i]); if (terminal_buffer[i] == '\0') j--; terminal_buffer[i] = '\0'; if ((j >= 72)&&(screen_y == 24)) { if (j == 72) screen_y -= 2; else if ((j-72)%80 == 0) screen_y--; } } set_screen_x_y(screen_x,screen_y); }
/* * terminal_backspace * DESCRIPTION: Deletes character immediately before cursor * INPUTS: none * OUTPUTS: none * RETURN VALUE: none * SIDE EFFECTS: Characters printed to screen */ void terminal_backspace(){ //Only backspace if the terminal is reading and at least 1 character has been typed if(*t_pos > 0 && *isReading == 1){ *t_pos = *t_pos-1; terminal_buffer[*t_pos] = ' '; int screen_x = get_screen_x(); if(screen_x % NUM_COLS == 0){ decrement_row(); //go back a line } print_buffer(); } }
void TileEditor::draw() { CL_Display::push_translate(get_screen_x(), get_screen_x()); //no_tile.draw(0, 0); CL_Display::fill_rect(CL_Rect(0, 0, 32, 32), CL_Color(155, 0, 155)); if (tile) { tile->get_sprite().draw(0, 0); CL_Display::flush(); for(int tile_y = 0; tile_y < 8; ++tile_y) for(int tile_x = 0; tile_x < 8; ++tile_x) { if (tile->get_col(tile_x, tile_y)) { CL_Display::fill_rect(CL_Rect(tile_x*16, tile_y*16, tile_x*16 + 16, tile_y*16 + 16), CL_Color(255, 0, 0, 128)); } } CL_Display::flush(); if (has_mouse_over()) { CL_Display::fill_rect(CL_Rect(CL_Point(int(mouse_pos.x)/16 * 16, int(mouse_pos.y)/16 * 16), CL_Size(16, 16)), CL_Color(255, 255, 255, 128)); } } else { } CL_Display::pop_modelview(); }
void Slider::draw() { CL_Display::push_modelview(); CL_Display::add_translate(get_screen_x(), get_screen_y()); CL_Display::fill_rect(CL_Rect(CL_Point(0, get_height()/2 - 2), CL_Size(get_width(), 5)), CL_Color(255, 255, 255, 255)); CL_Display::fill_rect(CL_Rect(CL_Point(int(-2 + (value/(end-start)) * get_width()), 0), CL_Size(5, get_height())), CL_Color(0, 0, 0, 255)); CL_Display::pop_modelview(); }
/** * switch_active_terminal_screen(uint32_t old_pid, uint32_t new_pid) * Description: switches the active terminal * Inputs: old_pid - old terminal, new_pid - new terminal * Outputs: none */ void switch_active_terminal_screen(uint32_t old_pid, uint32_t new_pid) { if(old_pid == KERNEL_PID || new_pid == KERNEL_PID) { log(WARN, "Can't switch terminal while in pre-shell kernel!", "switch_active_terminal_screen"); return; } pcb_t* old_pcb = get_pcb_ptr_pid(old_pid); pcb_t* new_pcb = get_pcb_ptr_pid(new_pid); uint32_t old_terminal = old_pcb->terminal_index; uint32_t new_terminal = new_pcb->terminal_index; if(old_terminal == new_terminal) { log(DEBUG, "No use switching to the same terminal screen", "switch_active_terminal_screen"); return; } void* old_backing = (void*) (VIDEO + (FOUR_KB * (old_terminal + 1))); void* new_backing = (void*) (VIDEO + (FOUR_KB * (new_terminal + 1))); // Identity map pages for video memory backing stores mmap_pid(new_pid, old_backing, old_backing, ACCESS_SUPER); mmap_pid(new_pid, new_backing, new_backing, ACCESS_SUPER); mmap_pid(new_pid, ((void*) VIDEO), ((void*) VIDEO), ACCESS_SUPER); // Copy video mem from VIDEO to backing for old_pid memcpy(old_backing, ((void*) VIDEO), FOUR_KB); // Save screen position switch_screen_pos_x[old_terminal] = get_screen_x(); switch_screen_pos_y[old_terminal] = get_screen_y(); // Copy video mem from backing for new_pid to VIDEO memcpy(((void*) VIDEO), new_backing, FOUR_KB); // Reset the location of the cursor reset_screen_pos(); // Unmap identity maped pages for video memory backing stores munmap_pid(new_pid, old_backing); munmap_pid(new_pid, new_backing); }