Data-IconText

 view release on metacpan or  search on metacpan

lib/Data/IconText.pm  view on Meta::CPAN

# Copyright (c) 2025 Philipp Schafft

# licensed under Artistic License 2.0 (see LICENSE file)

# ABSTRACT: Work with icon text

package Data::IconText;

use v5.20;
use strict;
use warnings;

use Carp;
use Scalar::Util qw(looks_like_number weaken);
use Data::Identifier v0.12;

use constant {
    WK_UNICODE_CP               => Data::Identifier->new(uuid => '5f167223-cc9c-4b2f-9928-9fe1b253b560')->register, # unicode-code-point
    WK_ASCII_CP                 => Data::Identifier->new(uuid => 'f4b073ff-0b53-4034-b4e4-4affe5caf72c')->register, # ascii-code-point
    WK_FREEDESKTOP_ICON_NAME    => Data::Identifier->new(uuid => '560906df-ebd1-41f6-b510-038b30522051')->register, # freedesktop-icon-name
};

use overload '""' => sub {$_[0]->as_string};

our $VERSION = v0.05;

my %_types = (
    db          => 'Data::TagDB',
    extractor   => 'Data::URIID',
    fii         => 'File::Information',
    store       => 'File::FStore',
);

my %_for_version = (
    v0.01 => {
        default_unicode => 0x2370, # U+2370 APL FUNCTIONAL SYMBOL QUAD QUESTION
        media_type => {
            text  => 0x270D,
            audio => 0x266B,
            video => 0x2707,
            image => 0x1F5BB,
        },
        media_subtype => {
            'application/pdf'                           => 0x1F5BA,
            'application/vnd.oasis.opendocument.text'   => 0x1F5CE,
        },
        special => {
            directory           => 0x1F5C0,
            parent_directory    => 0x2B11,
            regular             => 0x2299,
            regular_not_in_pool => 0x2298,
        },
        identifier => {},
    },
    v0.02 => {
        parent => v0.01,
        identifier => {
            '8be115d2-dc2f-4a98-91e1-a6e3075cbc31' => { # uuid
                '3c2c155f-a4a0-49f3-bdaf-7f61d25c6b8c' => 0x1F30D,  # sid:60    Earth
                '7b177183-083c-4387-abd3-8793eb647373' => 0x21E5,   #           write-mode@none
                '4dc9fd07-7ef3-4215-8874-31d78ed55c22' => 0x21A3,   #           write-mode@append only
                '3877b2ef-6c77-423f-b15f-76508fbd48ed' => 0x21A6,   #           write-mode@random access
                'bccdaf71-0c82-422e-af44-bb8396bf90ed' => 0x1F331,  # sid:92    plant
                '0a24c834-90bd-4abd-ad97-4bd3ca7e784a' => 0x1F332,  #           conifer
                '85061c8c-be7a-4171-a008-f2035a4b8b61' => 0x1F333,  #           broadleaf
                'eba923c3-a425-425d-80ab-0064258d108a' => 0x1F334,  #           palm
                '571fe2aa-95f6-4b16-a8d2-1ff4f78bdad1' => 0x1F981,  # sid:82    lion
                '3694d8ca-c969-5705-beca-01f17b1487e8' => 0x2642,   #           gender@male
                'ae1072ef-0865-5104-b257-0d45441fa5e5' => 0x2642,   #           sex@male
                'd642eff3-bee6-5d09-aea9-7c47b181dd83' => 0x2642,   # sid:75    gender-or-sex@male
                '25dfeb8e-ef9a-52a1-b5f1-073387734988' => 0x2640,   #           gender@female
                '3c4b6cdf-f5a8-50d6-8a3a-b0c0975f7e69' => 0x2640,   #           sex@female
                'db9b0db1-a451-59e8-aa3b-9994e683ded3' => 0x2640,   # sid:76    gender-or-sex@female
                '310f2b49-73a8-5f27-aeaf-5f34bc8e583f' => 0x26A5,   #           gender@herm
                '036c0fe8-5189-5134-99ec-0b1b05c7bbf4' => 0x26A5,   #           sex@herm
            },
        },
    },
    v0.03 => {
        parent => v0.02,
        identifier => {
            '560906df-ebd1-41f6-b510-038b30522051' => { # freedesktop-icon-name
                # 'address-book-new'                          => 0x0,
                # 'application-exit'                          => 0x0,
                # 'appointment-new'                           => 0x0,
                # 'call-start'                                => 0x0,
                # 'call-stop'                                 => 0x0,
                # 'contact-new'                               => 0x0,
                # 'document-new'                              => 0x0,
                # 'document-open'                             => 0x0,
                # 'document-open-recent'                      => 0x0,
                # 'document-page-setup'                       => 0x0,
                # 'document-print'                            => 0x0,
                # 'document-print-preview'                    => 0x0,
                # 'document-properties'                       => 0x0,
                # 'document-revert'                           => 0x0,
                # 'document-save'                             => 0x0,
                # 'document-save-as'                          => 0x0,
                # 'document-send'                             => 0x0,
                # 'edit-clear'                                => 0x0,
                # 'edit-copy'                                 => 0x0,
                # 'edit-cut'                                  => 0x0,
                # 'edit-delete'                               => 0x0,
                # 'edit-find'                                 => 0x0,
                # 'edit-find-replace'                         => 0x0,
                # 'edit-paste'                                => 0x0,
                # 'edit-redo'                                 => 0x0,
                # 'edit-select-all'                           => 0x0,
                'edit-undo'                                 => 0x238C,
                # 'folder-new'                                => 0x0,
                # 'format-indent-less'                        => 0x0,
                # 'format-indent-more'                        => 0x0,
                # 'format-justify-center'                     => 0x0,
                # 'format-justify-fill'                       => 0x0,
                # 'format-justify-left'                       => 0x0,
                # 'format-justify-right'                      => 0x0,
                # 'format-text-direction-ltr'                 => 0x0,
                # 'format-text-direction-rtl'                 => 0x0,
                # 'format-text-bold'                          => 0x0,
                # 'format-text-italic'                        => 0x0,
                # 'format-text-underline'                     => 0x0,
                # 'format-text-strikethrough'                 => 0x0,
                # 'go-bottom'                                 => 0x0,
                # 'go-down'                                   => 0x0,
                # 'go-first'                                  => 0x0,
                # 'go-home'                                   => 0x0,
                # 'go-jump'                                   => 0x0,
                # 'go-last'                                   => 0x0,
                # 'go-next'                                   => 0x0,
                # 'go-previous'                               => 0x0,
                'go-top'                                    => 0x1F51D,
                # 'go-up'                                     => 0x0,
                # 'help-about'                                => 0x0,
                # 'help-contents'                             => 0x0,
                # 'help-faq'                                  => 0x0,
                # 'insert-image'                              => 0x0,
                # 'insert-link'                               => 0x0,
                # 'insert-object'                             => 0x0,
                # 'insert-text'                               => 0x0,
                # 'list-add'                                  => 0x0,
                # 'list-remove'                               => 0x0,
                # 'mail-forward'                              => 0x0,
                # 'mail-mark-important'                       => 0x0,
                # 'mail-mark-junk'                            => 0x0,
                # 'mail-mark-notjunk'                         => 0x0,
                # 'mail-mark-read'                            => 0x0,
                # 'mail-mark-unread'                          => 0x0,
                # 'mail-message-new'                          => 0x0,
                # 'mail-reply-all'                            => 0x0,
                # 'mail-reply-sender'                         => 0x0,
                'mail-send'                                 => 0x1F4E9,
                # 'mail-send-receive'                         => 0x0,
                'media-eject'                               => 0x23CF,
                'media-playback-pause'                      => 0x23F8,
                'media-playback-start'                      => 0x23F5,
                'media-playback-stop'                       => 0x23F9,
                'media-record'                              => 0x23FA,
                'media-seek-backward'                       => 0x23EA,
                'media-seek-forward'                        => 0x23E9,
                'media-skip-backward'                       => 0x23EE,
                'media-skip-forward'                        => 0x23ED,
                # 'object-flip-horizontal'                    => 0x0,
                # 'object-flip-vertical'                      => 0x0,
                # 'object-rotate-left'                        => 0x0,
                # 'object-rotate-right'                       => 0x0,
                'process-stop'                              => 0x1F5D9,
                # 'system-lock-screen'                        => 0x0,
                # 'system-log-out'                            => 0x0,
                # 'system-run'                                => 0x0,
                # 'system-search'                             => 0x0,
                # 'system-reboot'                             => 0x0,
                # 'system-shutdown'                           => 0x0,
                # 'tools-check-spelling'                      => 0x0,
                # 'view-fullscreen'                           => 0x0,
                'view-refresh'                              => 0x1F5D8,
                # 'view-restore'                              => 0x0,
                # 'view-sort-ascending'                       => 0x0,
                # 'view-sort-descending'                      => 0x0,
                'window-close'                              => 0x1F5D9,
                # 'window-new'                                => 0x0,
                # 'zoom-fit-best'                             => 0x0,
                # 'zoom-in'                                   => 0x0,
                # 'zoom-original'                             => 0x0,
                # 'zoom-out'                                  => 0x0,
                # 'process-working'                           => 0x0,
                'accessories-calculator'                    => 0x1F5A9,
                # 'accessories-character-map'                 => 0x0,
                # 'accessories-dictionary'                    => 0x0,
                # 'accessories-screenshot-tool'               => 0x0,
                # 'accessories-text-editor'                   => 0x0,
                # 'help-browser'                              => 0x0,
                'multimedia-volume-control'                 => 0x1F39B,
                # 'preferences-desktop-accessibility'         => 0x0,
                # 'preferences-desktop-font'                  => 0x0,
                # 'preferences-desktop-keyboard'              => 0x0,
                # 'preferences-desktop-locale'                => 0x0,
                # 'preferences-desktop-multimedia'            => 0x0,
                # 'preferences-desktop-screensaver'           => 0x0,
                # 'preferences-desktop-theme'                 => 0x0,
                # 'preferences-desktop-wallpaper'             => 0x0,
                # 'system-file-manager'                       => 0x0,
                # 'system-software-install'                   => 0x0,
                # 'system-software-update'                    => 0x0,
                # 'utilities-system-monitor'                  => 0x0,
                # 'utilities-terminal'                        => 0x0,
                # 'applications-accessories'                  => 0x0,
                # 'applications-development'                  => 0x0,
                # 'applications-engineering'                  => 0x0,
                # 'applications-games'                        => 0x0,
                # 'applications-graphics'                     => 0x0,
                # 'applications-internet'                     => 0x0,
                # 'applications-multimedia'                   => 0x0,
                # 'applications-office'                       => 0x0,
                # 'applications-other'                        => 0x0,
                # 'applications-science'                      => 0x0,
                # 'applications-system'                       => 0x0,
                # 'applications-utilities'                    => 0x0,
                # 'preferences-desktop'                       => 0x0,
                # 'preferences-desktop-peripherals'           => 0x0,
                # 'preferences-desktop-personal'              => 0x0,
                # 'preferences-other'                         => 0x0,
                # 'preferences-system'                        => 0x0,
                # 'preferences-system-network'                => 0x0,
                # 'system-help'                               => 0x0,
                # 'audio-card'                                => 0x0,
                'audio-input-microphone'                    => 0x1F399,
                # 'battery'                                   => 0x0,
                'camera-photo'                              => 0x1F4F7,
                'camera-video'                              => 0x1F4F9,
                # 'camera-web'                                => 0x0,
                # 'computer'                                  => 0x0,
                # 'drive-harddisk'                            => 0x0,
                # 'drive-optical'                             => 0x0,
                # 'drive-removable-media'                     => 0x0,
                # 'input-gaming'                              => 0x0,
                'input-keyboard'                            => 0x2328,
                'input-mouse'                               => 0x1F5B1,
                # 'input-tablet'                              => 0x0,
                # 'media-flash'                               => 0x0,
                'media-floppy'                              => 0x1F4BE,
                'media-optical'                             => 0x1F4BF,
                'media-tape'                                => 0x1F5AD,
                'modem'                                     => 0xF580,
                # 'multimedia-player'                         => 0x0,
                # 'network-wired'                             => 0x0,
                # 'network-wireless'                          => 0x0,
                # 'pda'                                       => 0x0,
                'phone'                                     => 0x1F4DE,
                'printer'                                   => 0x1F5A8,
                # 'scanner'                                   => 0x0,
                # 'video-display'                             => 0x0,
                # 'emblem-default'                            => 0x0,
                # 'emblem-documents'                          => 0x0,
                # 'emblem-downloads'                          => 0x0,
                # 'emblem-favorite'                           => 0x0,
                # 'emblem-important'                          => 0x0,
                # 'emblem-mail'                               => 0x0,
                # 'emblem-photos'                             => 0x0,
                # 'emblem-readonly'                           => 0x0,
                # 'emblem-shared'                             => 0x0,
                # 'emblem-symbolic-link'                      => 0x0,
                # 'emblem-synchronized'                       => 0x0,
                # 'emblem-system'                             => 0x0,
                # 'emblem-unreadable'                         => 0x0,
                # 'face-angel'                                => 0x0,
                # 'face-angry'                                => 0x0,
                # 'face-cool'                                 => 0x0,
                # 'face-crying'                               => 0x0,
                # 'face-devilish'                             => 0x0,
                # 'face-embarrassed'                          => 0x0,
                # 'face-kiss'                                 => 0x0,
                # 'face-laugh'                                => 0x0,
                # 'face-monkey'                               => 0x0,
                # 'face-plain'                                => 0x0,
                # 'face-raspberry'                            => 0x0,
                # 'face-sad'                                  => 0x0,
                # 'face-sick'                                 => 0x0,
                # 'face-smile'                                => 0x0,
                # 'face-smile-big'                            => 0x0,
                # 'face-smirk'                                => 0x0,
                # 'face-surprise'                             => 0x0,
                # 'face-tired'                                => 0x0,
                # 'face-uncertain'                            => 0x0,
                # 'face-wink'                                 => 0x0,
                # 'face-worried'                              => 0x0,
                # 'flag-aa'                                   => 0x0,
                # 'application-x-executable'                  => 0x0,
                # 'audio-x-generic'                           => 0x0,
                # 'font-x-generic'                            => 0x0,
                # 'image-x-generic'                           => 0x0,
                # 'package-x-generic'                         => 0x0,
                # 'text-html'                                 => 0x0,
                # 'text-x-generic'                            => 0x0,
                # 'text-x-generic-template'                   => 0x0,
                # 'text-x-script'                             => 0x0,
                # 'video-x-generic'                           => 0x0,
                # 'x-office-address-book'                     => 0x0,
                # 'x-office-calendar'                         => 0x0,
                # 'x-office-document'                         => 0x0,
                # 'x-office-presentation'                     => 0x0,
                # 'x-office-spreadsheet'                      => 0x0,
                'folder'                                    => 0x1F4C1,
                # 'folder-remote'                             => 0x0,
                # 'network-server'                            => 0x0,
                # 'network-workgroup'                         => 0x0,
                # 'start-here'                                => 0x0,
                # 'user-bookmarks'                            => 0x0,
                # 'user-desktop'                              => 0x0,
                # 'user-home'                                 => 0x0,
                'user-trash'                                => 0x1F5D1,
                # 'appointment-missed'                        => 0x0,
                # 'appointment-soon'                          => 0x0,
                'audio-volume-high'                         => 0x1F50A,
                'audio-volume-low'                          => 0x1F508,
                'audio-volume-medium'                       => 0x1F509,
                'audio-volume-muted'                        => 0x1F507,
                # 'battery-caution'                           => 0x0,
                'battery-low'                               => 0x1FAAB,
                'dialog-error'                              => 0x1F6D1,
                'dialog-information'                        => 0x1F6C8,
                # 'dialog-password'                           => 0x0,
                'dialog-question'                           => 0x2BD1,
                'dialog-warning'                            => 0x26A0,
                # 'folder-drag-accept'                        => 0x0,
                # 'folder-open'                               => 0x0,
                # 'folder-visiting'                           => 0x0,
                # 'image-loading'                             => 0x0,
                # 'image-missing'                             => 0x0,
                # 'mail-attachment'                           => 0x0,
                # 'mail-unread'                               => 0x0,
                # 'mail-read'                                 => 0x0,
                # 'mail-replied'                              => 0x0,
                # 'mail-signed'                               => 0x0,
                # 'mail-signed-verified'                      => 0x0,
                'media-playlist-repeat'                     => 0x1F501,
                'media-playlist-shuffle'                    => 0x1F500,
                # 'network-error'                             => 0x0,
                # 'network-idle'                              => 0x0,
                # 'network-offline'                           => 0x0,
                # 'network-receive'                           => 0x0,
                # 'network-transmit'                          => 0x0,
                # 'network-transmit-receive'                  => 0x0,
                # 'printer-error'                             => 0x0,
                # 'printer-printing'                          => 0x0,
                # 'security-high'                             => 0x0,
                # 'security-medium'                           => 0x0,
                # 'security-low'                              => 0x0,
                # 'software-update-available'                 => 0x0,
                # 'software-update-urgent'                    => 0x0,
                # 'sync-error'                                => 0x0,
                # 'sync-synchronizing'                        => 0x0,
                # 'task-due'                                  => 0x0,
                # 'task-past-due'                             => 0x0,
                # 'user-available'                            => 0x0,
                # 'user-away'                                 => 0x0,
                # 'user-idle'                                 => 0x0,
                # 'user-offline'                              => 0x0,
                # 'user-trash-full'                           => 0x0,
                'weather-clear'                             => 0x1F323,
                # 'weather-clear-night'                       => 0x0,
                'weather-few-clouds'                        => 0x1F324,
                # 'weather-few-clouds-night'                  => 0x0,
                'weather-fog'                               => 0x1F32B,
                # 'weather-overcast'                          => 0x0,
                # 'weather-severe-alert'                      => 0x0,
                'weather-showers'                           => 0x1F327,
                'weather-showers-scattered'                 => 0x01F326,
                'weather-snow'                              => 0x1F328,



( run in 2.260 seconds using v1.01-cache-2.11-cpan-13bb782fe5a )