mirror of https://github.com/cy384/ssheven.git
basic mouse support
This commit is contained in:
parent
af285b6e6c
commit
f119a63078
|
@ -149,6 +149,15 @@ void draw_screen(Rect* r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// p is in window local coordinates
|
||||||
|
void mouse_click(Point p, bool click)
|
||||||
|
{
|
||||||
|
int row = p.v / con.cell_height;
|
||||||
|
int col = p.h / con.cell_width;
|
||||||
|
vterm_mouse_move(con.vterm, row, col, VTERM_MOD_NONE);
|
||||||
|
vterm_mouse_button(con.vterm, 1, click, VTERM_MOD_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
void draw_screen_color(Rect* r)
|
void draw_screen_color(Rect* r)
|
||||||
{
|
{
|
||||||
// get the intersection of our console region and the update region
|
// get the intersection of our console region and the update region
|
||||||
|
|
|
@ -38,4 +38,6 @@ Rect cell_rect(int x, int y, Rect bounds);
|
||||||
void toggle_cursor(void);
|
void toggle_cursor(void);
|
||||||
void check_cursor(void);
|
void check_cursor(void);
|
||||||
|
|
||||||
|
void mouse_click(Point p, bool click);
|
||||||
|
|
||||||
void update_console_colors(void);
|
void update_console_colors(void);
|
||||||
|
|
|
@ -646,6 +646,7 @@ void event_loop(void)
|
||||||
int exit_event_loop = 0;
|
int exit_event_loop = 0;
|
||||||
EventRecord event;
|
EventRecord event;
|
||||||
WindowPtr eventWin;
|
WindowPtr eventWin;
|
||||||
|
Point local_mouse_position;
|
||||||
|
|
||||||
// maximum length of time to sleep (in ticks)
|
// maximum length of time to sleep (in ticks)
|
||||||
// GetCaretTime gets the number of ticks between system caret on/off time
|
// GetCaretTime gets the number of ticks between system caret on/off time
|
||||||
|
@ -713,9 +714,15 @@ void event_loop(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case inContent:
|
case inContent:
|
||||||
|
GetMouse(&local_mouse_position);
|
||||||
|
mouse_click(local_mouse_position, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case mouseUp:
|
||||||
|
GetMouse(&local_mouse_position);
|
||||||
|
mouse_click(local_mouse_position, false);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
YieldToAnyThread();
|
YieldToAnyThread();
|
||||||
|
|
Loading…
Reference in New Issue