problem extracting data from GtkSourceView using Gtkd

Mike Wey mike-wey at example.com
Tue Jan 15 22:33:33 UTC 2019


On 14-01-2019 23:52, Chris Bare wrote:
> I would have posted this in the Gtkd forum, but it has been down for a 
> while.
> 
> I'm porting a GTK2/C program to Gtkd. I'm trying to read the data from a 
> GtkSourceView, but when I try to get the bounds, it's always zero.
> 
> Here's the c version that works:
>      GtkSourceBuffer *bf;
>      GtkTextIter start, end;
>      int len;
> 
>      bf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (w.mainTxt));
>      gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER(bf), &start, &end);
>      data = gtk_text_buffer_get_text (GTK_TEXT_BUFFER(bf), &start, &end, 
> FALSE);
> 
> Here's what I tried in D:
>      SourceBuffer bf;
>      auto start = new TextIter();
>      auto end = new TextIter();
> 
>      bf = this.mainTxt.getBuffer ();
>      bf.getBounds (start, end);
>      string str = bf.getText (start, end, false);
> 
> getBounds is defined as: getBounds(out TextIter start, out TextIter end)
> 
> Is there something I'm doing wrong?
> Any suggestions on what else to try?

Your code looks correct, and when copying it into the GtkD sourceview 
demo str does indeed hold the text displayed in the GtkSourceview.

Do you have a more complete example we could look at?

-- 
Mike Wey


More information about the Digitalmars-d-learn mailing list