Module:Keyboard vis: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
Tristanbay (talk | contribs)
undid other edit
Tag: Manual revert
Tristanbay (talk | contribs)
Switched to using images instead of plain text
Line 1: Line 1:
local p = {}
local p = {}


local CORNER_TL = '┌' -- U+250C ┌
local SIDE_L = '[[File:Keyboard_vis_side_left|20]]'
local CORNER_TR = '┐' -- U+2510 ┐
local SIDE_R = '[[File:Keyboard_vis_side_right|20]]'
local CORNER_BL = '└' -- U+2514 └
local BORDER_BLACK_KEY = '[[File:Keyboard_vis_border_black_key|20]]'
local CORNER_BR = '┘' -- U+2518 ┘
local BORDER_WHITE_KEY = '[[File:Keyboard_vis_border_white_key|20]]'
local BORDER_BLACK_KEY_TOP = '╥' -- U+2565 ╥
local BORDER_WHITE_KEY_TOP = '┬' -- U+252C ┬
local BORDER_KEY_BOTTOM = '┴' -- U+2534 ┴
local BORDER_BLACK_KEY_SIDE = '║' -- U+2551 ║
local BORDER_WHITE_KEY_SIDE = '│' -- U+2502 │


-- 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 = SIDE_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 .. SIDE_R
line_2 = line_2 .. BORDER_WHITE_KEY_SIDE
line_3 = line_3 .. BORDER_WHITE_KEY_SIDE
line_4 = line_4 .. CORNER_BR
local result = '<pre style="'
.. 'background-color: white; '
.. 'line-height: 1; '
.. 'font-family: Courier New, monospace; '
.. 'font-size: 1em; '
.. 'padding: 0.1em; '
.. 'margin: 0.1em;">'
.. string.format('\n%s\n%s\n%s\n%s\n', line_1, line_2, line_3, line_4)
.. '</pre>'
return result
return result
end
end


return p
return p

Revision as of 04:36, 5 December 2025

Module documentation[view] [edit] [history] [purge]
This module has a corresponding template that is currently missing or does not use this module. (edit template)

This module displays a Halberstadt-like keyboard layout for a given MOS pattern, assuming a 2:1 step ratio.

Introspection summary for Module:Keyboard vis 
Functions provided (1)
Line Function Params
10 vis_small (step_pattern)
Lua modules required (0)
Variable Module Functions used

No function descriptions were provided. The Lua code may have further information.


local p = {}

local SIDE_L			= '[[File:Keyboard_vis_side_left|20]]'
local SIDE_R			= '[[File:Keyboard_vis_side_right|20]]'
local BORDER_BLACK_KEY	= '[[File:Keyboard_vis_border_black_key|20]]'
local BORDER_WHITE_KEY	= '[[File:Keyboard_vis_border_white_key|20]]'

-- Produces a small keyboard visualization
-- Likely to display correctly on most devices
function p.vis_small(step_pattern)
	local step_pattern = step_pattern or "LLLsLLs"
	
	local result = SIDE_L
	
	for i = 1, #step_pattern do
		local current_step = step_pattern:sub(i,i)
		if current_step == "L" then
			result = result .. BORDER_BLACK_KEY
		elseif current_step == "s" then
			result = result .. BORDER_WHITE_KEY
		end
	end
	result = result .. SIDE_R
	
	return result
end

return p