SF.net SVN: geany: [789] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Mon Sep 4 15:57:55 UTC 2006
Revision: 789
http://svn.sourceforge.net/geany/?rev=789&view=rev
Author: ntrel
Date: 2006-09-04 08:57:46 -0700 (Mon, 04 Sep 2006)
Log Message:
-----------
Move current_word and clickpos to editor_info struct in sci_cb.c.
Move on_editor_button_press_event to sci_cb.c.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/callbacks.c
trunk/src/callbacks.h
trunk/src/document.c
trunk/src/keybindings.c
trunk/src/sci_cb.c
trunk/src/sci_cb.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-09-04 13:44:15 UTC (rev 788)
+++ trunk/ChangeLog 2006-09-04 15:57:46 UTC (rev 789)
@@ -6,6 +6,10 @@
Only save session when session files were loaded at startup.
* doc/geany.docbook:
Update command-line options and running instance behaviour.
+ * src/callbacks.c, src/callbacks.h, src/sci_cb.c, src/sci_cb.h,
+ src/keybindings.c, src/document.c:
+ Move current_word and clickpos to editor_info struct in sci_cb.c.
+ Move on_editor_button_press_event to sci_cb.c.
2006-09-03 Nick Treleaven <nick.treleaven at btinternet.com>
Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c 2006-09-04 13:44:15 UTC (rev 788)
+++ trunk/src/callbacks.c 2006-09-04 15:57:46 UTC (rev 789)
@@ -60,9 +60,6 @@
#endif
-// represents the word under the mouse pointer when right button(no. 3) is pressed
-gchar current_word[GEANY_MAX_WORD_LENGTH];
-
// represents the state while closing all tabs(used to prevent notebook switch page signals)
static gboolean closing_all = FALSE;
@@ -74,11 +71,7 @@
// the selection-changed signal from tv.tree_openfiles
//static gboolean switch_tv_notebook_page = FALSE;
-// holds the current position where the mouse pointer is when the popup menu for the scintilla
-// scintilla widget is shown
-static gint clickpos;
-
// real exit function
gint destroyapp(GtkWidget *widget, gpointer gdata)
{
@@ -1009,37 +1002,6 @@
}
-// calls the edit popup menu in the editor
-gboolean
-on_editor_button_press_event (GtkWidget *widget,
- GdkEventButton *event,
- gpointer user_data)
-{
- gint idx = GPOINTER_TO_INT(user_data);
- clickpos = sci_get_position_from_xy(doc_list[idx].sci, event->x, event->y, FALSE);
-
-#ifndef G_OS_WIN32
- if (event->button == 1)
- {
- return utils_check_disk_status(idx);
- }
-#endif
-
- if (event->button == 3)
- {
- sci_cb_find_current_word(doc_list[idx].sci, clickpos, current_word, sizeof current_word);
-
- utils_update_popup_goto_items((current_word[0] != '\0') ? TRUE : FALSE);
- utils_update_popup_copy_items(idx);
- utils_update_insert_include_item(idx, 0);
- gtk_menu_popup(GTK_MENU(app->popup_menu), NULL, NULL, NULL, NULL, event->button, event->time);
-
- return TRUE;
- }
- return FALSE;
-}
-
-
void
on_crlf_activate (GtkMenuItem *menuitem,
gpointer user_data)
@@ -1314,7 +1276,7 @@
}
else
{
- search_text = g_strdup(current_word);
+ search_text = g_strdup(editor_info.current_word);
flags = SCFIND_MATCHCASE | SCFIND_WHOLEWORD;
}
@@ -1383,7 +1345,7 @@
type);
if (tags == NULL) continue;
- tmtag = utils_find_tm_tag(tags, current_word);
+ tmtag = utils_find_tm_tag(tags, editor_info.current_word);
if (tmtag != NULL)
{
if (! utils_goto_file_line(
@@ -1396,9 +1358,9 @@
// if we are here, there was no match and we are beeping ;-)
utils_beep();
if (type == tm_tag_prototype_t)
- msgwin_status_add(_("Declaration of \"%s()\" not found"), current_word);
+ msgwin_status_add(_("Declaration of \"%s()\" not found"), editor_info.current_word);
else
- msgwin_status_add(_("Definition of \"%s()\" not found"), current_word);
+ msgwin_status_add(_("Definition of \"%s()\" not found"), editor_info.current_word);
}
@@ -2074,7 +2036,7 @@
}
}
- sci_insert_text(doc_list[idx].sci, clickpos, text);
+ sci_insert_text(doc_list[idx].sci, editor_info.click_pos, text);
g_free(text);
}
@@ -2114,7 +2076,7 @@
}
}
- sci_insert_text(doc_list[idx].sci, clickpos, text);
+ sci_insert_text(doc_list[idx].sci, editor_info.click_pos, text);
g_free(text);
}
@@ -2249,7 +2211,7 @@
if (strftime(time_str, sizeof time_str, format, tm) != 0)
{
/// FIXME inserts at wrong position if not clicked and the cursor was moved by keyboard
- sci_insert_text(doc_list[idx].sci, clickpos, time_str);
+ sci_insert_text(doc_list[idx].sci, editor_info.click_pos, time_str);
}
else
{
@@ -2270,7 +2232,7 @@
if (utils_strcmp(user_data, "blank"))
{
text = g_strdup("#include \"\"\n");
- pos = clickpos + 10;
+ pos = editor_info.click_pos + 10;
}
else
{
@@ -2278,7 +2240,7 @@
}
/// FIXME inserts at wrong position if not clicked and the cursor was moved by keyboard
- sci_insert_text(doc_list[idx].sci, clickpos, text);
+ sci_insert_text(doc_list[idx].sci, editor_info.click_pos, text);
g_free(text);
if (pos > 0) sci_goto_pos(doc_list[idx].sci, pos, FALSE);
}
Modified: trunk/src/callbacks.h
===================================================================
--- trunk/src/callbacks.h 2006-09-04 13:44:15 UTC (rev 788)
+++ trunk/src/callbacks.h 2006-09-04 15:57:46 UTC (rev 789)
@@ -20,8 +20,6 @@
* $Id$
*/
-extern gchar current_word[]; //needed for popup menu keybindings access
-
gint
destroyapp (GtkWidget *widget, gpointer gdata);
@@ -133,11 +131,6 @@
gpointer user_data);
gboolean
-on_editor_button_press_event (GtkWidget *widget,
- GdkEventButton *event,
- gpointer user_data);
-
-gboolean
on_tree_view_button_press_event (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data);
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2006-09-04 13:44:15 UTC (rev 788)
+++ trunk/src/document.c 2006-09-04 15:57:46 UTC (rev 789)
@@ -44,7 +44,6 @@
#include <stdlib.h>
#include "document.h"
-#include "callbacks.h"
#include "support.h"
#include "sciwrappers.h"
#include "sci_cb.h"
Modified: trunk/src/keybindings.c
===================================================================
--- trunk/src/keybindings.c 2006-09-04 13:44:15 UTC (rev 788)
+++ trunk/src/keybindings.c 2006-09-04 15:57:46 UTC (rev 789)
@@ -633,9 +633,10 @@
pos = sci_get_current_position(doc_list[idx].sci);
- sci_cb_find_current_word(doc_list[idx].sci, pos, current_word, GEANY_MAX_WORD_LENGTH);
+ sci_cb_find_current_word(doc_list[idx].sci, pos,
+ editor_info.current_word, GEANY_MAX_WORD_LENGTH);
- if (*current_word == 0)
+ if (*editor_info.current_word == 0)
utils_beep();
else
switch (menuitemkey)
Modified: trunk/src/sci_cb.c
===================================================================
--- trunk/src/sci_cb.c 2006-09-04 13:44:15 UTC (rev 788)
+++ trunk/src/sci_cb.c 2006-09-04 15:57:46 UTC (rev 789)
@@ -33,6 +33,10 @@
#include "utils.h"
#include "main.h"
+static gchar current_word[GEANY_MAX_WORD_LENGTH]; // holds word under the mouse or keyboard cursor
+
+EditorInfo editor_info = {current_word, -1};
+
static struct
{
gchar *text;
@@ -45,6 +49,38 @@
static void on_new_line_added(ScintillaObject *sci, gint idx);
+// calls the edit popup menu in the editor
+gboolean
+on_editor_button_press_event (GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data)
+{
+ gint idx = GPOINTER_TO_INT(user_data);
+ editor_info.click_pos = sci_get_position_from_xy(doc_list[idx].sci, event->x, event->y, FALSE);
+
+#ifndef G_OS_WIN32
+ if (event->button == 1)
+ {
+ return utils_check_disk_status(idx);
+ }
+#endif
+
+ if (event->button == 3)
+ {
+ sci_cb_find_current_word(doc_list[idx].sci, editor_info.click_pos,
+ current_word, sizeof current_word);
+
+ utils_update_popup_goto_items((current_word[0] != '\0') ? TRUE : FALSE);
+ utils_update_popup_copy_items(idx);
+ utils_update_insert_include_item(idx, 0);
+ gtk_menu_popup(GTK_MENU(app->popup_menu), NULL, NULL, NULL, NULL, event->button, event->time);
+
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
// callback func called by all editors when a signal arises
void on_editor_notification(GtkWidget *editor, gint scn, gpointer lscn, gpointer user_data)
{
Modified: trunk/src/sci_cb.h
===================================================================
--- trunk/src/sci_cb.h 2006-09-04 13:44:15 UTC (rev 788)
+++ trunk/src/sci_cb.h 2006-09-04 15:57:46 UTC (rev 789)
@@ -32,9 +32,22 @@
#define SSM(s, m, w, l) scintilla_send_message(s, m, w, l)
+typedef struct
+{
+ gchar *current_word; // holds word under the mouse or keyboard cursor
+ gint click_pos; // text position where the mouse was clicked
+} EditorInfo;
+
+extern EditorInfo editor_info;
+
gchar **html_entities;
+gboolean
+on_editor_button_press_event (GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data);
+
// callback func called by all editors when a signal arises
void on_editor_notification(GtkWidget* editor, gint scn, gpointer lscn, gpointer user_data);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list