|
|
@ -82,24 +82,33 @@ class Markup implements \Yggverse\Yoda\Interface\Model\Gtk\Pango\Markup |
|
|
|
): string |
|
|
|
): string |
|
|
|
{ |
|
|
|
{ |
|
|
|
return sprintf( |
|
|
|
return sprintf( |
|
|
|
'* %s', // @TODO |
|
|
|
'<span>%s</span>', // @TODO |
|
|
|
self::_wrap( |
|
|
|
self::_wrap( |
|
|
|
htmlspecialchars( |
|
|
|
htmlspecialchars( |
|
|
|
$value |
|
|
|
sprintf( |
|
|
|
|
|
|
|
'* %s', |
|
|
|
|
|
|
|
$value |
|
|
|
|
|
|
|
) |
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
self::TAG_LIST, |
|
|
|
$width |
|
|
|
$width |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static function quote( |
|
|
|
public static function quote( |
|
|
|
string $value |
|
|
|
string $value, |
|
|
|
|
|
|
|
int $width = self::WRAP_WIDTH |
|
|
|
): string |
|
|
|
): string |
|
|
|
{ |
|
|
|
{ |
|
|
|
return sprintf( |
|
|
|
return sprintf( |
|
|
|
'<i>%s</i>', |
|
|
|
'<i>%s</i>', |
|
|
|
htmlspecialchars( |
|
|
|
self::_wrap( |
|
|
|
$value |
|
|
|
htmlspecialchars( |
|
|
|
|
|
|
|
$value |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
self::TAG_QUOTE, |
|
|
|
|
|
|
|
$width |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
@ -113,6 +122,7 @@ class Markup implements \Yggverse\Yoda\Interface\Model\Gtk\Pango\Markup |
|
|
|
htmlspecialchars( |
|
|
|
htmlspecialchars( |
|
|
|
$value |
|
|
|
$value |
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
self::TAG_TEXT, |
|
|
|
$width |
|
|
|
$width |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
@ -131,8 +141,12 @@ class Markup implements \Yggverse\Yoda\Interface\Model\Gtk\Pango\Markup |
|
|
|
bool $close |
|
|
|
bool $close |
|
|
|
): string |
|
|
|
): string |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (in_array($const, [self::TAG_CODE])) |
|
|
|
if (in_array($const, [ |
|
|
|
{ |
|
|
|
self::TAG_CODE, |
|
|
|
|
|
|
|
self::TAG_LIST, |
|
|
|
|
|
|
|
self::TAG_QUOTE, |
|
|
|
|
|
|
|
self::TAG_TEXT |
|
|
|
|
|
|
|
])) { |
|
|
|
return sprintf( |
|
|
|
return sprintf( |
|
|
|
$close ? '</%s>' : '<%s>', |
|
|
|
$close ? '</%s>' : '<%s>', |
|
|
|
$const |
|
|
|
$const |
|
|
@ -145,6 +159,7 @@ class Markup implements \Yggverse\Yoda\Interface\Model\Gtk\Pango\Markup |
|
|
|
// @TODO optimization wanted, wordwrap / set_line_wrap not solution |
|
|
|
// @TODO optimization wanted, wordwrap / set_line_wrap not solution |
|
|
|
protected static function _wrap( |
|
|
|
protected static function _wrap( |
|
|
|
string $string, |
|
|
|
string $string, |
|
|
|
|
|
|
|
string $tag, |
|
|
|
int $width, |
|
|
|
int $width, |
|
|
|
string $break = PHP_EOL, |
|
|
|
string $break = PHP_EOL, |
|
|
|
int $line = 1, |
|
|
|
int $line = 1, |
|
|
@ -163,9 +178,21 @@ class Markup implements \Yggverse\Yoda\Interface\Model\Gtk\Pango\Markup |
|
|
|
if (isset($words[$line])) |
|
|
|
if (isset($words[$line])) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$label->set_markup( |
|
|
|
$label->set_markup( |
|
|
|
implode( |
|
|
|
sprintf( |
|
|
|
' ' , $words[$line] |
|
|
|
'%s%s%s', |
|
|
|
) . ' ' . $word |
|
|
|
self::tag( |
|
|
|
|
|
|
|
$tag, |
|
|
|
|
|
|
|
false |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
implode( |
|
|
|
|
|
|
|
' ' , $words[$line] |
|
|
|
|
|
|
|
) . ' ' . $word, |
|
|
|
|
|
|
|
self::tag( |
|
|
|
|
|
|
|
$tag, |
|
|
|
|
|
|
|
true |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if ($label->get_layout()->get_pixel_size()['width'] > $width) |
|
|
|
if ($label->get_layout()->get_pixel_size()['width'] > $width) |
|
|
|