static void checkinputs_splitted(char input, char *buff, char **ptr, t_history *history) { if (input == 127) mvbackspace(buff, ptr); else if (input == 126) { ft_putchar('~'); **ptr = '~'; (*ptr)++; } else if (input == 9) completion(buff, ptr); else if (input < 0) copycutpaste(input, buff, ptr); else if (input == 1) mvcstart(buff, ptr); else if (input == 5) mvcend(ptr); else if (input == 27) mvcursor(buff, ptr, history); else if (ft_isprint(input)) { ft_memmove((*ptr) + 1, (*ptr), ft_strlen((*ptr))); (*ptr)[0] = input; ft_putstr(*ptr); mvcleft(ft_strlen((*ptr)++) - 1); } }
void kput(char c) { // The background colour is black (0), the foreground is white (15). uint8_t backColour = 0; uint8_t foreColour = 15; // The attribute byte is made up of two nibbles - the lower being the // foreground colour, and the upper the background colour. uint8_t attributeByte = (backColour << 4) | (foreColour & 0x0F); // The attribute byte is the top 8 bits of the word we have to send to the // VGA board. uint16_t attribute = attributeByte << 8; uint16_t *location; // Handle a backspace, by moving the cursor back one space if (c == 0x08 && cursor_x) { cursor_x--; } // Handle a tab by increasing the cursor's X, but only to a point // where it is divisible by 8. else if (c == 0x09) { cursor_x = (cursor_x + 8) & ~(8 - 1); } // Handle carriage return else if (c == '\r') { cursor_x = 0; } // Handle newline by moving cursor back to left and increasing the row else if (c == '\n') { cursor_x = 0; cursor_y++; } // Handle any other printable character. else if(c >= ' ') { location = video_memory + (cursor_y * 80 + cursor_x); *location = c | attribute; cursor_x++; } // Check if we need to insert a new line because we have reached the end // of the screen. if (cursor_x >= 80) { cursor_x = 0; cursor_y ++; } // Scroll the screen if needed. scroll (); // Move the hardware cursor. mvcursor (); }
void kclear(void) { // Make an attribute byte for the default colours uint8_t attributeByte = (0 << 4) | (15 & 0x0F); uint16_t blank = 0x20 | (attributeByte << 8); int i; for(i = 0; i < 80 * 25; i++) { video_memory[i] = blank; } // Move the hardware cursor back to the start. cursor_x = 0; cursor_y = 0; mvcursor (); }
int keyhooks(void) { if (g_ftselect->buff[0] == 27) { if (g_ftselect->buff[2]) mvcursor(); else return (-1); } else if (g_ftselect->buff[0] == 4 || g_ftselect->buff[0] == 10) return (0); else if (g_ftselect->buff[0] == ' ') { g_ftselect->cursor->selected = (g_ftselect->cursor->selected) ? 0 : 1; mvbot(); } else if (g_ftselect->buff[0] == '\\') ft_putchar_fd(g_ftselect->buff[1], 2); return (1); }