scorninpc / php-gtk3

GTK3 extension for PHP
https://andor.com.br/
GNU Lesser General Public License v3.0
118 stars 13 forks source link

implement Glib::markup_escape_text #130 #135

Closed d47081 closed 4 months ago

d47081 commented 4 months ago

Not sure where to place it, so created separated namespace and implemented as the static method.

<?php 

var_dump(
    Glib::markup_escape_text('test <escape>', -1) // string(19) "test &lt;escape&gt;"
);

https://docs.gtk.org/glib/func.markup_escape_text.html

130

scorninpc commented 4 months ago

you're taking a dark turn

this escape is the same as PHP escape. are you sure?

d47081 commented 4 months ago

I don't know maybe both methods return same result by ISO, just implemented Glib API because not always PHP functions could be useful for GTK operations

d47081 commented 4 months ago

Where is dark turn? I'm just following API documentation, but not sure about Glib namespace, because maybe it's better

scorninpc commented 4 months ago

dark because you are binding all primitives methods, and now the root primitive (glib). If you still in this way, you will need implement atoms and anothers things at some point, that not coded to be binded

Ok, if you really want to escape with GLib, add g_markup_escape_text to Gtk

Gtk::markup_escape_text

d47081 commented 4 months ago

I'm usually create separated libraries for different subjects, because one time it grows to unmaintainable codebase.

as above - glib and pango, as understand they are not related with GTK 3

don't know, just reading documentation, that's at least another section on website https://docs.gtk.org/Pango

you're more experienced with GTK, so if you think that is wrong way, just close it. imho I've just opened this section https://docs.gtk.org/glib/index.html#functions and see lot of useful tools there, that because I have initiated new namespace for all of them, and this namespace is Glib

maybe once I'll want to use in PHP code, like markup_escape_text.

d47081 commented 4 months ago

p.s. about my issue #130, I have just tested this function and found it's really same as htmlspecialchars (still lazy to compare ISO compatibility as GTK docs about nothing).

my issue happened because I forgot to escape one line by htmlspecialchars, lol)

so I don't want this feature for right now, maybe will use htmlspecialchars until found some new method not available on PHP side, then re-write to Gtk namespace if you want.

scorninpc commented 4 months ago

I'm usually create separated libraries for different subjects, because one time it grows to unmaintainable codebase.

Yes, thats my main issue. I need only bind GTK

you're more experienced with GTK, so if you think that is wrong way, just close it.

Gtk 3 start change way to talk with GLib and Pango, and another libs, to try make a more consistant unique lib, so the ideia is to use only Gtk

But i really understand that sometimes make use of one these libs are much better (and fast), so you can implement inside Gtk. But, in this case, we have way to do with PHP

escapes is string parse, not a Gtk/Glib/Pango method, there is a ref to follow, so can be done with any languages. PHP has another escapes functions to test too =)

maybe one day we can make separeted php extensions that can talk one with other

d47081 commented 4 months ago

..and would be cool to see gtk4 progress because not sure it has a sense to spent a time for gtk3 as different implementations, cpp here and c there to merge

I'm also thinking about zephir-lang implementation but not sure that's possible. But you may take a look also https://zephir-lang.com

scorninpc commented 4 months ago

Gtk grow to a test of PHP-CPP, to make a GTK4 auto build

Write manualy all methods are bad way to do that, but i cannot find a nice Gtk4 definition

Anyway, i'm planning to make Gtk4 100% compatible with Gtk3, dont worry

d47081 commented 4 months ago

I still can't forget about this feature, and not very understand why did you added this one to the Gtk namespace: https://github.com/scorninpc/php-gtk3/issues/125#issuecomment-2241794404

Just won't use PHP htmlspecialchars because html is not pango markup, there is lot of another features..

Let's finally create Glib helpers collection in this lib?

d47081 commented 4 months ago

And about #125 it works, but sometimes I have alerts that ID not found, so would be good to implement resource existing helpers also, in same, Glib namespace (beside other features there).

We can make G namespace but not sure it's not taken and docs say that's Glib one.

d47081 commented 4 months ago

I'm ready to move Gtk::source_remove to Glib:source_remove as canonical or G::source_remove. Maybe it's better to place Glib folder in G one, not sure how is better.

To not change the API later, especially after new release.

I think developers will want some of those functions once, like me.

scorninpc commented 4 months ago

Sorry, but i think you dont get the main proposital of this project

I think you need to understand Gtk architecture before understand de main proposital of this project

https://en.wikipedia.org/wiki/GTK#/media/File:The_GTK_toolkit.png

This project are Gtk bind. Im not planning to bind all universe of glib. Only gtkmm has this bind fully

I cannot figure out all Gtk lib yet, think about all Gtk architecture

Thinking this, Gtk 4 removed alot layer with root libs, because end devs just not need to use that in must cases

I'm not planning bind Pango, Atk, Cairo, GLib, OpenGL, Wayland, X, GSK, ...... just GTK

I understand that GDK is alot helpfull on GTK3, so ok. I understand that you need Pango on GTK3, so ok

But this project will not cover all Gtk architecture, its impossible to do that hardcoded

d47081 commented 4 months ago

Yes, you are right, I'm beginner in GTK even 15 years of experience in dev

well, sorry for disturb, closing, maybe will do that in Gtk namespace when found an issue with htmlspecialchars.