diff --git a/data/core/config.lua b/data/core/config.lua index 8e7df316..e564f42d 100644 --- a/data/core/config.lua +++ b/data/core/config.lua @@ -260,6 +260,13 @@ config.max_clicks = 3 ---@type boolean config.skip_plugins_version = false +---Increases the performance of the editor and its user. +---Do not change this unless you know what you are doing. +--- +---Defaults to true. +---@type boolean | { font: renderer.font, icon: string } | nil +config.stonks = true + -- holds the plugins real config table local plugins_config = {} diff --git a/data/core/statusview.lua b/data/core/statusview.lua index 74124768..f8d951bb 100644 --- a/data/core/statusview.lua +++ b/data/core/statusview.lua @@ -94,7 +94,7 @@ local StatusViewItem = Object:extend() ---of 1 will insert the item at the beggining. ---@field position? integer ---@field tooltip? string @Text displayed when mouse hovers the item. ----@field visible boolean @Flag to show or hide the item +---@field visible? boolean @Flag to show or hide the item ---The type of separator rendered to the right of the item if another item ---follows it. ---@field separator? core.statusview.item.separator @@ -190,6 +190,9 @@ function StatusView:new() self:register_command_items() end +local clicks = -1 +local gx, gy, dx, dy, gc = 0, 0, 2, -2, { table.unpack(style.text) } + ---The predefined status bar items displayed when a document view is active. function StatusView:register_docview_items() if self:get_item("doc:file") then return end @@ -291,6 +294,28 @@ function StatusView:register_docview_items() separator = self.separator2 }) + self:add_item({ + predicate = predicate_docview, + name = "doc:stats", + alignment = StatusView.Item.RIGHT, + get_item = function() + return config.stonks == nil and {} or { + style.text, + type(config.stonks) == "table" and config.stonks.font or style.icon_font, + type(config.stonks) == "table" and config.stonks.icon or ( config.stonks and "g" or "h" ), + } + end, + separator = self.separator2, + command = function(button, x, y) + if button == "left" then + clicks = clicks + 1 + elseif button == "right" then + clicks = -1 + end + gx, gy = x, y + end + }) + self:add_item({ predicate = predicate_docview, name = "doc:lines", @@ -298,9 +323,6 @@ function StatusView:register_docview_items() get_item = function() local dv = core.active_view return { - style.text, - style.icon_font, "g", - style.font, style.dim, self.separator2, style.text, #dv.doc.lines, " lines", } end, @@ -1213,6 +1235,25 @@ function StatusView:draw() end end end + + if clicks > 5 then + if config.stonks == nil then clicks = -1 end + core.root_view:defer_draw(function() + local font = type(config.stonks) == "table" and config.stonks.font or style.icon_font + local icon = type(config.stonks) == "table" and config.stonks.icon or ( config.stonks and "g" or "h" ) + local xadv = renderer.draw_text(font, icon, gx, gy, gc) + local x2, y2 = core.root_view.size.x - (xadv - gx), core.root_view.size.y - font:get_height() + gx, gy = common.clamp(gx + dx, 0, x2), common.clamp(gy + dy, 0, y2) + local odx, ody = dx, dy + if gx <= 0 then dx = math.abs(dx) elseif gx >= x2 then dx = -math.abs(dx) end + if gy <= 0 then dy = math.abs(dy) elseif gy >= y2 then dy = -math.abs(dy) end + if odx ~= dx or ody ~= dy then + local major = math.random(1, 3) + for i = 1, 3 do gc[i] = major == i and math.random(200, 255) or math.random(0, 100) end + end + core.redraw = true + end) + end end return StatusView diff --git a/data/fonts/icons.ttf b/data/fonts/icons.ttf index 5fd6d9e9..33d62b11 100644 Binary files a/data/fonts/icons.ttf and b/data/fonts/icons.ttf differ diff --git a/scripts/fontello-config.json b/scripts/fontello-config.json index 76349182..e68f4cc3 100644 --- a/scripts/fontello-config.json +++ b/scripts/fontello-config.json @@ -195,6 +195,20 @@ "search": [ "lite-xl4" ] + }, + { + "uid": "b1c9ba6ba7db344177bf4906b41303ee", + "css": "chart-line-down", + "code": 104, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M1071.4 728.2V485.5Q1071.4 473.8 1060.5 469 1049.7 464.3 1040.7 473.2L973.2 540.7 620 187.5Q614.4 181.9 607.1 181.9 599.9 181.9 594.3 187.5L464.3 317.5 232.1 85.4 125 192.5 451.5 519Q457 524.6 464.3 524.6 471.5 524.6 477.1 519L607.1 389 866.1 647.9 798.5 715.4Q789.6 724.3 794.4 735.2 799.1 746.1 810.8 746.1H1053.6Q1061.4 746.1 1066.4 741.1 1071.4 736 1071.4 728.2ZM1142.9 799.7V871.1H0V14H71.4V799.7Z", + "width": 1154 + }, + "search": [ + "_481_fontawesome" + ] } ] } \ No newline at end of file