Set auto completion on Ninox editor
Hello everyone,
I was fed up with always having to close the code editor to fetch the name of a field or table, so I set up the Ninox code editor to have an auto-completion function :
press ctrl+space on the editor to display the completion list.
The list contain all Ninox functions, data base table and fields for each table and global user functions :
Ninox uses CodeMirror to edit its code. This editor is very complete and I didn't have too much trouble adding autocomplete. It is a classic CodeMirror add-on and there are many examples of how to do it on the web. The CodeMirror documentation also helped me a lot.
I think it is easy to improve the syntax highlighting. I will try it later.
Because this code is long, I create GitHub repository with all code I did and published in this forum. You can download it here : https://github.com/JacquesTur/Ninext
To add the code on your application, you can copy the content of the completion.html file on GitHub and put it in on one formula :
html("
put the copy of code here
");
Or use the following code in your formula:
html(http("GET", "https://raw.githubusercontent.com/JacquesTur/Ninext/main/completion.html").result)
In this last solution, your application will have directly the last modifications of the code in real time, the improvement... but also the new bugs .
71 replies
-
I have updated the completion. It is now version 1.04.
The new features are :
- name in color according to type :
- green: local variables,
- blue: Ninox functions
- red : global function
- black : fields
- grey : tables
- local variables detection
- detection of the type of variable returned by formulas, global functions and variables.
- display of possible fields on a formula, a global function or a variable that returns a table is followed by a dot.
-
Jacques TUR said:
Each module has its own version number which is displayed in the initialization form. The version number of the main module is displayed all the time, but the others only the first time the formula is run. I will fix this so that all version numbers are displayed all the time. Also, if the formula is not big enough, you can't see the bottom lines.
Please tell me if you can now see what the version number of the auto-completion module is. It should be 1.04 beta, like on the picture.I'm not sure why Jacques is asking if Peter can see the auto-completion version if the formula has already been run. I get the same message...
Peter Romão said:
"Modules version 1.01 beta already loaded"...in the Mac app and everything appears to be working as it should.
-
Peter Romão said:
Nope same thing is showing on the Mac. "Modules version 1.01 beta already loaded" Is there a way I can close the database to start loading from the beginning again? I used the close database command in the menu but to no avail.On the mac application, you have to close Ninox and reopen it to reload the modules.
-
I updated the autocompletion to version 1.05 to fix some bugs:
- Sometimes the list was not displayed, especially after a "select".
- Added variables declared in a for loop: "for i in select...". -
A huge time saver!! Thank you for sharing this!
-
Hi Jacques TUR
call me dumb, but...I used to have your formula beginning with
html(" <div id='completion" + this.ID + "'>auto-complétion v1.00.14 intialized<br>press ctrl+space into script editor to use it </div> <style id='exCoredMirrorStyle' type='text/css'>
and it worked, but now it doesn't anymore.
I've seen you made changes so I tried to follow your new instructions, but I can't get the editor working. Maybe I'm missing some piece of the procedure to "install" the script in my database.
Could you please explain me what I have to do, just like you would explain it to a baby?
Merci beaucoup!
-
Anyone else having trouble loading Jacques' tools? My DBs take forever to load and when they do the formula field is blank.
-
Jacques TUR , how does the new auto complete in v3.6 work with your code? Have you noticed any issues?
Content aside
-
14
Likes
- 2 yrs agoLast active
- 71Replies
- 1587Views
-
18
Following