• Jens' Script Editor - An on-calc lua editor 5 2
Currently:  

Author Topic: Jens' Script Editor - An on-calc lua editor  (Read 131359 times)

0 Members and 1 Guest are viewing this topic.

Offline stevon8ter

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 663
  • Rating: +10/-0
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #45 on: July 20, 2013, 05:29:16 pm »
Looks nice ;)
i will have to try this one day, i guess you're 'forcing' me to do a tiny bit of programming on calc again xd
None of my posts are meant offending... I you feel hurt by one of my posts, tell me ... So i can appoligise me and/or explain why i posted it


Hi there, I'm the allmighty (read as: stupid, weak...) STEVON8TER

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: Jens' Script Editor - An on-calc lua editor
« Reply #46 on: July 21, 2013, 03:07:57 am »
@AnToX98: Wow, thanks and congrats to you! My french is very poor but I undestood the most, really nice review! Maybe I'll add french translations for the great french community!

PS: Just noticed that "Skript" is actually german... I meant "Script"...  Now I can replace that dang letter everywhere!  :banghead:

Oh right at first I thought it might have been a mistake, but then I thought it was intentional, for a unique name to your program!
Great news on v0.3! I have never needed to use [[string]] before. I'm not sure what it does.
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Re: Jens' Script Editor - An on-calc lua editor
« Reply #47 on: July 21, 2013, 02:15:34 pm »
Actually I think the name could remain with "Skript" as long as any other reference to actual coding are changed to script. It would probably show the program's German roots or look a bit original.
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline jwalker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 660
  • Rating: +13/-0
  • Almost everything I have released includes a 'WZ'
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #48 on: July 21, 2013, 03:31:26 pm »
@jwalker: I think this is not possible as long as TI blocked all functions to use the file system. Also user-defined libraries are not supported.
It is, you place a document with public variables in the library portion of the Nspire and then call using the Lua var functions. You would just have to write a standard for how code can be imported, and boom you have library like functionality.
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=9612" alt="My computer geek score is greater than 41% of all people in the world! How do you compare? Click here to find out!"> </a>

Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads

Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #49 on: July 21, 2013, 04:06:22 pm »
@jwalker: Wow, didn't know that! I'll do some research about that. Is that function available in apilevel 1 and 2? That would be a nice option to kinda use the file system! :D
Sorry for nonsense.

Projects:



Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: Jens' Script Editor - An on-calc lua editor
« Reply #50 on: July 21, 2013, 07:08:52 pm »
@jwalker: Wow, didn't know that! I'll do some research about that. Is that function available in apilevel 1 and 2? That would be a nice option to kinda use the file system! :D
Here is an example : http://ourl.ca/10565/242834
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Jens' Script Editor - An on-calc lua editor
« Reply #51 on: July 22, 2013, 05:33:17 am »
A direct example is here : http://ourl.ca/18733/345285

Also, we have asked TI to give us more control ( / easier way) to access files like that, since it ca be useful for loading external data ..
« Last Edit: July 22, 2013, 05:34:14 am by adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #52 on: July 22, 2013, 05:43:55 pm »
@jwalker: I like your idea of importing code from a library and I'll start working on it tomorrow.
@Levak & adriweb: Thank you both for the links, now I understood the concept.
Question:
- To make a library with sourcecode entirely loadable the whole code has to be saved as a string and saved in a variable? And then use var.recall("file\\var") to get the code as string?
- What happenes if the string is too large to load?
« Last Edit: July 23, 2013, 08:52:34 am by Jens_K »
Sorry for nonsense.

Projects:



Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: Jens' Script Editor - An on-calc lua editor
« Reply #53 on: July 22, 2013, 06:35:19 pm »
- To make a library with sourcecode entirely loadable the whole code has to be saved as a string and saved in a variable? And then use var.recall("file//var") to get the code as string?
Yep
Quote
- What happenes if the string is too large to load?
IIRC the limit is something like 65535 (or another lower multiple of 2) characters.
It just cannot store more chars and the rest is lost, involving a shorten script that may be invalid.

You mays cut the source code then, or cut it cleverly by group of functions.

Edit : oh, and btw, guess wat, mylib documents are extracted in RAM, thus, if we dump the RAM while you have a Lua script exporting its code throught strings, you may find its source code in it (the RAM). Same for TI-Basic functions (I was like "why the fuck is there Nspire-Basic source code in here ?")
« Last Edit: July 22, 2013, 06:37:22 pm by Levak »
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #54 on: July 22, 2013, 06:45:57 pm »
Ah, ok, thank you very much! That feature is very easy to implement then! I'll just make a dialogue to set file and variable to load and then I'll use the paste mechanics to insert it :D
Sorry for nonsense.

Projects:



Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #55 on: July 23, 2013, 12:51:12 pm »
UPDATE!!
Version 0.4 is now attached to the first post!

New features:
- Undo/Redo up to 10 actions
- Import code from a library
- Go to line...
And as always:
- Various bugfixes and improvements

As you can see, there's nothing left on my ToDo-list. That means the program is nearly finished :D
Feel free to post all bugs you can find and all suggestions you have! Thank you all for your support! ;)
Sorry for nonsense.

Projects:



Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Jens' Script Editor - An on-calc lua editor
« Reply #56 on: July 23, 2013, 05:00:57 pm »
Congrats, quite awesome :)


Feedback :
- There are a few useless bits like "if xxxx == nil" and "if xxxx == true" etc. (can be replaced respectively bu "if not xxxx" and "if xxxx")
- The .tns file contains a large amount of debug/useless variables in Basic, you should clean that up :P
- What about making the selection mouse-based too ? (it'd feed more natural on all platforms, then, in addition to what's available now)
- Awwww you put all the sizes/coordinates in absolute values :( So, in Computer View on the software, it's still calculator-sized :( When you have some time, don't hesitate to convert all that to relative values (fractions of pww and pwh (platform.window:width()/height())
- I haven't yet looked very well at how you handle the font but could you think about making all the letters even-spaced (still monospaced, sure, however a bit less space in general between the letters ?). Also : you should add "S" to the list of letters to add an offset.
- For compatibility reasons, you should try to avoid gc=platform.gc() and look at this replacement for 3.2 (in conjunction to this for 3.1)
- Some autocompletion would be very nice too, maybe with a "popup" list as you type, that completes when you [tab] ?
« Last Edit: July 23, 2013, 05:02:11 pm by adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #57 on: July 23, 2013, 06:18:48 pm »
@adriweb:
- Yes, cleaning up the code is one of the things I planned to do until the final release
- How to check and delete those variables?
- Yeah, I thought about mouse-based selection but then I thought: "Why would anyone use the ported Script Editor when he could just use the original one on the PC?!"
- Same as above
- The problem here is that when I reduce the space between the letters even one pixel, Upper-case characters like "W" or "G" or "M" would overlap each other and the code wouldn't be readable anymore...
   About the "S": I just forgot to call __mG.initialChrOff() after changing the font, I'll fix that ;)
- I've set apilevel='1.0' for compatibility reasons, the new withGC doesn't work here (?)... But maybe I'll make a 3.2 Version of the Editor some day...
- I like the Idea an autocompletion, but that is huge function and I think I actually used EVERY user-caused event :P

PS: I know the code is far from perfect, I am still new to lua (and even to programming in general) and I'm still far from knowing all opportunities of lua. You may like posting some improvement proposal on the code. Thanks for the feedback! :)
« Last Edit: July 23, 2013, 06:27:21 pm by Jens_K »
Sorry for nonsense.

Projects:



Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Jens' Script Editor - An on-calc lua editor
« Reply #58 on: July 24, 2013, 08:56:40 am »
- How to check and delete those variables?
Usually, in a math page, to see them : press the var button, or Ctrl-L. To delete them : just do a bunch of "Delvar xxxx". But seeing the amount of variables you have here, you should just create a new .tns and copy/paste the lua page onto the new one, so there won't be a single basic variable anymore (until your scripts makes some)

- Yeah, I thought about mouse-based selection but then I thought: "Why would anyone use the ported Script Editor when he could just use the original one on the PC?!"
- Same as above
Well, then it'd work on the iPad too, for example :)

- The problem here is that when I reduce the space between the letters even one pixel, Upper-case characters like "W" or "G" or "M" would overlap each other and the code wouldn't be readable anymore...
   About the "S": I just forgot to call __mG.initialChrOff() after changing the font, I'll fix that ;)
Ok

- I've set apilevel='1.0' for compatibility reasons, the new withGC doesn't work here (?)... But maybe I'll make a 3.2 Version of the Editor some day...
If you "compile" your lua code with Luna and don't set an apilevel, then the script will work under all 3.x OSes. Then it's yoru job to detect what features are available. For example, detecting if we are on 3.2 (apilevel "2.0") is easy : if platform.withGC then .... end    or :   if platform.registerErrorHandler ....   
So that way you can have things that work on all platforms and newer versions can have more features if available :)

- I like the Idea an autocompletion, but that is huge function and I think I actually used EVERY user-caused event :P
Well, still, it'd be uber cool (and it's not even done correctly (pretty much the same as if there were none) in the computer software !)

PS: I know the code is far from perfect, I am still new to lua (and even to programming in general) and I'm still far from knowing all opportunities of lua. You may like posting some improvement proposal on the code. Thanks for the feedback! :)
It's pretty good core already, especially if you're new to Lua ;)
« Last Edit: July 24, 2013, 08:57:03 am by adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #59 on: July 24, 2013, 11:04:18 am »
Ok, I see that; I'll go to work now to make it ultra compatible ;)
Btw. I just finished working (more copy/pasting) on the portable nspire scripting API reference guide and it's viewer (small and easy via RichTextBox) and I think it doesn't look that bad yet, but it is 11KB big because of all the text, should I integrate it anyways? (Of cause on page 1.2)

Edit: I always searched a way to finally delete variables and now I guessed: "If 'Delvar xxxx' works in the calculator, maybe math.eval('Delvar xxxx') works in the skript..." and I guessed right! Thank you very much for that hint, now the editor wont create random variables! (I tested if the entered name is a math variable via 'if not var.strore("test"..name,"") then...' and that produced many stored empty variables, now they'll get deleted right after saving!) And also deleted files will be really deleted (not just overwritten by var.store(name,""))
« Last Edit: July 24, 2013, 12:35:33 pm by Jens_K »
Sorry for nonsense.

Projects: