use utf8;
use strict;
use warnings;
no  warnings 'qw';
use Shiar_Sheet::KeyboardChars 'kbchars';

my %guys = qw{
	! 🐀 @ 🐂 # 🐅 $ 🐇 % 🐉 ^ 🐍 & 🐎 * 🐐 ( 🐒 ) 🐓 _ 🐕 + 🐖
	1 ♙  2 ♖  3 ♘  4 ♗  5 ♕  6 ♔  7 ♚  8 ♛  9 ♝  0 ♞  -  ♜ = ♟
};

my %rows = qw`
	+- ♠ += ♥ ++ ♦ +_ ♣
	) ☺ +) ☹ 0 ☻  +6 ✂  +0 ☼  ^ ⚐ 6 ⚑
	+! ○ +1 ●  +@ □ +2 ■  +# ☆ +3 ★
	- ✗ = ✓  _ ✘ + ✔  +^ ☓

	q ↖ w ↑ e ↗  Q ⇖ W ⇑ E ⇗  +q ◤ +w ▲ +e ◥  +Q ◸ +W △ +E ◹
	a ← s ↔ d →  A ⇐ S ⇔ D ⇒  +a ◀ +s ◆ +d ▶  +A ◁ +S ◇ +D ▷
	z ↙ x ↓ c ↘  Z ⇙ X ⇓ C ⇘  +z ◣ +x ▼ +c ◢  +Z ◺ +X ▽ +C ◿
	1 ⤡ 2 ↕ 3 ⤢  ! ◄ @ ⇕ # ►

	r ┌ t ┬ y ┐  R ╔ T ╦ Y ╗  +u ╭ +i ╷ +o ╮
	f ├ g ┼ h ┤  F ╠ G ╬ H ╣  +j ╶ +k 🮯 +l ╴
	v └ b ┴ n ┘  V ╚ B ╩ N ╝  +m ╰ +, ╵ +. ╯
	4 ─ 5 │      $ ═ % ║
	{ ⋯ | ⋮ \\ · P ⋰ } ⋱      +| ⁙ +" ⁘
	[ ╳          p ╱ ] ╲
	+[ ┄ +4 ╌ +$ ┈  +\\ ┆ +5 ╎ +% ┊

	+r ╒ +R ╓ +t ╤ +T ╥ +y ╕ +Y ╖
	+f ╞ +F ╟ +g ╪ +G ╫ +h ╡ +H ╢
	+v ╘ +V ╙ +b ╧ +B ╨ +n ╛ +N ╜

	' ▬ " ▮
	> ▛ . ▘ , ▀ M ▜ m ▝
	l ▌ ( ▚ k █ & ▞ j ▐  ; ▎ : ▊  +; 🮇 +: 🮊
	O ▙ o ▖ i ▄ U ▟ u ▗  / ▂ ? ▆  +/ 🮂 +? 🮅
	7 ░ 8 ▒ 9 ▓
	+p 🮙 +] 🮘  +8 🮕 +* 🮖  +{ 🮗
	I 🭯 < 🭭 J 🭮 L 🭬  * 🮚 K 🮛

	+U 🮣 +I 🮦 +O 🮢  +7 🮫 +9 🮪
	+J 🮥 +K 🮮 +L 🮤  +P 🮨 +} 🮩
	+M 🮡 +< 🮧 +> 🮠  +& 🮬 +( 🮭
`;

$rows{' '} = "\N{FIGURE SPACE}";

my $groups = kbchars(\%rows);

use Encode 'decode';
my %cpcompat = (
	# lower cp437 representations from charset-encoding excluding BEL/BS/CR/LF
	(map {$_ => 'g3'} split //, '☺☻♥♦♣♠○♂♀♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼'),
	# upper characters converted to unicode
	(map {$_ => 'g4'} split //, decode('cp437', pack 'C*', 127..255)),
	(map {$_ => 'g2'} split //, decode('cp850', pack 'C*', 127..255)),
);

while (my ($k, $c) = each %rows) {
	$groups->{def}{''}{$k} = $cpcompat{$c} // (
		$c =~ /\p{In=1.1}/ ? 'g5' :
		$c =~ /\p{In=6.0}/ ? 'g6' :
		$c =~ /[\x{1FB00}-\x{1FBFF}]/ ? 'g7' : # Age=V13.0
		'g0'
	);
}
$groups->{def}{''}{')'} .= ' linkkeyboard/altgr/zoo';

+{
	%{ $groups },
	version => '1.2',
	title => 'Unicode semigraphics',
	category => 'specialized',
	intro => join("\n",
		sprintf('Keyboard mode to %s draw character graphics.',
			'<span title="without requiring a specialised editor">manually</span>',
		),
		'Inspired by <a href="/keyboard/altgr/msx-graph">MSX graph</a> mode,',
		'but reimagined for modern Unicode coverage.',
		'Freely available as <a href="/keyboard/symbols/unigraph">xorg symbols</a> export.',
	),
	moderows => '5421',
	flag => {
		g2 => ['cp850'    => 'shared international repetoire in most DOS code pages'],
		g3 => ['historic' => 'extended graphics presentations of control characters in cp437 ea'],
		g4 => ['cp437'    => '<em>ANSI art</em> drawing glyphs in English code page 437 (OEM-US)'],
		g5 => ['standard' => 'gathered in the original Unicode release in 1993'],
		g6 => ['extended' => 'later additions accumulated within a decade, mostly Unicode 3.2'],
		g7 => ['rare'     => 'exceptional <em>symbols for legacy computing</em> in Unicode since <abbr title="Unicode 13.0">2020</abbr>'],
	},
}
