diff --git a/ChangeLog b/ChangeLog index 254803e30..cd3e37149 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/src/callbacks.c b/src/callbacks.c index 71ea8bbf1..b36ba58f1 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -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); } } diff --git a/src/document.c b/src/document.c index 6e27faa18..07e1f7566 100644 --- a/src/document.c +++ b/src/document.c @@ -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; diff --git a/src/editor.c b/src/editor.c index 54602b152..522c4ff78 100644 --- a/src/editor.c +++ b/src/editor.c @@ -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]; diff --git a/src/editor.h b/src/editor.h index ddbb023ad..d1ab80d8c 100644 --- a/src/editor.h +++ b/src/editor.h @@ -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 diff --git a/src/highlighting.c b/src/highlighting.c index fb9b2012e..93f08d013 100644 --- a/src/highlighting.c +++ b/src/highlighting.c @@ -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" "!\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~" diff --git a/src/sciwrappers.c b/src/sciwrappers.c index d7d91b354..34353034b 100644 --- a/src/sciwrappers.c +++ b/src/sciwrappers.c @@ -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); +} + + diff --git a/src/sciwrappers.h b/src/sciwrappers.h index 5f0d9ab9d..575a662cc 100644 --- a/src/sciwrappers.h +++ b/src/sciwrappers.h @@ -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