Kaydet (Commit) e62ba3d4 authored tarafından Nick Treleaven's avatar Nick Treleaven

Use the character position under the mouse click for Go to…

Use the character position under the mouse click for Go to definition/declaration and for overridden middle click text paste

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@420 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 01ef13c1
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
* src/callbacks.c: Fixed segfault when inserting comments and no * src/callbacks.c: Fixed segfault when inserting comments and no
filetype is set. filetype is set.
* src/callbacks.c, src/sciwrappers.c, src/sciwrappers.h:
Use the character position under the mouse click for Go to
definition/declaration and for overridden middle click text paste.
2006-06-06 Enrico Troeger <enrico.troeger@uvena.de> 2006-06-06 Enrico Troeger <enrico.troeger@uvena.de>
......
...@@ -964,11 +964,13 @@ on_editor_button_press_event (GtkWidget *widget, ...@@ -964,11 +964,13 @@ on_editor_button_press_event (GtkWidget *widget,
GdkEventButton *event, GdkEventButton *event,
gpointer user_data) gpointer user_data)
{ {
gint idx = GPOINTER_TO_INT(user_data);
gint clickpos = sci_get_position_from_xy(doc_list[idx].sci, event->x, event->y, FALSE);
#ifndef GEANY_WIN32 #ifndef GEANY_WIN32
if (event->button == 1) if (event->button == 1)
{ {
utils_check_disk_status(GPOINTER_TO_INT(user_data)); utils_check_disk_status(idx);
} }
#endif #endif
...@@ -979,12 +981,11 @@ on_editor_button_press_event (GtkWidget *widget, ...@@ -979,12 +981,11 @@ on_editor_button_press_event (GtkWidget *widget,
if (gtk_clipboard_wait_is_text_available(cp)) if (gtk_clipboard_wait_is_text_available(cp))
{ {
gint idx = document_get_cur_idx();
gchar *text = gtk_clipboard_wait_for_text(cp); gchar *text = gtk_clipboard_wait_for_text(cp);
if (idx >= 0 && text != NULL) if (text != NULL)
{ {
sci_add_text(doc_list[idx].sci, text); sci_insert_text(doc_list[idx].sci, clickpos, text);
g_free(text); g_free(text);
return TRUE; return TRUE;
} }
...@@ -993,16 +994,12 @@ on_editor_button_press_event (GtkWidget *widget, ...@@ -993,16 +994,12 @@ on_editor_button_press_event (GtkWidget *widget,
if (event->button == 3) if (event->button == 3)
{ {
/// TODO pos should possibly be the position of the mouse pointer instead of the utils_find_current_word(doc_list[idx].sci, clickpos,
/// current sci position current_word, sizeof current_word);
gint pos = sci_get_current_position(doc_list[GPOINTER_TO_INT(user_data)].sci);
utils_find_current_word(doc_list[GPOINTER_TO_INT(user_data)].sci, pos,
current_word, sizeof current_word);
utils_update_popup_goto_items((current_word[0] != '\0') ? TRUE : FALSE); utils_update_popup_goto_items((current_word[0] != '\0') ? TRUE : FALSE);
utils_update_popup_copy_items(GPOINTER_TO_INT(user_data)); utils_update_popup_copy_items(idx);
utils_update_insert_include_item(GPOINTER_TO_INT(user_data), 0); utils_update_insert_include_item(idx, 0);
gtk_menu_popup(GTK_MENU(app->popup_menu), NULL, NULL, NULL, NULL, event->button, event->time); gtk_menu_popup(GTK_MENU(app->popup_menu), NULL, NULL, NULL, NULL, event->button, event->time);
return TRUE; return TRUE;
......
...@@ -480,6 +480,13 @@ gint sci_get_selected_text_length(ScintillaObject* sci) ...@@ -480,6 +480,13 @@ gint sci_get_selected_text_length(ScintillaObject* sci)
} }
gint sci_get_position_from_xy(ScintillaObject* sci, gint x, gint y, gboolean nearby)
{
// for nearby return -1 if there is no character near to the x,y point.
return SSM(sci, (nearby) ? SCI_POSITIONFROMPOINTCLOSE : SCI_POSITIONFROMPOINT, x, y);
}
void sci_get_xy_from_position(ScintillaObject* sci,gint pos, gint* x, gint* y) void sci_get_xy_from_position(ScintillaObject* sci,gint pos, gint* x, gint* y)
{ {
*x = SSM(sci, SCI_POINTXFROMPOSITION,0, (int) pos); *x = SSM(sci, SCI_POINTXFROMPOSITION,0, (int) pos);
......
...@@ -81,6 +81,7 @@ void sci_get_line (ScintillaObject* sci, gint line, gchar* text); ...@@ -81,6 +81,7 @@ void sci_get_line (ScintillaObject* sci, gint line, gchar* text);
gint sci_get_line_length (ScintillaObject* sci, gint line); gint sci_get_line_length (ScintillaObject* sci, gint line);
gint sci_get_line_count ( ScintillaObject* sci ); gint sci_get_line_count ( ScintillaObject* sci );
void sci_get_xy_from_position (ScintillaObject* sci,gint pos, gint* x, gint* y); void sci_get_xy_from_position (ScintillaObject* sci,gint pos, gint* x, gint* y);
gint sci_get_position_from_xy (ScintillaObject* sci, gint x, gint y, gboolean nearby);
void sci_set_undo_collection (ScintillaObject* sci, gboolean set); void sci_set_undo_collection (ScintillaObject* sci, gboolean set);
gboolean sci_get_undo_collection (ScintillaObject* sci); gboolean sci_get_undo_collection (ScintillaObject* sci);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment