Beaver  0.4.1
Macros | Functions | Variables
text.c File Reference
#include <glib.h>
#include <gtk/gtk.h>
#include <string.h>
#include "../struct.h"
#include "../search.h"
#include "beaver.h"
#include "api.h"

Macros

#define SEARCH_ALPHABET_SIZE   256
 

Functions

void beaver_text_insert_string_impl (const gchar *text)
 
BeaverTextSelectionbeaver_text_selection_position_impl (void)
 
gchar * beaver_text_selection_get_impl (void)
 
void beaver_text_selection_set_impl (const gchar *text)
 
enum BeaverTextFormat beaver_text_format_impl (void)
 
void beaver_text_replace_impl (const gchar *needle, const gchar *substitute, gboolean sensitive)
 
gboolean beaver_text_find_impl (const gchar *needle, guint offset, gboolean sensitive)
 

Variables

GtkWidget * MainNotebook
 
gint OpenedFilesCnt
 
GArray * FileProperties
 

Detailed Description

Implementation for text manipulations for plugins.

Function Documentation

◆ beaver_text_find_impl()

gboolean beaver_text_find_impl ( const gchar *  needle,
guint  offset,
gboolean  sensitive 
)

Searches for a needle in the text. When found the text will be selected at the position and TRUE will be returned. If nothing was found, then nothing will be selected and FALSE will be returned. The selected text can be altered via beaver_text_selection_get/set.

The search is done via Boyer-Moore-Horspool's Algorithm. See http://www-igm.univ-mlv.fr/~lecroq/string/node18.html for more explanation about it.

Parameters
needlethe string to search for
offsetwhere in the text to begin to search (0 for beginning of text)
sensitivewheter or not to search case sensitive
Return values
trueneedle was found in text
falseotherwise

◆ beaver_text_format_impl()

enum BeaverTextFormat beaver_text_format_impl ( void  )

Returns the format of the text. The format revers to the line-break type of the different OS's.

Return values
0UNIX line-break
2DOS line-break
1MAC line-break
-1Unknown or error

◆ beaver_text_insert_string_impl()

void beaver_text_insert_string_impl ( const gchar *  text)

Insert text at current cursos position. If no text/cursor position is avaible then ignore insert. Also if text is read-only, ignore the call.

Parameters
textstring to be inserted

◆ beaver_text_replace_impl()

void beaver_text_replace_impl ( const gchar *  needle,
const gchar *  substitute,
gboolean  sensitive 
)

Searches for needle in the text and replaces it with subsitute. Replaces all occurences of needle.

Parameters
needlethe search string to replace
substitutethe replacement of found needle
sensitivewheter or not to search case sensitive

◆ beaver_text_selection_get_impl()

gchar* beaver_text_selection_get_impl ( void  )

Get the text that was selected. Returns NULL if no text was selected or if no text is avaiable. The returned string should be freed after usage.

Returns
selected text. should be freed after usage.

◆ beaver_text_selection_position_impl()

BeaverTextSelection* beaver_text_selection_position_impl ( void  )
Returns
returns a structure with information about the position of the selection. structure must be freed after use with g_free. returns NULL if information could not be load.

◆ beaver_text_selection_set_impl()

void beaver_text_selection_set_impl ( const gchar *  text)

Overwrites the selection with the given text. If no text is selected then just insert the text at the current cursor position. If no text is avaiable or text is read-only then ignore the call.

Parameters
textthe text to be inserted into the selection