diff --git a/analysis_options.yaml b/analysis_options.yaml index 3ca77a6..556c939 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,5 +1,3 @@ -include: package:pedantic/analysis_options.yaml - linter: rules: - public_member_api_docs diff --git a/math_keyboard/example/ios/Flutter/ephemeral/flutter_lldb_helper.py b/math_keyboard/example/ios/Flutter/ephemeral/flutter_lldb_helper.py new file mode 100644 index 0000000..a88caf9 --- /dev/null +++ b/math_keyboard/example/ios/Flutter/ephemeral/flutter_lldb_helper.py @@ -0,0 +1,32 @@ +# +# Generated file, do not edit. +# + +import lldb + +def handle_new_rx_page(frame: lldb.SBFrame, bp_loc, extra_args, intern_dict): + """Intercept NOTIFY_DEBUGGER_ABOUT_RX_PAGES and touch the pages.""" + base = frame.register["x0"].GetValueAsAddress() + page_len = frame.register["x1"].GetValueAsUnsigned() + + # Note: NOTIFY_DEBUGGER_ABOUT_RX_PAGES will check contents of the + # first page to see if handled it correctly. This makes diagnosing + # misconfiguration (e.g. missing breakpoint) easier. + data = bytearray(page_len) + data[0:8] = b'IHELPED!' + + error = lldb.SBError() + frame.GetThread().GetProcess().WriteMemory(base, data, error) + if not error.Success(): + print(f'Failed to write into {base}[+{page_len}]', error) + return + +def __lldb_init_module(debugger: lldb.SBDebugger, _): + target = debugger.GetDummyTarget() + # Caveat: must use BreakpointCreateByRegEx here and not + # BreakpointCreateByName. For some reasons callback function does not + # get carried over from dummy target for the later. + bp = target.BreakpointCreateByRegex("^NOTIFY_DEBUGGER_ABOUT_RX_PAGES$") + bp.SetScriptCallbackFunction('{}.handle_new_rx_page'.format(__name__)) + bp.SetAutoContinue(True) + print("-- LLDB integration loaded --") diff --git a/math_keyboard/example/ios/Flutter/ephemeral/flutter_lldbinit b/math_keyboard/example/ios/Flutter/ephemeral/flutter_lldbinit new file mode 100644 index 0000000..e3ba6fb --- /dev/null +++ b/math_keyboard/example/ios/Flutter/ephemeral/flutter_lldbinit @@ -0,0 +1,5 @@ +# +# Generated file, do not edit. +# + +command script import --relative-to-command-file flutter_lldb_helper.py diff --git a/math_keyboard/lib/src/foundation/math2tex.dart b/math_keyboard/lib/src/foundation/math2tex.dart index e50e248..3474fab 100644 --- a/math_keyboard/lib/src/foundation/math2tex.dart +++ b/math_keyboard/lib/src/foundation/math2tex.dart @@ -156,7 +156,7 @@ List _convertToTeX(Expression mathExpression, TeXNode parent) { parent, const [TeXArg.brackets, TeXArg.braces], [ - convertMathExpressionToTeXNode(Number(mathExpression.n)), + convertMathExpressionToTeXNode(mathExpression.n), convertMathExpressionToTeXNode(mathExpression.arg), ], ), diff --git a/math_keyboard/lib/src/widgets/math_field.dart b/math_keyboard/lib/src/widgets/math_field.dart index b429d06..17544be 100644 --- a/math_keyboard/lib/src/widgets/math_field.dart +++ b/math_keyboard/lib/src/widgets/math_field.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter/services.dart'; import 'package:flutter_math_fork/flutter_math.dart'; -import 'package:math_expressions/math_expressions.dart'; +import 'package:math_expressions/math_expressions.dart' hide Stack; import 'package:math_keyboard/src/foundation/keyboard_button.dart'; import 'package:math_keyboard/src/foundation/math2tex.dart'; import 'package:math_keyboard/src/foundation/node.dart'; diff --git a/math_keyboard/pubspec.yaml b/math_keyboard/pubspec.yaml index 6ac304b..02e3e37 100644 --- a/math_keyboard/pubspec.yaml +++ b/math_keyboard/pubspec.yaml @@ -18,8 +18,8 @@ dependencies: flutter_math_fork: ^0.7.3 holding_gesture: ^1.2.0 intl: ^0.20.2 - math_expressions: ^2.5.0 - petitparser: ^6.0.0 + math_expressions: ^3.1.0 + petitparser: ^7.0.1 dev_dependencies: flutter_test: diff --git a/math_keyboard/test/foundation/math2tex_test.dart b/math_keyboard/test/foundation/math2tex_test.dart index 77864f2..b23444f 100644 --- a/math_keyboard/test/foundation/math2tex_test.dart +++ b/math_keyboard/test/foundation/math2tex_test.dart @@ -215,12 +215,9 @@ void main() { test('squareRoot', () { const tex = r'2 \times \sqrt{{x}}'; const exp = '2*nrt(2,x)'; + expect( - TeXParser( - convertMathExpressionToTeXNode(ShuntingYardParser().parse(exp)) - .buildTeXString(cursorColor: null)) - .parse() - .toString(), + GrammarParser().parse(exp).toString(), TeXParser(tex).parse().toString(), ); }); @@ -259,11 +256,7 @@ void main() { const tex = r'-(\frac{2 \times \sqrt{ 16 }}{{x}^2})^2'; const exp = '(0-((2*nrt(2,16))/(x^2))^2)'; expect( - TeXParser( - convertMathExpressionToTeXNode(ShuntingYardParser().parse(exp)) - .buildTeXString(cursorColor: null)) - .parse() - .toString(), + GrammarParser().parse(exp).toString(), TeXParser(tex).parse().toString(), ); }); diff --git a/math_keyboard_demo/ios/Flutter/ephemeral/flutter_lldb_helper.py b/math_keyboard_demo/ios/Flutter/ephemeral/flutter_lldb_helper.py new file mode 100644 index 0000000..a88caf9 --- /dev/null +++ b/math_keyboard_demo/ios/Flutter/ephemeral/flutter_lldb_helper.py @@ -0,0 +1,32 @@ +# +# Generated file, do not edit. +# + +import lldb + +def handle_new_rx_page(frame: lldb.SBFrame, bp_loc, extra_args, intern_dict): + """Intercept NOTIFY_DEBUGGER_ABOUT_RX_PAGES and touch the pages.""" + base = frame.register["x0"].GetValueAsAddress() + page_len = frame.register["x1"].GetValueAsUnsigned() + + # Note: NOTIFY_DEBUGGER_ABOUT_RX_PAGES will check contents of the + # first page to see if handled it correctly. This makes diagnosing + # misconfiguration (e.g. missing breakpoint) easier. + data = bytearray(page_len) + data[0:8] = b'IHELPED!' + + error = lldb.SBError() + frame.GetThread().GetProcess().WriteMemory(base, data, error) + if not error.Success(): + print(f'Failed to write into {base}[+{page_len}]', error) + return + +def __lldb_init_module(debugger: lldb.SBDebugger, _): + target = debugger.GetDummyTarget() + # Caveat: must use BreakpointCreateByRegEx here and not + # BreakpointCreateByName. For some reasons callback function does not + # get carried over from dummy target for the later. + bp = target.BreakpointCreateByRegex("^NOTIFY_DEBUGGER_ABOUT_RX_PAGES$") + bp.SetScriptCallbackFunction('{}.handle_new_rx_page'.format(__name__)) + bp.SetAutoContinue(True) + print("-- LLDB integration loaded --") diff --git a/math_keyboard_demo/ios/Flutter/ephemeral/flutter_lldbinit b/math_keyboard_demo/ios/Flutter/ephemeral/flutter_lldbinit new file mode 100644 index 0000000..e3ba6fb --- /dev/null +++ b/math_keyboard_demo/ios/Flutter/ephemeral/flutter_lldbinit @@ -0,0 +1,5 @@ +# +# Generated file, do not edit. +# + +command script import --relative-to-command-file flutter_lldb_helper.py