mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-24 08:37:42 +00:00
Developed an initial testing framework for the chirality changes, corrected default behavior of buildDefaultLayout when KLS lacks specifications for default layers.
This commit is contained in:
parent
621bdf0ce9
commit
2014b68437
6 changed files with 315 additions and 5 deletions
149
web/samples/chirality/chirality.js
Normal file
149
web/samples/chirality/chirality.js
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
KeymanWeb.KR(new Keyboard_chirality());
|
||||
|
||||
function Keyboard_chirality() {
|
||||
this.KI = "Keyboard_chirality";
|
||||
this.KN = "Development Chirality Test Keyboard";
|
||||
this.KV = {
|
||||
KMBM: 0x001F,
|
||||
F: ' 1em "Arial"',
|
||||
K102: 0,
|
||||
KLS: { 'default': new Array("`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "", "", "", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "[", "]", "\\", "", "", "", "a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "", "", "", "", "", "", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/", "", "", "", "", "", "")
|
||||
}
|
||||
};
|
||||
this.KH = '';
|
||||
this.KM = 0;
|
||||
// this.s18 = "ເແໂໄໃ";
|
||||
// this.s20 = "ະຽາ";
|
||||
// this.s22 = "່້໊໋໌";
|
||||
// this.s24 = "ໆຯ";
|
||||
this.gs = function (t, e) {
|
||||
return 0; //this.g0(t, e);
|
||||
};
|
||||
this.g0 = function (t, e) {
|
||||
// var k = KeymanWeb, r = 0, m = 0;
|
||||
// if (k.KKM(e, 16480, 48)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "໘");
|
||||
// } else if (k.KKM(e, 16480, 49)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "໑");
|
||||
// } else if (k.KKM(e, 16480, 50)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "໒");
|
||||
// } else if (k.KKM(e, 16480, 51)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "໓");
|
||||
// } else if (k.KKM(e, 16480, 52)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "໔");
|
||||
// } else if (k.KKM(e, 16480, 55)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "໕");
|
||||
// } else if (k.KKM(e, 16480, 56)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "໖");
|
||||
// } else if (k.KKM(e, 16480, 57)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "໗");
|
||||
// } else if (k.KKM(e, 16480, 87)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "໐");
|
||||
// } else if (k.KKM(e, 16384, 96)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "0");
|
||||
// } else if (k.KKM(e, 16384, 97)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "1");
|
||||
// } else if (k.KKM(e, 16384, 98)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "2");
|
||||
// } else if (k.KKM(e, 16384, 99)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "3");
|
||||
// } else if (k.KKM(e, 16384, 100)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "4");
|
||||
// } else if (k.KKM(e, 16384, 101)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "5");
|
||||
// } else if (k.KKM(e, 16384, 102)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "6");
|
||||
// } else if (k.KKM(e, 16384, 103)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "7");
|
||||
// } else if (k.KKM(e, 16384, 104)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "8");
|
||||
// } else if (k.KKM(e, 16384, 105)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "9");
|
||||
// } else if (k.KKM(e, 16384, 106)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "*");
|
||||
// } else if (k.KKM(e, 16384, 107)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "+");
|
||||
// } else if (k.KKM(e, 16384, 109)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "-");
|
||||
// } else if (k.KKM(e, 16384, 110)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, ".");
|
||||
// } else if (k.KKM(e, 16384, 111)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "/");
|
||||
// } else if (k.KKM(e, 16480, 187)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "€");
|
||||
// } else if (k.KKM(e, 16480, 189)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "໙");
|
||||
// } else if (k.KKM(e, 16480, 192)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "₭");
|
||||
// } else if (k.KKM(e, 16480, 219)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "[");
|
||||
// } else if (k.KKM(e, 16480, 221)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "]");
|
||||
// }
|
||||
// if (!m && k.KIK(e)) {
|
||||
// r = this.g1(t, e);
|
||||
// }
|
||||
// return r;
|
||||
};
|
||||
// this.g1 = function (t, e) {
|
||||
// var k = KeymanWeb, r = 0, m = 0;
|
||||
// if (k.KKM(e, 16400, 49)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "1");
|
||||
// } else if (k.KKM(e, 16400, 222)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "=");
|
||||
// } else if (k.KKM(e, 16400, 51)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "3");
|
||||
// } else if (k.KKM(e, 16400, 52)) {
|
||||
// r = m = 1;
|
||||
// k.KO(0, t, "4");
|
||||
// } else if (k.KKM(e, 16400, 53) && k.KCM(1, t, "ຳ", 1)) {
|
||||
// r = m = 1;
|
||||
// k.KO(1, t, "໌");
|
||||
// } else if (k.KKM(e, 16400, 53) && k.KA(0, k.KC(1, 1, t), this.s22)) {
|
||||
// r = m = 1;
|
||||
// k.KB(t);
|
||||
// } else if (k.KKM(e, 16400, 53) && k.KA(0, k.KC(1, 1, t), this.s18)) {
|
||||
// r = m = 1;
|
||||
// k.KB(t);
|
||||
// } else if (k.KKM(e, 16400, 53) && k.KA(0, k.KC(1, 1, t), this.s20)) {
|
||||
// r = m = 1;
|
||||
// k.KB(t);
|
||||
// } else if (k.KKM(e, 16400, 53) && k.KA(0, k.KC(1, 1, t), this.s24)) {
|
||||
// r = m = 1;
|
||||
// k.KB(t);
|
||||
// }
|
||||
// return r;
|
||||
// };
|
||||
}
|
||||
19
web/samples/chirality/halfDefined.js
Normal file
19
web/samples/chirality/halfDefined.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
KeymanWeb.KR(new Keyboard_halfDefined());
|
||||
|
||||
function Keyboard_halfDefined() {
|
||||
this.KI = "Keyboard_halfDefined";
|
||||
this.KN = "Development Underspecified Keyboard";
|
||||
this.KV = {
|
||||
KMBM: 0x001F,
|
||||
F: ' 1em "Arial"',
|
||||
K102: 0,
|
||||
KLS: { 'default': new Array("`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "", "", "", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "[", "]", "\\", "", "", "", "a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "", "", "", "", "", "", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/", "", "", "", "", "", "")
|
||||
}
|
||||
};
|
||||
this.KH = '';
|
||||
this.KM = 0;
|
||||
|
||||
this.gs = function (t, e) {
|
||||
return r = 0;
|
||||
};
|
||||
}
|
||||
116
web/samples/chirality/index.html
Normal file
116
web/samples/chirality/index.html
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
|
||||
<!-- Set the viewport width to match phone and tablet device widths -->
|
||||
<meta name="viewport" content="width=device-width,user-scalable=no" />
|
||||
|
||||
<!-- Allow KeymanWeb to be saved to the iPhone home screen -->
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
|
||||
<!-- Enable IE9 Standards mode -->
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
|
||||
<title>KeymanWeb Sample Page - Uncompiled Source</title>
|
||||
|
||||
<!-- Your page CSS -->
|
||||
<style type='text/css'>
|
||||
body {font-family: Tahoma,helvetica;}
|
||||
h3 {font-size: 1em;font-weight:normal;color: darkred; margin-bottom: 4px}
|
||||
.test {font-size: 1.5em; width:80%; min-height:30px; border: 1px solid gray;}
|
||||
#KeymanWebControl {width:50%;min-width:600px;}
|
||||
</style>
|
||||
|
||||
<!-- Insert uncompiled KeymanWeb source scripts -->
|
||||
<script src="../../source/kmwstring.js" type="application/javascript"></script>
|
||||
<script src="../../source/kmwbase.js" type="application/javascript"></script>
|
||||
<script src="../../source/keymanweb.js" type="application/javascript"></script>
|
||||
<script src="../../source/kmwosk.js" type="application/javascript"></script>
|
||||
<script src="../../source/kmwnative.js" type="application/javascript"></script>
|
||||
<script src="../../source/kmwcallback.js" type="application/javascript"></script>
|
||||
<script src="../../source/kmwkeymaps.js" type="application/javascript"></script>
|
||||
<script src="../../source/kmwlayout.js" type="application/javascript"></script>
|
||||
<script src="../../source/kmwinit.js" type="application/javascript"></script>
|
||||
|
||||
<!--
|
||||
For desktop browsers, a script for the user interface must be inserted here.
|
||||
|
||||
Standard UIs are toggle, button, float and toolbar.
|
||||
The toolbar UI is best for any page designed to support keyboards for
|
||||
a large number of languages.
|
||||
-->
|
||||
<script src="../../source/kmwuitoggle.js"></script>
|
||||
|
||||
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
|
||||
<script>
|
||||
// Thank you to https://stackoverflow.com/questions/22607150/getting-the-url-parameters-inside-the-html-page.
|
||||
var GetURLParameter = function(sParam) {
|
||||
var sPageURL = window.location.search.substring(1);
|
||||
var sURLVariables = sPageURL.split('&');
|
||||
for (var i = 0; i < sURLVariables.length; i++) {
|
||||
var sParameterName = sURLVariables[i].split('=');
|
||||
if (sParameterName[0] == sParam) {
|
||||
return sParameterName[1];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var attachType = GetURLParameter("mode");
|
||||
var attachText = attachType ? attachType : "default";
|
||||
|
||||
var kmw=window.tavultesoft.keymanweb;
|
||||
kmw.init({
|
||||
attachType: 'auto',
|
||||
resources:'resources'
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Add keyboard management script for local selection of keyboards to use -->
|
||||
<script src="./utilities.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<!-- Sample page HTML -->
|
||||
<body onload='loadKeyboards();'>
|
||||
<h2>KeymanWeb Sample Page - Uncompiled Source, Chirality Testing</h2>
|
||||
<p>This page is designed to stress-test the new support for chiral modifiers and state keys.</p>
|
||||
<p>Be sure to reference the developer console for additional feedback. </p>
|
||||
<hr/>
|
||||
<div>
|
||||
<!--
|
||||
The following DIV is used to position the Button or Toolbar User Interfaces on the page.
|
||||
If omitted, those User Interfaces will appear at the top of the document body.
|
||||
(It is ignored by other User Interfaces.)
|
||||
-->
|
||||
<div id='KeymanWebControl'>
|
||||
<h3>Type in your language in this text area:</h3>
|
||||
<textarea id='ta1' class='test' placeholder='Type here'></textarea>
|
||||
|
||||
<h3>or in this input field:</h3>
|
||||
<input class='test' value='' placeholder='or here'/>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<h3><a href="../index.html">Return to testing home page</a></h3>
|
||||
</body>
|
||||
|
||||
<!--
|
||||
*** DEVELOPER NOTE -- FIREFOX CONFIGURATION FOR TESTING ***
|
||||
*
|
||||
* If the URL bar starts with <b>file://</b>, Firefox may not load the font used
|
||||
* to display the special characters used in the On-Screen Keyboard.
|
||||
*
|
||||
* To work around this Firefox bug, navigate to <b>about:config</b>
|
||||
* and set <b>security.fileuri.strict_origin_policy</b> to <b>false</b>
|
||||
* while testing.
|
||||
*
|
||||
* Firefox resolves website-based CSS URI references correctly without needing
|
||||
* any configuration change, so this change should only be made for file-based testing.
|
||||
*
|
||||
***
|
||||
-->
|
||||
</html>
|
||||
22
web/samples/chirality/utilities.js
Normal file
22
web/samples/chirality/utilities.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
function loadKeyboards()
|
||||
{
|
||||
var kmw=tavultesoft.keymanweb;
|
||||
|
||||
// A testing keyboard handwritten with chirality information.
|
||||
kmw.addKeyboards({id:'chirality',name:'Chirality Testing',
|
||||
language:{
|
||||
id:'eng',name:'English',region:'North America'
|
||||
},
|
||||
filename:'chirality.js'
|
||||
});
|
||||
|
||||
// A testing keyboard using 10.0 format and the KLS layout specifier
|
||||
// without the 'shift' layer properly defined.
|
||||
// Add a fully-specified, locally-sourced, keyboard with custom font
|
||||
kmw.addKeyboards({id:'halfDefined',name:'Undefined Shift Layer Keyboard',
|
||||
language:{
|
||||
id:'eng',name:'English',region:'North America'
|
||||
},
|
||||
filename:'halfDefined.js'
|
||||
});
|
||||
}
|
||||
|
|
@ -29,5 +29,6 @@
|
|||
<h2><a href="./issue-53.html">Uncompiled Keymanweb - test touch-based keyboards with heterogenous layer structures/row counts.</a></h2>
|
||||
<h2><a href="./keyboard-errors/uncompiled - error test.html">Uncompiled KeymanWeb - tests keyboard error-handling functionality.</a></h2>
|
||||
<h2><a href="./attachment-api/index.html?mode=auto">Uncompiled KeymanWeb - tests the new Attachment/Enablement API functionality.</a><h2>
|
||||
<h2><a href="./chirality/index.html">Uncompiled KeymanWeb - chirality testing.</a><h2>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -2682,7 +2682,7 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
|
|||
|
||||
if(chiral) {
|
||||
layerCnt=32;
|
||||
offset=0x00;
|
||||
offset=0x01;
|
||||
} else {
|
||||
layerCnt=8;
|
||||
offset=0x10;
|
||||
|
|
@ -2772,6 +2772,7 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
|
|||
var layer=layers[n], kx, shiftKey=null, nextKey=null, allText='';
|
||||
var layerSpec = keyLabels[layer['id']];
|
||||
var isShift = layer['id'] == 'shift' ? 1 : 0;
|
||||
var isDefault = layer['id'] == 'default' || isShift ? 1 : 0;
|
||||
|
||||
rows=layer['row'];
|
||||
for(i=0; i<rows.length; i++)
|
||||
|
|
@ -2783,14 +2784,16 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
|
|||
kx=dfltCodes.indexOf(key['id']);
|
||||
|
||||
// Only create keys for defined layers. ('default' and 'shift' are always defined.)
|
||||
if(layerSpec) {
|
||||
if(layerSpec || isDefault) {
|
||||
// Get keycap text from visual keyboard array, if defined in keyboard
|
||||
if(kx >= 0 && kx < layerSpec.length) key['text']=layerSpec[kx];
|
||||
if(layerSpec) {
|
||||
if(kx >= 0 && kx < layerSpec.length) key['text']=layerSpec[kx];
|
||||
}
|
||||
|
||||
// Fall back to US English keycap text as default for the base two layers if not otherwise defined.
|
||||
// (Any 'ghost' keys must be explicitly defined in layout for these layers.)
|
||||
if(layer['id'] == 'default' || isShift) {
|
||||
if(key['text'] == '' && key['id'] != 'K_SPACE' && kx+65 * isShift < dfltText.length) {
|
||||
if(isDefault) {
|
||||
if((key['text'] == '' || typeof key['text'] == 'undefined') && key['id'] != 'K_SPACE' && kx+65 * isShift < dfltText.length) {
|
||||
key['text']=dfltText[kx+65*isShift];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue