bonjour à tou[te]s
désolé pour mon anglais
j’écris grâce à https://www.reverso.net/traduction-texte
apply_tag disturbed by accents
example :
using Gtk;
/*
valac --pkg gtk4 --pkg gtksourceview-5 g.vala && ./g
apply_tag sur GtkSource.Buffer questions si accents ( ou autres )
*/
int main(string[] argv) {
Gtk.Application app=new Gtk.Application(null,GLib.ApplicationFlags.HANDLES_OPEN);
app.activate.connect(() => {
Gtk.ApplicationWindow window=new Gtk.ApplicationWindow(app);
window.set_default_size(640,320);
GtkSource.View src=new GtkSource.View();
Gtk.TextTagTable tag=new Gtk.TextTagTable();
Gtk.TextTag tagl=new Gtk.TextTag("link");
tagl.set_property("underline",Pango.Underline.SINGLE);
tagl.foreground="#F6624A";
tag.add(tagl);
GtkSource.Buffer buf=new GtkSource.Buffer(tag);
buf.text= "\n aa https://www.aa"+
"\n bb http://www.bb"+
"\n éé https://www.cc"+
"\n dd https://www.dd"+
"\n ee http://www.ee";
src.set_buffer(buf);
window.set_child(src);
window.present();
Gtk.TextIter deb,fin;
int ts,te;
buf.get_start_iter(out deb);
buf.get_end_iter(out fin);
MatchInfo trv;
try { Regex url=new Regex("https?://[a-zA-Z0-9=?./-]+");
if ( url.match(buf.get_text(deb,fin,false),0,out trv) ) {
do { trv.fetch_pos(0,out ts,out te);
Gtk.TextIter start;
buf.get_iter_at_offset(out start,ts);
Gtk.TextIter end;
buf.get_iter_at_offset(out end,te);
print(buf.get_text(deb,fin,false).substring(ts,te-ts)+"\n");
buf.apply_tag(tagl,start,end);
} while ( trv.next() );
}
} catch ( Error e ) {
}
});
return app.run(argv);
}
it sounds but, after the accents, the 'link" mark is offset from the number of accented characters
I make a mistake where?
thank you in advance
oubli : linux manjaro, gtk 4, gtksource 5