/[beaver]/beaver/src/tools.c
ViewVC logotype

Diff of /beaver/src/tools.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by mikix, Tue May 13 23:08:29 2003 UTC revision 1.6 by mikix, Thu May 15 02:18:03 2003 UTC
# Line 84  gint max_from_selection (GtkTextView *Te Line 84  gint max_from_selection (GtkTextView *Te
84                    
85    Buffer = gtk_text_view_get_buffer(Text);    Buffer = gtk_text_view_get_buffer(Text);
86    gtk_text_buffer_get_selection_bounds (Buffer, NULL, &end);    gtk_text_buffer_get_selection_bounds (Buffer, NULL, &end);
87            
88    return gtk_text_iter_get_offset (&end);    return gtk_text_iter_get_offset (&end);
89  }  }
90    
# Line 105  gchar *get_selection (GtkTextBuffer *Buf Line 105  gchar *get_selection (GtkTextBuffer *Buf
105    
106    
107  /* Returns the contents of the buffer; must be g_free'd */  /* Returns the contents of the buffer; must be g_free'd */
   
108  gchar *get_text (GtkTextBuffer *Buffer)  gchar *get_text (GtkTextBuffer *Buffer)
109  {  {
110    GtkTextIter start, end;    GtkTextIter start, end;
# Line 118  gchar *get_text (GtkTextBuffer *Buffer) Line 117  gchar *get_text (GtkTextBuffer *Buffer)
117    return str;    return str;
118  }  }
119    
120  /* Replaces the currently selected text with new text */  /* Returns the contents of the buffer, from beginning to cursor;
121       must be g_free'd */
122    gchar *get_text_to_cursor (GtkTextBuffer *Buffer)
123    {
124      GtkTextIter start, end;
125      GtkTextMark *mark;
126      gchar *str;
127      
128      mark = gtk_text_buffer_get_mark (Buffer, "insert");
129      gtk_text_buffer_get_start_iter (Buffer, &start);
130      gtk_text_buffer_get_iter_at_mark (Buffer, &end, mark);
131      str = gtk_text_buffer_get_slice(Buffer,
132                       &start, &end, FALSE);
133      
134      return str;
135    }
136    
137    /* Returns the contents of the buffer, from cursor to end; must be g_free'd */
138    gchar *get_text_from_cursor (GtkTextBuffer *Buffer)
139    {
140      GtkTextIter start, end;
141      GtkTextMark *mark;
142      gchar *str;
143      
144      mark = gtk_text_buffer_get_mark (Buffer, "insert");
145      gtk_text_buffer_get_iter_at_mark (Buffer, &start, mark);
146      gtk_text_buffer_get_end_iter (Buffer, &end);
147      str = gtk_text_buffer_get_text (Buffer,
148                       &start, &end, FALSE);
149      
150      return str;
151    }
152    
153    /* Returns the line, 0-base, that the cursor is on */
154    gint get_line_of_cursor (GtkTextBuffer *Buffer)
155    {
156      GtkTextIter iter;
157      GtkTextMark *mark;
158      
159      mark = gtk_text_buffer_get_mark (Buffer, "insert");
160      gtk_text_buffer_get_iter_at_mark (Buffer, &iter, mark);
161      
162      return gtk_text_iter_get_line (&iter);
163    }
164    
165    /* Replaces the currently selected text with new text */
166  void replace_selection (GtkTextBuffer *Buffer, const gchar *str)  void replace_selection (GtkTextBuffer *Buffer, const gchar *str)
167  {  {
168    GtkTextIter start, end;    GtkTextIter start, end;
# Line 134  void replace_selection (GtkTextBuffer *B Line 177  void replace_selection (GtkTextBuffer *B
177    
178  /* Replaces the indicated text with new text; reinitializes start and end to  /* Replaces the indicated text with new text; reinitializes start and end to
179    point to beginning and end of inserted text*/    point to beginning and end of inserted text*/
   
180  void replace_text (GtkTextBuffer *Buffer, GtkTextIter *start, GtkTextIter *end, const gchar *text)  void replace_text (GtkTextBuffer *Buffer, GtkTextIter *start, GtkTextIter *end, const gchar *text)
181  {  {
182    GtkTextMark *mark;    GtkTextMark *mark;

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26