Add sci_set_marker_at_line(), sci_delete_marker_at_line(),

sci_is_marker_set_at_line() to the plugin API (thanks to Yura
Siamashka).
Add sci_toggle_marker_at_line().
Fix SciFuncs alignment.



git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4178 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2009-09-12 17:39:49 +00:00
parent 4b3cdd44ce
commit c100272031
8 changed files with 93 additions and 47 deletions

View File

@ -1,3 +1,15 @@
2009-09-12 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/keybindings.c, src/sciwrappers.c, src/sciwrappers.h,
src/plugindata.h, src/plugins.c, src/editor.c,
plugins/geanyfunctions.h:
Add sci_set_marker_at_line(), sci_delete_marker_at_line(),
sci_is_marker_set_at_line() to the plugin API (thanks to Yura
Siamashka).
Add sci_toggle_marker_at_line().
Fix SciFuncs alignment.
2009-09-11 Lex Trotman <elextr(at)gmail(dot)com>
* src/build.c

View File

@ -168,6 +168,12 @@
geany_functions->p_sci->set_target_end
#define sci_replace_target \
geany_functions->p_sci->replace_target
#define sci_set_marker_at_line \
geany_functions->p_sci->set_marker_at_line
#define sci_delete_marker_at_line \
geany_functions->p_sci->delete_marker_at_line
#define sci_is_marker_set_at_line \
geany_functions->p_sci->is_marker_set_at_line
#define templates_get_template_fileheader \
geany_functions->p_templates->get_template_fileheader
#define utils_str_equal \

View File

@ -316,10 +316,9 @@ static void on_margin_click(ScintillaObject *sci, SCNotification *nt)
if (nt->margin == 1)
{
gint line = sci_get_line_from_position(sci, nt->position);
gboolean set = sci_is_marker_set_at_line(sci, line, 1);
/*sci_marker_delete_all(editor->sci, 1);*/
sci_set_marker_at_line(sci, line, ! set, 1); /* toggle the marker */
sci_toggle_marker_at_line(sci, line, 1); /* toggle the marker */
}
/* left click on the folding margin to toggle folding state of current line */
else if (nt->margin == 2 && editor_prefs.folding)
@ -4471,7 +4470,7 @@ gboolean editor_goto_pos(GeanyEditor *editor, gint pos, gboolean mark)
/* mark the tag with the yellow arrow */
sci_marker_delete_all(editor->sci, 0);
sci_set_marker_at_line(editor->sci, line, TRUE, 0);
sci_set_marker_at_line(editor->sci, line, 0);
}
sci_goto_pos(editor->sci, pos, TRUE);

View File

@ -1811,9 +1811,7 @@ static void cb_func_goto_action(guint key_id)
return;
case GEANY_KEYS_GOTO_TOGGLEMARKER:
{
gboolean set = sci_is_marker_set_at_line(doc->editor->sci, cur_line, 1);
sci_set_marker_at_line(doc->editor->sci, cur_line, ! set, 1);
sci_toggle_marker_at_line(doc->editor->sci, cur_line, 1);
return;
}
case GEANY_KEYS_GOTO_NEXTMARKER:

View File

@ -50,7 +50,7 @@
enum {
/** The Application Programming Interface (API) version, incremented
* whenever any plugin data types are modified or appended to. */
GEANY_API_VERSION = 155,
GEANY_API_VERSION = 156,
/** The Application Binary Interface (ABI) version, incremented whenever
* existing fields in the plugin data types have to be changed or reordered. */
@ -293,39 +293,39 @@ ScintillaFuncs;
typedef struct SciFuncs
{
/** @deprecated Use @ref ScintillaFuncs::send_message() instead. */
long int (*send_message) (struct _ScintillaObject* sci, unsigned int iMessage,
long int (*send_message) (struct _ScintillaObject *sci, unsigned int iMessage,
long unsigned int wParam, long int lParam);
void (*send_command) (struct _ScintillaObject* sci, gint cmd);
void (*send_command) (struct _ScintillaObject *sci, gint cmd);
void (*start_undo_action) (struct _ScintillaObject* sci);
void (*end_undo_action) (struct _ScintillaObject* sci);
void (*start_undo_action) (struct _ScintillaObject *sci);
void (*end_undo_action) (struct _ScintillaObject *sci);
void (*set_text) (struct _ScintillaObject *sci, const gchar *text);
void (*insert_text) (struct _ScintillaObject *sci, gint pos, const gchar *text);
void (*get_text) (struct _ScintillaObject *sci, gint len, gchar *text);
gint (*get_length) (struct _ScintillaObject *sci);
gint (*get_current_position) (struct _ScintillaObject *sci);
void (*set_current_position) (struct _ScintillaObject* sci, gint position,
void (*set_current_position) (struct _ScintillaObject *sci, gint position,
gboolean scroll_to_caret);
gint (*get_col_from_position) (struct _ScintillaObject* sci, gint position);
gint (*get_line_from_position) (struct _ScintillaObject* sci, gint position);
gint (*get_position_from_line) (struct _ScintillaObject* sci, gint line);
void (*replace_sel) (struct _ScintillaObject* sci, const gchar *text);
void (*get_selected_text) (struct _ScintillaObject* sci, gchar *text);
gint (*get_selected_text_length) (struct _ScintillaObject* sci);
gint (*get_selection_start) (struct _ScintillaObject* sci);
gint (*get_selection_end) (struct _ScintillaObject* sci);
gint (*get_selection_mode) (struct _ScintillaObject* sci);
void (*set_selection_mode) (struct _ScintillaObject* sci, gint mode);
void (*set_selection_start) (struct _ScintillaObject* sci, gint position);
void (*set_selection_end) (struct _ScintillaObject* sci, gint position);
void (*get_text_range) (struct _ScintillaObject* sci, gint start, gint end, gchar *text);
gchar* (*get_line) (struct _ScintillaObject* sci, gint line_num);
gint (*get_line_length) (struct _ScintillaObject* sci, gint line);
gint (*get_line_count) (struct _ScintillaObject* sci);
gboolean (*get_line_is_visible) (struct _ScintillaObject* sci, gint line);
void (*ensure_line_is_visible) (struct _ScintillaObject* sci, gint line);
void (*scroll_caret) (struct _ScintillaObject* sci);
gint (*find_matching_brace) (struct _ScintillaObject* sci, gint pos);
gint (*get_col_from_position) (struct _ScintillaObject *sci, gint position);
gint (*get_line_from_position) (struct _ScintillaObject *sci, gint position);
gint (*get_position_from_line) (struct _ScintillaObject *sci, gint line);
void (*replace_sel) (struct _ScintillaObject *sci, const gchar *text);
void (*get_selected_text) (struct _ScintillaObject *sci, gchar *text);
gint (*get_selected_text_length) (struct _ScintillaObject *sci);
gint (*get_selection_start) (struct _ScintillaObject *sci);
gint (*get_selection_end) (struct _ScintillaObject *sci);
gint (*get_selection_mode) (struct _ScintillaObject *sci);
void (*set_selection_mode) (struct _ScintillaObject *sci, gint mode);
void (*set_selection_start) (struct _ScintillaObject *sci, gint position);
void (*set_selection_end) (struct _ScintillaObject *sci, gint position);
void (*get_text_range) (struct _ScintillaObject *sci, gint start, gint end, gchar *text);
gchar* (*get_line) (struct _ScintillaObject *sci, gint line_num);
gint (*get_line_length) (struct _ScintillaObject *sci, gint line);
gint (*get_line_count) (struct _ScintillaObject *sci);
gboolean (*get_line_is_visible) (struct _ScintillaObject *sci, gint line);
void (*ensure_line_is_visible) (struct _ScintillaObject *sci, gint line);
void (*scroll_caret) (struct _ScintillaObject *sci);
gint (*find_matching_brace) (struct _ScintillaObject *sci, gint pos);
gint (*get_style_at) (struct _ScintillaObject *sci, gint position);
gchar (*get_char_at) (struct _ScintillaObject *sci, gint pos);
gint (*get_current_line) (struct _ScintillaObject *sci);
@ -337,10 +337,13 @@ typedef struct SciFuncs
gchar* (*get_contents_range) (struct _ScintillaObject *sci, gint start, gint end);
gchar* (*get_selection_contents) (struct _ScintillaObject *sci);
void (*set_font) (struct _ScintillaObject *sci, gint style, const gchar *font, gint size);
gint (*get_line_end_position) (ScintillaObject* sci, gint line);
void (*set_target_start) (ScintillaObject *sci, gint start);
void (*set_target_end) (ScintillaObject *sci, gint end);
gint (*replace_target) (ScintillaObject *sci, const gchar *text, gboolean regex);
gint (*get_line_end_position) (struct _ScintillaObject *sci, gint line);
void (*set_target_start) (struct _ScintillaObject *sci, gint start);
void (*set_target_end) (struct _ScintillaObject *sci, gint end);
gint (*replace_target) (struct _ScintillaObject *sci, const gchar *text, gboolean regex);
void (*set_marker_at_line) (struct _ScintillaObject *sci, gint line_number, gint marker);
void (*delete_marker_at_line) (struct _ScintillaObject *sci, gint line_number, gint marker);
gboolean (*is_marker_set_at_line) (struct _ScintillaObject *sci, gint line, gint marker);
}
SciFuncs;

View File

@ -171,7 +171,10 @@ static SciFuncs sci_funcs = {
&sci_get_line_end_position,
&sci_set_target_start,
&sci_set_target_end,
&sci_replace_target
&sci_replace_target,
&sci_set_marker_at_line,
&sci_delete_marker_at_line,
&sci_is_marker_set_at_line
};
static TemplateFuncs template_funcs = {

View File

@ -257,19 +257,31 @@ gint sci_get_zoom( ScintillaObject* sci )
}
void sci_set_marker_at_line( ScintillaObject* sci, gint line_number, gboolean set, gint marker )
/** Set a line marker.
* @param sci Scintilla widget.
* @param line_number Line number.
* @param marker Marker number. */
void sci_set_marker_at_line( ScintillaObject* sci, gint line_number, gint marker )
{
if ( set )
{
SSM( sci, SCI_MARKERADD, line_number, marker);
}
else
{
SSM( sci, SCI_MARKERDELETE, line_number, marker);
}
SSM( sci, SCI_MARKERADD, line_number, marker);
}
/** Delete a line marker.
* @param sci Scintilla widget.
* @param line_number Line number.
* @param marker Marker number. */
void sci_delete_marker_at_line( ScintillaObject* sci, gint line_number, gint marker )
{
SSM( sci, SCI_MARKERDELETE, line_number, marker);
}
/** Check if a line has a marker set.
* @param sci Scintilla widget.
* @param line Line number.
* @param marker Marker number.
* @return Whether it's set. */
gboolean sci_is_marker_set_at_line(ScintillaObject* sci, gint line, gint marker)
{
gint state;
@ -279,6 +291,17 @@ gboolean sci_is_marker_set_at_line(ScintillaObject* sci, gint line, gint marker)
}
void sci_toggle_marker_at_line(ScintillaObject* sci, gint line, gint marker)
{
gboolean set = sci_is_marker_set_at_line(sci, line, marker);
if (!set)
sci_set_marker_at_line(sci, line, marker);
else
sci_delete_marker_at_line(sci, line, marker);
}
/* Returns the line number of the next marker that matches marker_mask, or -1.
* marker_mask is a bitor of 1 << marker_index. (See MarkerHandleSet::MarkValue()).
* Note: If there is a marker on the line, it returns the same line. */

View File

@ -52,7 +52,9 @@ void sci_set_eol_mode (ScintillaObject* sci, gint eolmode);
void sci_zoom_in (ScintillaObject* sci);
void sci_zoom_out (ScintillaObject* sci);
void sci_zoom_off (ScintillaObject* sci);
void sci_set_marker_at_line (ScintillaObject* sci, gint line_number, gboolean set, gint marker );
void sci_set_marker_at_line (ScintillaObject* sci, gint line_number, gint marker);
void sci_delete_marker_at_line (ScintillaObject* sci, gint line_number, gint marker);
void sci_toggle_marker_at_line (ScintillaObject* sci, gint line, gint marker);
gboolean sci_is_marker_set_at_line (ScintillaObject* sci, gint line, gint marker);
gint sci_marker_next (ScintillaObject* sci, gint line, gint marker_mask, gboolean wrap);
gint sci_marker_previous (ScintillaObject* sci, gint line, gint marker_mask, gboolean wrap);