Module:Infobox MOS: Difference between revisions

Ganaram inukshuk (talk | contribs)
m Comment out generator in mossteps for now
Ganaram inukshuk (talk | contribs)
Added keyboard visualization
Line 33: Line 33:
t1[#t1+1] = t2[i]
t1[#t1+1] = t2[i]
end
end
end
-- Helper function (TODO: make this its own module?)
-- Creates a keyboard visualization, based on the defacto Halberstadt layout
function p.kb_vis(input_mos)
local input_mos = input_mos or mos.new(5, 2)
local brightest_mode = mos.brightest_mode(input_mos)
local CORNER_TL = '┌'
local CORNER_TR = '┐'
local CORNER_BL = '└'
local CORNER_BR = '┘'
local BORDER_BLACK_KEY_TOP = '╥'
local BORDER_WHITE_KEY_TOP = '┬'
local BORDER_KEY_BOTTOM = '┴'
local BORDER_BLACK_KEY_SIDE = '║'
local BORDER_WHITE_KEY_SIDE = '│'
local line_1 = CORNER_TL
local line_2 = BORDER_WHITE_KEY_SIDE
local line_3 = BORDER_WHITE_KEY_SIDE
local line_4 = CORNER_BL
for i = 1, #brightest_mode do
local current_step = brightest_mode:sub(i,i)
if current_step == "L" then
line_1 = line_1 .. BORDER_BLACK_KEY_TOP
line_2 = line_2 .. BORDER_BLACK_KEY_SIDE
line_3 = line_3 .. BORDER_WHITE_KEY_SIDE
line_4 = line_4 .. BORDER_KEY_BOTTOM
elseif current_step == "s" then
line_1 = line_1 .. BORDER_WHITE_KEY_TOP
line_2 = line_2 .. BORDER_WHITE_KEY_SIDE
line_3 = line_3 .. BORDER_WHITE_KEY_SIDE
line_4 = line_4 .. BORDER_KEY_BOTTOM
end
end
line_1 = line_1 .. CORNER_TR
line_2 = line_2 .. BORDER_WHITE_KEY_SIDE
line_3 = line_3 .. BORDER_WHITE_KEY_SIDE
line_4 = line_4 .. CORNER_BR
local vis = string.format('<pre style="line-height: 1; font-family: monospace; font-size: 1.25em; padding: 0.1em; margin: 0.1em">%s\n%s\n%s\n%s</pre>', line_1, line_2, line_3, line_4)
return vis
end
end


Line 479: Line 524:
local sections = {}
local sections = {}
-- Keyboard visualization
local kb_vis = p.kb_vis(tuning_parsed)
p.concatenate_tables(sections, kb_vis)
-- Scale structure section
-- Scale structure section