[apps/code] Fix cursor position when inserting Python commands

Change-Id: I2f5cdc72220cc61b0c8830d746c63f705a7c928e
This commit is contained in:
Léa Saviot
2018-04-26 17:52:11 +02:00
parent 87becaa854
commit 8801b9f383
3 changed files with 17 additions and 17 deletions

View File

@@ -19,7 +19,7 @@ PythonCommandBin = "bin(x)"
PythonCommandCeil = "ceil(x)"
PythonCommandChoice = "choice(list)"
PythonCommandCmathFunction = "cmath.function"
PythonCommandCmathFunctionWithoutArg = "cmath."
PythonCommandCmathFunctionWithoutArg = "cmath."
PythonCommandColor = "color(r,g,b)"
PythonCommandComplex = "complex(a,b)"
PythonCommandCopySign = "copysign(x,y)"
@@ -57,7 +57,7 @@ PythonCommandIsFinite = "isfinite(x)"
PythonCommandIsInfinite = "isinf(x)"
PythonCommandIsNaN = "isnan(x)"
PythonCommandKandinskyFunction = "kandinsky.function"
PythonCommandKandinskyFunctionWithoutArg = "kandinsky."
PythonCommandKandinskyFunctionWithoutArg = "kandinsky."
PythonCommandLdexp = "ldexp(x,i)"
PythonCommandLgamma = "lgamma(x)"
PythonCommandLength = "len(object)"
@@ -66,7 +66,7 @@ PythonCommandLog10 = "log10(x)"
PythonCommandLog2 = "log2(x)"
PythonCommandLogComplex = "log(z,a)"
PythonCommandMathFunction = "math.function"
PythonCommandMathFunctionWithoutArg = "math."
PythonCommandMathFunctionWithoutArg = "math."
PythonCommandMax = "max(list)"
PythonCommandMin = "min(list)"
PythonCommandModf = "modf(x)"
@@ -80,7 +80,7 @@ PythonCommandRadians = "radians(x)"
PythonCommandRandom = "random()"
PythonCommandRandint = "randint(a,b)"
PythonCommandRandomFunction = "random.function"
PythonCommandRandomFunctionWithoutArg = "random."
PythonCommandRandomFunctionWithoutArg = "random."
PythonCommandRandrange = "randrange(start, stop)"
PythonCommandRangeStartStop = "range(start, stop)"
PythonCommandRangeStop = "range(stop)"
@@ -100,6 +100,6 @@ PythonCommandTanh = "tanh(x)"
PythonCommandTrunc = "trunc(x)"
PythonCommandImag = "z.imag"
PythonCommandReal = "z.real"
PythonCommandImagWithoutArg = "().imag"
PythonCommandRealWithoutArg = "().real"
PythonCommandImagWithoutArg = ".imag"
PythonCommandRealWithoutArg = ".real"
PythonCommandUniform = "uniform(a,b)"

View File

@@ -293,7 +293,7 @@ bool PythonToolbox::selectLeaf(ToolboxMessageTree * selectedMessageTree) {
const char * editedText = I18n::translate(node->insertedText());
int strippedEditedTextMaxLength = strlen(editedText)+1;
char strippedEditedText[strippedEditedTextMaxLength];
Shared::ToolboxHelpers::TextToInsertForCommandMessage(node->insertedText(), strippedEditedText, strippedEditedTextMaxLength);
Shared::ToolboxHelpers::TextToInsertForCommandMessage(node->insertedText(), strippedEditedText, strippedEditedTextMaxLength, true);
sender()->handleEventWithText(strippedEditedText, true);
app()->dismissModalViewController();
return true;

View File

@@ -20,25 +20,25 @@ NonEqualityCondition = "!="
NonEqualityConditionWithArg = "x!=y"
EqualityCondition = "=="
EqualityConditionWithArg = "x==y"
WhileLoop = "while ():\n "
WhileLoop = "while :\n "
WhileLoopWithArg = "while condition:\n instruction"
IfOrIfElseStatement = "if () or ():\n \nelse:\n "
IfOrIfElseStatement = "if or :\n \nelse:\n "
IfOrIfElseStatementWithArg = "if condition1 or condition2:\n instruction1\nelse:\n instruction2"
IfAndIfElseStatement = "if () and ():\n \nelse:\n "
IfAndIfElseStatement = "if and :\n \nelse:\n "
IfAndIfElseStatementWithArg = "if condition1 and condition2:\n instruction1\nelse:\n instruction2"
IfElifElseStatement = "if ():\n \nelif ():\n \nelse:\n "
IfElifElseStatement = "if :\n \nelif :\n \nelse:\n "
IfElifElseStatementWithArg = "if condition1:\n instruction1\nelif condition2:\n instruction2\nelse:\n instruction3"
IfThenStatement= "if ():\n "
IfThenStatement= "if :\n "
IfThenStatementWithArg = "if condition:\n instruction"
IfElseStatement = "if ():\n \nelse:\n "
IfElseStatement = "if :\n \nelse:\n "
IfElseStatementWithArg = "if condition:\n instruction1\nelse:\n instruction2"
ForInListLoop = "for i in ():\n "
ForInListLoop = "for i in :\n "
ForInListLoopWithArg = "for i in list:\n instruction"
ForInRange3ArgsLoop = "for i in range(,,):\n "
ForInRange3ArgsLoop = "for i in range(,,):\n "
ForInRange3ArgsLoopWithArg = "for i in range(start, stop, step):\n instruction"
ForInRange2ArgsLoop = "for i in range(,):\n "
ForInRange2ArgsLoop = "for i in range(,):\n "
ForInRange2ArgsLoopWithArg = "for i in range(start, stop):\n instruction"
ForInRange1ArgLoop = "for i in range():\n "
ForInRange1ArgLoop = "for i in range():\n "
ForInRange1ArgLoopWithArg = "for i in range(size):\n instruction"
PythonCommandDef = "def •():\n "
PythonCommandDefWithArg = "def function(x):"