Module:Keyboard vis: Difference between revisions

Ganaram inukshuk (talk | contribs)
Created page with "local p = {} local CORNER_TL = '┌' local CORNER_TR = '┐' local CORNER_BL = '└' local CORNER_BR = '┘' local BORDER_BLACK_KEY_TOP = '╥' local BORDER_WHITE..."
 
Tristanbay (talk | contribs)
fixed resizing
 
(18 intermediate revisions by 2 users not shown)
Line 1: Line 1:
local p = {}
local p = {}


local CORNER_TL = ''
local END_L = '[[File:Keyboard_vis_end_left.png|20px]]'
local CORNER_TR = ''
local END_R = '[[File:Keyboard_vis_end_right.png|20px]]'
local CORNER_BL = '└'
local BORDER_BLACK_KEY = '[[File:Keyboard_vis_border_black_key.png|20px]]'
local CORNER_BR = '┘'
local BORDER_WHITE_KEY = '[[File:Keyboard_vis_border_white_key.png|20px]]'
local BORDER_BLACK_KEY_TOP = '╥'
local BORDER_WHITE_KEY_TOP = '┬'
local BORDER_KEY_BOTTOM = '┴'
local BORDER_BLACK_KEY_SIDE = ''
local BORDER_WHITE_KEY_SIDE = ''


-- Produces a small keyboard visualization
-- Produces a small keyboard visualization
Line 16: Line 11:
local step_pattern = step_pattern or "LLLsLLs"
local step_pattern = step_pattern or "LLLsLLs"
local line_1 = CORNER_TL
local result = END_L
local line_2 = BORDER_WHITE_KEY_SIDE
local line_3 = BORDER_WHITE_KEY_SIDE
local line_4 = CORNER_BL
for i = 1, #step_pattern do
for i = 1, #step_pattern do
local current_step = step_pattern:sub(i,i)
local current_step = step_pattern:sub(i,i)
if current_step == "L" then
if current_step == "L" then
line_1 = line_1 .. BORDER_BLACK_KEY_TOP
result = result .. BORDER_BLACK_KEY
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
elseif current_step == "s" then
line_1 = line_1 .. BORDER_WHITE_KEY_TOP
result = result .. BORDER_WHITE_KEY
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
end
end
line_1 = line_1 .. CORNER_TR
result = result .. END_R
line_2 = line_2 .. BORDER_WHITE_KEY_SIDE
line_3 = line_3 .. BORDER_WHITE_KEY_SIDE
line_4 = line_4 .. CORNER_BR
return string.format('<pre style="background-color: white; line-height: 1; font-family: Courier New, monospace; font-size: 1em; padding: 0.1em; margin: 0.1em">%s\n%s\n%s\n%s</pre>', line_1, line_2, line_3, line_4)
return result
end
end


return p
return p