geany  1.38
About: Geany is a text editor (using GTK2) with basic features of an integrated development environment (syntax highlighting, code folding, symbol name auto-completion, ...). F: office T: editor programming GTK+ IDE
  Fossies Dox: geany-1.38.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

sciwrappers.h File Reference

Wrapper functions for the Scintilla editor widget SCI_* messages. More...

#include "geany.h"
#include "gtkcompat.h"
#include "Scintilla.h"
#include "ScintillaWidget.h"
Include dependency graph for sciwrappers.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void sci_set_text (ScintillaObject *sci, const gchar *text)
 Sets all text. More...
 
gboolean sci_has_selection (ScintillaObject *sci)
 Checks if there's a selection. More...
 
void sci_end_undo_action (ScintillaObject *sci)
 Ends grouping a set of edits together as one Undo action. More...
 
void sci_start_undo_action (ScintillaObject *sci)
 Begins grouping a set of edits together as one Undo action. More...
 
void sci_set_marker_at_line (ScintillaObject *sci, gint line_number, gint marker)
 Sets a line marker. More...
 
void sci_delete_marker_at_line (ScintillaObject *sci, gint line_number, gint marker)
 Deletes a line marker. More...
 
gboolean sci_is_marker_set_at_line (ScintillaObject *sci, gint line, gint marker)
 Checks if a line has a marker set. More...
 
gint sci_get_col_from_position (ScintillaObject *sci, gint position)
 Gets the column number relative to the start of the line that position is on. More...
 
gint sci_get_line_from_position (ScintillaObject *sci, gint position)
 Gets the line number from position. More...
 
gint sci_get_position_from_line (ScintillaObject *sci, gint line)
 Gets the position for the start of line. More...
 
gint sci_get_current_position (ScintillaObject *sci)
 Gets the cursor position. More...
 
void sci_set_current_position (ScintillaObject *sci, gint position, gboolean scroll_to_caret)
 Sets the cursor position. More...
 
gint sci_get_selection_start (ScintillaObject *sci)
 Gets the selection start position. More...
 
gint sci_get_selection_end (ScintillaObject *sci)
 Gets the selection end position. More...
 
void sci_replace_sel (ScintillaObject *sci, const gchar *text)
 Replaces selection. More...
 
gint sci_get_selection_mode (ScintillaObject *sci)
 Gets selection mode. More...
 
void sci_set_selection_mode (ScintillaObject *sci, gint mode)
 Sets selection mode. More...
 
void sci_set_selection_start (ScintillaObject *sci, gint position)
 Sets the selection start position. More...
 
void sci_set_selection_end (ScintillaObject *sci, gint position)
 Sets the selection end position. More...
 
gint sci_get_length (ScintillaObject *sci)
 Gets the length of all text. More...
 
gchar * sci_get_contents (ScintillaObject *sci, gint buffer_len)
 Allocates and fills a buffer with text from the start of the document. More...
 
gint sci_get_selected_text_length (ScintillaObject *sci)
 Gets selected text length. More...
 
gchar * sci_get_selection_contents (ScintillaObject *sci)
 Gets selected text. More...
 
gchar * sci_get_line (ScintillaObject *sci, gint line_num)
 Gets line contents. More...
 
gint sci_get_line_length (ScintillaObject *sci, gint line)
 Gets line length. More...
 
gint sci_get_line_count (ScintillaObject *sci)
 Gets the total number of lines. More...
 
gint sci_get_line_end_position (ScintillaObject *sci, gint line)
 Gets the position at the end of a line. More...
 
gboolean sci_get_line_is_visible (ScintillaObject *sci, gint line)
 Checks if a line is visible (folding may have hidden it). More...
 
void sci_ensure_line_is_visible (ScintillaObject *sci, gint line)
 Makes line visible (folding may have hidden it). More...
 
gint sci_get_tab_width (ScintillaObject *sci)
 Gets display tab width (this is not indent width, see GeanyIndentPrefs). More...
 
gchar sci_get_char_at (ScintillaObject *sci, gint pos)
 Gets a character. More...
 
void sci_scroll_caret (ScintillaObject *sci)
 Scrolls the cursor in view. More...
 
gint sci_find_text (ScintillaObject *sci, gint flags, struct Sci_TextToFind *ttf)
 Finds text in the document. More...
 
void sci_set_font (ScintillaObject *sci, gint style, const gchar *font, gint size)
 Sets the font for a particular style. More...
 
void sci_goto_line (ScintillaObject *sci, gint line, gboolean unfold)
 Jumps to the specified line in the document. More...
 
gint sci_get_style_at (ScintillaObject *sci, gint position)
 Gets style ID at position. More...
 
gchar * sci_get_contents_range (ScintillaObject *sci, gint start, gint end)
 Gets text between start and end. More...
 
void sci_insert_text (ScintillaObject *sci, gint pos, const gchar *text)
 Inserts text. More...
 
void sci_set_target_start (ScintillaObject *sci, gint start)
 
void sci_set_target_end (ScintillaObject *sci, gint end)
 
gint sci_replace_target (ScintillaObject *sci, const gchar *text, gboolean regex)
 
gint sci_get_lexer (ScintillaObject *sci)
 Gets the currently used lexer. More...
 
void sci_send_command (ScintillaObject *sci, gint cmd)
 Sends Scintilla commands without any parameters. More...
 
gint sci_get_current_line (ScintillaObject *sci)
 Gets current line number. More...
 
void sci_indicator_set (ScintillaObject *sci, gint indic)
 Sets the current indicator. More...
 
void sci_indicator_clear (ScintillaObject *sci, gint pos, gint len)
 Clears the currently set indicator from a range of text. More...
 
void sci_set_line_indentation (ScintillaObject *sci, gint line, gint indent)
 Sets the indentation of a line. More...
 
gint sci_get_line_indentation (ScintillaObject *sci, gint line)
 Gets the indentation width of a line. More...
 
gint sci_find_matching_brace (ScintillaObject *sci, gint pos)
 Finds a matching brace at pos. More...
 
void sci_get_text (ScintillaObject *sci, gint len, gchar *text)
 Gets all text. More...
 
void sci_get_selected_text (ScintillaObject *sci, gchar *text)
 Gets selected text. More...
 
void sci_get_text_range (ScintillaObject *sci, gint start, gint end, gchar *text)
 Gets text between start and end. More...
 

Detailed Description

Wrapper functions for the Scintilla editor widget SCI_* messages.

You should also check the http://scintilla.org documentation, as it is more detailed.

To get Scintilla notifications, use the "editor-notify" signal .

Note
These functions were originally from the cssed project (http://cssed.sf.net, thanks).
See also
scintilla_send_message().

Definition in file sciwrappers.h.

Function Documentation

◆ sci_delete_marker_at_line()

void sci_delete_marker_at_line ( ScintillaObject *  sci,
gint  line_number,
gint  marker 
)

Deletes a line marker.

Parameters
sciScintilla widget.
line_numberLine number.
markerMarker number.

Definition at line 399 of file sciwrappers.c.

References sci, and SCI_MARKERDELETE.

Referenced by on_sci_notify(), and sci_toggle_marker_at_line().

◆ sci_end_undo_action()

◆ sci_ensure_line_is_visible()

void sci_ensure_line_is_visible ( ScintillaObject *  sci,
gint  line 
)

Makes line visible (folding may have hidden it).

Parameters
sciScintilla widget.
lineLine number.

Definition at line 816 of file sciwrappers.c.

References line, sci, and SCI_ENSUREVISIBLE.

Referenced by document_find_text(), document_search_bar_find(), and editor_display_current_line().

◆ sci_find_matching_brace()

gint sci_find_matching_brace ( ScintillaObject *  sci,
gint  pos 
)

Finds a matching brace at pos.

Parameters
sciScintilla widget.
posPosition.
Returns
Matching brace position.
Since
0.15

Definition at line 1291 of file sciwrappers.c.

References pos, sci, and SCI_BRACEMATCH.

Referenced by auto_close_chars(), autocomplete_scope(), delay_match_brace(), editor_show_calltip(), get_fold_header_after(), and goto_matching_brace().

◆ sci_find_text()

gint sci_find_text ( ScintillaObject *  sci,
gint  flags,
struct Sci_TextToFind ttf 
)

Finds text in the document.

The ttf argument should be a pointer to a Sci_TextToFind structure which contains the text to find and the range in which the text should be searched.

Please refer to the Scintilla documentation for a more detailed description.

Parameters
sciScintilla widget.
flagsBitmask of Scintilla search flags (SCFIND_*, see Scintilla documentation).
ttfPointer to a TextToFind structure which contains the text to find and the range.
Returns
The position of the start of the found text if it succeeds, otherwise -1. The chrgText.cpMin and chrgText.cpMax members of TextToFind are filled in with the start and end positions of the found text.

Definition at line 995 of file sciwrappers.c.

References sci, and SCI_FINDTEXT.

Referenced by detect_tabs_and_spaces(), document_search_bar_find(), editor_replace_spaces(), editor_replace_tabs(), find_in_current_style(), and search_find_text().

◆ sci_get_char_at()

◆ sci_get_col_from_position()

gint sci_get_col_from_position ( ScintillaObject *  sci,
gint  position 
)

Gets the column number relative to the start of the line that position is on.

Parameters
sciScintilla widget.
positionPosition.
Returns
The column.

Definition at line 480 of file sciwrappers.c.

References position, sci, and SCI_GETCOLUMN.

Referenced by auto_multiline(), check_line_breaking(), create_statusbar_statistics(), delay_match_brace(), editor_replace_tabs(), editor_select_lines(), editor_strip_trailing_spaces(), sci_deselect_last_newline(), split_line(), and ui_update_statusbar().

◆ sci_get_contents()

gchar * sci_get_contents ( ScintillaObject *  sci,
gint  buffer_len 
)

Allocates and fills a buffer with text from the start of the document.

Parameters
sciScintilla widget.
buffer_lenBuffer length to allocate, including the terminating null char, e.g. sci_get_length() + 1. Alternatively use -1 to get all text (since Geany 1.23).
Returns
A copy of the text. Should be freed when no longer needed.
Since
1.23 (0.17)

Definition at line 743 of file sciwrappers.c.

References sci, sci_get_length(), SCI_GETTEXT, and text.

Referenced by document_clone(), and tools_word_count().

◆ sci_get_contents_range()

gchar * sci_get_contents_range ( ScintillaObject *  sci,
gint  start,
gint  end 
)

Gets text between start and end.

Parameters
sciScintilla widget.
startStart position.
endEnd position.
Returns
The text inside the given range. Should be freed when no longer needed.
Since
0.17

Definition at line 1104 of file sciwrappers.c.

References NULL, sci, sci_get_text_range(), and text.

Referenced by get_doc_words(), get_xml_indent(), insert_indent_after_line(), parse_cpp_function_at_line(), and parse_function_at_line().

◆ sci_get_current_line()

◆ sci_get_current_position()

◆ sci_get_length()

◆ sci_get_lexer()

◆ sci_get_line()

gchar * sci_get_line ( ScintillaObject *  sci,
gint  line_num 
)

Gets line contents.

Parameters
sciScintilla widget.
line_numLine number.
Returns
A NULL-terminated copy of the line text.

Definition at line 713 of file sciwrappers.c.

References sci, sci_get_string(), and SCI_GETLINE.

Referenced by auto_multiline(), close_block(), editor_indicator_set_on_line(), editor_insert_text_block(), filetypes_detect_from_document(), find_document_usage(), read_current_word(), and read_indent().

◆ sci_get_line_count()

◆ sci_get_line_end_position()

gint sci_get_line_end_position ( ScintillaObject *  sci,
gint  line 
)

◆ sci_get_line_from_position()

◆ sci_get_line_indentation()

gint sci_get_line_indentation ( ScintillaObject *  sci,
gint  line 
)

Gets the indentation width of a line.

Parameters
sciScintilla widget.
lineLine to get the indentation from.
Returns
Indentation width.
Since
0.19

Definition at line 1376 of file sciwrappers.c.

References line, sci, and SCI_GETLINEINDENTATION.

Referenced by change_tab_indentation(), close_block(), detect_indent_width(), document_detect_indent_type(), editor_change_line_indent(), find_block_stop(), get_indent_size_after_line(), insert_indent_after_line(), and reflow_lines().

◆ sci_get_line_is_visible()

gboolean sci_get_line_is_visible ( ScintillaObject *  sci,
gint  line 
)

Checks if a line is visible (folding may have hidden it).

Parameters
sciScintilla widget.
lineLine number.
Returns
Whether line will be drawn on the screen.

Definition at line 806 of file sciwrappers.c.

References line, sci, and SCI_GETLINEVISIBLE.

Referenced by fold_changed().

◆ sci_get_line_length()

gint sci_get_line_length ( ScintillaObject *  sci,
gint  line 
)

Gets line length.

Parameters
sciScintilla widget.
lineLine number.
Returns
Length.

Definition at line 689 of file sciwrappers.c.

References line, sci, and SCI_LINELENGTH.

Referenced by document_replace_sel(), editor_indent(), read_indent(), and sci_delete_line().

◆ sci_get_position_from_line()

◆ sci_get_selected_text()

void sci_get_selected_text ( ScintillaObject *  sci,
gchar *  text 
)

Gets selected text.

Deprecated:
sci_get_selected_text is deprecated and should not be used in newly-written code. Use sci_get_selection_contents() instead.
Parameters
sciScintilla widget.
textText buffer; must be allocated sci_get_selected_text_length() + 1 bytes for null-termination.

Definition at line 764 of file sciwrappers.c.

References sci, SCI_GETSELTEXT, and text.

◆ sci_get_selected_text_length()

gint sci_get_selected_text_length ( ScintillaObject *  sci)

Gets selected text length.

Parameters
sciScintilla widget.
Returns
Length.

Definition at line 788 of file sciwrappers.c.

References sci, and SCI_GETSELTEXT.

Referenced by create_statusbar_statistics().

◆ sci_get_selection_contents()

gchar * sci_get_selection_contents ( ScintillaObject *  sci)

Gets selected text.

Parameters
sciScintilla widget.
Returns
The selected text. Should be freed when no longer needed.
Since
0.17

Definition at line 778 of file sciwrappers.c.

References sci, sci_get_string(), and SCI_GETSELTEXT.

Referenced by document_clone(), editor_get_default_selection(), find_usage(), get_current_word_or_sel(), on_context_action1_activate(), on_toggle_case1_activate(), replace_special_character(), search_find_selection(), tools_execute_custom_command(), and tools_word_count().

◆ sci_get_selection_end()

◆ sci_get_selection_mode()

gint sci_get_selection_mode ( ScintillaObject *  sci)

Gets selection mode.

Parameters
sciScintilla widget.
Returns
Selection mode.

Definition at line 1331 of file sciwrappers.c.

References sci, and SCI_GETSELECTIONMODE.

Referenced by check_line_breaking(), document_replace_sel(), and sci_get_cursor_virtual_space().

◆ sci_get_selection_start()

◆ sci_get_style_at()

◆ sci_get_tab_width()

gint sci_get_tab_width ( ScintillaObject *  sci)

Gets display tab width (this is not indent width, see GeanyIndentPrefs).

Parameters
sciScintilla widget.
Returns
Width.
Since
0.15

Definition at line 878 of file sciwrappers.c.

References sci, and SCI_GETTABWIDTH.

Referenced by count_indent_size(), editor_replace_spaces(), editor_replace_tabs(), fix_indentation(), write_html_file(), and write_latex_file().

◆ sci_get_text()

void sci_get_text ( ScintillaObject *  sci,
gint  len,
gchar *  text 
)

Gets all text.

Deprecated:
sci_get_text is deprecated and should not be used in newly-written code. Use sci_get_contents() instead.
Parameters
sciScintilla widget.
lenLength of text buffer, usually sci_get_length() + 1.
textText buffer; must be allocated len + 1 bytes for null-termination.

Definition at line 727 of file sciwrappers.c.

References sci, SCI_GETTEXT, and text.

Referenced by document_save_file().

◆ sci_get_text_range()

void sci_get_text_range ( ScintillaObject *  sci,
gint  start,
gint  end,
gchar *  text 
)

Gets text between start and end.

Deprecated:
sci_get_text_range is deprecated and should not be used in newly-written code. Use sci_get_contents_range() instead.
Parameters
sciScintilla widget.
startStart.
endEnd.
textText will be zero terminated and must be allocated (end - start + 1) bytes.

Definition at line 1085 of file sciwrappers.c.

References Sci_TextRange::chrg, Sci_CharacterRange::cpMax, Sci_CharacterRange::cpMin, Sci_TextRange::lpstrText, sci, SCI_GETTEXTRANGE, and text.

Referenced by editor_do_comment(), editor_do_comment_toggle(), editor_do_uncomment(), editor_find_current_word_sciwc(), handle_xml(), match_last_chars(), save_convert_to_encoding(), and sci_get_contents_range().

◆ sci_goto_line()

void sci_goto_line ( ScintillaObject *  sci,
gint  line,
gboolean  unfold 
)

Jumps to the specified line in the document.

If unfold is set and line is hidden by a fold, it is unfolded first to ensure it is visible.

Parameters
sciScintilla widget.
lineLine.
unfoldWhether to unfold first.

Definition at line 1033 of file sciwrappers.c.

References line, sci, SCI_ENSUREVISIBLE, and SCI_GOTOLINE.

Referenced by set_cursor_position().

◆ sci_has_selection()

◆ sci_indicator_clear()

void sci_indicator_clear ( ScintillaObject *  sci,
gint  pos,
gint  len 
)

Clears the currently set indicator from a range of text.

Starting at pos, len characters long. In order to make this function properly, you need to set the current indicator before with sci_indicator_set().

Parameters
sciScintilla widget.
posStarting position.
lenLength.
Since
0.16

Definition at line 1259 of file sciwrappers.c.

References pos, sci, and SCI_INDICATORCLEARRANGE.

Referenced by editor_indicator_clear().

◆ sci_indicator_set()

void sci_indicator_set ( ScintillaObject *  sci,
gint  indic 
)

Sets the current indicator.

This is necessary to define an indicator for a range of text or clearing indicators for a range of text.

Parameters
sciScintilla widget.
indicThe indicator number to set.
See also
sci_indicator_clear
Since
0.16

Definition at line 1234 of file sciwrappers.c.

References sci, and SCI_SETINDICATORCURRENT.

Referenced by editor_goto_next_snippet_cursor(), editor_indicator_clear(), and editor_indicator_set_on_range().

◆ sci_insert_text()

◆ sci_is_marker_set_at_line()

gboolean sci_is_marker_set_at_line ( ScintillaObject *  sci,
gint  line,
gint  marker 
)

Checks if a line has a marker set.

Parameters
sciScintilla widget.
lineLine number.
markerMarker number.
Returns
Whether it's set.

Definition at line 411 of file sciwrappers.c.

References line, sci, and SCI_MARKERGET.

Referenced by on_sci_notify(), and sci_toggle_marker_at_line().

◆ sci_replace_sel()

◆ sci_replace_target()

gint sci_replace_target ( ScintillaObject *  sci,
const gchar *  text,
gboolean  regex 
)

◆ sci_scroll_caret()

void sci_scroll_caret ( ScintillaObject *  sci)

◆ sci_send_command()

void sci_send_command ( ScintillaObject *  sci,
gint  cmd 
)

Sends Scintilla commands without any parameters.

Parameters
sciThe Scintilla GtkWidget.
cmdSCI_COMMAND.
See also
http://scintilla.org for the documentation.
Since
0.16

Definition at line 1180 of file sciwrappers.c.

References sci.

Referenced by cb_func_clipboard_action(), cb_func_editor_action(), cb_func_goto_action(), cb_func_select_action(), check_line_breaking(), editor_start_auto_complete(), insert_line_after(), insert_line_before(), on_editor_scroll_event(), on_toggle_case1_activate(), and show_autocomplete().

◆ sci_set_current_position()

void sci_set_current_position ( ScintillaObject *  sci,
gint  position,
gboolean  scroll_to_caret 
)

◆ sci_set_font()

void sci_set_font ( ScintillaObject *  sci,
gint  style,
const gchar *  font,
gint  size 
)

Sets the font for a particular style.

Parameters
sciScintilla widget.
styleThe style.
fontThe font name.
sizeThe font size.

Definition at line 1019 of file sciwrappers.c.

References sci, and sci_set_font_fractional().

◆ sci_set_line_indentation()

void sci_set_line_indentation ( ScintillaObject *  sci,
gint  line,
gint  indent 
)

Sets the indentation of a line.

Parameters
sciScintilla widget.
lineLine to indent.
indentIndentation width.
Since
0.19

Definition at line 1362 of file sciwrappers.c.

References indent, line, sci, and SCI_SETLINEINDENTATION.

Referenced by change_tab_indentation(), close_block(), editor_change_line_indent(), join_lines(), and reflow_lines().

◆ sci_set_marker_at_line()

void sci_set_marker_at_line ( ScintillaObject *  sci,
gint  line_number,
gint  marker 
)

Sets a line marker.

Parameters
sciScintilla widget.
line_numberLine number.
markerMarker number.

Definition at line 388 of file sciwrappers.c.

References sci, and SCI_MARKERADD.

Referenced by editor_goto_pos(), on_sci_notify(), and sci_toggle_marker_at_line().

◆ sci_set_selection_end()

◆ sci_set_selection_mode()

void sci_set_selection_mode ( ScintillaObject *  sci,
gint  mode 
)

Sets selection mode.

Parameters
sciScintilla widget.
modeMode.

Definition at line 1341 of file sciwrappers.c.

References sci, and SCI_SETSELECTIONMODE.

Referenced by document_replace_sel().

◆ sci_set_selection_start()

◆ sci_set_target_end()

void sci_set_target_end ( ScintillaObject *  sci,
gint  end 
)

◆ sci_set_target_start()

void sci_set_target_start ( ScintillaObject *  sci,
gint  start 
)

◆ sci_set_text()

void sci_set_text ( ScintillaObject *  sci,
const gchar *  text 
)

Sets all text.

Parameters
sciScintilla widget.
textText.

Definition at line 293 of file sciwrappers.c.

References NULL, sci, SCI_SETTEXT, and text.

Referenced by document_new_file(), and document_open_file_full().

◆ sci_start_undo_action()