use utf8;
use strict;
use warnings;
use Shiar_Sheet::KeyboardChars 'kbchars';
our %get;

my %rows = (
	'1' => '¼',
	'@' => '²',
	'2' => '½',
	'#' => 'ⁿ',
	'3' => '¾',
	'4' => '∩',
	'5' => '‰',
	'^' => '⌡',
	'6' => '⌠',
	'7' => '√',
	'8' => '∞',
	'(' => '◘', # inverted ·
	'9' => '·', # smaller than •
	')' => '◙',
	'0' => '○',
	'_' => '🮯',
	'-' => '─',
	'+' => '≡',
	'=' => '±',
	'~' => '≈',
	'`' => '∽',

	'Q' => '🮙',
	'q' => '🮘',
	'W' => '🭮',
	'w' => '🭬',
	'E' => '🭯',
	'e' => '🭭',
	'R' => '⌐',
	'r' => '┌',
	't' => '┬',
	'Y' => '¬',
	'y' => '┐',
	'U' => '🮅',
	'u' => '▂',
	'I' => '▀',
	'i' => '▄',
	'O' => '🮂',
	'o' => '▆',
	'P' => '🮖',
	'p' => '█',
	'[' => '☺',
	'{' => '☻',
	']' => '♪',
	'}' => '♫',

	'A' => '▮',
	'a' => '▬',
	'S' => '🮚',
	's' => '🮛',
	'D' => '▚',
	'd' => '▞',
	'F' => '▗',
	'f' => '├',
	'G' => '⟊', # ┼ without connecting right
	'g' => '┼',
	'H' => '▖',
	'h' => '┤',
	'J' => '🮊',
	'j' => '▎',
	'K' => '▐',
	'k' => '▌',
	'L' => '🮇',
	'l' => '▊',
	'"' => '♥',
	"'" => '♣',
	':' => '♦',
	';' => '♠',
	'|' => '│',
	'\\'=> '╲',

	'Z' => '◦', # small white circle
	'z' => '☼',
	'X' => '•', # small black circle
	'x' => '╳',
	'C' => '⁃',
	'c' => '◇', # ◊
	'V' => '▝',
	'v' => '└',
	'B' => '▬',
	'b' => '┴',
	'N' => '▘',
	'n' => '┘',
	'M' => '♀',
	'm' => '♂',
	'<' => '«',
	',' => '≤',
	'>' => '»',
	'.' => '≥',
	'?' => '÷',
	'/' => '╱',

);

my %compat = (
	'Q' => '▨',
	'q' => '▧',
	'W' => '◀', #
	'w' => '▶',
	'E' => '▲',
	'e' => '▼', #
	'U' => '▓',
	'J' => '░',
	'O' => '▔',
	'P' => '▒',
	'S' => '⧗',
	's' => '⧓',
	'G' => '╂',
	'_' => '┿',
	'L' => '▕',
);

if (exists $get{compat}) {
	%rows = (%rows, %compat);
}

my $groups = kbchars(\%rows);

# replace rare punctuation distinctions by symbols
$groups->{def}{''}{$_}[0] =~ s/g[78]/g6/ for keys %rows;

$groups->{def}{''}{$_}[0] = 'g7'
	for grep { $rows{$_} =~ /[\x{2500}-\x{259F}]/ } keys %rows;
$groups->{flag}{g7} = ['drawing', 'box drawing or block elements'];

$groups->{def}{''}{$_}[0] = 'g8' for keys %compat; # mostly U+1FBxx
$groups->{flag}{g8} = ['legacy',
	'drawing symbols best represented by Unicode 13.0'
	. (exists $get{compat} && ', converted to compatible equivalents')
];

+{
	%{ $groups },
	version => '1.0',
	title => 'MSX graph',
	category => 'legacy/msx',
	intro => join("\n",
		'Resulting <a href="/unicode">selection</a>',
		'of equivalent <a href="/charset">Unicode</a> characters',
		"when the <em>graph</em> key is pressed on an MSX home computer",
		"(International model such as Toshiba HX10 or Phillips NMS 8245).",
		'See also <a href="/keyboard/altgr/msx">letters and symbols</a>',
		"from pressing <em>code</em>.",
	),
	description => [
		"MSX keyboard layout table",
		"with the graph modifier key.",
	],
	image => 'data/keyboard/thumb/msxgraph.jpg',
	imagealt => 'Graph key on a Toshiba HX10 with graph labels',
}
