Gsc Utils

Gsc Utils — Useful functions

Synopsis

gchar *             gsc_get_last_word_and_iter          (GtkTextView *text_view,
                                                         GtkTextIter *start_word,
                                                         GtkTextIter *end_word);
gchar *             gsc_get_last_word                   (GtkTextView *text_view);
gchar *             gsc_get_last_word_cleaned           (GtkTextView *text_view);
void                gsc_get_cursor_pos                  (GtkTextView *text_view,
                                                         gint *x,
                                                         gint *y);
gchar *             gsc_gsv_get_text                    (GtkTextView *text_view);
void                gsc_replace_actual_word             (GtkTextView *text_view,
                                                         const gchar *text);
gboolean            gsc_char_is_separator               (gunichar ch);
gchar *             gsc_clear_word                      (const gchar *word);
gchar *             gsc_compute_line_indentation        (GtkTextView *view,
                                                         GtkTextIter *cur);
gchar *             gsc_get_text_with_indent            (const gchar *content,
                                                         gchar *indent);
void                gsc_insert_text_with_indent         (GtkTextView *view,
                                                         const gchar *text);
gboolean            gsc_is_valid_word                   (gchar *current_word,
                                                         gchar *completion_word);
gboolean            gsc_get_window_position_in_cursor   (GtkWindow *window,
                                                         GtkTextView *view,
                                                         gint *x,
                                                         gint *y,
                                                         gboolean *resized);
void                gsc_get_window_position_center_screen
                                                        (GtkWindow *window,
                                                         gint *x,
                                                         gint *y);
void                gsc_get_window_position_center_parent
                                                        (GtkWindow *window,
                                                         GtkWidget *parent,
                                                         gint *x,
                                                         gint *y);

Description

Details

gsc_get_last_word_and_iter ()

gchar *             gsc_get_last_word_and_iter          (GtkTextView *text_view,
                                                         GtkTextIter *start_word,
                                                         GtkTextIter *end_word);

text_view :

The GtkTextView

start_word :

if != NULL then assign it the start position of the word

end_word :

if != NULL then assing it the end position of the word

Returns :

the last word written in the GtkTextView or ""

gsc_get_last_word ()

gchar *             gsc_get_last_word                   (GtkTextView *text_view);

text_view :

The GtkTextView

Returns :

the last word written in the GtkTextView or ""

gsc_get_last_word_cleaned ()

gchar *             gsc_get_last_word_cleaned           (GtkTextView *text_view);

See gsc_get_last_word and gsc_clear_word

text_view :

The GtkTextView

Returns :

the last word written in the GtkTextView or "" (new allocated)

gsc_get_cursor_pos ()

void                gsc_get_cursor_pos                  (GtkTextView *text_view,
                                                         gint *x,
                                                         gint *y);

Gets the cursor position on the screen.

text_view :

The GtkTextView

x :

Assign the x position of the cursor

y :

Assign the y position of the cursor

gsc_gsv_get_text ()

gchar *             gsc_gsv_get_text                    (GtkTextView *text_view);

text_view :

The GtkTextView

Returns :

All the GtkTextView content .

gsc_replace_actual_word ()

void                gsc_replace_actual_word             (GtkTextView *text_view,
                                                         const gchar *text);

Replaces the current word in the GtkTextView with the new word

text_view :

The GtkTextView

text :

The text to be inserted instead of the current word

gsc_char_is_separator ()

gboolean            gsc_char_is_separator               (gunichar ch);

A separator is a character like (, an space etc. An _ is not a separator

ch :

The character to check

Returns :

TRUE if the ch is a separator

gsc_clear_word ()

gchar *             gsc_clear_word                      (const gchar *word);

Clean the word eliminates the special characters at the start of this word. By example "$variable" is cleaned to "variable"

word :

The word to be cleaned

Returns :

New allocated string with the word cleaned. If all characters are separators, it return NULL;

gsc_compute_line_indentation ()

gchar *             gsc_compute_line_indentation        (GtkTextView *view,
                                                         GtkTextIter *cur);

view :

The GtkTextView

cur :

Cursor in the line where we compute the indentation

Returns :

New allocated string with the indentation of this line

gsc_get_text_with_indent ()

gchar *             gsc_get_text_with_indent            (const gchar *content,
                                                         gchar *indent);

content :

The initial text to indent

indent :

Indentation string. You can get the indentation of a line with gsc_compute_line_indentation.

Returns :

New allocated string with the content indented.

gsc_insert_text_with_indent ()

void                gsc_insert_text_with_indent         (GtkTextView *view,
                                                         const gchar *text);

This function indent the text and insert it into the view in the current position.

view :

The GtkTextView where we will insert the indented text

text :

Text to indent and insert into the view.

gsc_is_valid_word ()

gboolean            gsc_is_valid_word                   (gchar *current_word,
                                                         gchar *completion_word);

current_word :

The current word

completion_word :

The completion word

Returns :

TRUE if the completion_word starts with current_word and it is not the same word.

gsc_get_window_position_in_cursor ()

gboolean            gsc_get_window_position_in_cursor   (GtkWindow *window,
                                                         GtkTextView *view,
                                                         gint *x,
                                                         gint *y,
                                                         gboolean *resized);

window :

Window to set

view :

Parent view where we get the cursor position

x :

The returned x position

y :

The returned y position

resized :

Returns :

TRUE if the position is over the text and FALSE if the position is under the text.

gsc_get_window_position_center_screen ()

void                gsc_get_window_position_center_screen
                                                        (GtkWindow *window,
                                                         gint *x,
                                                         gint *y);

Assing x and y values to center the window in the screen

window :

Window to set

x :

The returned x position

y :

The returned y position

gsc_get_window_position_center_parent ()

void                gsc_get_window_position_center_parent
                                                        (GtkWindow *window,
                                                         GtkWidget *parent,
                                                         gint *x,
                                                         gint *y);

Assing x and y values to center the window in the parent widget

window :

Window to set

parent :

Parent widget where we want to center the window

x :

The returned x position

y :

The returned y position