Commit Graph

132 Commits

Author SHA1 Message Date
Émilie Feral
555617aff3 [apps/code] Factorize VariableBoxController::addNode 2020-06-04 14:50:09 +02:00
Émilie Feral
705b1812f1 [apps/code] VariableBoxController: fix NodeNameCompare when nameLength >
nodeNameLength (step 2)
2020-06-04 14:50:09 +02:00
Émilie Feral
41bb169edd [apps/variable_box_controller] Auto-import: ignore variable when it is
the autocompleted one
2020-06-04 14:50:09 +02:00
Émilie Feral
d82e6de6e8 [apps/code] VariableBoxController: fix NodeNameCompare when nameLength >
nodeNameLength
2020-06-04 14:50:09 +02:00
Émilie Feral
2b53ea748d [apps/code] Typo 2020-06-04 14:50:09 +02:00
Léa Saviot
5412410723 [apps/code] Remove duplicates in the variable box
Example script:
from turtle import *
hideturtle()

We had "hideturtle" in the local variables, and "hideturtle()" in the
imported. Now we should only have the latter.
2020-06-04 14:50:09 +02:00
Léa Saviot
40d98389d4 [apps/code] Cleaner code in VariableBoxController::loadCurrentVariablesInScript 2020-06-04 14:50:09 +02:00
Léa Saviot
6b558c3328 [apps/code] Replace if with assertion 2020-06-04 14:50:09 +02:00
Léa Saviot
b466a8711b [apps/code] Remove dead code 2020-06-04 14:50:09 +02:00
Léa Saviot
38443c0e83 [apps/code] Fix VariableBoxController::empty
No scenario, but it seems right to reset m_shortenResultCharCount
2020-06-04 14:50:09 +02:00
Léa Saviot
c102bf2e4e [apps/code] Fix again variable_box_controller
Scenario: add the script
from matplotlib.pyplot import *\nfrom math import *\n\ng=9.81\n\ndef x(t,v_0,alpha):\n  return v_0*cos(alpha)*t\ndef y(t,v_0,alpha,h_0):\n  return -0.5*g*t**2+v_0*sin(alpha)*t+h_0\n\ndef vx(v_0,alpha):\n  return v_0*cos(alpha)\ndef vy(t,v_0,alpha):\n  return -g*t+v_0*sin(alpha)\n\ndef t_max(v_0,alpha,h_0):\n  return (v_0*sin(alpha)+sqrt((v_0**2)*(sin(alpha)**2)+2*g*h_0))/g\n\ndef simulation(v_0=15,alpha=pi/4,h_0=2):\n  tMax=t_max(v_0,alpha,h_0)\n  accuracy=1/10**(floor(log10(tMax))-1)\n  T_MAX=floor(tMax*accuracy)+1\n  X=[x(t/accuracy,v_0,alpha) for t in range(T_MAX)]\n  Y=[y(t/accuracy,v_0,alpha,h_0) for t in range(T_MAX)]\n  VX=[vx(v_0,alpha) for t in range(T_MAX)]\n  VY=[vy(t/accuracy,v_0,alpha) for t in range(T_MAX)]\n  for i in range(T_MAX):\n    arrow(X[i],Y[i],VX[i]/accuracy,VY[i]/accuracy)\n  grid()\n  show()tan(if :\n    \n  celse:\n  )c
then autocomplete after the last c.
2020-06-04 14:50:09 +02:00
Léa Saviot
5d49f5dca2 [apps/code] Fix VariableBoxController::addNodesFromImportMaybe
Scenario: write a ascrip "from matplotlib.pyplot0 import *" than open
the variable box
2020-06-04 14:50:09 +02:00
Léa Saviot
2bea3f3d47 [apps/code] Fix again VariableBoxController::loadCurrentVariablesInScript 2020-06-04 14:50:09 +02:00
Léa Saviot
00291c8974 [apps/code] Fix var initialisation in variable_box_controller 2020-06-04 14:50:09 +02:00
Léa Saviot
691c6739af [apps/variable_box_controller] Fix loadCurrentVariablesInScript
Scenario: write the script:

def squares():
  for i in range(660):
    forward(L)lo)

Put the cursor right of "lo" and press backspace.
2020-06-04 14:50:08 +02:00
Léa Saviot
a53edf5202 [apps/code] Remove TODOs 2020-06-04 14:50:07 +02:00
Léa Saviot
f763bb50ac [apps/code] Do not display subtitles in var box from console 2020-06-04 14:50:07 +02:00
Léa Saviot
780c593c26 [apps/code] Autocompletion for "abs" proposes parentheses 2020-06-04 14:50:06 +02:00
Léa Saviot
c915eb0b27 [apps/code] Do not autocomplete with arguments
Eg : arr|ow(x,y,dx,dy) should give arrow(|,,,)
2020-06-04 14:50:06 +02:00
Léa Saviot
0dac6b5bac [apps/code] Replace int with size_t 2020-06-04 14:50:06 +02:00
Léa Saviot
7ef17960c8 [apps/code/variable_box_controller] More TODOs removal 2020-06-04 14:50:06 +02:00
Léa Saviot
714410287a [apps/code] Remove TODOs 2020-06-04 14:50:06 +02:00
Léa Saviot
c5f2f7cf83 [apps/code] Remove TODO comments 2020-06-04 14:50:06 +02:00
Léa Saviot
43d0ab5ea7 [apps] Rename displayEmptyController -> displayEmptyControllerIfNeeded 2020-06-04 14:50:06 +02:00
Léa Saviot
e28f4ed7e2 [apps/code/variable_box_controller] Use std::min 2020-06-04 14:50:06 +02:00
Léa Saviot
59db24c518 [apps/code/variable_box_controller] Comment out unused variables 2020-06-04 14:50:06 +02:00
Léa Saviot
cf6b9d580b [apps/code] rename Script::scriptContent() -> Script::content() 2020-06-04 14:50:06 +02:00
Léa Saviot
5986716031 [apps/code] Fix first varbox row that never appeared again
After scrolling down
2020-06-04 14:50:06 +02:00
Léa Saviot
2fbf5d2d9f [apps/code] No variables starting with underscore in imported variables
In the variable box
2020-06-04 14:50:06 +02:00
Léa Saviot
ccca872a0f [appx/code] Empty variable box before loading it in the console 2020-06-04 14:50:06 +02:00
Léa Saviot
0c82334a96 [apps/code] Fix preventing module importations in varbox from console 2020-06-04 14:50:06 +02:00
Léa Saviot
5ffcb77c69 [apps/code] Fix missing return 2020-06-04 14:50:06 +02:00
Léa Saviot
ac654f0097 [apps/code] Load varbox before returning it in console 2020-06-04 14:50:06 +02:00
Léa Saviot
d1c8bbdaf7 [apps/code] The console marks imported script for the var box
After lauching the console, if we fetch a script we mark it as fetched.
When the variable box displays variables from imported scripts, it scans
all the variables from the scripts marked as fetched.
2020-06-04 14:50:06 +02:00
Léa Saviot
9e973adbab [apps/code] VarBox from console 2020-06-04 14:50:06 +02:00
Léa Saviot
d8cab18eb3 [apps/code] Do not display varbox source name if it does not fit 2020-06-04 14:50:06 +02:00
Léa Saviot
4fb0a7e467 [apps/code] properly display the importation source
- It sould be nameOfScript.py, not just nameOfScript, when the source is
a script
- Fix the source for script name variables. For instance, "from
script1 import *" should display the node "script1" with the source "script1.py"
- If a script has the same name as a module, the module will be imported
and not the script, so do not load its variables (even if the module is
not in the toolbox).
2020-06-04 14:50:06 +02:00
Léa Saviot
f9bbc94eea [apps/code] Handle autocompletionAlternativeAtIndex with no nodes 2020-06-04 14:50:05 +02:00
Léa Saviot
2a823419ff [apps/code] Cycle through possible autocompletions with up/down 2020-06-04 14:50:05 +02:00
Léa Saviot
afdf34bbb9 [apps/code] Signed/unsigned comparison 2020-06-04 14:50:05 +02:00
Léa Saviot
e7bfb3b5f3 [apps/code] Use variable 2020-06-04 14:50:05 +02:00
Léa Saviot
94e9a10f16 [apps/code] Autocomplete only with parentheses if needed
For instance, type "abs", there is "()" autocompletion
2020-06-04 14:50:05 +02:00
Léa Saviot
5d2910188d [apps/code] Add the parentheses in the autocompletion 2020-06-04 14:50:05 +02:00
Léa Saviot
da2730dd64 [apps/code] Autocomplete at the end of tokens
Not at the end of "words" separated by spaces.
2020-06-04 14:50:05 +02:00
Léa Saviot
7636c001e1 [apps/code] Fix varbox parentheses bug
Scenario: write i, open the varbox and select "in" -> parentheses are
added, but there shouldn't be any
2020-06-04 14:50:05 +02:00
Léa Saviot
e630b0e9e5 [apps/code] Remove __import__ from builtins 2020-06-04 14:50:05 +02:00
Léa Saviot
dd6c2a4f54 [apps/code] Translate the variable box 2020-06-04 14:50:05 +02:00
Léa Saviot
5393ec7273 [apps/code] Add matplotlib.pyplot in the var box 2020-06-04 14:50:05 +02:00
Léa Saviot
003317647e [apps/code] Display empty message in var box 2020-06-04 14:50:05 +02:00
Léa Saviot
398de8bda3 [apps/code] Empty controller in the var box 2020-06-04 14:50:05 +02:00