Re: GtkTextView: Applying tags at the cursor

2006-10-25 Thread Samuel Lidén Borell
I've already solved this, but thanks for your reply.

Madhusudan E wrote:
 Hi, 
 You can use GtkTextTag.
 Tags should be in the GtkTextTagTable for a given GtkTextBuffer before using
 them with that buffer. 
 gtk_text_buffer_create_tag() is the best way to create tags. See gtk-demo
 for numerous examples. 

 Hope this helps.

 Rgds,
 Madhusudan E
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


GtkTextView: Applying tags at the cursor

2006-10-24 Thread Samuel Lidén Borell
Hi,

I'm working on a web site creation software that uses Gtk, Glade and
Python for the UI. I'm using the GtkTextView widget to let the user edit
text with basic formatting but I have a question:

How do I apply a tag at the cursor so that inserted text gets it's
formatting? Right now I surround the cursor with two zero-width spaces
(an invisible Unicode character) and then I apply the tag to the spaces.
This gives new text the right formatting, but it's an ugly solution that
has some bugs...

Kind regards,
Samuel Liden Borell
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GtkTextView: Applying tags at the cursor

2006-10-24 Thread Lance Dillon
- Original Message 
From: Samuel Lidén Borell [EMAIL PROTECTED]
To: gtk-app-devel-list@gnome.org
Sent: Tuesday, October 24, 2006 1:49:54 PM
Subject: GtkTextView: Applying tags at the cursor

Hi,

I'm working on a web site creation software that uses Gtk, Glade and
Python for the UI. I'm using the GtkTextView widget to let the user edit
text with basic formatting but I have a question:

How do I apply a tag at the cursor so that inserted text gets it's
formatting? Right now I surround the cursor with two zero-width spaces
(an invisible Unicode character) and then I apply the tag to the spaces.
This gives new text the right formatting, but it's an ugly solution that
has some bugs...

-
I'm not sure there you can just add a tag at the current cursor position.  I'm 
creating the GTK2 bindings for the language Pike, and in my tests I created an 
array of tags that I need to apply at a certain position, then I added the text 
for that position, then applied that tags for that text range.  Something like 
this:

void insert_text(char *text) {
  GtkTextIter *start,*end,*iter;
  GtkTextMark *mark;

  mark=gtk_text_buffer_get_insert(GTK_TEXT_BUFFER(buffer));
  gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(buffer),start,mark);
  *start=*iter;
  gtk_text_buffer_insert(GTK_TEXT_BUFFER(buffer),text,-1);
  mark=gtk_text_buffer_get_insert(GTK_TEXT_BUFFER(buffer));
  gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(buffer),end,mark);
  /* foreach tag */
gtk_text_buffer_apply_tag(GTK_TEXT_BUFFER(buffer),tag,start,end);
  /* end */
}

I fudged on the foreach array iteration.  I have it simpler in pike, but 
basically the same thing.






___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list