Fix using direct Scintilla access in document.c and callbacks.

Add wrapper functions instead.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3000 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2008-09-25 18:29:53 +00:00
parent f701893ef7
commit 83d6c2e8e2
8 changed files with 38 additions and 7 deletions

View File

@ -13,6 +13,10 @@
When using editor_get_eol_char_* functions with an invalid editor
object, return the appropriate value according to the eol character
preference (just in case).
* src/callbacks.c, src/document.c, src/editor.c, src/editor.h,
src/highlighting.c, src/sciwrappers.c, src/sciwrappers.h:
Fix using direct Scintilla access in document.c and callbacks.
Add wrapper functions instead.
2008-09-25 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>

View File

@ -283,7 +283,7 @@ on_undo1_activate (GtkMenuItem *menuitem,
if (doc != NULL && document_can_undo(doc))
{
SSM(doc->editor->sci, SCI_CANCEL, 0, 0);
sci_cancel(doc->editor->sci);
document_undo(doc);
}
}
@ -297,7 +297,7 @@ on_redo1_activate (GtkMenuItem *menuitem,
if (doc != NULL && document_can_redo(doc))
{
SSM(doc->editor->sci, SCI_CANCEL, 0, 0);
sci_cancel(doc->editor->sci);
document_redo(doc);
}
}

View File

@ -1824,7 +1824,7 @@ document_replace_range(GeanyDocument *doc, const gchar *find_text, const gchar *
if (find_len <= 0)
{
gchar chNext = sci_get_char_at(sci, SSM(sci, SCI_GETTARGETEND, 0, 0));
gchar chNext = sci_get_char_at(sci, sci_get_target_end(sci));
if (chNext == '\r' || chNext == '\n')
movepastEOL = 1;
@ -1838,7 +1838,7 @@ document_replace_range(GeanyDocument *doc, const gchar *find_text, const gchar *
/* make the next search start after the replaced text */
start = search_pos + replace_len + movepastEOL;
if (find_len == 0)
start = SSM(sci, SCI_POSITIONAFTER, start, 0); /* prevent '[ ]*' regex rematching part of replaced text */
start = sci_get_position_after(sci, start); /* prevent '[ ]*' regex rematching part of replaced text */
ttf.chrg.cpMin = start;
end += replace_len - find_len; /* update end of range now text has changed */
ttf.chrg.cpMax = end;

View File

@ -59,6 +59,10 @@
#include "keybindings.h"
/* Note: Avoid using SSM in files not related to scintilla, use sciwrappers.h instead. */
#define SSM(s, m, w, l) scintilla_send_message(s, m, w, l)
/* holds word under the mouse or keyboard cursor */
static gchar current_word[GEANY_MAX_WORD_LENGTH];

View File

@ -31,9 +31,6 @@
#define GEANY_WORDCHARS "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
#define GEANY_MAX_WORD_LENGTH 192
/* Note: Avoid using SSM in files not related to scintilla, use sciwrappers.h instead. */
#define SSM(s, m, w, l) scintilla_send_message(s, m, w, l)
/** Whether to use tabs, spaces or both to indent. */
typedef enum

View File

@ -37,6 +37,9 @@
#include "symbols.h"
/* Note: Avoid using SSM in files not related to scintilla, use sciwrappers.h instead. */
#define SSM(s, m, w, l) scintilla_send_message(s, m, w, l)
/* Whitespace has to be set after setting wordchars. */
#define GEANY_WHITESPACE_CHARS " \t" "!\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~"

View File

@ -1086,3 +1086,20 @@ void sci_set_scroll_stop_at_last_line(ScintillaObject* sci, gboolean set)
{
SSM(sci, SCI_SETENDATLASTLINE, set, 0);
}
void sci_cancel(ScintillaObject *sci)
{
SSM( sci, SCI_CANCEL, 0, 0);
}
gint sci_get_target_end(ScintillaObject *sci)
{
return SSM( sci, SCI_GETTARGETEND, 0, 0);
}
gint sci_get_position_after(ScintillaObject *sci, gint start)
{
return SSM(sci, SCI_POSITIONAFTER, start, 0);
}

View File

@ -183,4 +183,10 @@ void sci_set_caret_policy_x (ScintillaObject * sci, gint policy, gint slop);
void sci_set_caret_policy_y (ScintillaObject * sci, gint policy, gint slop);
void sci_set_scroll_stop_at_last_line (ScintillaObject* sci, gboolean set);
void sci_cancel (ScintillaObject *sci);
gint sci_get_target_end (ScintillaObject *sci);
gint sci_get_position_after (ScintillaObject *sci, gint start);
#endif