Port mouse cursor change over hyperlinks to C
This commit is contained in:
parent
271b623f82
commit
1c1d0a4e91
@ -6,6 +6,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
|
#include "screen.h"
|
||||||
|
#include "lineops.h"
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
extern void set_click_cursor(bool yes);
|
extern void set_click_cursor(bool yes);
|
||||||
@ -21,7 +23,7 @@ contains_mouse(Window *w) {
|
|||||||
static inline bool
|
static inline bool
|
||||||
cell_for_pos(Window *w, unsigned int *x, unsigned int *y) {
|
cell_for_pos(Window *w, unsigned int *x, unsigned int *y) {
|
||||||
unsigned int qx = (unsigned int)((double)global_state.mouse_x / global_state.cell_width);
|
unsigned int qx = (unsigned int)((double)global_state.mouse_x / global_state.cell_width);
|
||||||
unsigned int qy = (unsigned int)((double)global_state.mouse_x / global_state.cell_width);
|
unsigned int qy = (unsigned int)((double)global_state.mouse_y / global_state.cell_height);
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
Screen *screen = w->render_data.screen;
|
Screen *screen = w->render_data.screen;
|
||||||
if (screen && qx <= screen->columns && qy <= screen->lines) {
|
if (screen && qx <= screen->columns && qy <= screen->lines) {
|
||||||
@ -34,6 +36,8 @@ void
|
|||||||
handle_move_event(Window *w, int UNUSED button, int UNUSED modifiers) {
|
handle_move_event(Window *w, int UNUSED button, int UNUSED modifiers) {
|
||||||
unsigned int x, y;
|
unsigned int x, y;
|
||||||
if (cell_for_pos(w, &x, &y)) {
|
if (cell_for_pos(w, &x, &y)) {
|
||||||
|
Line *line = screen_visual_line(w->render_data.screen, y);
|
||||||
|
has_click_cursor = (line && line_url_start_at(line, x) < line->xnum) ? true : false;
|
||||||
if (x != w->mouse_cell_x || y != w->mouse_cell_y) {
|
if (x != w->mouse_cell_x || y != w->mouse_cell_y) {
|
||||||
w->mouse_cell_x = x; w->mouse_cell_y = y;
|
w->mouse_cell_x = x; w->mouse_cell_y = y;
|
||||||
}
|
}
|
||||||
@ -75,7 +79,7 @@ mouse_event(int button, int modifiers) {
|
|||||||
} else {
|
} else {
|
||||||
Tab *t = global_state.tabs + global_state.active_tab;
|
Tab *t = global_state.tabs + global_state.active_tab;
|
||||||
for (size_t i = 0; i < t->num_windows; i++) {
|
for (size_t i = 0; i < t->num_windows; i++) {
|
||||||
if (contains_mouse(t->windows + i)) {
|
if (contains_mouse(t->windows + i) && t->windows[i].render_data.screen) {
|
||||||
handle_event(t->windows + i, button, modifiers);
|
handle_event(t->windows + i, button, modifiers);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1208,6 +1208,12 @@ line(Screen *self, PyObject *val) {
|
|||||||
return (PyObject*) self->linebuf->line;
|
return (PyObject*) self->linebuf->line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Line*
|
||||||
|
screen_visual_line(Screen *self, index_type y) {
|
||||||
|
if (y >= self->lines) return NULL;
|
||||||
|
return visual_line_(self, y);
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
visual_line(Screen *self, PyObject *args) {
|
visual_line(Screen *self, PyObject *args) {
|
||||||
// The line corresponding to the yth visual line, taking into account scrolling
|
// The line corresponding to the yth visual line, taking into account scrolling
|
||||||
|
|||||||
@ -64,6 +64,7 @@ bool screen_is_selection_dirty(Screen *self);
|
|||||||
bool screen_invert_colors(Screen *self);
|
bool screen_invert_colors(Screen *self);
|
||||||
void screen_update_cell_data(Screen *self, void *address, size_t sz);
|
void screen_update_cell_data(Screen *self, void *address, size_t sz);
|
||||||
bool screen_is_cursor_visible(Screen *self);
|
bool screen_is_cursor_visible(Screen *self);
|
||||||
|
Line* screen_visual_line(Screen *self, index_type y);
|
||||||
unsigned long screen_current_char_width(Screen *self);
|
unsigned long screen_current_char_width(Screen *self);
|
||||||
#define DECLARE_CH_SCREEN_HANDLER(name) void screen_##name(Screen *screen);
|
#define DECLARE_CH_SCREEN_HANDLER(name) void screen_##name(Screen *screen);
|
||||||
DECLARE_CH_SCREEN_HANDLER(bell)
|
DECLARE_CH_SCREEN_HANDLER(bell)
|
||||||
|
|||||||
@ -17,3 +17,8 @@ static inline bool
|
|||||||
is_word_char(uint32_t ch) {
|
is_word_char(uint32_t ch) {
|
||||||
return uc_is_general_category_withtable(ch, UC_CATEGORY_MASK_L | UC_CATEGORY_MASK_N);
|
return uc_is_general_category_withtable(ch, UC_CATEGORY_MASK_L | UC_CATEGORY_MASK_N);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
is_url_char(uint32_t ch) {
|
||||||
|
return ch && !uc_is_general_category_withtable(ch, UC_CATEGORY_MASK_C | UC_CATEGORY_MASK_Z);
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user