From 8ef698c535a133a6ba07a14d45b56abc691fd6b4 Mon Sep 17 00:00:00 2001 From: yggverse Date: Wed, 31 Jul 2024 23:16:10 +0300 Subject: [PATCH] add word wrap support for listing --- src/Abstract/Model/Gtk/Pango/Markup.php | 10 +++++++--- src/Model/Gtk/Pango/Markup/Gemtext.php | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Abstract/Model/Gtk/Pango/Markup.php b/src/Abstract/Model/Gtk/Pango/Markup.php index 0780515e..8c7a0665 100644 --- a/src/Abstract/Model/Gtk/Pango/Markup.php +++ b/src/Abstract/Model/Gtk/Pango/Markup.php @@ -82,8 +82,11 @@ class Markup implements \Yggverse\Yoda\Interface\Model\Gtk\Pango\Markup { return sprintf( '* %s', // @TODO - htmlspecialchars( - $value + self::_wrap( + htmlspecialchars( + $value + ), + $width ) ); } @@ -105,7 +108,7 @@ class Markup implements \Yggverse\Yoda\Interface\Model\Gtk\Pango\Markup int $width = self::WRAP_WIDTH ): string { - return self::_wrap( // @TODO slow + return self::_wrap( htmlspecialchars( $value ), @@ -138,6 +141,7 @@ class Markup implements \Yggverse\Yoda\Interface\Model\Gtk\Pango\Markup throw new Exception; } + // @TODO optimization wanted, wordwrap / set_line_wrap not solution protected static function _wrap( string $string, int $width, diff --git a/src/Model/Gtk/Pango/Markup/Gemtext.php b/src/Model/Gtk/Pango/Markup/Gemtext.php index 9ed45df6..a3611c6b 100644 --- a/src/Model/Gtk/Pango/Markup/Gemtext.php +++ b/src/Model/Gtk/Pango/Markup/Gemtext.php @@ -138,7 +138,8 @@ class Gemtext extends \Yggverse\Yoda\Abstract\Model\Gtk\Pango\Markup else { $line[] = self::list( - $entity->getItem() + $entity->getItem(), + $width ); }