local alpha = require("alpha") local col = function(strlist, opts) -- strlist is a TABLE of TABLES, representing columns of text -- opts is a text display option -- column spacing local padding = 12 -- fill lines up to the maximim length with 'fillchar' local fillchar = ' ' -- columns padding char (for testing) local padchar = ' ' -- define maximum string length in a table local maxlen = function(str) local max = 0 for i in pairs(str) do if #str[i] > max then max = #str[i] end end return max end -- add as much right-padding to align the text block local pad = function(str, max) local strlist = {} for i in pairs(str) do if #str[i] < max then local newstr = str[i] .. string.rep(fillchar, max-#str[i]) table.insert(strlist, newstr) else table.insert(strlist, str[i]) end end return strlist end -- this is a table for text strings local values = {} -- process all the lines for i=1,maxlen(strlist) do local str = '' -- process all the columns but last, because we dont wand extra padding -- after last column for column=1,#strlist-1 do local maxstr = maxlen(strlist[column]) local padded = pad(strlist[column], maxstr) if strlist[column][i] == nil then str = str .. string.rep(fillchar, maxstr) .. string.rep(padchar, padding) else str = str .. padded[i] .. string.rep(padchar, padding) end end -- lets process the last column, no extra padding do local maxstr = maxlen(strlist[#strlist]) local padded = pad(strlist[#strlist], maxstr) if strlist[#strlist][i] == nil then str = str .. string.rep(fillchar, maxlen(strlist[#strlist])) else str = str .. padded[i] end end -- insert result into output table table.insert(values, { type = "text", val = str, opts = opts }) end return values end local window_managment = { "ALT-ENT new tab terminal", "ALT-NUM move to tab n", "ALT-v horizontal split", "ALT-v vertical split", } local text_managment = { "CTRL-t new file", "CTRL-w :q", "CTRL-n open file manager" } local applications = { "ALT+ESC htop", "ALT+t termusic", "ALT+r ranger", "ALT+m matrix", } local head = { type = "text", val = { [[ .█▄╥ _▄K¥▄ ]], [[ █ '▀▄_ ▄▄ ╓▄▀" ▀▌ ]], [[ █ "▀▄, ▓ ▀▀▄ ▄▀- █ ]], [[ ▐▌ ▀▄▌▀▀▀▀'""▀▀█ ▀▄ _▄▀ ▓ ]], [[ ▓ "▓╥ "▓_.▓▀ ╫ ]], [[ )▌ ▀█ ╫ ]], [[ ▐∩ █ ]], [[ ▐∩ ▐▌ ]], [[ ▐µ █▌ ]], [[ ▓ ╨▓▓█▄▄╥_ ,▄▄█████▄ █ ]], [[ ▐▄ `"▀▀██▄ ▐███▌╓_ .▓" ]], [[ "▓▄ _▄▄███▀' ▄▄▄▄┐ "▀▀█████▄ .▄K▀▀▀▀█ ]], [[▐▌▀▀▀▀ª ▀▀' "▀▄, _ _╥▄▀ ]], [[ ▓▄ _╥µ __ ,▄▄ ]µ ` ╫▌@╨ ▀▌ ]], [[ "▀▄` ▓K" *▌▄▄▀" "▀▀▓▀ ▀▄ ]], [[ █. ▐▌ j▌ _ █ ]], [[ █ , ▀▄ ▐▌ ▄▓"▀▀▀▀" ]], [[ ▐█K▀▀"▀¥██▌▄▄_ ╨▓_ _█ ,▄▄K▀▀ ]], [[ ▐▌ "▀W "▀" "█µ ]], [[ ▐█ "▓_ ]], [[ _▓▀ ▀▄ ]], [[ j█____ _ ▀▄ ]], [[ ''"▓" ▓⌐ ]], [[ █ ▐▌ ]], [[ ▀ ▀ ]], }, opts = { position = "center", hl = "Type", }, } local foot = { type = "text", val = "footer", opts = { position = "center", hl = "Number", }, } local block1 = { type = "group", val = col({window_managment, text_managment}, { position = "center", hl = {{ "Title", 0, 7 }, {"Comment", 7, 37}, {"Title", 37, 44}, {"Comment", 44, -1}}}), opts = { spacing = 0 }, } local block2 = { type = "group", val = col({applications}, { position = "center", hl = {{"Comment", 7, -1}, { "Title", 0, 7 }} }), opts = { spacing = 0 }, } local opts = { layout = { { type = "padding", val = 2 }, head, { type = "padding", val = 2 }, block1, { type = "padding", val = 2 }, block2, }, opts = { noautocmd = true, margin = 5, }, } alpha.setup(opts)