From 189b293e70dfdd6f5cb78c1207d69c166f2c5785 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Wed, 28 Feb 2024 23:52:50 +0100 Subject: Add Nonicons font as a library and make the `nonicons` plugin use it (#253) --- manifest.json | 23 ++- plugins/font_nonicons.lua | 416 ++++++++++++++++++++++++++++++++++++++++++++++ plugins/nonicons.lua | 132 +++++++-------- 3 files changed, 502 insertions(+), 69 deletions(-) create mode 100644 plugins/font_nonicons.lua diff --git a/manifest.json b/manifest.json index f81f893..331abf4 100644 --- a/manifest.json +++ b/manifest.json @@ -431,6 +431,20 @@ "id": "findfileimproved", "dependencies": { "thread": { } } }, + { + "name": "Nonicons font", + "description": "[Nonicons](https://github.com/yamatsum/nonicons/) font with mapping", + "version": "20230530", + "type": "library", + "path": "plugins/font_nonicons.lua", + "id": "font_nonicons", + "files": [ + { + "url": "https://github.com/yamatsum/nonicons/raw/8454b3b6c3ceeee18b386b7882c5a071dcf0f3af/dist/nonicons.ttf", + "checksum": "da0a065856c44ea3fd3b9fba2fff5e25a32992dc3a3c5df6e9bfca2cd106a8cc" + } + ] + }, { "description": "Allows users to load fonts with [fontconfig](https://www.freedesktop.org/software/fontconfig/fontconfig-user.html).", "version": "0.1", @@ -1437,11 +1451,14 @@ "mod_version": "3" }, { - "description": "File icons set for TreeView. Download [font](https://github.com/yamatsum/nonicons/raw/6a2faf4fbdfbe353c5ae6a496740ac4bfb6d0e74/dist/nonicons.ttf) to your config/fonts folder", - "version": "0.2.1", + "description": "File icons set for TreeView. Uses the [Nonicons](https://github.com/yamatsum/nonicons/) font", + "version": "0.3", "path": "plugins/nonicons.lua", "id": "nonicons", - "mod_version": "3" + "mod_version": "3", + "dependencies": { + "font_nonicons": {} + } }, { "description": "Change the opaqueness/transparency of `lite-xl` using shift+mousewheel or a command.", diff --git a/plugins/font_nonicons.lua b/plugins/font_nonicons.lua new file mode 100644 index 0000000..3afc594 --- /dev/null +++ b/plugins/font_nonicons.lua @@ -0,0 +1,416 @@ +-- To obtain the mapping: +--[[ +wget -qO .fantasticonrc.js https://github.com/yamatsum/nonicons/raw/master/.fantasticonrc.js \ +&& node -e 'console.log(Object.entries(require("./.fantasticonrc.js").codepoints).reduce((acc,v) => acc+" [\"" + v[0] + "\"] = " + v[1] + ",\n", "{\n") + "}")' +--]] + +local codepoints = { + ["alert-16"] = 61697, + ["angular-16"] = 61698, + ["archive-16"] = 61699, + ["arrow-both-16"] = 61700, + ["arrow-down-16"] = 61701, + ["arrow-left-16"] = 61702, + ["arrow-right-16"] = 61703, + ["arrow-switch-16"] = 61704, + ["arrow-up-16"] = 61705, + ["backbone-16"] = 61706, + ["beaker-16"] = 61707, + ["bell-16"] = 61708, + ["bell-slash-16"] = 61709, + ["bold-16"] = 61710, + ["book-16"] = 61711, + ["bookmark-16"] = 61712, + ["bookmark-slash-16"] = 61713, + ["briefcase-16"] = 61714, + ["broadcast-16"] = 61715, + ["browser-16"] = 61716, + ["bug-16"] = 61717, + ["c-16"] = 61718, + ["c-plusplus-16"] = 61719, + ["c-sharp-16"] = 61720, + ["calendar-16"] = 61721, + ["check-16"] = 61722, + ["check-circle-16"] = 61723, + ["check-circle-fill-16"] = 61724, + ["checklist-16"] = 61725, + ["chevron-down-16"] = 61726, + ["chevron-left-16"] = 61727, + ["chevron-right-16"] = 61728, + ["chevron-up-16"] = 61729, + ["circle-16"] = 61730, + ["circle-slash-16"] = 61731, + ["clippy-16"] = 61732, + ["clock-16"] = 61733, + ["code-16"] = 61734, + ["code-review-16"] = 61735, + ["code-square-16"] = 61736, + ["comment-16"] = 61737, + ["comment-discussion-16"] = 61738, + ["container-16"] = 61739, + ["cpu-16"] = 61740, + ["credit-card-16"] = 61741, + ["cross-reference-16"] = 61742, + ["css-16"] = 61743, + ["dart-16"] = 61744, + ["dash-16"] = 61745, + ["database-16"] = 61746, + ["desktop-download-16"] = 61747, + ["device-camera-16"] = 61748, + ["device-camera-video-16"] = 61749, + ["device-desktop-16"] = 61750, + ["device-mobile-16"] = 61751, + ["diff-16"] = 61752, + ["diff-added-16"] = 61753, + ["diff-ignored-16"] = 61754, + ["diff-modified-16"] = 61755, + ["diff-removed-16"] = 61756, + ["diff-renamed-16"] = 61757, + ["docker-16"] = 61758, + ["dot-16"] = 61759, + ["dot-fill-16"] = 61760, + ["download-16"] = 61761, + ["ellipsis-16"] = 61762, + ["elm-16"] = 61763, + ["eye-16"] = 61764, + ["eye-closed-16"] = 61765, + ["file-16"] = 61766, + ["file-badge-16"] = 61767, + ["file-binary-16"] = 61768, + ["file-code-16"] = 61769, + ["file-diff-16"] = 61770, + ["file-directory-16"] = 61771, + ["file-directory-outline-16"] = 61772, + ["file-submodule-16"] = 61773, + ["file-symlink-file-16"] = 61774, + ["file-zip-16"] = 61775, + ["filter-16"] = 61776, + ["flame-16"] = 61777, + ["fold-16"] = 61778, + ["fold-down-16"] = 61779, + ["fold-up-16"] = 61780, + ["gear-16"] = 61781, + ["gift-16"] = 61782, + ["git-branch-16"] = 61783, + ["git-commit-16"] = 61784, + ["git-compare-16"] = 61785, + ["git-merge-16"] = 61786, + ["git-pull-request-16"] = 61787, + ["globe-16"] = 61788, + ["go-16"] = 61789, + ["grabber-16"] = 61790, + ["graph-16"] = 61791, + ["heading-16"] = 61792, + ["heart-16"] = 61793, + ["heart-fill-16"] = 61794, + ["history-16"] = 61795, + ["home-16"] = 61796, + ["horizontal-rule-16"] = 61797, + ["hourglass-16"] = 61798, + ["html-16"] = 61799, + ["hubot-16"] = 61800, + ["image-16"] = 61801, + ["inbox-16"] = 61802, + ["infinity-16"] = 61803, + ["info-16"] = 61804, + ["issue-closed-16"] = 61805, + ["issue-opened-16"] = 61806, + ["issue-reopened-16"] = 61807, + ["italic-16"] = 61808, + ["java-16"] = 61809, + ["javascript-16"] = 61810, + ["json-16"] = 61811, + ["kebab-horizontal-16"] = 61812, + ["key-16"] = 61813, + ["kotlin-16"] = 61814, + ["kubernetes-16"] = 61815, + ["law-16"] = 61816, + ["light-bulb-16"] = 61817, + ["link-16"] = 61818, + ["link-external-16"] = 61819, + ["list-ordered-16"] = 61820, + ["list-unordered-16"] = 61821, + ["location-16"] = 61822, + ["lock-16"] = 61823, + ["logo-gist-16"] = 61824, + ["logo-github-16"] = 61825, + ["lua-16"] = 61826, + ["mail-16"] = 61827, + ["mark-github-16"] = 61828, + ["markdown-16"] = 61829, + ["megaphone-16"] = 61830, + ["mention-16"] = 61831, + ["meter-16"] = 61832, + ["milestone-16"] = 61833, + ["mirror-16"] = 61834, + ["moon-16"] = 61835, + ["mortar-board-16"] = 61836, + ["mute-16"] = 61837, + ["nginx-16"] = 61838, + ["no-entry-16"] = 61839, + ["node-16"] = 61840, + ["north-star-16"] = 61841, + ["note-16"] = 61842, + ["npm-16"] = 61843, + ["octoface-16"] = 61844, + ["organization-16"] = 61845, + ["package-16"] = 61846, + ["package-dependencies-16"] = 61847, + ["package-dependents-16"] = 61848, + ["paintbrush-16"] = 61849, + ["paper-airplane-16"] = 61850, + ["pencil-16"] = 61851, + ["people-16"] = 61852, + ["perl-16"] = 61853, + ["person-16"] = 61854, + ["php-16"] = 61855, + ["pin-16"] = 61856, + ["play-16"] = 61857, + ["plug-16"] = 61858, + ["plus-16"] = 61859, + ["plus-circle-16"] = 61860, + ["project-16"] = 61861, + ["pulse-16"] = 61862, + ["python-16"] = 61863, + ["question-16"] = 61864, + ["quote-16"] = 61865, + ["r-16"] = 61866, + ["react-16"] = 61867, + ["rectangle-16"] = 61868, + ["reply-16"] = 61869, + ["repo-16"] = 61870, + ["repo-clone-16"] = 61871, + ["repo-forked-16"] = 61872, + ["repo-pull-16"] = 61873, + ["repo-push-16"] = 61874, + ["repo-template-16"] = 61875, + ["report-16"] = 61876, + ["require-16"] = 61877, + ["rocket-16"] = 61878, + ["rss-16"] = 61879, + ["ruby-16"] = 61880, + ["rust-16"] = 61881, + ["scala-16"] = 61882, + ["screen-full-16"] = 61883, + ["screen-normal-16"] = 61884, + ["search-16"] = 61885, + ["server-16"] = 61886, + ["share-16"] = 61887, + ["share-android-16"] = 61888, + ["shield-16"] = 61889, + ["shield-check-16"] = 61890, + ["shield-lock-16"] = 61891, + ["shield-x-16"] = 61892, + ["sign-in-16"] = 61893, + ["sign-out-16"] = 61894, + ["skip-16"] = 61895, + ["smiley-16"] = 61896, + ["square-16"] = 61897, + ["square-fill-16"] = 61898, + ["squirrel-16"] = 61899, + ["star-16"] = 61900, + ["star-fill-16"] = 61901, + ["stop-16"] = 61902, + ["stopwatch-16"] = 61903, + ["strikethrough-16"] = 61904, + ["sun-16"] = 61905, + ["swift-16"] = 61906, + ["sync-16"] = 61907, + ["tag-16"] = 61908, + ["tasklist-16"] = 61909, + ["telescope-16"] = 61910, + ["terminal-16"] = 61911, + ["three-bars-16"] = 61912, + ["thumbsdown-16"] = 61913, + ["thumbsup-16"] = 61914, + ["tmux-16"] = 61915, + ["toml-16"] = 61916, + ["tools-16"] = 61917, + ["trashcan-16"] = 61918, + ["triangle-down-16"] = 61919, + ["triangle-left-16"] = 61920, + ["triangle-right-16"] = 61921, + ["triangle-up-16"] = 61922, + ["typescript-16"] = 61923, + ["typography-16"] = 61924, + ["unfold-16"] = 61925, + ["unlock-16"] = 61926, + ["unmute-16"] = 61927, + ["unverified-16"] = 61928, + ["upload-16"] = 61929, + ["verified-16"] = 61930, + ["versions-16"] = 61931, + ["vim-16"] = 61932, + ["vim-command-mode-16"] = 61933, + ["vim-insert-mode-16"] = 61934, + ["vim-normal-mode-16"] = 61935, + ["vim-replace-mode-16"] = 61936, + ["vim-select-mode-16"] = 61937, + ["vim-terminal-mode-16"] = 61938, + ["vim-visual-mode-16"] = 61939, + ["vue-16"] = 61940, + ["workflow-16"] = 61941, + ["x-16"] = 61942, + ["x-circle-16"] = 61943, + ["x-circle-fill-16"] = 61944, + ["yaml-16"] = 61945, + ["yarn-16"] = 61946, + ["zap-16"] = 61947, + ["multi-select-16"] = 61948, + ["number-16"] = 61949, + ["trash-16"] = 61950, + ["video-16"] = 61951, + ["class-16"] = 61952, + ["constant-16"] = 61953, + ["field-16"] = 61954, + ["interface-16"] = 61955, + ["keyword-16"] = 61956, + ["snippet-16"] = 61957, + ["struct-16"] = 61958, + ["type-16"] = 61959, + ["variable-16"] = 61960, + ["blocked-16"] = 61961, + ["codescan-16"] = 61962, + ["codescan-checkmark-16"] = 61963, + ["codespaces-16"] = 61964, + ["dependabot-16"] = 61965, + ["duplicate-16"] = 61966, + ["person-add-16"] = 61967, + ["sidebar-collapse-16"] = 61968, + ["sidebar-expand-16"] = 61969, + ["table-16"] = 61970, + ["elixir-16"] = 61971, + ["terraform-16"] = 61972, + ["columns-16"] = 61973, + ["diamond-16"] = 61974, + ["git-pull-request-closed-16"] = 61975, + ["git-pull-request-draft-16"] = 61976, + ["hash-16"] = 61977, + ["issue-draft-16"] = 61978, + ["rows-16"] = 61979, + ["select-single-16"] = 61980, + ["eslint-16"] = 61981, + ["prettier-16"] = 61982, + ["vscode-16"] = 61983, + ["copy-16"] = 61984, + ["key-asterisk-16"] = 61985, + ["paste-16"] = 61986, + ["sort-asc-16"] = 61987, + ["sort-desc-16"] = 61988, + ["babel-16"] = 61989, + ["ionic-16"] = 61990, + ["next-16"] = 61991, + ["svelte-16"] = 61992, + ["capacitor-16"] = 61993, + ["graphql-16"] = 61994, + ["accessibility-16"] = 61995, + ["apps-16"] = 61996, + ["bell-fill-16"] = 61997, + ["cloud-16"] = 61998, + ["cloud-offline-16"] = 61999, + ["code-of-conduct-16"] = 62000, + ["feed-discussion-16"] = 62001, + ["feed-forked-16"] = 62002, + ["feed-heart-16"] = 62003, + ["feed-merged-16"] = 62004, + ["feed-person-16"] = 62005, + ["feed-repo-16"] = 62006, + ["feed-rocket-16"] = 62007, + ["feed-star-16"] = 62008, + ["feed-tag-16"] = 62009, + ["feed-trophy-16"] = 62010, + ["file-directory-fill-16"] = 62011, + ["file-directory-open-fill-16"] = 62012, + ["id-badge-16"] = 62013, + ["iterations-16"] = 62014, + ["log-16"] = 62015, + ["person-fill-16"] = 62016, + ["repo-deleted-16"] = 62017, + ["repo-locked-16"] = 62018, + ["single-select-16"] = 62019, + ["sliders-16"] = 62020, + ["stack-16"] = 62021, + ["tab-external-16"] = 62022, + ["telescope-fill-16"] = 62023, + ["trophy-16"] = 62024, + ["webhook-16"] = 62025, + ["accessibility-inset-16"] = 62026, + ["alert-fill-16"] = 62027, + ["arrow-down-left-16"] = 62028, + ["arrow-down-right-16"] = 62029, + ["arrow-up-left-16"] = 62030, + ["arrow-up-right-16"] = 62031, + ["cache-16"] = 62032, + ["checkbox-16"] = 62033, + ["clock-fill-16"] = 62034, + ["command-palette-16"] = 62035, + ["copilot-16"] = 62036, + ["copilot-error-16"] = 62037, + ["copilot-warning-16"] = 62038, + ["file-added-16"] = 62039, + ["file-moved-16"] = 62040, + ["file-removed-16"] = 62041, + ["git-merge-queue-16"] = 62042, + ["issue-tracked-by-16"] = 62043, + ["issue-tracked-in-16"] = 62044, + ["paperclip-16"] = 62045, + ["prisma-16"] = 62046, + ["project-roadmap-16"] = 62047, + ["project-symlink-16"] = 62048, + ["shield-slash-16"] = 62049, + ["skip-fill-16"] = 62050, + ["devices-16"] = 62051, + ["discussion-closed-16"] = 62052, + ["discussion-duplicate-16"] = 62053, + ["discussion-outdated-16"] = 62054, + ["error-16"] = 62055, + ["fiscal-host-16"] = 62056, + ["goal-16"] = 62057, + ["issue-tracks-16"] = 62058, + ["layout-16"] = 62059, + ["loading-16"] = 62060, + ["move-to-bottom-16"] = 62061, + ["move-to-end-16"] = 62062, + ["move-to-start-16"] = 62063, + ["move-to-top-16"] = 62064, + ["not-found-16"] = 62065, + ["passkey-fill-16"] = 62066, + ["pin-slash-16"] = 62067, + ["project-template-16"] = 62068, + ["read-16"] = 62069, + ["rel-file-path-16"] = 62070, + ["sparkle-fill-16"] = 62071, + ["sponsor-tiers-16"] = 62072, + ["template-16"] = 62073, + ["unlink-16"] = 62074, + ["unread-16"] = 62075, + ["zoom-in-16"] = 62076, + ["zoom-out-16"] = 62077, +} + +local utf8 = setmetatable({}, { + __index = function(t, k) + local cp = codepoints[k] + if not cp then return nil end + + local res + if cp < 0x0080 then + res = cp + elseif cp < 0x0800 then + res = string.char(0xC0 | (cp >> 6), 0x80 | (cp & 0x3F)) + elseif cp < 0x10000 then + res = string.char(0xE0 | (cp >> 12), 0x80 | ((cp >> 6) & 0x3F), 0x80 | (cp & 0x3F)) + else + res = string.char(0xF0 | (cp >> 18), 0x80 | ((cp >> 12) & 0x3F), 0x80 | ((cp >> 6) & 0x3F), 0x80 | (cp & 0x3F)) + end + + t[k] = res + return res + end +}) + +return { + codepoints = codepoints, + utf8 = utf8, + path = USERDIR .. PATHSEP .. "libraries" .. PATHSEP .. "font_nonicons" .. PATHSEP .. "nonicons.ttf" +} diff --git a/plugins/nonicons.lua b/plugins/nonicons.lua index 9865e40..9489531 100644 --- a/plugins/nonicons.lua +++ b/plugins/nonicons.lua @@ -2,13 +2,14 @@ -- Author: Jipok -- Doesn't work well with scaling mode == "ui" -local core = require "core" local common = require "core.common" local config = require "core.config" local style = require "core.style" local TreeView = require "plugins.treeview" local Node = require "core.node" +local nonicons = require "libraries.font_nonicons" + -- Config config.plugins.nonicons = common.merge({ use_default_dir_icons = false, @@ -49,75 +50,74 @@ config.plugins.nonicons = common.merge({ } }, config.plugins.nonicons) -local icon_font = renderer.font.load(USERDIR.."/fonts/nonicons.ttf", 15 * SCALE) -local chevron_width = icon_font:get_width("") +local icon_font = renderer.font.load(nonicons.path, 15 * SCALE) +local map = nonicons.utf8 +local chevron_width = icon_font:get_width(map["chevron-down-16"]) local previous_scale = SCALE local extension_icons = { - [".lua"] = { "#51a0cf", "" }, - [".md"] = { "#519aba", "" }, -- Markdown - [".cpp"] = { "#519aba", "" }, - [".c"] = { "#599eff", "" }, - [".h"] = { "#599eff", "" }, - [".py"] = { "#3572A5", "" }, -- Python - [".pyc"] = { "#519aba", "" }, [".pyd"] = { "#519aba", "" }, - [".php"] = { "#a074c4", "" }, - [".cs"] = { "#596706", "" }, -- C# - [".conf"] = { "#6d8086", "" }, [".cfg"] = { "#6d8086", "" }, - [".toml"] = { "#6d8086", "" }, - [".yaml"] = { "#6d8086", "" }, [".yml"] = { "#6d8086", "" }, - [".json"] = { "#854CC7", "" }, - [".css"] = { "#563d7c", "" }, - [".html"] = { "#e34c26", "" }, - [".js"] = { "#cbcb41", "" }, -- JavaScript - [".go"] = { "#519aba", "" }, - [".jpg"] = { "#a074c4", "" }, [".png"] = { "#a074c4", "" }, - [".sh"] = { "#4d5a5e", "" }, -- Shell - [".java"] = { "#cc3e44", "" }, - [".scala"] = { "#cc3e44", "" }, - [".kt"] = { "#F88A02", "" }, -- Kotlin - [".pl"] = { "#519aba", "" }, [".pm"] = { "#519aba", "" }, -- Perl - [".r"] = { "#358a5b", "" }, - [".rake"] = { "#701516", "" }, - [".rb"] = { "#701516", "" }, -- Ruby - [".rs"] = { "#dea584", "" }, -- Rust - [".rss"] = { "#cc3e44", "" }, - [".sql"] = { "#dad8d8", "" }, - [".swift"] = { "#e37933", "" }, - [".ts"] = { "#519aba", "" }, -- TypeScript - [".elm"] = { "#519aba", "" }, - [".diff"] = { "#41535b", "" }, - [".ex"] = { "#a074c4", "" }, [".exs"] = { "#a074c4", "" }, -- Elixir + [".lua"] = { "#51a0cf", "lua-16" }, + [".md"] = { "#519aba", "markdown-16" }, -- Markdown + [".cpp"] = { "#519aba", "c-plusplus-16" }, + [".c"] = { "#599eff", "c-16" }, + [".h"] = { "#599eff", "heading-16" }, + [".py"] = { "#3572A5", "python-16" }, -- Python + [".pyc"] = { "#519aba", "python-16" }, [".pyd"] = { "#519aba", "python-16" }, + [".php"] = { "#a074c4", "php-16" }, + [".cs"] = { "#596706", "c-sharp-16" }, -- C# + [".conf"] = { "#6d8086", "gear-16" }, [".cfg"] = { "#6d8086", "gear-16" }, + [".toml"] = { "#6d8086", "toml-16" }, + [".yaml"] = { "#6d8086", "yaml-16" }, [".yml"] = { "#6d8086", "yaml-16" }, + [".json"] = { "#854CC7", "json-16" }, + [".css"] = { "#563d7c", "css-16" }, + [".html"] = { "#e34c26", "html-16" }, + [".js"] = { "#cbcb41", "javascript-16" }, -- JavaScript + [".go"] = { "#519aba", "go-16" }, + [".jpg"] = { "#a074c4", "image-16" }, [".png"] = { "#a074c4", "image-16" }, + [".sh"] = { "#4d5a5e", "terminal-16" }, -- Shell + [".java"] = { "#cc3e44", "java-16" }, + [".scala"] = { "#cc3e44", "scala-16" }, + [".kt"] = { "#F88A02", "kotlin-16" }, -- Kotlin + [".pl"] = { "#519aba", "perl-16" }, [".pm"] = { "#519aba", "perl-16" }, -- Perl + [".r"] = { "#358a5b", "r-16" }, + [".rake"] = { "#701516", "ruby-16" }, + [".rb"] = { "#701516", "ruby-16" }, -- Ruby + [".rs"] = { "#dea584", "rust-16" }, -- Rust + [".rss"] = { "#cc3e44", "rss-16" }, + [".sql"] = { "#dad8d8", "database-16" }, + [".swift"] = { "#e37933", "swift-16" }, + [".ts"] = { "#519aba", "typescript-16" }, -- TypeScript + [".elm"] = { "#519aba", "elm-16" }, + [".diff"] = { "#41535b", "file-diff-16" }, + [".ex"] = { "#a074c4", "elixir-16" }, [".exs"] = { "#a074c4", "elixir-16" }, -- Elixir + [".vim"] = { "#8f00ff", "vim-16" }, -- Following without special icon: - [".awk"] = { "#4d5a5e", "" }, - [".nim"] = { "#F88A02", "" }, - [".zig"] = { "#cbcb41", "" }, - -- START: Adding per https://github.com/lite-xl/lite-xl-plugins/issues/144 - [".vim"] = { "#8f00ff", "" }, - [".j2"] = { "#ffff00", "" }, - [".ini"] = { "#ffffff", "" }, - [".fish"] = { "#ca2c92", "" }, - [".bash"] = { "#4169e1", "" }, - -- END: Adding per https://github.com/lite-xl/lite-xl-plugins/issues/144 + [".awk"] = { "#4d5a5e", "code-16" }, + [".nim"] = { "#F88A02", "code-16" }, + [".zig"] = { "#cbcb41", "code-16" }, + [".j2"] = { "#ffff00", "milestone-16" }, + [".ini"] = { "#ffffff", "pencil-16" }, + [".fish"] = { "#ca2c92", "terminal-16" }, + [".bash"] = { "#4169e1", "terminal-16" }, } local known_names_icons = { - ["changelog"] = { "#657175", "" }, ["changelog.txt"] = { "#4d5a5e", "" }, - ["changelog.md"] = { "#519aba", "" }, - ["makefile"] = { "#6d8086", "" }, - ["dockerfile"] = { "#296478", "" }, - ["docker-compose.yml"] = { "#4289a1", "" }, - ["license"] = { "#d0bf41", "" }, - ["cmakelists.txt"] = { "#6d8086", "" }, - ["readme.md"] = { "#72b886", "" }, ["readme"] = { "#72b886", "" }, - ["init.lua"] = { "#2d6496", "" }, - ["setup.py"] = { "#559dd9", "" }, - ["build.zig"] = { "#6d8086", "" }, + ["changelog"] = { "#657175", "history-16" }, ["changelog.txt"] = { "#4d5a5e", "history-16" }, + ["changelog.md"] = { "#519aba", "history-16" }, + ["makefile"] = { "#6d8086", "terminal-16" }, + ["dockerfile"] = { "#296478", "docker-16" }, + ["docker-compose.yml"] = { "#4289a1", "docker-16" }, + ["license"] = { "#d0bf41", "file-badge-16" }, + ["cmakelists.txt"] = { "#6d8086", "gear-16" }, + ["readme.md"] = { "#72b886", "file-16" }, ["readme"] = { "#72b886", "file-16" }, + ["init.lua"] = { "#2d6496", "lua-16" }, + ["setup.py"] = { "#559dd9", "python-16" }, + ["build.zig"] = { "#6d8086", "gear-16" }, } -- Preparing colors -for k, v in pairs(extension_icons) do +for _, v in pairs(extension_icons) do v[1] = { common.color(v[1]) } end -for k, v in pairs(known_names_icons) do +for _, v in pairs(known_names_icons) do v[1] = { common.color(v[1]) } end @@ -129,15 +129,15 @@ function TreeView:get_item_icon(item, active, hovered) icon_font:set_size( icon_font:get_size() * (SCALE / previous_scale) ) - chevron_width = icon_font:get_width("") + chevron_width = icon_font:get_width(map["chevron-down-16"]) previous_scale = SCALE end if not config.plugins.nonicons.use_default_dir_icons then - icon = "" -- unicode 61766 + icon = map["file-16"] -- unicode 61766 font = icon_font color = style.text if item.type == "dir" then - icon = item.expanded and "" or "" -- unicode U+F23C and U+F23B + icon = item.expanded and map["file-directory-open-fill-16"] or map["file-directory-fill-16"] -- unicode U+F23C and U+F23B end end if config.plugins.nonicons.draw_treeview_icons then @@ -147,7 +147,7 @@ function TreeView:get_item_icon(item, active, hovered) end if custom_icon ~= nil then color = custom_icon[1] - icon = custom_icon[2] + icon = map[custom_icon[2]] font = icon_font end if active or hovered then @@ -162,9 +162,9 @@ local TreeView_draw_item_chevron = TreeView.draw_item_chevron function TreeView:draw_item_chevron(item, active, hovered, x, y, w, h) if not config.plugins.nonicons.use_default_chevrons then if item.type == "dir" then - local chevron_icon = item.expanded and "" or "" + local chevron_icon = item.expanded and "chevron-down-16" or "chevron-right-16" local chevron_color = hovered and style.accent or style.text - common.draw_text(icon_font, chevron_color, chevron_icon, nil, x, y, 0, h) + common.draw_text(icon_font, chevron_color, map[chevron_icon], nil, x, y, 0, h) end return chevron_width + style.padding.x/4 end -- cgit v1.2.3