void gui_cursor_display_debug_info () { struct t_gui_focus_info *focus_info; char str_info[1024]; if (!gui_cursor_debug) return; focus_info = gui_focus_get_info (gui_cursor_x, gui_cursor_y); if (focus_info) { snprintf (str_info, sizeof (str_info), "%s(%d,%d) window:0x%lx, buffer:0x%lx (%s), " "bar_window:0x%lx (bar: %s, item: %s, line: %d, col: %d), " "chat: %d, word: \"%s\"", gui_color_get_custom ("yellow,red"), focus_info->x, focus_info->y, (long unsigned int)focus_info->window, (long unsigned int)focus_info->buffer, (focus_info->buffer) ? (focus_info->buffer)->full_name : "-", (long unsigned int)focus_info->bar_window, (focus_info->bar_window) ? ((focus_info->bar_window)->bar)->name : "-", (focus_info->bar_item) ? focus_info->bar_item : "-", focus_info->bar_item_line, focus_info->bar_item_col, focus_info->chat, focus_info->chat_word); gui_input_delete_line (gui_current_window->buffer); gui_input_insert_string (gui_current_window->buffer, str_info, -1); gui_focus_free_info (focus_info); } }
const char * gui_mouse_grab_event2input () { struct t_gui_focus_info *focus_info; static char area[256]; area[0] = '\0'; focus_info = gui_focus_get_info (gui_mouse_event_x[0], gui_mouse_event_y[0]); if (focus_info) { if (focus_info->bar_item) { snprintf (area, sizeof (area), "@item(%s)", focus_info->bar_item); } else if (focus_info->bar_window) { snprintf (area, sizeof (area), "@bar(%s)", ((focus_info->bar_window)->bar)->name); } else if (focus_info->chat) { snprintf (area, sizeof (area), "@chat"); } else { snprintf (area, sizeof (area), "@*"); } gui_focus_free_info (focus_info); } return area; }
void gui_cursor_move_area_add_xy (int add_x, int add_y) { int x, y, width, height, area_found; struct t_gui_focus_info *focus_info_old, *focus_info_new; if (!gui_cursor_mode) gui_cursor_mode_toggle (); area_found = 0; x = gui_cursor_x; y = gui_cursor_y; width = gui_window_get_width (); height = gui_window_get_height (); focus_info_old = gui_focus_get_info (x, y); if (!focus_info_old) return; focus_info_new = NULL; if (add_x != 0) x += add_x; else y += add_y; while ((x >= 0) && (x < width) && (y >= 0) && (y < height)) { focus_info_new = gui_focus_get_info (x, y); if (!focus_info_new) { gui_focus_free_info (focus_info_old); return; } if (((focus_info_new->window && focus_info_new->chat) || focus_info_new->bar_window) && ((focus_info_old->window != focus_info_new->window) || (focus_info_old->bar_window != focus_info_new->bar_window))) { area_found = 1; break; } if (add_x != 0) x += add_x; else y += add_y; } if (area_found) { if (focus_info_new->window && focus_info_new->chat) { x = (focus_info_new->window)->win_chat_x; y = (focus_info_new->window)->win_chat_y; } else if (focus_info_new->bar_window) { x = (focus_info_new->bar_window)->x; y = (focus_info_new->bar_window)->y; } else area_found = 0; } if (area_found) { gui_cursor_x = x; gui_cursor_y = y; gui_cursor_display_debug_info (); gui_window_move_cursor (); } gui_focus_free_info (focus_info_old); if (focus_info_new) gui_focus_free_info (focus_info_new); }