Module:Keyboard vis: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
ArrowHead294 (talk | contribs)
mNo edit summary
ArrowHead294 (talk | contribs)
mNo edit summary
Line 16: Line 16:
function p.vis_small(step_pattern, debug_mode)
function p.vis_small(step_pattern, debug_mode)
local step_pattern = step_pattern or "LLLsLLs"
local step_pattern = step_pattern or "LLLsLLs"
local debugg = yesno(debug_mode)
local line_1 = CORNER_TL
local line_1 = CORNER_TL
Line 42: Line 41:
line_4 = line_4 .. CORNER_BR
line_4 = line_4 .. CORNER_BR
local out_str = (debugg == true and '&lt;pre style=&quot;' or '<pre style="')
local out_str = (debug_mode == true and '&lt;pre style=&quot;' or '<pre style="')
.. 'background-color: white; '
.. 'background-color: white; '
.. 'line-height: 1; '
.. 'line-height: 1; '
Line 49: Line 48:
.. 'padding: 0.1em; '
.. 'padding: 0.1em; '
.. 'margin: 0.1em;'
.. 'margin: 0.1em;'
.. (debugg == true and '&quot;&gt;' or '">')
.. (debug_mode == true and '&quot;&gt;' or '">')
.. string.format('\n%s\n%s\n%s\n%s\n', line_1, line_2, line_3, line_4)
.. string.format('\n%s\n%s\n%s\n%s\n', line_1, line_2, line_3, line_4)
.. (debugg == true and '&lt;/pre&gt;' or '</pre>')
.. (debug_mode == true and '&lt;/pre&gt;' or '</pre>')
return out_str
return out_str
end
end


return p
return p

Revision as of 16:31, 6 March 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
16 vis_small (step_pattern, debug_mode)
Lua modules required (1)
Variable Module Functions used
yesno Module:Yesno dependency not used

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


local yesno = require("Module:Yesno")
local p = {}

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	= '│'

-- Produces a small keyboard visualization
-- Likely to display correctly on most devices
function p.vis_small(step_pattern, debug_mode)
	local step_pattern = step_pattern or "LLLsLLs"
	
	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, #step_pattern do
		local current_step = step_pattern: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 out_str = (debug_mode == true and '&lt;pre style=&quot;' or '<pre style="')
		.. 'background-color: white; '
		.. 'line-height: 1; '
		.. 'font-family: Courier New, monospace; '
		.. 'font-size: 1em; '
		.. 'padding: 0.1em; '
		.. 'margin: 0.1em;'
		.. (debug_mode == true and '&quot;&gt;' or '">')
		.. string.format('\n%s\n%s\n%s\n%s\n', line_1, line_2, line_3, line_4)
		.. (debug_mode == true and '&lt;/pre&gt;' or '</pre>')
	return out_str
end

return p