nesemu/debugger/cursor.h

75 lines
1.8 KiB
C
Raw Permalink Normal View History

2024-01-14 21:59:13 -05:00
//
// Created by william on 1/12/24.
//
#ifndef NESEMULATOR_CURSOR_H
#define NESEMULATOR_CURSOR_H
#include <curses.h>
#define CURSOR_OFFSET_UP (-1)
#define CURSOR_OFFSET_DOWN 1
#define CURSOR_OFFSET_LEFT (-1)
#define CURSOR_OFFSET_RIGHT 1
#define CURSOR_AT_ENABLED A_REVERSE
#define CURSOR_AT_DISABLED A_NORMAL
typedef struct cursor {
WINDOW *window;
int min_x;
int min_y;
int max_x;
int max_y;
int multiplier_x;
int multiplier_y;
int width;
int pos_x;
int pos_y;
bool enabled;
} Cursor;
/**
* Initializes a cursor with default values.
*
* @param cursor A reference to the cursor to initialize
* @param window The window the cursor is in
*/
void cursor_init(Cursor *cursor, WINDOW *window, int max_x, int max_y);
/**
* Enables a cursor, making it visible in its window.
*
* @param cursor The cursor
*/
void cursor_enable(Cursor *cursor);
/**
* Disables a cursor, removing it from the display.
*
* @param cursor The cursor
*/
void cursor_disable(Cursor *cursor);
/**
* Sets the position of the cursor.
* The positions are from left to right (horizontal) and top to bottom (vertical).
*
* @param cursor The cursor
* @param x The new horizontal position
* @param y The new vertical position
*/
void cursor_set_pos(Cursor *cursor, int x, int y);
/**
* Moves the position of the cursor by an offset. This function ensures that the cursor is kept in the window bounds.
* A negative offset moves the cursor position towards the 0 direction (left or top).
* A position offset moves it in the opposite direction (right or bottom).
*
* @param cursor The cursor
* @param offset_x The horizontal offset
* @param offset_y The vertical offset
*/
void cursor_move(Cursor *cursor, int offset_x, int offset_y);
#endif //NESEMULATOR_CURSOR_H