Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/developer/10319-remove-old-…
Browse files Browse the repository at this point in the history
…escape-epic-ldml' into feat/core/10369-marker-sequence-again-epic-ldml
  • Loading branch information
srl295 committed Jan 18, 2024
2 parents b0fd4f4 + e4e7d9f commit 94dbff9
Show file tree
Hide file tree
Showing 61 changed files with 1,189 additions and 679 deletions.
14 changes: 14 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Keyman Version History

## 17.0.246 alpha 2024-01-17

* fix(web): Add null check for changing the keyboard during typing (#10346)
* chore(common): Update crowdin strings for Khmer (#10411)
* docs(common): Update website README.md (#10399)
* docs(linux): Add documentation for Core API verification (#10409)
* fix(web): right-flick gesture-preview positioning (#10406)

## 17.0.245 alpha 2024-01-16

* chore(core): Ignore C++ symbols (#10386)
* fix(android): Fix OSK rotation issues (#10373)
* feat(developer): add `-m` parameter to kmc to control message severity (#10258)

## 17.0.244 alpha 2024-01-15

* refactor(core): Move `km_core_state_context_*` tests to separate file (#10375)
Expand Down
2 changes: 1 addition & 1 deletion VERSION.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17.0.245
17.0.247
1 change: 1 addition & 0 deletions android/KMAPro/kMAPro/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
android:exported="true"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize"
android:label="@string/app_name"
android:resizeableActivity="false"
android:launchMode="singleTask">

<!-- See http://stackoverflow.com/questions/1733195/android-intent-filter-for-a-particular-file-extension/2062112#2062112 -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
import android.content.res.Configuration;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Display;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
Expand Down Expand Up @@ -107,8 +110,9 @@ public boolean onTouch(View view, MotionEvent event) {
break;
case MotionEvent.ACTION_UP:
// Save the currentHeight when the user releases
int orientation = context.getResources().getConfiguration().orientation;
String keyboardHeightKey = (orientation == Configuration.ORIENTATION_LANDSCAPE) ?
Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int rotation = display.getRotation();
String keyboardHeightKey = (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) ?
KMManager.KMKey_KeyboardHeightLandscape : KMManager.KMKey_KeyboardHeightPortrait;
editor.putInt(keyboardHeightKey, currentHeight);
editor.commit();
Expand Down
7 changes: 5 additions & 2 deletions android/KMAPro/kMAPro/src/main/res/values-km-rKH/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- app_name removed in 16.0 beta. Set in build.gradle -->
<!-- Context: Menu Action -->
<string name="action_share" comment="Menu action to send text content to another app">ចែក​រំលែក</string>
<!-- Context: Menu Action -->
Expand Down Expand Up @@ -32,6 +33,8 @@
<string name="ic_text_size_up" comment="Make text bigger">ទំហំអក្សរ​កាន់តែ​ធំ</string>
<!-- Context: Text Size dialog -->
<string name="ic_text_size_down" comment="Make text smaller">ទំហំ​អក្សរ​កាន់តែ​តូច</string>
<!-- Context: Text Size dialog -->
<string name="ic_text_size_slider" comment="Adjust text size">របារំកិលទំហំអក្សរ</string>
<!-- Context: Clear Text dialog -->
<string name="all_text_will_be_cleared" comment="Erase all the text">\nអក្សរ​ទាំង​អស់​នឹង​ត្រូវ​លុបចេញ\n</string>
<!-- Context: Get Started menu -->
Expand Down Expand Up @@ -81,7 +84,7 @@
<!-- Context: Keyman Settings menu / Spacebar caption hint -->
<string name="spacebar_caption_hint_blank" comment="Spacebar caption hint - blank">កុំបង្ហាញពាក្យនៅលើគ្រាប់ចុចដកឃ្លា</string>
<!-- Context: Keyman Settings menu / Haptic feedback -->
<string name="haptic_feedback" comment="haptic feedback on key press">Vibrate when typing</string>
<string name="haptic_feedback" comment="haptic feedback on key press">ញ័រពេលវាយអក្សរ​</string>
<!-- Context: Keyman Settings menu -->
<string name="show_banner" comment="text suggestions banner">បង្ហាញ​បដា​ជានិច្ច</string>
<!-- Context: Keyman Settings menu -->
Expand Down Expand Up @@ -155,5 +158,5 @@
<!-- Context: KMP Package strings -->
<string name="minimum_keyboard_version_not_supported" comment="Notification when keyboard has functionality not supported by current Keyman"> ក្ដារចុចត្រូវការ Keyman ជំនាន់ថ្មីជាងនេះ</string>
<!-- Context: anywhere -->
<string name="unable_to_open_browser" comment="Notification when a browser activity cannot be launched">Unable to launch web browser</string>
<string name="unable_to_open_browser" comment="Notification when a browser activity cannot be launched">មិនអាចដំណើរការកម្មវិធីបើកមើលគេហទំព័រ</string>
</resources>
11 changes: 8 additions & 3 deletions android/KMEA/app/src/main/java/com/keyman/engine/KMManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@
import android.text.InputType;
import android.util.Log;
import android.view.View;
import android.view.Display;
import android.view.Surface;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
Expand Down Expand Up @@ -2016,10 +2019,12 @@ public static int getBannerHeight(Context context) {
public static int getKeyboardHeight(Context context) {
int defaultHeight = (int) context.getResources().getDimension(R.dimen.keyboard_height);
SharedPreferences prefs = context.getSharedPreferences(context.getString(R.string.kma_prefs_name), Context.MODE_PRIVATE);
int orientation = context.getResources().getConfiguration().orientation;
if (orientation == Configuration.ORIENTATION_PORTRAIT) {

Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int rotation = display.getRotation();
if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) {
return prefs.getInt(KMManager.KMKey_KeyboardHeightPortrait, defaultHeight);
} else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
} else if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
return prefs.getInt(KMManager.KMKey_KeyboardHeightLandscape, defaultHeight);
}

Expand Down
8 changes: 4 additions & 4 deletions android/KMEA/app/src/main/res/values-km-rKH/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<!-- Context: Button label -->
<string name="label_update" comment="Dialog button to update a resource">អាប់ដេត</string>
<!-- Context: No internet for updates -->
<string name="no_internet_connection" comment="Internet connection missing">No internet connection</string>
<string name="no_internet_connection" comment="Internet connection missing">មិនមាន​ការតភ្ជាប់អ៊ីធើណិត</string>
<!-- Context: Keyboard Updates -->
<string name="cannot_connect" comment="Error message when network connection fails">មិនអាច​ភ្ជាប់​ទៅម៉ាស៊ីនមេរបស់ Keyman បានទេ!</string>
<!-- Context: Keyboard Updates -->
Expand Down Expand Up @@ -126,11 +126,11 @@
<!-- Context: Model Info -->
<string name="confirm_delete_model" comment="Confirmation to delete a dictionary">តើ​អ្នក​ចង់​លុប​បញ្ជី​ពាក្យនេះ​ឬ?</string>
<!-- Context: Model Deleted -->
<string name="model_deleted" comment="Notification when a dictionary is deleted">Dictionary deleted</string>
<string name="model_deleted" comment="Notification when a dictionary is deleted">បញ្ជី​ពាក្យត្រូវបានលុប</string>
<!-- Context: Language Settings Keyboard install strings -->
<string name="keyboard_install_toast" comment="Notification when a keyboard is installed">បានដំឡើង​ក្ដារចុច %1$s</string>
<!-- Context: Language Settings Keyboard uninstall strings -->
<string name="keyboard_deleted_toast" comment="Notification when a keyboard is deleted">Keyboard deleted</string>
<string name="keyboard_deleted_toast" comment="Notification when a keyboard is deleted">ក្ដារចុចត្រូវបានលុប</string>
<!-- Context: Language Settings menu strings -->
<string name="enable_corrections" comment="Enable corrections from the suggestion banner">បើក​ការកែពាក្យ</string>
<!-- Context: Language Settings menu strings -->
Expand Down Expand Up @@ -164,5 +164,5 @@
<!-- Context: Other strings -->
<string name="help_bubble_text">ចុច​ត្រង់​នេះ​ដើម្បី​ប្ដូរ​ក្ដារចុច</string>
<!-- Context: anywhere -->
<string name="unable_to_open_browser" comment="Notification when a browser activity cannot be launched">Unable to launch web browser</string>
<string name="unable_to_open_browser" comment="Notification when a browser activity cannot be launched">មិនអាចដំណើរការកម្មវិធីបើកមើលគេហទំព័រ</string>
</resources>
2 changes: 2 additions & 0 deletions common/web/types/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export { defaultCompilerOptions, CompilerBaseOptions, CompilerCallbacks, Compile
compilerExceptionToString, compilerErrorFormatCode,
compilerLogLevelToSeverity, CompilerLogLevel, compilerEventFormat, ALL_COMPILER_LOG_LEVELS,
ALL_COMPILER_LOG_FORMATS, CompilerLogFormat,
CompilerMessageOverride,
CompilerMessageOverrideMap,

KeymanCompilerArtifact,
KeymanCompilerArtifactOptional,
Expand Down
68 changes: 67 additions & 1 deletion common/web/types/src/util/compiler-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ export enum CompilerErrorSeverity {
Fatal = 0x400000, // OOM or should-not-happen internal problem
};

export const CompilerErrorSeverityValues = [
CompilerErrorSeverity.Info,
CompilerErrorSeverity.Hint,
CompilerErrorSeverity.Warn,
CompilerErrorSeverity.Error,
CompilerErrorSeverity.Fatal,
]

/**
* Mask values for mapping compiler errors
*/
Expand Down Expand Up @@ -50,6 +58,9 @@ export class CompilerError {
static baseError(code: number): number {
return code & CompilerErrorMask.BaseError;
}
static namespace(code: number): CompilerErrorNamespace {
return code & CompilerErrorMask.Namespace;
}
static formatSeverity(code: number): string {
return errorSeverityName[CompilerError.severity(code)] ?? 'UNKNOWN';
}
Expand Down Expand Up @@ -156,6 +167,22 @@ export class CompilerError {
static exceptionToString(e?: any) : string {
return `${(e ?? 'unknown error').toString()}\n\nCall stack:\n${(e instanceof Error ? e.stack : (new Error()).stack)}`;
}

/**
* Returns the corresponding error severity value from a partial name match,
* e.g. 'inf' returns CompilerErrorSeverity.Info, or returns null if not found
* @param name
* @returns
*/
static severityNameToValue(name: string): CompilerErrorSeverity {
name = name.toLowerCase();
for(let level of CompilerErrorSeverityValues) {
if(errorSeverityName[level].startsWith(name)) {
return level;
}
}
return null;
}
};

/** @deprecated use `CompilerError.severity` instead */
Expand Down Expand Up @@ -183,6 +210,9 @@ export function compilerEventFormat(e : CompilerEvent | CompilerEvent[]) : strin
* ranges must not be changed as external modules may depend on specific error
* codes. Individual errors are defined at a compiler level, for example,
* kmc-ldml/src/compiler/messages.ts.
*
* kmc defines a mapping between each namespace and the corresponding compiler's
* error reporting class in kmc/src/messages/messageNamespaces.ts
*/
export enum CompilerErrorNamespace {
/**
Expand Down Expand Up @@ -259,11 +289,22 @@ export interface CompilerFileSystemCallbacks {
existsSync(name: string): boolean;
}

type CompilerErrorSeverityOverride = CompilerErrorSeverity | 'disable';
export interface CompilerMessageOverrideMap {
[code:number]: CompilerErrorSeverityOverride;
};

export interface CompilerMessageOverride {
code: number;
level: CompilerErrorSeverityOverride;
};

export interface CompilerCallbackOptions {
logLevel?: CompilerLogLevel;
logFormat?: CompilerLogFormat;
color?: boolean; // null or undefined == use console default
compilerWarningsAsErrors?: boolean;
messageOverrides?: CompilerMessageOverrideMap;
};

export interface KeymanCompilerArtifact {
Expand Down Expand Up @@ -352,6 +393,28 @@ export class CompilerFileCallbacks implements CompilerCallbacks {
return messages.find(m => failureCodes.includes(CompilerError.severity(m.code))) != undefined;
}

/**
*
* @param event
* @param overrides
* @returns true if event has been suppressed
*/
static applyMessageOverridesToEvent(event: CompilerEvent, overrides: CompilerMessageOverrideMap) {
// Override event severity from user preference -- this will not override
// fatal or error events
const severity = overrides?.[CompilerError.error(event.code)] ??
CompilerError.severity(event.code);

if(severity == 'disable') {
return true;
}

// Override the default event severity with the command line option
event.code = severity | (event.code & ~CompilerErrorMask.Severity);

return false;
}

/**
* Returns `true` if any message in the `messages` array is a Fatal or Error
* message, and if `compilerWarningsAsErrors` is `true`, then also returns
Expand Down Expand Up @@ -393,8 +456,11 @@ export class CompilerFileCallbacks implements CompilerCallbacks {
}

reportMessage(event: CompilerEvent): void {
const disable = CompilerFileCallbacks.applyMessageOverridesToEvent(event, this.options.messageOverrides);
this.messages.push(event);
this.parent.reportMessage({filename: this.filename, ...event});
if(!disable) {
this.parent.reportMessage({filename: this.filename, ...event});
}
}

debug(msg: string): void {
Expand Down
2 changes: 1 addition & 1 deletion common/web/types/src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function escapeRegexChar(ch: string) {
}

/** chars that must be escaped: syntax, C0 + C1 controls */
const REGEX_SYNTAX_CHAR = /^[\u0000-\u001F\u007F-\u009F{}\[\]\\?.^$*-]$/;
const REGEX_SYNTAX_CHAR = /^[\u0000-\u001F\u007F-\u009F{}\[\]\\?.^$*()/-]$/;

function escapeRegexCharIfSyntax(ch: string) {
// escape if syntax or not valid
Expand Down
2 changes: 1 addition & 1 deletion core/src/kmx/kmx_processevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using namespace kmx;

/* Globals */

KMX_BOOL km::core::kmx::g_debug_ToConsole = TRUE;
KMX_BOOL km::core::kmx::g_debug_ToConsole = FALSE;
KMX_BOOL km::core::kmx::g_debug_KeymanLog = TRUE;
KMX_BOOL km::core::kmx::g_silent = FALSE;

Expand Down
16 changes: 4 additions & 12 deletions core/src/ldml/ldml_markers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ namespace core {
namespace ldml {


const std::u32string REGEX_PREFIX = U"\\uffff\\u0008"; // does not include '\\' because it might be a range
// the 'prefix part' of a regex marker sequence, followed by RAW_PREFIX or REGEX_ANY_MATCH
const std::u32string REGEX_PREFIX = U"\\uffff\\u0008";
const std::u32string RAW_PREFIX = U"\uffff\u0008";
const std::u32string REGEX_ANY_MATCH = U"[\\u0001-\\ud7fe]";

Expand Down Expand Up @@ -317,16 +318,12 @@ std::u32string remove_markers(const std::u32string &str, marker_map *markers, ma
}
out.append(last, i);
assert(*i == lookfor); // assert that find() worked
last = i; // keep track of the last segment appendd.
last = i; // keep track of the last segment appended.

std::u32string rest(i, str.end());
if (rest.length() <= lookfor_str.length()) {
// not enough left so it can't match, so continue
i = str.end(); // end of string
if (encoding == plain_sentinel) {
// in plain mode, delete any irregular sequences
last = i;
}
continue;
}

Expand All @@ -336,15 +333,10 @@ std::u32string remove_markers(const std::u32string &str, marker_map *markers, ma

if (rest != lookfor_str) {
// no match - could be backslash something else
if (encoding == plain_sentinel) {
// in plain mode, delete any irregular sequences
last = i;
}
continue;
}

// matches. Skip over the prefix
last = i;
assert(i != str.end()); // caught above

KMX_DWORD marker_no;
if (encoding == plain_sentinel) {
Expand Down
8 changes: 4 additions & 4 deletions core/tests/unit/ldml/test_transforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ test_strutils() {
std::cout << __FILE__ << ":" << __LINE__ << " - bad0" << std::endl;
const std::u32string src = U"6\U0000ffff\U00000008"; // missing trailing marker #
const std::u32string dst = remove_markers(src, map);
const std::u32string expect = U"6";
const std::u32string expect = src;
zassert_string_equal(dst, expect);
assert_equal(map.size(), 0);
}
Expand All @@ -668,7 +668,7 @@ test_strutils() {
std::cout << __FILE__ << ":" << __LINE__ << " - bad1" << std::endl;
const std::u32string src = U"6\U0000ffffq"; // missing sentinel subtype
const std::u32string dst = remove_markers(src, map);
const std::u32string expect = U"6"; // 'q' removed
const std::u32string expect = src; // 'q' removed
zassert_string_equal(dst, expect);
assert_equal(map.size(), 0);
}
Expand All @@ -677,7 +677,7 @@ test_strutils() {
std::cout << __FILE__ << ":" << __LINE__ << " - bad1b" << std::endl;
const std::u32string src = U"6\U0000ffff"; // missing code
const std::u32string dst = remove_markers(src, map);
const std::u32string expect = U"6";
const std::u32string expect = src;
zassert_string_equal(dst, expect);
assert_equal(map.size(), 0);
}
Expand All @@ -686,7 +686,7 @@ test_strutils() {
std::cout << __FILE__ << ":" << __LINE__ << " - bad1c" << std::endl;
const std::u32string src = U"6\U0000ffffzz"; // missing code
const std::u32string dst = remove_markers(src, map);
const std::u32string expect = U"6z";
const std::u32string expect = src;
zassert_string_equal(dst, expect);
assert_equal(map.size(), 0);
}
Expand Down
4 changes: 3 additions & 1 deletion developer/src/common/web/test-helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export class TestCompilerCallbacks implements CompilerCallbacks {
}

printMessages() {
process.stdout.write(CompilerError.formatEvent(this.messages));
if(this.messages.length) {
process.stdout.write(CompilerError.formatEvent(this.messages));
}
}

hasMessage(code: number): boolean {
Expand Down
Loading

0 comments on commit 94dbff9

Please sign in to comment.