#include "../tui.hpp" namespace ui { void Mouse::parse_ansi(char buf[]) { int button = 0; char state = '\0'; if (sscanf(buf + 3, "%d;%d;%d%c", &button, &pos.x, &pos.y, &state) == 4) { auto btn_index = static_cast(button); uint8_t click_type = btn_index & 0xC3; if (click_type == 0b00000000) { btn0 = (state == 'M'); } else if (click_type == 0b00000001) { btn1 = (state == 'M'); } else if (click_type == 0b00000010) { btn2 = (state == 'M'); } else if (click_type == 0b01000000) { scroll++; } else if (click_type == 0b01000001) { scroll--; } } } bool Mouse::is_pressed(int index_btn) { switch (index_btn) { case 0: return btn0; case 1: return btn1; case 2: return btn2; default: return false; } } void Mouse::reset_scroll() { scroll = 0; } int Mouse::get_scroll() { return scroll; } Mouse::pos_t Mouse::get_pos() { return pos; } }