Merge remote-tracking branch 'origin/master' into ios-keyboard-struct

This commit is contained in:
Gabriel Wong 2017-11-14 14:25:11 +07:00
commit 9dbc70da24
75 changed files with 779 additions and 700 deletions

View file

@ -18,7 +18,7 @@
//document.body.style.backgroundColor="transparent";
window.console.log('Device type = '+device);
window.console.log('Keyboard height = '+oskHeight);
var kmw=window['tavultesoft']['keymanweb'];
var kmw=window['keyman'];
kmw.init({'app':device,'fonts':'fonts/'});
kmw['util']['setOption']('attachType','manual');
kmw['oninserttext'] = insertText;
@ -38,7 +38,7 @@
if(h > 0) {
oskHeight = h;
}
var kmw=window['tavultesoft']['keymanweb'];
var kmw=window['keyman'];
kmw['correctOSKTextSize']();
}
@ -63,7 +63,8 @@
// Query KMW if a given keyboard uses chiral modifiers.
function setIsChiral(keyboardProperties) {
var name = typeof(keyboardProperties.internalName) == "undefined" ? keyboardProperties.keyboardName : keyboardProperties.internalName;
var isChiral = tavultesoft.keymanweb.isChiral(name);
var kmw=window['keyman'];
var isChiral = kmw.isChiral(name);
window.console.log('For keyboard "' + name + '"');
window.console.log('setIsChiral = ' + isChiral);
@ -74,7 +75,9 @@
function setKeymanLanguage(keyboardName, internalName, languageName, langId, version, font, oskFont) {
//oskFont.files = ['NotoSansSyriacWestern-Regular.svg#NotoSansSyriacWesternRegular'];
//window.console.log('oskFonts = '+JSON.stringify(oskFont));
var kmw=window['tavultesoft']['keymanweb'];
var kmw=window['keyman'];
var kbdInterface=kmw['interface'];
// Defaults for mising arguments
switch (arguments.length) {
case 1:
@ -94,7 +97,7 @@
break;
}
kmw['KRS']({KN:keyboardName,KI:'Keyboard_'+internalName,KLC:langId,KL:languageName,
kbdInterface.registerStub({KN:keyboardName,KI:'Keyboard_'+internalName,KLC:langId,KL:languageName,
KF:internalName+'-'+version+'.js',KFont:font,KOskFont:oskFont});
kmw['setActiveKeyboard']('Keyboard_'+internalName,langId);
kmw['osk']['show'](true);
@ -106,7 +109,8 @@
}
function resetContext() {
tavultesoft.keymanweb.resetContext();
var kmw=window['keyman'];
kmw.resetContext();
}
function updateKMText(text) {
@ -114,14 +118,14 @@
text = '';
}
var ta = document.getElementById('ta');
var kmw = window['tavultesoft']['keymanweb'];
var kmw = window['keyman'];
ta.value = text;
kmw['setActiveElement'](ta);
}
function updateKMSelectionRange(start, end) {
var ta = document.getElementById('ta');
var kmw = window['tavultesoft']['keymanweb'];
var kmw = window['keyman'];
ta.selectionStart = ta._KeymanWebSelectionStart = start;
ta.selectionEnd = ta._KeymanWebSelectionEnd = end;
kmw['setActiveElement'](ta);
@ -175,22 +179,22 @@
function showHelpBubble() {
fragmentToggle = (fragmentToggle + 1) % 100;
var kmw = window['tavultesoft']['keymanweb'];
var kmw = window['keyman'];
var pos = kmw['touchMenuPos']();
window.console.log('showHelpBubble ' + pos);
window.location.hash = 'showHelpBubble-' + fragmentToggle + '+keyPos=' + pos;
}
function executePopupKey(keyID, keyText) {
var kmw=window['tavultesoft']['keymanweb'];
var kmw=window['keyman'];
// KMW only needs keyID to process the popup key. keyText merely logged to console
window.console.log('executePopupKey('+keyID+'); keyText: ' + keyText);
kmw['executePopupKey'](keyID);
}
function executeHardwareKeystroke(code, shift, lstates) {
var kmw=window['tavultesoft']['keymanweb'];
var kmw=window['keyman'];
window.console.log('executeHardwareKeystroke:('+code+', ' + shift + ', ' + lstates + ');');
try {
var r = kmw['executeHardwareKeystroke'](code, shift, lstates);
@ -201,7 +205,7 @@
}
function popupVisible(value) {
var kmw=window['tavultesoft']['keymanweb'];
var kmw=window['keyman'];
kmw['popupVisible'](value);
}

View file

@ -12,8 +12,8 @@
function Keyboard_chirality() {
this.KI = "Keyboard_chirality";
this.KN = "Development Chirality Test Keyboard";
this.KMBM = 0x001F;
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", ",", ".", "/", "", "", "", "", "", ""),
@ -42,6 +42,7 @@ function Keyboard_chirality() {
};
this.g0 = function (t, e) {
var k = KeymanWeb, r = 0, m = 0;
var osk = keyman.osk;
// Handwritten time!
var kls = this.KV.KLS;
@ -52,7 +53,7 @@ function Keyboard_chirality() {
for(var i = 0; i < layers.length; i++) {
// Obtain the modifier code to match for the selected layer.
// The following uses a non-public property potentially subject to change in the future.
var modCode = k.osk.modifierCodes['VIRTUAL_KEY'] | k.osk.getModifierState(layers[i]);
var modCode = osk.modifierCodes['VIRTUAL_KEY'] | osk.getModifierState(layers[i]);
var layer = layers[i];
for(var key=0; key < kls[layer].length; key++) {
@ -61,9 +62,9 @@ function Keyboard_chirality() {
if(keySymbol == "K_*") {
continue;
} else if(kls[layer][key] != '') {
if (k.KKM(e, modCode, k.osk.keyCodes[keySymbol])) {
if (k.KKM(e, modCode, osk.keyCodes[keySymbol])) {
r = m = 1;
if(k.KSM(e, k.osk.modifierCodes['CAPS'])) {
if(k.KSM(e, osk.modifierCodes['CAPS'])) {
k.KO(0, t, kls[layer][key].toUpperCase());
} else {
k.KO(0, t, kls[layer][key]);

View file

@ -43,6 +43,7 @@
C0452BAB1F9F1FE10064431A /* Language.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0452BAA1F9F1FE10064431A /* Language.swift */; };
C0452BAD1F9F21270064431A /* Keyboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0452BAC1F9F21270064431A /* Keyboard.swift */; };
C0452BAF1F9F22A80064431A /* Font.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0452BAE1F9F22A80064431A /* Font.swift */; };
C055E6EB1F99ED090035C2DD /* RegisteredFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = C055E6EA1F99ED090035C2DD /* RegisteredFont.swift */; };
C06085B41F9485E40057E5B9 /* UIButton+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = C06085B31F9485E40057E5B9 /* UIButton+Helpers.swift */; };
C06D372F1F81F4E100F61AE0 /* KeymanEngine.h in Headers */ = {isa = PBXBuildFile; fileRef = C06D372D1F81F4E100F61AE0 /* KeymanEngine.h */; settings = {ATTRIBUTES = (Public, ); }; };
C06D37331F81F5C300F61AE0 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = CECB38941F2199BC0098882F /* Reachability.m */; };
@ -169,6 +170,8 @@
C0452BAC1F9F21270064431A /* Keyboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Keyboard.swift; sourceTree = "<group>"; };
C0452BAE1F9F22A80064431A /* Font.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Font.swift; sourceTree = "<group>"; };
C04C2A6C1F6B7D9A00BA42B6 /* LanguageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LanguageViewController.swift; sourceTree = "<group>"; };
C055E6EA1F99ED090035C2DD /* RegisteredFont.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift;
path = RegisteredFont.swift; sourceTree = "<group>"; };
C06085B31F9485E40057E5B9 /* UIButton+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIButton+Helpers.swift"; sourceTree = "<group>"; };
C06D372B1F81F4E100F61AE0 /* KeymanEngine.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = KeymanEngine.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C06D372D1F81F4E100F61AE0 /* KeymanEngine.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KeymanEngine.h; sourceTree = "<group>"; };
@ -376,6 +379,7 @@
C0D3F35D1F9F33490055C7CF /* Options.swift */,
C0D3F35F1F9F3AD80055C7CF /* InstallableKeyboard.swift */,
C007C4641F9F52D8006461B9 /* LanguagesAPICall.swift */,
C055E6EA1F99ED090035C2DD /* RegisteredFont.swift */,
);
path = Model;
sourceTree = "<group>";
@ -606,7 +610,7 @@
F243887514BBD43000A3E055 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0900;
LastUpgradeCheck = 0910;
ORGANIZATIONNAME = "SIL International";
TargetAttributes = {
98F9D6961954112F0087AA43 = {
@ -763,6 +767,7 @@
C0EF3E7B1F95B65300CE9BD4 /* KeymanWebViewDelegate.swift in Sources */,
C06D37411F81F5C400F61AE0 /* LanguageViewController.swift in Sources */,
C06D37421F81F5C400F61AE0 /* KeyboardPickerButton.swift in Sources */,
C055E6EB1F99ED090035C2DD /* RegisteredFont.swift in Sources */,
C0324B931F87689B00AF3785 /* KeymanURLProtocol.swift in Sources */,
C0452BAB1F9F1FE10064431A /* Language.swift in Sources */,
C06D37431F81F5C400F61AE0 /* KeyboardPickerBarButtonItem.swift in Sources */,
@ -907,7 +912,6 @@
isa = XCBuildConfiguration;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
ARCHS = "$(ARCHS_STANDARD)";
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
@ -919,7 +923,7 @@
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
@ -961,7 +965,6 @@
isa = XCBuildConfiguration;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
ARCHS = "$(ARCHS_STANDARD)";
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
@ -973,7 +976,7 @@
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "iPhone Distribution: Summer Institute of Linguistics, Inc (SIL) (3YE4W86L3G)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
@ -1008,11 +1011,6 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F27FCAF6157FD95E00FBBA20 /* Keyman-lib.xcconfig */;
buildSettings = {
ARCHS = (
"$(ARCHS_STANDARD)",
x86_64,
i386,
);
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_NAME = "$(TARGET_NAME)";
@ -1024,11 +1022,6 @@
isa = XCBuildConfiguration;
baseConfigurationReference = F27FCAF6157FD95E00FBBA20 /* Keyman-lib.xcconfig */;
buildSettings = {
ARCHS = (
"$(ARCHS_STANDARD)",
x86_64,
i386,
);
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
PRODUCT_NAME = "$(TARGET_NAME)";
VALID_ARCHS = "arm64 armv7s armv7 x86_64 i386";
@ -1040,7 +1033,6 @@
baseConfigurationReference = 6C0A140E151EA930007FA4AD /* Debug.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD)";
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
@ -1082,7 +1074,6 @@
baseConfigurationReference = 6C0A1411151EA930007FA4AD /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD)";
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;

View file

@ -15,8 +15,6 @@ public struct Key {
public static let fontFiles = "files"
// Font filename is deprecated
public static let fontFilename = "filename"
public static let fontName = "fontname"
public static let fontRegistered = "fontregistered"
public static let keyboardInfo = "keyboardInfo"
/// Array of user keyboards info list in UserDefaults

View file

@ -68,7 +68,7 @@ class KeyboardInfoViewController: UITableViewController, UIAlertViewDelegate {
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if !isCustomKeyboard {
if indexPath.row == 1 {
let url = URL(string:"http://help.keyman.com/keyboard/\(keyboardID)/\(keyboardVersion)/")!
let url = URL(string: "http://help.keyman.com/keyboard/\(keyboardID)/\(keyboardVersion)/")!
if let openURL = Manager.shared.openURL {
openURL(url)
} else {

View file

@ -30,7 +30,7 @@ public class KeyboardPickerBarButtonItem: UIBarButtonItem {
if UIDevice.current.userInterfaceIdiom == .phone {
let landscapeImagePath = keymanBundle.path(
forResource:"keyboard_icon_landscape\(retinaSuffix)", ofType: "png")!
forResource: "keyboard_icon_landscape\(retinaSuffix)", ofType: "png")!
landscapeImagePhone = UIImage(contentsOfFile: landscapeImagePath)
}
}

View file

@ -21,7 +21,7 @@ public class KeyboardPickerButton: UIButton {
setColor(UIColor(red: 0.62, green: 0.68, blue: 0.76, alpha: 1.0))
addTarget(self, action: #selector(self.showKeyboardPicker), for: .touchUpInside)
let bundlePath = Bundle(for: type(of :self)).path(forResource: "Keyman", ofType: "bundle")!
let bundlePath = Bundle(for: type(of: self)).path(forResource: "Keyman", ofType: "bundle")!
let retinaSuffix = Manager.shared.retinaScreen ? "@2x" : ""
let imagePath = Bundle(path: bundlePath)!.path(forResource: "keyboard_icon\(retinaSuffix)", ofType: "png")!

View file

@ -107,8 +107,8 @@ UIGestureRecognizerDelegate {
/// The key format is $languageID_$keyboardID. For example, "eng_european2" returns the English EuroLatin2 keyboard
public private(set) var keyboardsDictionary: [String: InstallableKeyboard] = [:]
/// Dictionary of available Keyman keyboard fonts
public private(set) var keymanFonts: [String: [String: Any]] = [:]
/// Dictionary of available Keyman keyboard fonts keyed by font filename
public private(set) var keymanFonts: [String: RegisteredFont] = [:]
/// Keyman system-wide keyboard
public let isSystemKeyboard: Bool
@ -422,7 +422,7 @@ UIGestureRecognizerDelegate {
let kb = activeUserDefaults().userKeyboard(withID: keyboardID, languageID: languageID)
?? repositoryKeyboard(withID: keyboardID, languageID: languageID)
if let filename = kb?.font?.source.first(where: { $0.hasFontExtension }) {
return keymanFonts[filename]?[Key.fontName] as? String
return keymanFonts[filename]?.name
}
return nil
}
@ -434,7 +434,7 @@ UIGestureRecognizerDelegate {
let kb = activeUserDefaults().userKeyboard(withID: keyboardID, languageID: languageID)
?? repositoryKeyboard(withID: keyboardID, languageID: languageID)
if let filename = kb?.oskFont?.source.first(where: { $0.hasFontExtension }) {
return keymanFonts[filename]?[Key.fontName] as? String
return keymanFonts[filename]?.name
}
return nil
}
@ -998,15 +998,13 @@ UIGestureRecognizerDelegate {
for fontFilename in directoryContents where fontFilename.hasFontExtension {
if let fontInfo = keymanFonts[fontFilename] {
if fontInfo[Key.fontRegistered] as? Int == 0 {
if !fontInfo.isRegistered {
if let newFontInfo = registerFont(withFilename: fontFilename) {
keymanFonts[fontFilename] = newFontInfo
}
}
} else {
if let fontInfo = registerFont(withFilename: fontFilename) {
keymanFonts[fontFilename] = fontInfo
}
} else if let fontInfo = registerFont(withFilename: fontFilename) {
keymanFonts[fontFilename] = fontInfo
}
}
}
@ -1022,16 +1020,16 @@ UIGestureRecognizerDelegate {
}
for fontFilename in directoryContents where fontFilename.hasFontExtension {
if var fontInfo = keymanFonts[fontFilename], fontInfo[Key.fontRegistered] as? Int != 0 {
if var fontInfo = keymanFonts[fontFilename], fontInfo.isRegistered {
if unregisterFont(withFilename: fontFilename) {
fontInfo[Key.fontRegistered] = 0
fontInfo.isRegistered = false
keymanFonts[fontFilename] = fontInfo
}
}
}
}
private func registerFont(withFilename fontFilename: String) -> [String: Any]? {
private func registerFont(withFilename fontFilename: String) -> RegisteredFont? {
guard let fontURL = activeFontDirectory()?.appendingPathComponent(fontFilename),
FileManager.default.fileExists(atPath: fontURL.path) else {
return nil
@ -1041,13 +1039,14 @@ UIGestureRecognizerDelegate {
kmLog("Failed to open \(fontURL)", checkDebugPrinting: false)
return nil
}
guard let font = CGFont(provider) else {
guard let font = CGFont(provider),
let cfFontName = font.postScriptName else {
kmLog("Failed to read font at \(fontURL)", checkDebugPrinting: false)
return nil
}
var didRegister: Bool = false
let fontName = font.postScriptName! as String
var didRegister = false
let fontName = cfFontName as String
if !fontExists(fontName) {
var errorRef: Unmanaged<CFError>?
didRegister = CTFontManagerRegisterFontsForURL(fontURL as CFURL, .none, &errorRef)
@ -1059,11 +1058,7 @@ UIGestureRecognizerDelegate {
kmLog("Registered font: \(fontURL)", checkDebugPrinting: true)
}
}
return [
Key.fontName: fontName,
// TODO: Check if didRegister should be true if font exists
Key.fontRegistered: didRegister ? 1 : 0
]
return RegisteredFont(name: fontName, isRegistered: didRegister)
}
private func unregisterFont(withFilename fontFilename: String) -> Bool {

View file

@ -0,0 +1,17 @@
//
// RegisteredFont.swift
// KeymanEngine
//
// Created by Gabriel Wong on 2017-10-20.
// Copyright © 2017 SIL International. All rights reserved.
//
public struct RegisteredFont {
public let name: String
public var isRegistered: Bool
public init(name: String, isRegistered: Bool) {
self.name = name
self.isRegistered = isRegistered
}
}

View file

@ -30,7 +30,7 @@
window.addEventListener('load', init, false);
function init() {
var kmw=window['tavultesoft']['keymanweb'];
var kmw=window['keyman'];
kmw.init({'app':device,'fonts':'fonts/'});
kmw['util']['setOption']('attachType','manual');
kmw['oninserttext'] = insertText;
@ -49,7 +49,7 @@
function setOskHeight(height) {
oskHeight = height;
var kmw=window['tavultesoft']['keymanweb'];
var kmw=window['keyman'];
kmw['correctOSKTextSize']();
}
@ -73,7 +73,7 @@
var keyboardOffset = 0;
function setKeymanLanguage(keyboardName,internalName,languageName,langId,version,font,oskFont) {
var kmw=window['tavultesoft']['keymanweb'];
var kmw=window['keyman'];
// Defaults for mising arguments
switch(arguments.length)
{
@ -86,7 +86,7 @@
langId='';
}
kmw['KRS']({KN:keyboardName,KI:'Keyboard_'+internalName,KLC:langId,KL:languageName,KF:internalName+'-'+version+'.js',KFont:font,KOskFont:oskFont});
kmw.interface['registerStub']({KN:keyboardName,KI:'Keyboard_'+internalName,KLC:langId,KL:languageName,KF:internalName+'-'+version+'.js',KFont:font,KOskFont:oskFont});
kmw['setActiveKeyboard']('Keyboard_'+internalName,langId);
kmw['osk']['show'](true);
}
@ -166,23 +166,14 @@
}
function langMenuPos() {
var kmw = window['tavultesoft']['keymanweb'];
var kmw = window['keyman'];
var pos = kmw['touchMenuPos']();
return pos;
}
/*
function oskRowCount() {
var rowCount = 5;
if (typeof(tavultesoft.keymanweb.osk.layers[0]) != 'undefined')
rowCount = tavultesoft.keymanweb.osk.layers[0].row.length;
return rowCount;
}*/
function setCursorRange(pos, length) {
var ta = document.getElementById('ta');
var kmw = window['tavultesoft']['keymanweb'];
var kmw = window['keyman'];
ta.selectionStart = ta._KeymanWebSelectionStart = pos;
ta.selectionEnd = ta._KeymanWebSelectionEnd = pos + length;
kmw['setActiveElement'](ta);
@ -192,19 +183,19 @@
function setKeymanVal(text) {
if(undefined == text) text = '';
var ta = document.getElementById('ta');
var kmw = window['tavultesoft']['keymanweb'];
var kmw = window['keyman'];
ta.value = text;
kmw['setActiveElement'](ta);
return ta.value;
}
function executePopupKey(keyID, keyText) {
var kmw=window['tavultesoft']['keymanweb'];
var kmw=window['keyman'];
kmw['executePopupKey'](keyID, keyText);
}
function popupVisible(value) {
var kmw=window['tavultesoft']['keymanweb'];
var kmw=window['keyman'];
kmw['popupVisible'](value);
}

View file

@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]? = nil) -> Bool {
Manager.applicationGroupIdentifier = "group.KMEI"
Manager.shared.isDebugPrintingOn = true
Manager.shared.canRemoveDefaultKeyboard = true

View file

@ -36,10 +36,7 @@ class ActivityItemProvider: UIActivityItemProvider {
case UIActivityType.postToFacebook?:
return "\(text)\n\n\(fbText)"
case UIActivityType.postToTwitter?:
if text.characters.count > 140 {
return text[..<text.index(text.startIndex, offsetBy: 140)]
}
return text
return text.prefix(140)
default:
return text
}

View file

@ -19,7 +19,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var navigationController: UINavigationController?
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]? = nil) -> Bool {
Manager.applicationGroupIdentifier = "group.KM4I"
#if DEBUG
Manager.shared.isDebugPrintingOn = true

View file

@ -125,10 +125,10 @@ class MainViewController: UIViewController, TextViewDelegate, UIActionSheetDeleg
// Check for configuration profiles/fonts to install
let kmFonts = Manager.shared.keymanFonts
var profilesByFontName = [String: String](minimumCapacity: kmFonts.count - 1)
for (key, value) in kmFonts where key != "keymanweb-osk.ttf" {
let fontName = value[Key.fontName] as! String
let type = key[key.range(of: ".", options: .backwards)!.lowerBound...]
profilesByFontName[fontName] = key.replacingOccurrences(of: type, with: ".mobileconfig")
for (filename, font) in kmFonts where filename != "keymanweb-osk.ttf" {
let fontName = font.name
let type = filename[filename.range(of: ".", options: .backwards)!.lowerBound...]
profilesByFontName[fontName] = filename.replacingOccurrences(of: type, with: ".mobileconfig")
}
let customFonts = UIFont.familyNames.filter { !systemFonts.contains($0) && !($0 == "KeymanwebOsk") }

View file

@ -17,19 +17,19 @@
NSRect rect2 = NSMakeRect(rect1.size.width, 0, rect.size.width*0.23, rect.size.height);
NSRect rect3 = NSMakeRect(rect2.origin.x + rect2.size.width, 0, rect.size.width*0.21, rect.size.height);
CGContextSetFillColorWithColor(context, [NSColor colorWithRed:246.0/255.0 green:137.0/255.0 blue:36.0/255.0 alpha:1.0].CGColor);
CGContextSetFillColorWithColor(context, [NSColor colorWithSRGBRed:246.0/255.0 green:137.0/255.0 blue:36.0/255.0 alpha:1.0].CGColor);
CGContextBeginPath(context);
CGContextAddRect(context, rect1);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFill);
CGContextSetFillColorWithColor(context, [NSColor colorWithRed:204.0/255.0 green:56.0/255.0 blue:70.0/255.0 alpha:1.0].CGColor);
CGContextSetFillColorWithColor(context, [NSColor colorWithSRGBRed:204.0/255.0 green:56.0/255.0 blue:70.0/255.0 alpha:1.0].CGColor);
CGContextBeginPath(context);
CGContextAddRect(context, rect2);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFill);
CGContextSetFillColorWithColor(context, [NSColor colorWithRed:121.0/255.0 green:195.0/255.0 blue:218.0/255.0 alpha:1.0].CGColor);
CGContextSetFillColorWithColor(context, [NSColor colorWithSRGBRed:121.0/255.0 green:195.0/255.0 blue:218.0/255.0 alpha:1.0].CGColor);
CGContextBeginPath(context);
CGContextAddRect(context, rect3);
CGContextClosePath(context);

View file

@ -164,7 +164,7 @@
[textField setBackgroundColor:[NSColor clearColor]];
[textField setAlignment:NSLeftTextAlignment];
[textField setFont:[NSFont systemFontOfSize:tableView.rowHeight*0.5]];
[textField setTextColor:[NSColor colorWithRed:0.0 green:0.0 blue:0.1 alpha:1.0]];
[textField setTextColor:[NSColor colorWithSRGBRed:0.0 green:0.0 blue:0.1 alpha:1.0]];
[textField setStringValue:[info objectForKey:@"HeaderTitle"]];
[rowView addSubview:textField];
return rowView;
@ -177,7 +177,7 @@
NSDictionary *info = [self.tableContents objectAtIndex:row];
BOOL isHeader = ([info objectForKey:@"HeaderTitle"] != nil);
if (isHeader)
[rowView setBackgroundColor:[NSColor colorWithRed:186.0/255.0 green:211.0/255.0 blue:1.0 alpha:1.0]];
[rowView setBackgroundColor:[NSColor colorWithSRGBRed:186.0/255.0 green:211.0/255.0 blue:1.0 alpha:1.0]];
}
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {

View file

@ -91,8 +91,16 @@ typedef enum {
NSUInteger index = NSNotFound;
if ((index = [value rangeOfString:@"filename="].location) != NSNotFound)
_downloadFilename = [NSString stringWithString:[value substringFromIndex:index+9]];
else if ((index = [value rangeOfString:@"url="].location) != NSNotFound)
downloadUrl = [NSURL URLWithString:[[NSString stringWithString:[value substringFromIndex:index+4]] stringByRemovingPercentEncoding]];
else if ((index = [value rangeOfString:@"url="].location) != NSNotFound) {
NSString *urlString = [NSString stringWithString:[value substringFromIndex:index+4]];
if ([urlString respondsToSelector:@selector(stringByRemovingPercentEncoding)])
urlString = [urlString stringByRemovingPercentEncoding];
else if ([urlString respondsToSelector:@selector(stringByReplacingPercentEscapesUsingEncoding:)]) {
// OS version prior to 10.9 - use this (now deprecated) method instead:
urlString = [urlString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
}
downloadUrl = [NSURL URLWithString:urlString];
}
}
if (downloadUrl && _downloadFilename) {

View file

@ -34,7 +34,7 @@
NSSize size = self.window.frame.size;
[self.window setMaxSize:NSMakeSize(size.width*1.6, size.height*1.6)];
[self.window setMinSize:NSMakeSize(size.width*0.8, size.height*0.8)];
[self.window setBackgroundColor:[NSColor colorWithRed:241.0/255.0 green:242.0/255.0 blue:242.0/255.0 alpha:1.0]];
[self.window setBackgroundColor:[NSColor colorWithSRGBRed:241.0/255.0 green:242.0/255.0 blue:242.0/255.0 alpha:1.0]];
_helpButton = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 17, 17)];
[_helpButton setTitle:@""];

View file

@ -10,6 +10,7 @@
* Refactored code paths relating to KMW's embedding in the iOS and Android apps. (#211)
* Added support for L/R Alt and Ctrl modifiers for keyboards. (#9) (#52)
* Added support for use of the Caps Lock state within keyboards if specified by a keyboard designer.
* Reworked the keyboard-interfacing API calls and base layout of KeymanWeb (#349)
* Fixed keyboard loading upon initialization, redundant cloud requests for keyboards. (#103)
* Fixed next-layer processing (#116) (#358)
* Fixed auto-attaching mode bug. (#352)

View file

@ -36,7 +36,7 @@
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
var kmw=window.tavultesoft.keymanweb;
var kmw=window.keyman;
kmw.init({
attachType:'auto',
resources:''

View file

@ -28,7 +28,7 @@
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
var kmw=window.tavultesoft.keymanweb;
var kmw=window.keyman;
kmw.init({
attachType:'auto',
resources:''
@ -45,7 +45,7 @@
<script>
function loadKeyboards()
{
var kmw=tavultesoft.keymanweb;
var kmw=keyman;
kmw.addKeyboards();
// Set US English as the default, allowing time to fully initialize

View file

@ -42,7 +42,7 @@
function loadKeyboards()
{
var kmw=tavultesoft.keymanweb;
var kmw=keyman;
// The first keyboard added will be the default keyboard for touch devices.
// For faster loading, it may be best for the default keybaord to be
@ -82,7 +82,7 @@
// Script to allow a user to add any keyboard to the keyboard menu
function addKeyboard(n)
{
var sKbd,kmw=tavultesoft.keymanweb;
var sKbd,kmw=keyman;
switch(n)
{
case 1:

View file

@ -1,111 +0,0 @@
<!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>
var kmw=window.tavultesoft.keymanweb;
kmw.init({
resources:'resources',
attachType:'manual'
});
</script>
<!-- Add keyboard management script for local selection of keyboards to use -->
<script src="./samplehdr.js"></script>
</head>
<!-- Sample page HTML -->
<body onload='loadKeyboards();'>
<h2>KeymanWeb Sample Page - Uncompiled Source</h2>
<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'></div>
<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'/>
<!-- The following elements show how the language menu can be dynamically extended at any time -->
<h3>Add a keyboard by keyboard name:</h3>
<input type='input' id='kbd_id1' class='kmw-disabled' onkeypress="clickOnEnter(event,1);"/>
<input type='button' id='btn1' onclick='addKeyboard(1);' value='Add' />
<h3>Add a keyboard by ISO 639 language code:</h3>
<input type='input' id='kbd_id2' class='kmw-disabled' onkeypress="clickOnEnter(event,2);"/>
<input type='button' id='btn2' onclick='addKeyboard(2);' value='Add' />
<h3>Add a keyboard by language name:</h3>
<input type='input' id='kbd_id3' class='kmw-disabled' onkeypress="clickOnEnter(event,3);"/>
<input type='button' id='btn3' onclick='addKeyboard(3);' value='Add' />
<h3><a href="../samples/index.html">Return to samples home page</a></h3>
</div>
</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>

View file

@ -44,9 +44,9 @@
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
var kmw=window.tavultesoft.keymanweb;
var kmw=window.keyman;
kmw.init({
attachType:'auto',
attachType:'auto',
resources:'resources'
});
</script>

View file

@ -64,7 +64,7 @@ del %EMBED_OUTPUT%\kmw-smpstring.js 2>nul
if not exist %EMBED_OUTPUT%\kmw-smpstring.js goto fail
del kmwtemp.js 2>nul
%compilecmd% --define tavultesoft.__BUILD__=%BUILD% --externs %SOURCE%\kmwreleasestub.js --js %SOURCE%\kmwbase.js --js %SOURCE%\keymanweb.js --js %SOURCE%\kmwosk.js --js %SOURCE%\kmwembedded.js --js %SOURCE%\kmwcallback.js --js %SOURCE%\kmwkeymaps.js --js %SOURCE%\kmwlayout.js --js %SOURCE%\kmwinit.js --compilation_level SIMPLE_OPTIMIZATIONS --js_output_file kmwtemp.js --warning_level VERBOSE
%compilecmd% --define keyman.__BUILD__=%BUILD% --externs %SOURCE%\kmwreleasestub.js --js %SOURCE%\kmwbase.js --js %SOURCE%\keymanweb.js --js %SOURCE%\kmwosk.js --js %SOURCE%\kmwembedded.js --js %SOURCE%\kmwcallback.js --js %SOURCE%\kmwkeymaps.js --js %SOURCE%\kmwlayout.js --js %SOURCE%\kmwinit.js --compilation_level SIMPLE_OPTIMIZATIONS --js_output_file kmwtemp.js --warning_level VERBOSE
if not exist kmwtemp.js goto fail
echo Append SMP extensions
@ -109,7 +109,7 @@ rem Compile KeymanWeb code modules for native keymanweb use, stubbing out and re
echo Compile Keymanweb
del %WEB_OUTPUT%\kmwtemp.js 2>nul
%compilecmd% --define tavultesoft.__BUILD__=%BUILD% --externs %SOURCE%\kmwreleasestub.js --js %SOURCE%\kmwbase.js --js %SOURCE%\keymanweb.js --js %SOURCE%\kmwosk.js --js %SOURCE%\kmwnative.js --js %SOURCE%\kmwcallback.js --js %SOURCE%\kmwkeymaps.js --js %SOURCE%\kmwlayout.js --js %SOURCE%\kmwinit.js --compilation_level SIMPLE_OPTIMIZATIONS --js_output_file %WEB_OUTPUT%\kmwtemp.js --warning_level VERBOSE
%compilecmd% --define keyman.__BUILD__=%BUILD% --externs %SOURCE%\kmwreleasestub.js --js %SOURCE%\kmwbase.js --js %SOURCE%\keymanweb.js --js %SOURCE%\kmwosk.js --js %SOURCE%\kmwnative.js --js %SOURCE%\kmwcallback.js --js %SOURCE%\kmwkeymaps.js --js %SOURCE%\kmwlayout.js --js %SOURCE%\kmwinit.js --compilation_level SIMPLE_OPTIMIZATIONS --js_output_file %WEB_OUTPUT%\kmwtemp.js --warning_level VERBOSE
if not exist %WEB_OUTPUT%\kmwtemp.js goto fail
echo Append SMP string extensions to Keymanweb

View file

@ -134,7 +134,7 @@ if [ $BUILD_EMBED = true ]; then
assert $EMBED_OUTPUT/kmw-smpstring.js
rm kmwtemp.js 2>/dev/null
$compilecmd --define tavultesoft.__BUILD__=$BUILD --externs $SOURCE/kmwreleasestub.js --js $SOURCE/kmwbase.js --js $SOURCE/keymanweb.js --js $SOURCE/kmwosk.js --js $SOURCE/kmwembedded.js --js $SOURCE/kmwcallback.js --js $SOURCE/kmwkeymaps.js --js $SOURCE/kmwlayout.js --js $SOURCE/kmwinit.js --compilation_level SIMPLE_OPTIMIZATIONS --js_output_file kmwtemp.js --warning_level VERBOSE
$compilecmd --define keyman.__BUILD__=$BUILD --externs $SOURCE/kmwreleasestub.js --js $SOURCE/kmwbase.js --js $SOURCE/keymanweb.js --js $SOURCE/kmwosk.js --js $SOURCE/kmwembedded.js --js $SOURCE/kmwcallback.js --js $SOURCE/kmwkeymaps.js --js $SOURCE/kmwlayout.js --js $SOURCE/kmwinit.js --compilation_level SIMPLE_OPTIMIZATIONS --js_output_file kmwtemp.js --warning_level VERBOSE
assert kmwtemp.js
echo Append SMP extensions
@ -179,7 +179,7 @@ if [ $BUILD_COREWEB = true ]; then
# Compile KeymanWeb code modules for native keymanweb use, stubbing out and removing references to debug functions
echo Compile Keymanweb
rm $WEB_OUTPUT/kmwtemp.js 2>/dev/null
$compilecmd --define tavultesoft.__BUILD__=$BUILD --externs $SOURCE/kmwreleasestub.js --js $SOURCE/kmwbase.js --js $SOURCE/keymanweb.js --js $SOURCE/kmwosk.js --js $SOURCE/kmwnative.js --js $SOURCE/kmwcallback.js --js $SOURCE/kmwkeymaps.js --js $SOURCE/kmwlayout.js --js $SOURCE/kmwinit.js --compilation_level SIMPLE_OPTIMIZATIONS --js_output_file $WEB_OUTPUT/kmwtemp.js --warning_level VERBOSE
$compilecmd --define keyman.__BUILD__=$BUILD --externs $SOURCE/kmwreleasestub.js --js $SOURCE/kmwbase.js --js $SOURCE/keymanweb.js --js $SOURCE/kmwosk.js --js $SOURCE/kmwnative.js --js $SOURCE/kmwcallback.js --js $SOURCE/kmwkeymaps.js --js $SOURCE/kmwlayout.js --js $SOURCE/kmwinit.js --compilation_level SIMPLE_OPTIMIZATIONS --js_output_file $WEB_OUTPUT/kmwtemp.js --warning_level VERBOSE
assert $WEB_OUTPUT/kmwtemp.js
echo Append SMP string extensions to Keymanweb

View file

@ -6,7 +6,7 @@
// If KMW is already initialized, the KMW script has been loaded more than once. We wish to prevent resetting the
// KMW system, so we use the fact that 'initialized' is only 1 / true after all scripts are loaded for the initial
// load of KMW.
if(!window['tavultesoft']['keymanweb']['initialized']) {
if(!window['keyman']['initialized']) {
/******************************************************************
* Main Keyman Web Module
@ -18,7 +18,8 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
(function()
{
// Declare KeymanWeb, OnScreen Keyboard and Util objects
var keymanweb=window['tavultesoft']['keymanweb'],osk=keymanweb['osk'],util=keymanweb['util'],device=util.device;
var keymanweb=window['keyman'],osk=keymanweb['osk'],util=keymanweb['util'],device=util.device;
var kbdInterface=keymanweb['interface'];
/**
* Function debug
@ -1510,7 +1511,7 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
tFlag,Lscript = util._CreateElement('SCRIPT');
URL=URL+((arguments.length > 1) && byLanguage ? 'languages' : 'keyboards')
+'?jsonp=tavultesoft.keymanweb.register';
+'?jsonp=keyman.register';
// Set callback timer
tFlag='&timerid='+window.setTimeout(
@ -3133,14 +3134,14 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
// Support backspace in simulated input DIV from physical keyboard where not matched in rule I3363 (Build 301)
if(Levent.Lcode == 8 && !LeventMatched && Levent.Ltarg.className != null && Levent.Ltarg.className.indexOf('keymanweb-input') >= 0) {
keymanweb.KO(1,keymanweb._LastActiveElement,"");
kbdInterface.output(1,keymanweb._LastActiveElement,"");
}
} else {
// Mnemonic layout
if(Levent.Lcode == 8) { // I1595 - Backspace for mnemonic
keymanweb._KeyPressToSwallow = 1;
if(!keymanweb.callKeyboardStartGroup(Levent.Ltarg,Levent)) {
keymanweb.KO(1,keymanweb._LastActiveElement,""); // I3363 (Build 301)
kbdInterface.output(1,keymanweb._LastActiveElement,""); // I3363 (Build 301)
}
return false; //added 16/3/13 to fix double backspace on mnemonic layouts on desktop
}
@ -3158,7 +3159,7 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
} else {
Lch = Levent.Lcode-64;
}
keymanweb.KO(0, Levent.Ltarg, String._kmwFromCharCode(Lch)); //I3319
kbdInterface.output(0, Levent.Ltarg, String._kmwFromCharCode(Lch)); //I3319
LeventMatched = 1;
}
@ -4231,15 +4232,17 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
keymanweb.addKeyboardArray(keymanweb.deferredStubs);
// KRS stubs (legacy format registration)
for(j=0; j<keymanweb.deferredKRS.length; j++)
keymanweb.KRS(keymanweb.deferredKRS[j]);
for(j=0; j<keymanweb.deferredKRS.length; j++) {
kbdInterface.registerStub(keymanweb.deferredKRS[j]);
}
// Initialize the desktop UI
keymanweb.initializeUI()
keymanweb.initializeUI();
// Register deferred keyboards
for(j=0; j<keymanweb.deferredKR.length; j++)
keymanweb.KR(keymanweb.deferredKR[j]);
for(j=0; j<keymanweb.deferredKR.length; j++) {
kbdInterface.registerKeyboard(keymanweb.deferredKR[j]);
}
// Exit initialization here if we're using an embedded code path.
if(keymanweb.isEmbedded) {

View file

@ -3,24 +3,20 @@
Copyright 2017 SIL International
***/
var keyman = window['keyman'] || {};
/** @define {number} build counter that gets set by the build environment */
keyman.__BUILD__ = 299;
/**
* Base code: Declare tavultesoft, major component namespaces and instances, utility functions
* Base code: Declare major component namespaces, instances, and utility functions
*/
// If a copy of the script is already loaded, detect this and prevent re-initialization / data reset.
var tavultesoft = window['tavultesoft'] = window['tavultesoft'] || {};
if(!window['keyman']['loaded']) {
/** @define {number} build counter that gets set by the build environment */
tavultesoft.__BUILD__ = 299;
if(!tavultesoft['keymanweb']) {
(function()
{
// Define exposed base object
var tavultesoft = window['tavultesoft'] = {};
var keymanweb = tavultesoft['keymanweb'] = {
(function() {
var keymanweb = window['keyman'] = {
_TitleElement: null, // I1972 - KeymanWeb Titlebar should not be a link
_Enabled: 1, // Is KeymanWeb running?
_IE: 0, // browser version identification
@ -70,18 +66,19 @@ if(!tavultesoft['keymanweb']) {
modStateFlags: 0 // Tracks the present state of the physical keyboard's active modifier flags. Needed for AltGr simulation.
};
// Signals that a KMW load has occurred in order to prevent double-loading.
keymanweb['loaded'] = true;
keymanweb['initialized'] = 0;
keymanweb['build'] = tavultesoft.__BUILD__;
keymanweb['build'] = keyman.__BUILD__;
keymanweb['version'] = '10.0';
keymanweb['helpURL'] = 'http://help.keyman.com/go';
// Expose (old) KeymanWeb object for use by compiled keyboards (replaces legacy object in earlier versions)
window['KeymanWeb'] = keymanweb;
// Define public OSK, user interface and utility function objects
var util = keymanweb['util'] = {};
var osk = keymanweb['osk'] = {ready:false};
var ui = keymanweb['ui'] = {};
var kbdInterface = keymanweb['interface'] = {};
// Stub functions (defined later in code only if required)
keymanweb.setDefaultDeviceOptions = function(opt){}

File diff suppressed because it is too large Load diff

View file

@ -6,13 +6,13 @@
// If KMW is already initialized, the KMW script has been loaded more than once. We wish to prevent resetting the
// KMW system, so we use the fact that 'initialized' is only 1 / true after all scripts are loaded for the initial
// load of KMW.
if(!window['tavultesoft']['keymanweb']['initialized']) {
if(!window['keyman']['initialized']) {
/*__STARTDEBUG__*/
/*----------------------------------------------------------------------------------------------------*/
(function()
{
var keymanweb=tavultesoft['keymanweb'],util=keymanweb['util'];
var keymanweb=window['keyman'],util=keymanweb['util'],kbdInterface=keymanweb['interface'];
keymanweb._LogDebug = true; //false; // typeof(debug) == 'undefined' ? true : debug;
if(util.device.formFactor == 'phone')return; // I3363 (Build 301)
@ -168,7 +168,7 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
{
if(keymanweb._DeadKeys[Li].p > Lp) Lp = keymanweb._DeadKeys[Li].p;
}
Ls = keymanweb.KC(Lp+1, Lp+1, Pelem); Lt = '<span style="font-size: 12pt">';
Ls = kbdInterface.context(Lp+1, Lp+1, Pelem); Lt = '<span style="font-size: 12pt">';
if(Ls !== false && Ls._kmwLength() > Lp) //I3319
{
/* We want to show the previous character in the context */
@ -219,7 +219,7 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
if(keymanweb._DeadKeys[Li].p > Lp) Lp = keymanweb._DeadKeys[Li].p;
}
var Ls = keymanweb.KC(Lp, Lp, Pelem);
var Ls = kbdInterface.context(Lp, Lp, Pelem);
Lt = keymanweb._DebugDepth + ' &nbsp; Context='+Ls+'<br>';
for(Li = 0; Li < keymanweb._DeadKeys.length; Li++)

View file

@ -9,7 +9,8 @@
(function() {
// Declare KeymanWeb and related objects
var keymanweb=window['tavultesoft']['keymanweb'],osk=keymanweb['osk'],util=keymanweb['util'],device=util.device;
var keymanweb=window['keyman'],osk=keymanweb['osk'],util=keymanweb['util'],device=util.device;
var kbdInterface=keymanweb['interface'];
// Allow definition of application name
keymanweb.options['app']='';
@ -532,16 +533,16 @@
*/
keymanweb.processDefaultMapping = function(code, shift, Lelem, keyName) {
if (code == osk.keyCodes.K_SPACE) {
keymanweb.KO(0, Lelem, ' ');
kbdInterface.output(0, Lelem, ' ');
return true;
}
else if (code == osk.keyCodes.K_ENTER) {
keymanweb.KO(0, Lelem, '\n');
kbdInterface.output(0, Lelem, '\n');
return true;
}
var ch = osk.defaultKeyOutput(keyName, code, shift);
if(ch) {
keymanweb.KO(0, Lelem, ch);
kbdInterface.output(0, Lelem, ch);
return true;
}

View file

@ -10,18 +10,16 @@
/* */
/********************************************************/
(function()
{
(function() {
// Declare KeymanWeb object
var keymanweb=window['tavultesoft']['keymanweb'];
var keymanweb=window['keyman'];
// We don't want to instantly init() in case this code is used via bookmarklet.
var readyStateCheckInterval = window.setInterval(function() {
if (document.readyState === "complete")
{
if (document.readyState === "complete") {
window.clearInterval(readyStateCheckInterval);
keymanweb.init(null);
}
}, 10);
}, 10);
})();

View file

@ -6,16 +6,15 @@
// If KMW is already initialized, the KMW script has been loaded more than once. We wish to prevent resetting the
// KMW system, so we use the fact that 'initialized' is only 1 / true after all scripts are loaded for the initial
// load of KMW.
if(!window['tavultesoft']['keymanweb']['initialized']) {
if(!window['keyman']['initialized']) {
/**
* Cross-browser compatibility keymaps
*/
(function()
{
(function() {
// Declare KeymanWeb object
var keymanweb=window['tavultesoft']['keymanweb'];
var keymanweb=window['keyman'];
/* I732 START - 13/03/2007 MCD: Swedish: Start mapping of keystroke to US keyboard #2 */
/* I732 START - 13/03/2007 MCD: Swedish: Start mapping of keystroke to US keyboard #2 */
var ffie = keymanweb._VKMap_FF_IE = {};
//ffie['k109'] = 189; // - // These two number-pad VK rules are *not* correct for more recent FF! JMD 8/11/12
@ -148,7 +147,7 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
s1['k191'] = 63;
keymanweb._USCharCode = [s0,s1];
/**
* Function _USKeyCodeToCharCode
* Scope Private
@ -156,10 +155,9 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
* @return {number} Character code
* Description Translate keyboard codes to standard US layout codes
*/
keymanweb._USKeyCodeToCharCode = function(Levent)
{
keymanweb._USKeyCodeToCharCode = function(Levent) {
return keymanweb._USCharCode[Levent.Lmodifiers & 0x10 ? 1 : 0]['k'+Levent.Lcode];
};
})();
})();
}

View file

@ -2,8 +2,8 @@
KeymanWeb 10.0
Copyright 2017 SIL International
***/
if (!window['tavultesoft']['keymanweb']['initialized']) {
window['tavultesoft']['keymanweb']['dfltLayout'] = {
if (!window['keyman']['initialized']) {
window['keyman']['dfltLayout'] = {
"desktop":
{
"font": "Tahoma,Helvetica",

View file

@ -6,7 +6,7 @@
// If KMW is already initialized, the KMW script has been loaded more than once. We wish to prevent resetting the
// KMW system, so we use the fact that 'initialized' is only 1 / true after all scripts are loaded for the initial
// load of KMW.
if(!window['tavultesoft']['keymanweb']['initialized']) {
if(!window['keyman']['initialized']) {
/*****************************************/
/* */
/* On-Screen (Visual) Keyboard Code */
@ -14,48 +14,50 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
/*****************************************/
(function() {
// Declare KeymanWeb object
var keymanweb=window['tavultesoft']['keymanweb'],osk=keymanweb['osk'],util=keymanweb['util'],device=util.device;
var keymanweb=window['keyman'],osk=keymanweb['osk'],util=keymanweb['util'],device=util.device;
var dbg=keymanweb.debug;
// Force full initialization
keymanweb.isEmbedded = false;
keymanweb.isEmbedded = false;
/**
* Set default device options
* @param {Object} opt device options object
*/
*/
keymanweb.setDefaultDeviceOptions=function(opt) {
// Element attachment type
if(opt['attachType'] == '') opt['attachType'] = (device.touchable ? 'manual' : 'auto');
// Element attachment type
if(opt['attachType'] == '') opt['attachType'] = (device.touchable ? 'manual' : 'auto');
}
/**
* Customized wait display
*
* Customized wait display
*
* @param {string|boolean} s displayed text (or false)
*/
util.wait = function(s) {
*/
util.wait = function(s) {
// Keyboards loaded with page are initialized before the page is ready,
// so cannot use the wait indicater (and don't need it, anyway)
// Do not display if a blocking cloud server error has occurred (to prevent multiple errors)
var bg=keymanweb.waiting;
if(typeof(bg) == 'undefined' || bg == null || keymanweb.warned) return;
if(typeof(bg) == 'undefined' || bg == null || keymanweb.warned) {
return;
}
var nn=bg.firstChild.childNodes;
if(s) {
if(s) {
bg.pending=true;
window.setTimeout(function() {
if(bg.pending) {
window.scrollTo(0,0);
window.setTimeout(function() {
if(bg.pending) {
window.scrollTo(0,0);
nn[0].style.display='none';
nn[1].className='kmw-wait-text'; nn[1].innerHTML=s;
nn[1].className='kmw-wait-text'; nn[1].innerHTML=s;
nn[2].style.display='block';
bg.style.display='block';
}
},1000);
} else {
} else {
if(bg.pending) {
nn[1].innerHTML='';
nn[1].innerHTML='';
bg.pending=false; bg.style.display='none';
}
}
@ -64,7 +66,7 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
// Get default style sheet path
keymanweb.getStyleSheetPath=function(ssName) {
var ssPath = util['getOption']('resources')+'osk/'+ssName;
return ssPath;
return ssPath;
}
/**
@ -97,7 +99,11 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
*/
keymanweb.KC_ = function(n, ln, Pelem) {
var Ldv, tempContext = '';
if(Pelem.body) var Ldoc=Pelem; else var Ldoc=Pelem.ownerDocument; // I1481 - use Ldoc to get the ownerDocument when no selection is found
if(Pelem.body) {
var Ldoc=Pelem;
} else {
var Ldoc=Pelem.ownerDocument; // I1481 - use Ldoc to get the ownerDocument when no selection is found
}
if(device.touchable) {
tempContext = keymanweb.getTextBeforeCaret(Pelem);

View file

@ -6,18 +6,17 @@
// If KMW is already initialized, the KMW script has been loaded more than once. We wish to prevent resetting the
// KMW system, so we use the fact that 'initialized' is only 1 / true after all scripts are loaded for the initial
// load of KMW.
if(!window['tavultesoft']['keymanweb']['initialized']) {
if(!window['keyman']['initialized']) {
/*****************************************/
/* */
/* On-Screen (Visual) Keyboard Code */
/* */
/*****************************************/
(function()
{
(function() {
// Declare KeymanWeb and member objects
var keymanweb=window['tavultesoft']['keymanweb'], osk=keymanweb['osk'],
util=keymanweb['util'],device=util.device,dbg=keymanweb.debug;
var keymanweb=window['keyman'], osk=keymanweb['osk'], util=keymanweb['util'], device=util.device, dbg=keymanweb.debug;
var kbdInterface=keymanweb['interface'];
// Define Keyman Developer modifier bit-flags (exposed for use by other modules)
osk.modifierCodes = {
@ -965,7 +964,7 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
switch(keyName)
{
case 'K_BKSP': //Only desktop UI, not touch devices. TODO: add repeat while mouse down for desktop UI
keymanweb.KO(1,keymanweb._LastActiveElement,"");
kbdInterface.output(1,keymanweb._LastActiveElement,"");
break;
case 'K_TAB':
var bBack=(osk.layerId == 'shift');
@ -980,7 +979,7 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
case 'K_ENTER':
// Insert new line in text area fields
if(Lelem.nodeName == 'TEXTAREA' || (typeof Lelem.base != 'undefined' && Lelem.base.nodeName == 'TEXTAREA'))
keymanweb.KO(0, Lelem, '\n');
kbdInterface.output(0, Lelem, '\n');
// Or move to next field from TEXT fields
else
{
@ -996,7 +995,7 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
}
break;
case 'K_SPACE':
keymanweb.KO(0, Lelem, ' ');
kbdInterface.output(0, Lelem, ' ');
break;
case 'K_CAPS':
case 'K_NUMLOCK':
@ -1007,7 +1006,9 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
default:
// The following is physical layout dependent, so should be avoided if possible. All keys should be mapped.
var ch = osk.defaultKeyOutput(keyName,Lkc.Lcode,keyShiftState);
if(ch)keymanweb.KO(0, Lelem, ch);
if(ch) {
kbdInterface.output(0, Lelem, ch);
}
}
}
@ -2391,12 +2392,13 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
// Get nearest key if touching a hidden key or the end of a key row
if((key && (key.className.indexOf('key-hidden') >= 0))
|| t.className.indexOf('kmw-key-row') >= 0)
{
|| t.className.indexOf('kmw-key-row') >= 0) {
key = osk.findNearestKey(e,t);
}
// Do not do anything if no key identified!
if(key == null) return;
if(key == null) {
return;
}
// Get key name (K_...) from element ID
var keyIdComponents = key.id.split('-');
@ -2412,25 +2414,19 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
osk.keyPending = null;
}
// Also backspace, to allow delete to repeat while key held
else if(keyName == 'K_BKSP')
{
keymanweb.KO(1,keymanweb._LastActiveElement,"");
else if(keyName == 'K_BKSP') {
kbdInterface.output(1,keymanweb._LastActiveElement,"");
osk.deleting = window.setTimeout(osk.repeatDelete,500);
osk.keyPending = null;
}
else
{
if(osk.keyPending)
{
} else {
if(osk.keyPending) {
osk.highlightKey(osk.keyPending,false);
osk.clickKey(osk.keyPending);
osk.clearPopup();
// Decrement the number of unreleased touch points to prevent
// sending the keystroke again when the key is actually released
osk.touchCount--;
}
else
{
} else {
// If this key has subkey, start timer to display subkeys after delay, set up release
osk.touchHold(key);
//if(key.subKeys != null) osk.subkeyDelayTimer=window.setTimeout(function(){osk.showSubKeys(key);},osk.popupDelay);
@ -2724,11 +2720,9 @@ if(!window['tavultesoft']['keymanweb']['initialized']) {
/**
* Repeat backspace as long as the backspace key is held down
**/
osk.repeatDelete = function()
{
if(osk.deleting)
{
keymanweb.KO(1,keymanweb._LastActiveElement,"");
osk.repeatDelete = function() {
if(osk.deleting) {
kbdInterface.output(1,keymanweb._LastActiveElement,"");
osk.deleting = window.setTimeout(osk.repeatDelete,100);
}
}

View file

@ -6,7 +6,7 @@
// If a UI module has been loaded, we can rely on the publically-published 'name' property
// having been set as a way to short-out a UI reload. Its parent object always exists by
// this point in the build process.
if(!window['tavultesoft']['keymanweb']['ui']['name']) {
if(!window['keyman']['ui']['name']) {
/********************************/
/* */
@ -25,7 +25,7 @@ if(!window['tavultesoft']['keymanweb']['ui']['name']) {
try {
// Declare KeymanWeb, OnScreen keyboard and Util objects
var keymanweb=window['tavultesoft']['keymanweb'],osk=keymanweb['osk'],
var keymanweb=window['keyman'],osk=keymanweb['osk'],
util=keymanweb['util'],dbg=keymanweb['debug'];
// Disable UI for touch devices

View file

@ -6,7 +6,7 @@
// If a UI module has been loaded, we can rely on the publically-published 'name' property
// having been set as a way to short-out a UI reload. Its parent object always exists by
// this point in the build process.
if(!window['tavultesoft']['keymanweb']['ui']['name']) {
if(!window['keyman']['ui']['name']) {
/********************************/
/* */
/* Floating User Interface */
@ -25,7 +25,7 @@ if(!window['tavultesoft']['keymanweb']['ui']['name']) {
try {
// Declare KeymanWeb, OnScreen keyboard and Util objects
var keymanweb=window['tavultesoft']['keymanweb'];
var keymanweb=window['keyman'];
var util=keymanweb['util'];
var osk=keymanweb['osk'];
var dbg=keymanweb['debug'];

View file

@ -6,7 +6,7 @@
// If a UI module has been loaded, we can rely on the publically-published 'name' property
// having been set as a way to short-out a UI reload. Its parent object always exists by
// this point in the build process.
if(!window['tavultesoft']['keymanweb']['ui']['name']) {
if(!window['keyman']['ui']['name']) {
/********************************/
/* */
/* Toggle User Interface Code */
@ -25,7 +25,7 @@ if(!window['tavultesoft']['keymanweb']['ui']['name']) {
try {
// Declare KeymanWeb, OnScreen Keyboard and Util objects
var keymanweb=window['tavultesoft']['keymanweb'],osk=keymanweb['osk'],util=keymanweb['util'];
var keymanweb=window['keyman'],osk=keymanweb['osk'],util=keymanweb['util'];
var dbg=keymanweb['debug'];
// Disable UI for touch devices

View file

@ -6,7 +6,7 @@
// If a UI module has been loaded, we can rely on the publically-published 'name' property
// having been set as a way to short-out a UI reload. Its parent object always exists by
// this point in the build process.
if(!window['tavultesoft']['keymanweb']['ui']['name']) {
if(!window['keyman']['ui']['name']) {
/********************************/
/* */
/* Toolbar User Interface */
@ -25,7 +25,7 @@ if(!window['tavultesoft']['keymanweb']['ui']['name']) {
try {
// Declare KeymanWeb, OnScreen keyboard and Util objects
var keymanweb=window['tavultesoft']['keymanweb'],osk=keymanweb['osk'],util=keymanweb['util'],dbg=keymanweb['debug'];
var keymanweb=window['keyman'],osk=keymanweb['osk'],util=keymanweb['util'],dbg=keymanweb['debug'];
// Disable UI for touch devices
if(util['isTouchDevice']()) throw '';

View file

@ -59,7 +59,7 @@
var attachType = GetURLParameter("mode");
var attachText = attachType ? attachType : "default";
var kmw=window.tavultesoft.keymanweb;
var kmw=window.keyman;
kmw.init({
attachType: attachType ? attachType : '',
resources:'resources'

View file

@ -1,6 +1,6 @@
function loadKeyboards()
{
var kmw=tavultesoft.keymanweb;
var kmw=keyman;
// The first keyboard added will be the default keyboard for touch devices.
// For faster loading, it may be best for the default keybaord to be

View file

@ -42,6 +42,7 @@ function Keyboard_chirality() {
};
this.g0 = function (t, e) {
var k = KeymanWeb, r = 0, m = 0;
var osk = keyman.osk;
// Handwritten time!
var kls = this.KV.KLS;
@ -52,7 +53,7 @@ function Keyboard_chirality() {
for(var i = 0; i < layers.length; i++) {
// Obtain the modifier code to match for the selected layer.
// The following uses a non-public property potentially subject to change in the future.
var modCode = k.osk.modifierCodes['VIRTUAL_KEY'] | k.osk.getModifierState(layers[i]);
var modCode = osk.modifierCodes['VIRTUAL_KEY'] | osk.getModifierState(layers[i]);
var layer = layers[i];
for(var key=0; key < kls[layer].length; key++) {
@ -61,9 +62,9 @@ function Keyboard_chirality() {
if(keySymbol == "K_*") {
continue;
} else if(kls[layer][key] != '') {
if (k.KKM(e, modCode, k.osk.keyCodes[keySymbol])) {
if (k.KKM(e, modCode, osk.keyCodes[keySymbol])) {
r = m = 1;
if(k.KSM(e, k.osk.modifierCodes['CAPS'])) {
if(k.KSM(e, osk.modifierCodes['CAPS'])) {
k.KO(0, t, kls[layer][key].toUpperCase());
} else {
k.KO(0, t, kls[layer][key]);

View file

@ -44,7 +44,7 @@
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
var kmw=window.tavultesoft.keymanweb;
var kmw=window.keyman;
kmw.init({
attachType: 'auto',
resources:'resources'

View file

@ -1,6 +1,6 @@
function loadKeyboards()
{
var kmw=tavultesoft.keymanweb;
var kmw=keyman;
// A testing keyboard handwritten with chirality information.
kmw.addKeyboards({id:'chirality',name:'Chirality Testing',

View file

@ -36,5 +36,6 @@
<h2><a href="./issue116/">Next-layer processing testing</a></h2>
<h2><a href="./issue160/">Uxxxx code testing</a></h2>
<h2><a href="./issue271">Test page for interactions between setActiveKeyboard and the toolbar UI.</a></h2>
<p><a href="../">Return to main index.</a>
</body>
</html>

View file

@ -44,7 +44,7 @@
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
var kmw=window.tavultesoft.keymanweb;
var kmw=window.keyman;
kmw.init({
resources:'resources',
attachType:'auto'

View file

@ -44,7 +44,7 @@
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
var kmw=window.tavultesoft.keymanweb;
var kmw=window.keyman;
kmw.init({
resources:'resources',
attachType:'auto'

View file

@ -44,9 +44,10 @@
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
var kmw=window.tavultesoft.keymanweb;
var kmw=window.keyman;
kmw.init({
resources:'resources'
resources:'resources',
attachType:'auto'
});
kmw.addKeyboards(
{id:'issue160',name:'Issue 160',languages:{id:'eng',name:'English'}, filename:'./issue160-1.0.js'},

View file

@ -44,7 +44,7 @@
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
var kmw=window.tavultesoft.keymanweb;
var kmw=window.keyman;
kmw.init({
resources:'resources'
});

View file

@ -42,7 +42,7 @@
function loadKeyboards()
{
var kmw=tavultesoft.keymanweb;
var kmw=keyman;
// The first keyboard added will be the default keyboard for touch devices.
// For faster loading, it may be best for the default keybaord to be

View file

@ -44,7 +44,7 @@
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
var kmw=window.tavultesoft.keymanweb;
var kmw=window.keyman;
kmw.init({
resources:'resources',
attachType:'auto'

View file

@ -42,7 +42,7 @@
function loadKeyboards()
{
var kmw=tavultesoft.keymanweb;
var kmw=keyman;
// Add a fully-specified, locally-sourced, keyboard.
kmw.addKeyboards({id:'layered_debug_keyboard',name:'Web_Layer_Debugging',
@ -56,7 +56,7 @@
// Script to allow a user to add any keyboard to the keyboard menu
function addKeyboard(n)
{
var sKbd,kmw=tavultesoft.keymanweb;
var sKbd,kmw=keyman;
switch(n)
{
case 1:
@ -80,7 +80,7 @@
function removeKeyboard(n)
{
var sKbd=document.getElementById('kbd_id4').value, kmw=tavultesoft.keymanweb;
var sKbd=document.getElementById('kbd_id4').value, kmw=keyman;
kmw["removeKeyboards"](sKbd);
}

View file

@ -44,7 +44,7 @@
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
var kmw=window.tavultesoft.keymanweb;
var kmw=window.keyman;
kmw.init({
resources:'resources',
attachType:'auto'

View file

@ -42,7 +42,7 @@
function loadKeyboards()
{
var kmw=tavultesoft.keymanweb;
var kmw=keyman;
// The first keyboard added will be the default keyboard for touch devices.
// For faster loading, it may be best for the default keybaord to be

View file

@ -44,7 +44,7 @@
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
var kmw=window.tavultesoft.keymanweb;
var kmw=window.keyman;
kmw.init({
resources:'resources',
attachType:'auto'

View file

@ -42,7 +42,7 @@
function loadKeyboards()
{
var kmw=tavultesoft.keymanweb;
var kmw=keyman;
// The first keyboard added will be the default keyboard for touch devices.
// For faster loading, it may be best for the default keybaord to be

View file

@ -6,7 +6,7 @@
function loadKeyboards()
{
var kmw=tavultesoft.keymanweb;
var kmw=keyman;
// We start by adding a keyboard correctly. It's best to include a 'control' in our experiment.
kmw.addKeyboards({id:'us',name:'English',languages:{id:'eng',name:'English'},

View file

@ -44,9 +44,10 @@
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
var kmw=window.tavultesoft.keymanweb;
var kmw=window.keyman;
kmw.init({
resources:'resources'
resources:'resources',
attachType:'auto'
});
</script>

View file

@ -42,7 +42,7 @@
function loadKeyboards()
{
var kmw=tavultesoft.keymanweb;
var kmw=keyman;
// The first keyboard added will be the default keyboard for touch devices.
// For faster loading, it may be best for the default keybaord to be
@ -84,7 +84,7 @@
// Script to allow a user to add any keyboard to the keyboard menu
function addKeyboard(n)
{
var sKbd,kmw=tavultesoft.keymanweb;
var sKbd,kmw=keyman;
switch(n)
{
case 1:

View file

@ -44,7 +44,7 @@
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
var kmw=window.tavultesoft.keymanweb;
var kmw=window.keyman;
kmw.init({
resources:'resources',
attachType:'manual'
@ -87,8 +87,7 @@
<input type='input' id='kbd_id3' class='kmw-disabled' onkeypress="clickOnEnter(event,3);"/>
<input type='button' id='btn3' onclick='addKeyboard(3);' value='Add' />
<h3><a href="../index.html">Return to testing home page</a></h3>
<h3><a href="./">Return to testing home page</a></h3>
</div>
</body>

View file

@ -44,7 +44,7 @@
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
var kmw=window.tavultesoft.keymanweb;
var kmw=window.keyman;
kmw.init({
attachType:'auto',
resources:'resources'
@ -87,8 +87,7 @@
<input type='input' id='kbd_id3' class='kmw-disabled' onkeypress="clickOnEnter(event,3);"/>
<input type='button' id='btn3' onclick='addKeyboard(3);' value='Add' />
<h3><a href="../index.html">Return to testing home page</a></h3>
<h3><a href="./">Return to testing home page</a></h3>
</div>
</body>

View file

@ -213,6 +213,8 @@ type
function JavaScript_String(ch: DWord): string; // I2242
function IsKeyboardVersion10OrLater: Boolean;
procedure ReportError(line: Integer; msgcode: LongWord; const text: string); // I1971
function ExpandSentinel(pwsz: PWideChar): TSentinelRecord;
function CallFunctionName(s: WideString): WideString;
@ -243,6 +245,8 @@ type
function FormatModifierAsBitflags(FBitMask: Cardinal): string;
function FormatKeyAsString(key: Integer): string;
function JavaScript_SetupDebug: string;
function JavaScript_SetupEpilog: string;
function JavaScript_SetupProlog: string;
public
function Compile(AOwnerProject: TProject; const InFile: string; const OutFile: string; Debug: Boolean; Callback: TCompilerCallback): Boolean; // I3681 // I4140 // I4688 // I4866
constructor Create;
@ -889,7 +893,30 @@ begin
if not FMnemonic then
begin
if (fkp.ShiftFlags and KMX_ISVIRTUALKEY) = KMX_ISVIRTUALKEY then
Result := fkp.ShiftFlags
begin
if IsKeyboardVersion10OrLater then
begin
// Full chiral modifier and state key support starts with KeymanWeb 10.0
Result := fkp.ShiftFlags;
end
else
begin
// Non-chiral support only and no support for state keys
if (fkp.ShiftFlags and (
KMX_LCTRLFLAG or KMX_RCTRLFLAG or KMX_LALTFLAG or KMX_RALTFLAG)) <> 0 then // I4118
begin
ReportError(fkp.Line, CWARN_ExtendedShiftFlagsNotSupportedInKeymanWeb, 'Extended shift flags LALT, RALT, LCTRL, RCTRL are not supported in KeymanWeb');
end;
if (fkp.ShiftFlags and (
KMX_CAPITALFLAG or KMX_NOTCAPITALFLAG or KMX_NUMLOCKFLAG or KMX_NOTNUMLOCKFLAG or KMX_SCROLLFLAG or KMX_NOTSCROLLFLAG)) <> 0 then // I4118
begin
ReportError(fkp.Line, CWARN_ExtendedShiftFlagsNotSupportedInKeymanWeb, 'Extended shift flags CAPS and NCAPS are not supported in KeymanWeb');
end;
Result := KMX_ISVIRTUALKEY or (Integer(fkp.ShiftFlags) and (KMX_SHIFTFLAG or KMX_CTRLFLAG or KMX_ALTFLAG));
end;
end
else
begin
Result := KMX_ISVIRTUALKEY;
@ -1580,7 +1607,9 @@ begin
fMnemonic := vMnemonic = 1;
Result := Result + Format(
'%s%s'+
'KeymanWeb.KR(new %s());%s'+
'%s%s'+
'function %s()%s'+
'{%s'+
'%s%s%s'+
@ -1592,7 +1621,10 @@ begin
'%sthis.KBVER="%s";%s'+ // I4155
'%sthis.KMBM=%s;%s'+
'%s',
[sName, nl,
[
JavaScript_SetupProlog, nl,
sName, nl,
JavaScript_SetupEpilog, nl,
sName, nl,
nl,
FTabStop, JavaScript_SetupDebug, nl,
@ -1904,6 +1936,11 @@ begin
Result := False;
end;
function TCompileKeymanWeb.IsKeyboardVersion10OrLater: Boolean;
begin
Result := fk.version >= VERSION_100;
end;
procedure TCompileKeymanWeb.CheckStoreForInvalidFunctions(key: PFILE_KEY; store: PFILE_STORE); // I1520
var
n: Integer;
@ -2160,13 +2197,37 @@ end;
///
function TCompileKeymanWeb.JavaScript_SetupDebug: string;
begin
if FDebug then
Result := 'var modCodes = tavultesoft.keymanweb.osk.modifierCodes;'+nl+
FTabStop+'var keyCodes = tavultesoft.keymanweb.osk.keyCodes;'+nl
if IsKeyboardVersion10OrLater then
begin
if FDebug then
Result := 'var modCodes = tavultesoft.keymanweb.osk.modifierCodes;'+nl+
FTabStop+'var keyCodes = tavultesoft.keymanweb.osk.keyCodes;'+nl
else
Result := '';
end
else
Result := '';
end;
function TCompileKeymanWeb.JavaScript_SetupProlog: string;
begin
if IsKeyboardVersion10OrLater then
begin
Result := 'if(parseFloat(tavultesoft.keymanweb.version) < 10) {'+nl+
FTabStop+'tavultesoft.keymanweb.util.alert("This keyboard requires KeymanWeb 10.0 or later");'+nl+
'} else {';
end
else
Result := '';
end;
function TCompileKeymanWeb.JavaScript_SetupEpilog: string;
begin
if IsKeyboardVersion10OrLater then
Result := '}'
else
Result := '';
end;
///
/// Converts a modifier bit mask integer into its component bit flags
///
@ -2205,21 +2266,27 @@ begin
//TODO: We need to think about mnemonic layouts which are incompletely supported at present
//tavultesoft.keymanweb.osk.
Result := '';
for i := 0 to High(mask) do
if IsKeyboardVersion10OrLater then
begin
if FBitMask and (1 shl i) <> 0 then
// This depends on flags defined in KeymanWeb 10.0
Result := '';
for i := 0 to High(mask) do
begin
if Result <> '' then Result := Result + ' | ';
Result := Result + 'modCodes.'+mask[i];
if FBitMask and (1 shl i) <> 0 then
begin
if Result <> '' then Result := Result + ' | ';
Result := Result + 'modCodes.'+mask[i];
end;
end;
end;
if Result = '' then
Result := '0';
if Result = '' then
Result := '0';
Result := Result + ' /* 0x' + IntToHex(FBitMask, 4) + ' */';
Result := Result + ' /* 0x' + IntToHex(FBitMask, 4) + ' */'
end
else
Result := '0x'+IntToHex(FBitMask, 4);
end;
///
@ -2231,9 +2298,15 @@ end;
///
function TCompileKeymanWeb.FormatKeyAsString(key: Integer): string;
begin
if (key <= 255) and (KMWVKeyNames[key] <> '')
then Result := 'keyCodes.'+KMWVKeyNames[key]+ ' /* 0x' + IntToHex(key, 2) + ' */'
else Result := '0x' + IntToHex(key, 2);
if IsKeyboardVersion10OrLater then
begin
// Depends on flags defined in KeymanWeb 10.0
if (key <= 255) and (KMWVKeyNames[key] <> '')
then Result := 'keyCodes.'+KMWVKeyNames[key]+ ' /* 0x' + IntToHex(key, 2) + ' */'
else Result := '0x' + IntToHex(key, 2);
end
else
Result := '0x' + IntToHex(key, 2);
end;
///

View file

@ -119,7 +119,7 @@
<a href='' id='install_link'>Install Keyboard into native Keyman</a>
</div>
<script>
tavultesoft.keymanweb.init({
keyman.init({
ui:'button',
resources:'/resource/',
keyboards:'/keyboard/',
@ -127,20 +127,20 @@
attachType:'auto'
});
tavultesoft.keymanweb.addEventListener('keyboardchange',
keyman.addEventListener('keyboardchange',
function (p) {
//alert(p.internalName);
var nm = p.internalName.substr('Keyboard_'.length);
document.getElementById('install_link').href='keyman://localhost/open?direct=true&url='+location.protocol+'//'+location.host+'/kbinstall/'+nm+'-'+debugKeyboards[nm].version+'.json';
});
//tavultesoft.keymanweb.addEventListener
//keyman.addEventListener
window.onload = function() {
window.setTimeout(
function () {
//document.getElementById('ta1').focus();
tavultesoft.keymanweb.moveToElement('ta1');
keyman.moveToElement('ta1');
}, 10);
}
</script>

View file

@ -3,6 +3,7 @@
## 10.0 alpha
* Keyman Developer moved to open source (#121)
* KeymanWeb is now continuously integrated with Developer, ensuring that each update uses the most current version possible (#122)
- Additional KeymanWeb compatibility fixes (#349)
* Keyman Developer compiler now generates keyboards that distinguish left and right ctrl/alt (#313)
* Keyman Developer visual editors now supports keyboards that distinguish left and right ctrl/alt for web/mobile targets (#342)
* The `&version` store is now optional and the compiler will determine and report on the minimum version required if it is not present (#334)

View file

@ -1254,7 +1254,9 @@ DWORD ProcessSystemStore(PFILE_KEYBOARD fk, DWORD SystemID, PFILE_STORE sp)
case TSS_VERSION:
if((fk->dwFlags & KF_AUTOMATICVERSION) == 0) return CERR_VersionAlreadyIncluded;
p = sp->dpString;
if(*p < '5') AddWarning(CWARN_OldVersion);
if (wcstof(p, NULL) < 5.0) {
AddWarning(CWARN_OldVersion);
}
if(wcsncmp(p, L"3.0", 3) == 0) fk->version = VERSION_50; //0x0a0b000n= a.bn
else if(wcsncmp(p, L"3.1", 3) == 0) fk->version = VERSION_50; //all versions < 5.0
@ -1266,7 +1268,8 @@ DWORD ProcessSystemStore(PFILE_KEYBOARD fk, DWORD SystemID, PFILE_STORE sp)
else if(wcsncmp(p, L"7.0", 3) == 0) fk->version = VERSION_70;
else if(wcsncmp(p, L"8.0", 3) == 0) fk->version = VERSION_80;
else if(wcsncmp(p, L"9.0", 3) == 0) fk->version = VERSION_90;
else return CERR_InvalidVersion;
else if (wcsncmp(p, L"10.0", 4) == 0) fk->version = VERSION_100;
else return CERR_InvalidVersion;
if(fk->version < VERSION_60) FOldCharPosMatching = TRUE;
@ -2251,6 +2254,16 @@ DWORD GetXString(PFILE_KEYBOARD fk, PWSTR str, PWSTR token, PWSTR output, int ma
if ((sFlag & (LCTRLFLAG | LALTFLAG)) && (sFlag & (RCTRLFLAG | RALTFLAG))) {
AddWarning(CWARN_MixingLeftAndRightModifiers);
}
// If we use chiral modifiers, or we use state keys, and we target web in the keyboard, and we don't manually specify a keyboard version, bump the minimum
// version to 10.0. This makes an assumption that if we are using these features in a keyboard and it has no version specified, that we want to use the features
// in the web target platform, even if there are platform() rules excluding this possibility. In that (rare) situation, the keyboard developer should simply specify
// the &version to be 9.0 or whatever to avoid this behaviour.
if (sFlag & (LCTRLFLAG | LALTFLAG | RCTRLFLAG | RALTFLAG | CAPITALFLAG | NOTCAPITALFLAG | NUMLOCKFLAG | NOTNUMLOCKFLAG | SCROLLFLAG | NOTSCROLLFLAG) &&
CompileTarget == CKF_KEYMANWEB &&
fk->dwFlags & KF_AUTOMATICVERSION) {
VERIFY_KEYBOARD_VERSION(fk, VERSION_100, 0);
}
//printf("sFlag: %x\n", sFlag);
tstr[mx++] = UC_SENTINEL;

View file

@ -29,9 +29,7 @@ const
SKeymanVersion = SKeymanVersion100;
// At present, we have no features in version 10 of Keyman that are not in
// version 9, so we can force version 9 for keyboards for back-compat
SKeymanKeyboardVersion = SKeymanVersion90;
SKeymanKeyboardVersion = SKeymanVersion100;
SKeymanInstallerComponentCode = '{C289B903-7EE8-49C7-B186-BE98259EC540}';
implementation

View file

@ -83,6 +83,22 @@ type
PKeyboardInfo = ^TKeyboardInfo;
const
VERSION_30 = $00000300;
VERSION_31 = $00000301;
VERSION_32 = $00000302;
VERSION_40 = $00000400;
VERSION_50 = $00000500;
VERSION_501 = $00000501;
VERSION_60 = $00000600;
VERSION_70 = $00000700;
VERSION_80 = $00000800;
VERSION_90 = $00000900;
VERSION_100 = $00000A00;
VERSION_MIN = VERSION_50;
VERSION_MAX = VERSION_100;
const
HK_ALT = $00010000;
HK_CTRL = $00020000;

View file

@ -68,9 +68,10 @@
#define VERSION_70 0x00000700
#define VERSION_80 0x00000800
#define VERSION_90 0x00000900
#define VERSION_100 0x00000A00
#define VERSION_MIN VERSION_50
#define VERSION_MAX VERSION_90
#define VERSION_MAX VERSION_100
/*
Special flag for WM_CHAR/WM_KEY???/WM_SYSKEY???: says that key has been

View file

@ -0,0 +1,3 @@
*.kmx
*.js
*.json

View file

@ -0,0 +1,10 @@
store(&VERSION) '10.0'
store(&NAME) 'Version 10 Chiral'
store(&TARGETS) 'any'
begin Unicode > use(main)
group(main) using keys
+ [LALT K_A] > 'LALT K_A'

View file

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<KeymanDeveloperProject>
<Options>
<BuildPath></BuildPath>
<CompilerWarningsAsErrors>False</CompilerWarningsAsErrors>
<WarnDeprecatedCode>True</WarnDeprecatedCode>
</Options>
<Files>
<File>
<ID>id_9572b9cbe3b74bafc127d47ca531dad4</ID>
<Filename>version10chiral.kmn</Filename>
<Filepath>version10chiral.kmn</Filepath>
<FileVersion>1.0</FileVersion>
<FileType>.kmn</FileType>
<Details>
<Name>Version 10 Chiral</Name>
</Details>
</File>
<File>
<ID>id_1743b3bf01d8aeb93df498c08ca4db46</ID>
<Filename>version10nonchiral.kmn</Filename>
<Filepath>version10nonchiral.kmn</Filepath>
<FileVersion>1.0</FileVersion>
<FileType>.kmn</FileType>
<Details>
<Name>Version 10 Non-Chiral</Name>
</Details>
</File>
<File>
<ID>id_9e738c3aaaf2c7c392b5c242c5682eeb</ID>
<Filename>version9chiral.kmn</Filename>
<Filepath>version9chiral.kmn</Filepath>
<FileVersion>1.0</FileVersion>
<FileType>.kmn</FileType>
<Details>
<Name>Version 9 Chiral</Name>
</Details>
</File>
<File>
<ID>id_491347ca21b6f633239efa7d7a0a1f8b</ID>
<Filename>version9nonchiral.kmn</Filename>
<Filepath>version9nonchiral.kmn</Filepath>
<FileVersion>1.0</FileVersion>
<FileType>.kmn</FileType>
<Details>
<Name>Version 9 non-chiral</Name>
</Details>
</File>
</Files>
</KeymanDeveloperProject>

View file

@ -0,0 +1,9 @@
store(&VERSION) '10.0'
store(&NAME) 'Version 10 Non-Chiral'
store(&TARGETS) 'any'
begin Unicode > use(main)
group(main) using keys
+ [ALT K_A] > 'ALT K_A'

View file

@ -0,0 +1,10 @@
c Should build with warnings or errors
store(&VERSION) '9.0'
store(&NAME) 'Version 9 Chiral'
store(&TARGETS) 'any'
begin Unicode > use(main)
group(main) using keys
+ [LALT K_A] > 'LALT K_A'

View file

@ -0,0 +1,9 @@
store(&VERSION) '9.0'
store(&NAME) 'Version 9 non-chiral'
store(&TARGETS) 'any'
begin Unicode > use(main)
group(main) using keys
+ [ALT K_A] > 'ALT K_A'