Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI-Nspire => Topic started by: Jens_K on July 10, 2013, 05:12:27 pm

Title: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 10, 2013, 05:12:27 pm
Hi,
Inspired by "oclua" I started to make an own on-calc lua editor and finished the first version of it in summer 2013. It had many flaws and lacked some important features, so I decided to make a second, vastly improved version of it:

Features:
- Fully functioning code editor on page 1.1
  - Monospaced characters
  - Syntax highlighting (customizable)
  - Autocompletion menu: basic lua functions, nspire api function, global script variables, custom items
  - Undo/redo actions
  - Select code to copy, cut, paste, etc.
  - Find function
  - Save & load infinite amount of scripts with length each up to 1.7 million characters
  - Hotkeys for special characters
  - Full support for UTF8-encoded unicode characters
  - Import code from librarys and saved scripts
  - Autosave function
  - Customizable color-set
  - Customizable font

- Entirely crash protected live testing on page 1.2
  - Nearly no restrictions
  - Full support of event handlers using "on"s metatable
  - Resets global environment after each build
  - Pause/Unpause scripts
  - Full module (physics & colors) support
  - Calls all initialization event handlers
  - Full support of 2DEditors

- Console
  - Logs "print" outputs, errors and status logs of the editor
  - Can be deleted, copy&pasted and resized with Nspires layout options
  - Commands can be entered to execute them during live-testing a script

- Shortened portable version of the Nspire api reference guide on page 2.1
- Shortened portable version of the lua reference manual & chipmunk physics api guide on page 2.2

- Compatible to:
  - OS 3.1 and OS>3.1
  - Greyscale models
  - Clickpad models
  - Desktop
  - iPad

(http://www.ticalc.org/archives/files/ss/858/85825.gif)(http://www.ticalc.org/archives/files/ss/858/85829.gif)(http://www.ticalc.org/archives/files/ss/858/85839.gif)(http://www.ticalc.org/archives/files/ss/858/85840.gif)

Current Version: 2.2.1
Current Size: 73KB

The attached zip file contains the editor files for OS 3.1 and OS>3.1, controls pictures of both Nspire layouts and a readme.txt

Bug reports are welcome!  :) 

Spoiler For old post:
Hi,
I recently found oclua.tns and I liked the idea of an on-calc skript editor but I didn't like to write code in the "Notes" app. Therefore I started to make a fully functioning on-calc skript editor based on the idea of how oclua works. I also managed to prevent crashes of the editor because of a crash in the written code! I've been working on it several weeks now and I think it's time to show you the progress:

Main features:
- fully functioning code editor
- run your code without any limitations
- stop it
- it wont crash (except for infinite loops)
- Syntax is colored
- Save infinite amount of skripts
- Select code to copy, cut, etc.
- undo/redo actions
- Import code from librarys
- shortened portable version of the nspire api reference guide on page 1.2
- Most math buttons get converted to valid lua code
- compatible to:
  - OS 3.x
  - Greyscale models
  - Clickpad models
  - Desktop
  - iPad

Planned Features:
- Undo/redo actions  Done in 0.4
- Select/Mark code to copy/paste etc.  Done in 0.3
- Make things safer to use, like "File"==>"New"  Done in 0.2
- mark operators'n'stuff correctly  Done in 0.2
- help and instructions  Done in 0.2
- support for the clickpad layout  Done in 0.1.1
- better visuals for greyscale displays  Done in 0.1.1

Eventually future features:
- shortened portable version of the nspire api reference guide  Done in 0.4.2
- paint a picture, convert it and put it into your code on-calc  Use nSpaint (http://ourl.ca/12418)!

Controls:
Spoiler For Controls:
nspire touchpad:
(http://imageshack.us/a/img15/4814/36qs.png)

nspire clickpad:
(http://imageshack.us/a/img41/6456/eqyd.png)

Screenshots:
Spoiler For Screenshots:
(http://imageshack.us/a/img560/5691/aght.jpg)(http://imageshack.us/a/img11/4614/mc8o.jpg)
(http://imageshack.us/a/img801/1369/h0ym.jpg)(http://imageshack.us/a/img28/6076/qt4g.jpg)

API Reference Guide:
(http://imageshack.us/a/img825/1520/2vta.jpg)(http://imageshack.us/a/img199/4439/6294.jpg)

By now the file is 28KB in size and it has about 1400 lines of code (without the API Reference Guide).

Current version: 1.0.2

Sorry for language errors :P

Download it here: http://www.ticalc.org/archives/files/fileinfo/454/45484.html (http://www.ticalc.org/archives/files/fileinfo/454/45484.html)
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Jonius7 on July 11, 2013, 05:25:39 am
This is great! As you may or may not be aware there have been several previous attempts at creating a on-calc lua editor, after oclua. yatto made a lua editor called LuaCS, and Levak created a fork from it. Actually I also remember someone else translating the French from Levak's version.
http://ndlessly.wordpress.com/?s=luacs

But yours seems the most featured packed at the moment :)

Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Sorunome on July 11, 2013, 05:34:03 am
wait, we get to program lua on-calc? AWESOME!
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Jonius7 on July 11, 2013, 06:04:23 am
I just realised something. The braces and brackets don't work on a clickpad, because they are grouped together as one button, unlike the touchpad. Hope you can fix this to accomodate clickpads too! The other buttons seem to work fine.
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Jens_K on July 11, 2013, 07:50:01 am
@Jonius7:
1.) No, I didn't know that... LuaCS looks better than mine, but there's no actual error handling and oclua keeps crashing as it has always done. Also you only can save 1 program. Also characters like [] and {} and : are as tedious to type as they were in the "Notes" App.
2.) The image is edited; there aren't really "[]" and "{}" Buttons, I redefined following buttons: "e^x"==>"["; "10^x"==>"]"; "ln("==>"{"; "log("==>"}"; "(-)"==>":"
It's very handy like this on the touchpad layout. I'll implement a feature to swap the layout, maybe the "cos" and "tan" buttons for "[" and "]" and the "^-1" versions for "{" and "}"? Unfortunately I don't know anyone with a clickpad nspire to try it out :/


Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: DJ Omnimaga on July 11, 2013, 11:48:45 pm
Interesting. Is it in any way related to the SDK that recently made front page news on TI-Planet or was it something else?
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Jonius7 on July 12, 2013, 04:02:47 am
I think yours looks quite good. Maybe because you're using "serif" font instead of "sansserif" which I think the other ones use.

Also I have a clickpad, but I used kArmTI (nspire_emu with extra features, I recommend it) to test the clickpad, it can handle all the main 6 editions of TI-nspire.
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Lionel Debroux on July 12, 2013, 04:10:57 am
Quote
(nspire_emu with extra features, I recommend it)
Its closed-source nature is not a good thing for the community, though.
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: ElementCoder on July 12, 2013, 07:07:25 am
This looks really nice. I especially like the not-crashing-on-error part :D This drives me to get back to Lua programming again now that it's portable once more. I hope you stick with the project.
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Jonius7 on July 12, 2013, 07:08:03 am
Quote
(nspire_emu with extra features, I recommend it)
Its closed-source nature is not a good thing for the community, though.

A bit off topic but yeah.
Is the version on mediafire updated? I downloaded it before you made those changes about [] {}

Also about painting a picture, you might want to look at nSpaint. http://ourl.ca/12418
perhaps you could call integration of that program with the Skript editor as you did with executing the script itself :).
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Jens_K on July 12, 2013, 09:51:01 am
@Jonius7: nspire
1.) Thanks for your the hint for the emulator, but I don't get it to work: everytime I try to start "nspire_emu.exe" a black window flashes once and nothing else happenes :/
2.) I haven't made an update yet, because I don't get the emulator to work :/ But those button rebinds are already in the current version.
3.) BIG thanks for that reference to nSpaint!!! :D Now I don't have to do that; Chockosta wrote ~2200 lines of code for that! I'll ask him for permission for integration or I'll just put a note somewhere...
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: lkj on July 12, 2013, 04:22:15 pm
Looking really good already.

If you want to use nspire_emu, there's a tutorial over at TI-Planet: http://tiplanet.org/forum/viewtopic.php?f=15&t=8698 (http://tiplanet.org/forum/viewtopic.php?f=15&t=8698).
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Jens_K on July 12, 2013, 05:53:15 pm
UPDATE!
Version 0.1.1 now attached on the first post

New features:
- math button input get converted to lua code (like the root or the pi button)
- better visuals on greyscale displays
- support for clickpad layout (switch in the menu) explanation in the "Controls" spoiler of the first post
- settings will be saved now

@lkj: Thanks for the link! I'll test now what I just updated on the emulator :P
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Jonius7 on July 13, 2013, 06:31:22 am
@Jonius7: nspire
1.) Thanks for your the hint for the emulator, but I don't get it to work: everytime I try to start "nspire_emu.exe" a black window flashes once and nothing else happenes :/
2.) I haven't made an update yet, because I don't get the emulator to work :/ But those button rebinds are already in the current version.
3.) BIG thanks for that reference to nSpaint!!! :D Now I don't have to do that; Chockosta wrote ~2200 lines of code for that! I'll ask him for permission for integration or I'll just put a note somewhere...

Yeah nspire_emu is command line, unless you run it from a cmd it does the flashy window thing.
kArmTI by SpiroH (http://ourl.ca/16585), adds a nice gui interface and a whole lot more.
Both take a bit to understand how to set up (which is kinda annoying :(, but worth it in the end :) )
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Levak on July 13, 2013, 06:50:40 am
1.) Thanks for your the hint for the emulator, but I don't get it to work: everytime I try to start "nspire_emu.exe" a black window flashes once and nothing else happenes :/
https://tiplanet.org/forum/viewtopic.php?f=57&t=8698
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Jens_K on July 13, 2013, 10:12:32 am
I spent 1 morning now to set up the nspire_emu and nspire_emu_gtk, I got OS 2.x to work on the nspire_emu but that sais I must update to 3.x to open my skript editor (even without platform.apilevel='1.0') but when I try to run 3.x the nspire_emu sais "Invalid Image"... Either the nspire_emu_gtk doesn't extract 3.x images right or the nspire_emu is not able to run them...
Anyways, does everything in the update work as intended?
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Lionel Debroux on July 13, 2013, 10:23:34 am
nspire_emu_gtk is fantastically outdated. The only proper emulator for the Nspire is nspire_emu 0.70 :)
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Jens_K on July 13, 2013, 10:51:07 am
Yes, I only used the gtk to extract boot2.img to boot2.raw but apparently that doesn't work anymore with 3.x
The recommended tool of TI-Planet "imgmanip" I can't use because I don't know how to C++  :-\

Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Lionel Debroux on July 13, 2013, 10:57:28 am
Just use a recent version of GCC (g++) or Clang, passing a couple trivial defines on the command line to turn a couple Pascal-like keywords into their C++ equivalents :)
The source code is not provided in directly-usable form for obvious, though annoying and heart-breaking, legal reasons.
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Levak on July 13, 2013, 12:12:21 pm
Yes, I only used the gtk to extract boot2.img to boot2.raw but apparently that doesn't work anymore with 3.x
The recommended tool of TI-Planet "imgmanip" I can't use because I don't know how to C++  :-\
You can also use polydumper (https://tiplanet.org/forum/archives_voir.php?id=3829) in order to dump the boot2.raw from the calc.
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Jonius7 on July 14, 2013, 12:38:57 am
I got a -1? Huh?
Either someone doesn't like what I said, about kArmTI maybe?
nspire_emu is the base original TI-nspire emulator by goplat, and most other versions are derived from nspire_emu
   as mentioned by others there are good tutorials on how to set up nspire_emu on tiplanet.org
As I said, kArmTI is nspire_emu with customisable skins, and a few other features by SpiroH, and it is updated to nspire_emu_070
nspire_emu_gtk by xspire is outdated, based on nspire_emu_0.2.6, which iirc doesn't support OS 3.0

That also reminds me I had the batch files from Levak, which allows easier running of nspire_emu and its functions, which I modified but I never got to finish.
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Jens_K on July 14, 2013, 05:18:11 am
Sorry, but I'm busy next 2 days... I'll do another try with the emulators then. I don't know why anyone would give a -1 to those posts so I gave +1 to make that up.
Title: Re: Re: Re: Jens' Skript Editor - a on-calc lua editor
Post by: DJ Omnimaga on July 14, 2013, 12:19:56 pm
Sorry, but I'm busy next 2 days... I'll do another try with the emulators then. I don't know why anyone would give a -1 to those posts so I gave +1 to make that up.
some people here despise the fact that KarmTI is closed source so much that they rate down every post that says anything positive about the emulator. I think staff threatened a ban before on such abuse of the rating system, but nothing has been done yet I think because due to the way ratings are stored in the database, it is impossible to know *when exactly* somebody in particular rated a certain post. It is possible that admins are just unaware of any suspicious activity, though, so I would suggest that you report the post then write in the reason that there might be rating abuse. Of course it could totally be a mistake as well (accidentally clicking the wrong icon).
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Lionel Debroux on July 14, 2013, 12:22:25 pm
Downrating a post which contains anything positive about the noxious closed-source emulator (derived from an open-source emulator, at that) is not a mistake, it's the right thing to do. And at the time of this writing, the fact is that most of this topic's posts which contain positive things about that emulator have not been downrated.

Downrating is normally the only allowed way to express oneself about the emulator and its badness for a community, since the matter is in moderation territory...
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: DJ Omnimaga on July 14, 2013, 06:57:45 pm
the fact is that most of this topic's posts which contain positive things about that emulator have not been downrated.

Downrating is normally the only allowed way to express oneself about the emulator and its badness for a community, since the matter is in moderation territory...
The reason why they're not downrated is because somebody uprated them after someone downrated them. AFAIK, though, only 1 post was downrated, so it might have been a misclick.

And true, although this could be seen as an attempt at circumventing forum rules. That said, since Omnimaga hasn't upgraded to SMF 2.x yet, it is impossible to know who rated what, so the rating system isn't actively moderated unless vandalism or harrassment is suspected, in which case members need to use the Report to moderator function to let staff know.

Also weird post downrating can cause unnecessary off-topicness anyway.
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Levak on July 14, 2013, 07:10:42 pm
Even if it is a pure off-topic, ...
only 1 post was downrated, so it might have been a misclick.
... so you're still thinking that downgrading posts, where there are positive arguments about that emulator, is a mistake/misclick ? even after what Lionel said ?
I also don't really like the way that uprating downratings hides what the first who downrated wanted to say by this vote.
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: DJ Omnimaga on July 14, 2013, 07:27:32 pm
Not necessarily, but it is still possible, since only one single post appears to have been downrated in this topic in particular, even though a few other posts shared similar content. Unless I missed some? However, I know that in certain other topics, it was 100% not a mistake, since several posts defending/showcasing the emulator were downrated.

As for uprating downrated posts it's only because some people find that the downvote was unfair in the current scenario. Else it could either have stayed that way or received even more downvotes.

Back on-topic now?
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Jonius7 on July 15, 2013, 01:03:45 am
My head is spinning a little bit after all those posts about the Post Ratings, which is all good and great discussion, but it's important to get back on topic.

- I noticed in v0.1.1 that the program doesn't load on the display until you press a button. Nice touch, though initially a bit confusing.
- The save dialogue works but either doesn't refresh right away or is taken away by input from the coding window (you can still move around it while the save dialogue is open. I'm sure that shouldn't be too hard to fix.
- Does load work only after you exit the program and re-open it?
- Other than that, looks and works great.
- Perhaps you could add syntax colouring for if, end, function etc.
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Jens_K on July 15, 2013, 01:27:06 pm
@Jonius7: Finally someone gets back to topic :)
- When the program doesn't load on the display? Right at the launch? I think I already fixed that in my current state of development...
- I'll block the opportunity to move around while save dialogue. And you're right, I forgot to update the screen after the save dialogue, I'll fix that.
- The load function works fine with my CX... When you save a "file", loading right after that doesn't work? What exactly? Does the menu not update after saving?
- syntax colouring is planned for future versions

Thank you very much for the feedback!
Title: Re: Jens' Skript Editor - a on-calc lua editor
Post by: Jens_K on July 16, 2013, 08:52:33 pm
UPDATE!!
Version 0.2 is now attached to the first post!

New features:
- Syntax colouring
- Help and instructions
- Support for non-ASCII-characters (use might be a bit confusing)
- Message boxes for safety
- Various bugfixes and improvements
Title: Re: Re: Jens' Skript Editor - An on-calc lua editor
Post by: DJ Omnimaga on July 17, 2013, 05:16:58 pm
Great features addition. :D
Title: Re: Jens' Skript Editor - An on-calc lua editor
Post by: Jonius7 on July 19, 2013, 05:48:27 am
About the save load function, On first load of the document, I found out that the load option was greyed out. Going back to the home menu and coming back to the document worked though, and also showed my previously saved documents, which I couldn't access before.
I like the syntax colouring now, it's much more comprehensive. I tried a few commands (if, end, function) all nice blue font, and stuff in "quotes" was highlighted in purple.
It's really quite good and almost feature complete and I love the import via clipboard option. That makes things much easier for importing stuff from oclua :)
Title: Re: Jens' Skript Editor - An on-calc lua editor
Post by: imath on July 19, 2013, 06:56:55 am
sounds great!
Title: Re: Jens' Skript Editor - An on-calc lua editor
Post by: imath on July 19, 2013, 07:00:08 am
when the code is long,is it flexible?
Title: Re: Jens' Skript Editor - An on-calc lua editor
Post by: mdr1 on July 19, 2013, 08:57:01 am
This editor is really great! I've got suggestions:
* Enable user to select code copy/delete it.
* Enable user to paste code.
* Add a coloration for strings with [[string]].
* Be able to insert faster usefull functions with the menu.
Good job!
Title: Re: Jens' Skript Editor - An on-calc lua editor
Post by: Jens_K on July 19, 2013, 11:23:03 am
@imath: I think there are many ways to interprete that question (or my english is not good enough...):
- The number of lines of a code doesn't impact the performance because the code is saved in the RAM as a table with one line per index and only the visible lines get rendered.
- The number of visible characters on the screen does impact the performance because rendering a string/char is relatively slow.
- The number of characters in a visible line does impact the performance because every character of the visible lines does impact the syntax colouring and have to be processed.
- Moving around in large codes is also easy with the clickable scrollbar on the right.(Have anyone notice it yet?!) But i think I'll add a "jump to line..."option.

@mdr1:
- I'm working on copy/paste functions (just finished paste function)

Thanks to everybody for the nice feedback! I think the editor is finished soon! :D
Title: Re: Re: Jens' Skript Editor - An on-calc lua editor
Post by: DJ Omnimaga on July 19, 2013, 12:26:02 pm
Yeah I think he meant when our code is long, some other Lua editors ran incredibly slow apparently.
Title: Re: Jens' Skript Editor - An on-calc lua editor
Post by: AnToX98 on July 19, 2013, 03:53:37 pm
Jens I like so much your work, you're incredible ! I even did a news on TI-planet for this awesome work ! http://tiplanet.org/forum/viewtopic.php?p=145643#p145643
I hope this project will be finished soon because this is the best Lua on-calc Editor ever, congrats !
Title: Re: Jens' Skript Editor - An on-calc lua editor
Post by: Hayleia on July 19, 2013, 04:16:44 pm
Welcome to Omnimaga AnToX98, you can introduce yourself here (http://www.omnimaga.org/index.php?board=10.0).
Title: Re: Jens' Skript Editor - An on-calc lua editor
Post by: Jens_K on July 19, 2013, 07:13:05 pm
@AnToX98: Wow, thanks and congrats to you! My french is very poor but I understood 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:
Title: Re: Jens' Skript Editor - An on-calc lua editor
Post by: DJ Omnimaga on July 20, 2013, 02:18:10 am
Yeah I meant to ask about that before (the script mispelling) but I kept forgetting. :P I guessed it was due to English not being your native language and script being written with a k in your language. (kinda like how I often say Irak instead of Iraq due to the French word using a K or how I often use connection instead of connexion in French, since I only use that word in English sentences)
Title: Re: Jens' Skript Editor - An on-calc lua editor
Post by: imath on July 20, 2013, 08:53:20 am
@imath: I think there are many ways to interprete that question (or my english is not good enough...):
- The number of lines of a code doesn't impact the performance because the code is saved in the RAM as a table with one line per index and only the visible lines get rendered.
- The number of visible characters on the screen does impact the performance because rendering a string/char is relatively slow.
- The number of characters in a visible line does impact the performance because every character of the visible lines does impact the syntax colouring and have to be processed.
- Moving around in large codes is also easy with the clickable scrollbar on the right.(Have anyone notice it yet?!) But i think I'll add a "jump to line..."option.

@mdr1:
- I'm working on copy/pasfe functions (just finished paste function)

Thanks to everybody for the nice feedback! I think the editor is finished soon! :D


I think we can add a "#include " function?
Title: Re: Jens' Skript Editor - An on-calc lua editor
Post by: jwalker on July 20, 2013, 12:58:18 pm
Perhaps you should add an "Import code from library" feature, and use similar concepts that are used to load strings from documents in the TI-Nspire library.
Title: Re: Jens' Skript Editor - An on-calc lua editor
Post by: Jens_K on July 20, 2013, 02:50:11 pm
@imath: maybe you mean the "require" function? Unfortunately this function was introduced in platform.apiLevel='2.0' (=OS 3.2) but I set platform.apiLevel='1.0' (=OS 3.0) in the editor to make it backward compatible, so you couldn't use those 3.2 functions. (There are only 2 not thaat useful modules anyways)

@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.

PS: Expect Version 0.3 later today!
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 20, 2013, 04:18:13 pm
UPDATE!!
Version 0.3 is now attached to the first post!

New features:
- Select code to copy, cut, etc.
- "Insert" menu added to insert useful functions
- Various bugfixes and improvements:
  - [[Strings]] are now marked correctly
  - Nau wis inglisch taitel (Skcript)
  - on.create()/on.construction and on.activate() are now fired right after running the main program
  - editor wont crash now if on.charIn is not defined and user presses a button
  - (hopefully) fixed the issue that the "Load" menu won't load correctly right after launch
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: stevon8ter 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
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jonius7 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.
Title: Re: Re: Jens' Script Editor - An on-calc lua editor
Post by: DJ Omnimaga 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.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: jwalker 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.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K 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
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Levak 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
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb 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 ..
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K 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?
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Levak 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 ?")
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K 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
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K 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! ;)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb 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 (http://wiki.inspired-lua.org/platform.withGC) (in conjunction to this (http://pastebin.com/sWLz3NXi) for 3.1)
- Some autocompletion would be very nice too, maybe with a "popup" list as you type, that completes when you [tab] ?
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K 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! :)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb 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 ;)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K 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,""))
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jim Bauwens on July 24, 2013, 01:46:45 pm
Jens, regarding the manual, you could save it in an external document that you but in the MyLib folder. You then could make the editor detect if it's present and load it if that's the case.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Legimet on July 24, 2013, 02:57:54 pm
Can you post the Lua source code here? (Or is there a way to extract it from the tns?)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 24, 2013, 03:02:43 pm
UPDATE!!
Version 0.4.2 is now attached to the first post!

New features:
- API Reference Guide on page 1.2
- Full compatibility to OS 3.2
- Full compatibility to the desktop view
- Mouse based selection
- Various bugfixes and improvements

Why .2? I don't know ;D but I know this will be one of the last development versions (maybe the last) :D

@Jim Bauwens: Do mean saving the contend of the API Reference Guide as a library? It's only 10KB do you think this is worth the effort?
@Legimet: Open the tns in the student software and there click "insert"==>"Script Editor"==>"Edit Script"
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on July 24, 2013, 03:07:06 pm
Ah, very nice update :)

Edit : also, what about apilevel 2 documention ? (without the physics stuff, though)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 24, 2013, 03:36:12 pm
Edit : also, what about apilevel 2 documention ? (without the physics stuff, though)
I made the content when I didn't know that apilevel 2 functions can be available in apilevel 1 and now I forgot to add them... Update tomorrow :P
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on July 24, 2013, 03:40:48 pm
Well, most of apilevel 1 are in apilevel 2. The contrary is false, of course.

Some things I came across while testing :
- Can you also alphabetize the documentation ? ;)  (http://alphabetizer.flap.tv/ might even work as expected)
- So, now that the computer view works fine (except some dialogs (http://i.imgur.com/wqZCd8H.png)), the thing missing so that it works on the iPad is.... the keyboard showing up :P
In fact, on the iPad, the keyboard doesn't apprear in Lua until you specifically make it pop up. Look at the apilevel "2.2" functions (http://wiki.inspired-lua.org/Changes_in_OS_3.4) (as usual, don't force the apilevel in your script, and test if the "touch" table is present. If it is, then do the tablet-related stuff.)

Edit : Example :
Code: [Select]
if platform.isTabletModeRendering then

if touch then -- maybe even : if touch and touch.enabled() then
if not touch.isKeyboardVisible() then
touch.showKeyboard()
end
end

end

Edit2 : that could be in your on.mouseUp routine.

Also, the iPad would require another key/something to go back to the editor... any ideas ?

Edit 3 :
When you paste, you are waiting for an event like a click to occur, what about just showing the pasted text as soon as it's done ? ;)


Edit 4 :
HA ! I made it work on the iPad, it's Awesome ! I'm gonna make a little video sometime (or well, when it fully works ^^) :P
(Well, there is still that back-to-editor issue but still :P)

Edit 5 : You should put copy/paste in an "Edit" toolpalette.
(also, there is an issue on the iPad version, you may have to put that somewhere : "platform.window:setFocus(false) platform.window:setFocus(true)" .
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 24, 2013, 04:06:51 pm
- At the moment the contend is save like this: content["Graphics"]["drawString"]=... and the menu is created via pairs(content) and the pairs function doesn't sort in any way... I'look what I can do here.
- Ah, didn't know that I have to trigger the keyboard, that'll defenitely be in the update tomorrow
- About the button, I found that picture on the TI website:
(http://education.ti.com/en/us/~/media/Images/TI%20Education/US/iPad%20App/product-ipad-proper-math-notations.png)
There is a EE button on the right, doesn't that work?
- I'm still a bit confused about setting the api level: What do I have to do that the editor runs on older OS (3.0-3.1) but also executes newer functions?
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on July 24, 2013, 04:17:45 pm
- At the moment the contend is save like this: content["Graphics"]["drawString"]=... and the menu is created via pairs(content) and the pairs function doesn't sort in any way... I'look what I can do here.
Well, in the output script, reordering the things by hand would work ^^

- Ah, didn't know that I have to trigger the keyboard, that'll defenitely be in the update tomorrow
Here's a version with the keyboard working in the iPad : http://pastebin.com/x49Xmsis

- About the button, I found that picture on the TI website:
(http://education.ti.com/en/us/~/media/Images/TI%20Education/US/iPad%20App/product-ipad-proper-math-notations.png)
There is a EE button on the right, doesn't that work?
Yes there is. I guess it can work, I haven't tested. However, the thing is : How do I access the keyboard on the iPad, while in the user's script ? ;)
Maybe you'll have to force a toolpalette with a "Back to Editor" function, or force the "EE" key (backing up the user's on.charIn, handle the EE button, then let the user's charIn resume/continue.)

- I'm still a bit confused about setting the api level: What do I have to do that the editor runs on older OS (3.0-3.1) but also executes newer functions?
- Don't put any platform.apilevel at the top of the script source
- make a bunch of tests for the functions that are new in 3.2 and 3.4. (the if you made, that's good. However you dont need if on.resize, that exists on all versions.  ; whatch out with on.create/on.construction. in on.construction all the API isn't ready yet. if you need some API things in it, reconsider this by making init codes within on.resize for example)
- compile the .lua file with Luna to get a .tns working with any 3.x OS.
- make any change to the .tns with a 3.1 software if needed (here, adding the tab 1.2...) .
- Save under OS/software 3.1




Edit : watch out for the screen size available when the keyboard is up, on the iPad. There are some functions that will help you here : http://wiki.inspired-lua.org/Changes_in_OS_3.4 (platform.window:getScrollHeight() etc.)

Edit2 : see the edits on my post before ?
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 24, 2013, 04:35:45 pm
When you paste, you are waiting for an event like a click to occur, what about just showing the pasted text as soon as it's done ? ;)
Yeah, I'll fix that

Edit 5 : You should put copy/paste in an "Edit" toolpalette.
Ok, I'll do that

Well, in the output script, reordering the things by hand would work ^^
Yeah, but... work :( ok, I'll do it

Yes there is. I guess it can work, I haven't tested. However, the thing is : How do I access the keyboard on the iPad, while in the user's script ? ;)
Maybe you'll have to force a toolpalette with a "Back to Editor" function, or force the "EE" key (backing up the user's on.charIn, handle the EE button, then let the user's charIn resume/continue.)
Maybe I'll just leave the Keyboard up and when the event on.keyboardDown() is fired, it'll automatically return to the editor because <epic> the last chance of return was destroyed </nonsense>

- Don't put any platform.apilevel at the top of the script source
- make a bunch of tests for the functions that are new in 3.2 and 3.4. (the if you made, that's good. However you dont need if on.resize, that exists on all versions.  ; whatch out with on.create/on.construction. in on.construction all the API isn't ready yet. if you need some API things in it, reconsider this by making init codes within on.resize for example)
- compile the .lua file with Luna to get a .tns working with any 3.x OS.
- make any change to the .tns with a 3.1 software if needed (here, adding the tab 1.2...) .
- Save under OS/software 3.1

Edit : watch out for the screen size available when the keyboard is up, on the iPad. There are some functions that will help you here : http://wiki.inspired-lua.org/Changes_in_OS_3.4 (platform.window:getScrollHeight() etc.)
Ok, I'll see what I can do here...

Edit: Can you please post the video here so I can see the situation?
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: mdr1 on July 24, 2013, 05:00:54 pm
Good improvements! And the included documentation is really great!

But I found a bug: when we press "tab", the cursor doesn't move. Moreover, why not insert a real tab instead of several spaces?

PS: Maybe .2 because of support for 0S 3.2? Or for the new page 1.2?
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on July 24, 2013, 05:16:08 pm
Ok, so :

a working .tns for the iPad (with fixes for the toolpalette bug, the keyboard now shows, and I overwrote the user toolpalette if it existed to have a menu item to go back to the editor. A better approach would be to scan for the user script for a toolpalette register, get the table and add an item (to go back to the editor)...) :
http://www.mirari.fr/4Cn9

(code I added when you inits the user script, after the series of if on.construction, if on.Resize, if on.create etc. :
            if platform.isTabletModeRendering and platform.isTabletModeRendering() then toolpalette.register({{"Script Editor",{"Go back", __mG.reloadSEHandlers}}}) end
)

also :
Code: [Select]
function __mG.on.mouseUp()
    __mG.mouseDown=nil
    if platform.isTabletModeRendering and platform.isTabletModeRendering() then -- 3.4 detection
        -- toolpalette bug workaround
        platform.window:setFocus(false)
        platform.window:setFocus(true)
        if touch then
             if not touch.isKeyboardVisible() then
                  touch.showKeyboard()
             end
        end
    end
end

and I put the toolpalette bug workaround in some places.

The full source with my changes :
http://pastebin.com/fX4CddMb


Edit :
- mdr1: works for me (on TINCS, though)
- Jens : well, it now works as expected with all that :) I'll do a video later.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 24, 2013, 05:17:20 pm
@mdr1:
- Thanks but please note that I didn't wrote it myself, it's from the official TI-nspire API Reference Guide (http://education.ti.com/nspire/scripting-api)
- Oh, thanks for the report, I'll fix it!
- "Maybe .2 because of support for 0S 3.2? Or for the new page 1.2?" Yeah, that's exactly what I meant... ;)

@adriweb: Thanks for the code, I'll implement those fixes tomorrow (Much to do tomorrow ;) ) but with your current code, if the user would change the menu somewhen after initialisation, the escape option would be overwritten. But I could redefine/modify toolpalette.register to add that menu item every time the user creates a new menu.

Edit:
In the Reference Guide I used
Code: [Select]
textBox=D2Editor.newRichText()
...
if textBox.setFontSize then
    textBox:setFontSize(size)
end
Is this right? I'm a bit confused because of ./:
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on July 24, 2013, 05:24:10 pm
Another feedback for the iPad (in addition to my post above with edits if you didn't see all that)
Since there is no "Esc" key, could you do something about that for the dialogs ?

Edit : yes about your idea to append a "back to script" to the user's toolpalette but now the "difficult" part is to get the user's toolpalette... (that would require parsing the types code for the table...)
Edit2 : wait, what am I thinking, just overwrite the register function >.> I'm tired lol

(Edit3 : typo)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 24, 2013, 06:06:07 pm
- About the "Esc" key: Which Key would be good?
- I forgot to ask: Are there characters like "[]" and "{}" on the ipad keyboard or do I have to do a "ipad layout" with better rebindings?
- About the toolpalette, thats the plan:
...
__mG.oldTPregister = toolpalette.register
function __mG.newTPregister(menu)
    table.insert(menu,{"Script Editor",{"Return",__mG.reloadSEhandlers}})
    __mG.oldTPregister(menu)
end
...
function __mG.runCode()
    toolpalette.register=__mG.newTPregister
    ...
end
...
function __mG.reloadSEhandlers()
    toolpalette.register=__mG.oldTPregister
    ....
end

No problems here :D and no time to be tired! It's time to work (Update 0.2 was released 3 am XD)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on July 24, 2013, 06:12:55 pm
- Esc key => Well, I'm not sure.... I'll see tomorrow on the iPad (I don't have it with me anymore now) but maybe space ?
- I believe they are available and act the same as in the computer software (or the calc), for the charIn.
- Toolpalette : yep ^^
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 24, 2013, 06:24:45 pm
@adriweb: Ok, then thank you for all your feedback and help! I think we'll get this to work on an iPad :D (after we filled like the whole page 5 in one day ^^)
Good night, I'll continue tomorrow!
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 25, 2013, 10:25:30 am
UPDATE!!
Version 0.4.3 is now attached to the first post!

New features:
- fully compatible to iPad (hopefully):
   - if on iPad, menu item "Script Editor" with special features gets attached to every user menu
   - Accept/Cancel Messages/Dialogues by clicking on/outside them
   - Improvements for Keyboard
- Copy/paste options now in the "Code" menu
- Controls layout option "no button rebindings" added
- Various bugfixes and Improvements, e.g.:
   - Messageboxes now look right in the desktop view
   - Menu items of the API Reference Guide are now sorted alphabetic

After I lost the work of hours on the content update of the Reference Guide to apiLevel='2.0' because of a stupid infinite loop I decided to ragequit and continue tonight ;)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on July 25, 2013, 03:14:08 pm
Very nice, I'll test that soon (and probably edit this post then) :)

Also, when in infinite loops on TINCS, you can "try" holding F12 (or pause, I dont rememeber which...), sometimes it breaks out of it.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 25, 2013, 08:31:47 pm
Update!
Version 0.4.4 is now attached to the first post!

Really small update here:
- apiLevel='2.0' functions added to the Reference Guide
- enhanced "About" Messagebox
- No improvements/bugfixes this time >:D

I hope this is one of the last versions, I actually have nothing left to do! :D
Special thanks to the TI-Planet user Lionel Debroux who keeps posting translations of the changelogs on the article of AnToX98 (http://tiplanet.org/forum/viewtopic.php?f=43&t=12651&sid=074aed37319c51e47c2ca618904ac2e1) ;D(http://www.omnimaga.org/Themes/default/images/gpbp_arrow_up.gif) (Yes, I'm still keeping an eye on it ;))
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Lionel Debroux on July 26, 2013, 09:29:18 am
Lately, Adriweb has been picking up a bit of slack in my changelog translations :)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 27, 2013, 01:18:40 pm
I think the program is finished, does everything work now? If so, then I'll compile it with Luna and then upload to ticalc.org.

Edit: Would there be problems if I'd just leave out setting the apilevel and don't compile with Luna? I tested it with apilevel='1.0' and '2.0'
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on July 27, 2013, 03:02:11 pm
I think the program is finished, does everything work now? If so, then I'll compile it with Luna and then upload to ticalc.org.

Edit: Would there be problems if I'd just leave out setting the apilevel and don't compile with Luna? I tested it with apilevel='1.0' and '2.0'
Well, as long as it runs on 3.1 :)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 27, 2013, 03:17:07 pm
Well, I guess not (I noticed that running a program made in OS 3.2 wont work on nspires with OS 3.0/3.1 without setting the apilevel to 1.0) but where do I get a 3.1 software to add page 1.2? And another question: I used "if touch and touch.isKeyboardAvailable then" somewhere; is that right or is "touch.isKeyboardAvailable" a function?
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: AnToX98 on July 28, 2013, 02:25:35 am
Wow I'm back from vacation and already 0.4.4's update ! Awesome work Jens !
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on July 28, 2013, 07:24:35 am
Well, I guess not (I noticed that running a program made in OS 3.2 wont work on nspires with OS 3.0/3.1 without setting the apilevel to 1.0) but where do I get a 3.1 software to add page 1.2?

You can download 3.1 software(s) here :
http://tiplanet.org/forum/archives_list.php?multi_chaine_search=Logiciels+TI-Nspire+3.1
(take the mac or PC version according to your platform, Teacher edition ("enseignant") lasts 90 days, student 30.)

And another question: I used "if touch and touch.isKeyboardAvailable then" somewhere; is that right or is "touch.isKeyboardAvailable" a function?
It's actually a function, but since Only the tablets' OS have it implemented... it works the same way. For forward compatibility, try calling the function, though, instead.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 28, 2013, 09:52:05 am
I don't get luna to work, I guess it's because I installed everything on my HDD while my SSD is my system drive. I'll just include two versions then:
- "apilevel1 OS 3.x" with "platform.apilevel='1.0'"
- "apilevel2+ OS 3.2+" without an apilevel setting
If I get it to work some day or find another way I'll update the file.

@AnToX98: Yes, 6 weeks holiday + Jens + Music = great programming progress :D
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on July 28, 2013, 01:59:38 pm
I don't get luna to work, I guess it's because I installed everything on my HDD while my SSD is my system drive. I'll just include two versions then:
- "apilevel1 OS 3.x" with "platform.apilevel='1.0'"
- "apilevel2+ OS 3.2+" without an apilevel setting
If I get it to work some day or find another way I'll update the file.

Good enough :)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 28, 2013, 03:43:27 pm
:hyper: IT'S FINISHED!!! :hyper:
Version 1.0 is now attached to the first post!

There are only small improvements from Version 0.4.4, but this is the final version!
It's the last version for now, but I already have ideas for 2.0!

Thanks to all who helped and supported me!
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: stevon8ter on July 28, 2013, 04:38:21 pm
congrats :D

i'll have to keep a look out for the games made with this, maybe i could clone some of them onto my ipad ;) (uses lua as well ;) )
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: stevon8ter on July 28, 2013, 04:38:25 pm
congrats :D

i'll have to keep a look out for the games made with this, maybe i could clone some of them onto my ipad ;) (uses lua as well ;) )
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 30, 2013, 03:35:54 pm
And finally (after 2 days) it's up on ticalc.org here:
http://www.ticalc.org/archives/files/fileinfo/454/45484.html (http://www.ticalc.org/archives/files/fileinfo/454/45484.html)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jonius7 on July 31, 2013, 06:16:01 am
Wow in the last few days, progress went from fast to supersonic!
Only one little thing, when you indent your code, and then backspace it, it comes out as backspacing spaces instead of an indent.
Also, how do you scroll down the info in the API guide?
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 31, 2013, 06:41:35 am
@Jonius7: Nice to see you back here :)
-About the indent: an indent is 4 spaces. Backspace removes only 1 character (=1 space) to remove the indent/the 4 spaces press shift+tab
-About the scrolling: for some reason you first have to click on the text and then you have a cursor to move around. But thats TI's Textbox, I think I can't do anything about it...

And as I said earlier to AnToX98:
6 weeks holiday + Jens + Music = great programming progress :D
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jonius7 on August 04, 2013, 10:17:10 am
And as I said earlier to AnToX98:
6 weeks holiday + Jens + Music = great programming progress :D
Yeah I wish I could do that, I probably could, but I get lazy and instead play too much games during my breaks.
Also, great effort making it iPad compatible. That must not have been easy.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Legimet on August 07, 2013, 11:42:13 am
Looks great! :)
Is there a way to extract saved lua code into a plain text file on a computer, to run with luna later?
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on August 07, 2013, 12:14:37 pm
@Legimet: Yes, do this:
1) Copy the script editor tns to a pc and run it with the student software/emulator
2) Load your file
3) menu==>code==>select all
4) press ctrl+c
then you can paste it anywhere as plain text and it is compatible to every text/script editor
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jonius7 on August 12, 2013, 10:14:55 am
Hmm I wish I had a valid license for TI Student Software.
Since I don't have it, I have heard of another way that may be possible with TNS2XML or something similar, but I haven't tried such stuff yet.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on August 12, 2013, 12:52:21 pm
You have tried the 2 demos ? (1 month + 3 months of trial in total)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Legimet on August 18, 2013, 06:45:01 am
I use Linux, so that's not a solution for me.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Levak on August 18, 2013, 07:01:38 am
I use Linux, so that's not a solution for me.
I use linux too and wine is my friend. I can even reinstall multiple trials by completly unintalling wine.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Legimet on August 18, 2013, 07:03:55 am
If it works in Linux, that's fine, but I'll probably just use TNS2XML.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on August 18, 2013, 01:13:50 pm
Maybe it's possible to extract stored variables out of .tns files? The code is saved as plain text in "jsefYOUR_NAME" (If you named your file "omnimaga" then it's stored in "jsefomnimaga")
I should include those tips in future versions in the redme.txt

PS: I have a completely unrelated idea: How about an "empy tns file" where you can paste your code and then it will forever execute the pasted code?
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: ElementCoder on August 18, 2013, 01:16:23 pm
PS: I have a completely unrelated idea: How about an "empy tns file" where you can paste your code and then it will forever execute the pasted code?
That's what oclua does (or at least the version I still have around) you write your script in a notepad or another thing, then copy/paste it in the lua script and it will execute your code.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on August 18, 2013, 03:04:33 pm
Yes, but everytime you want to execute your program, you have to select the code, copy it, switch page and paste. I'd make a tns, which ,once pasted code, forever starts up with your program, it would then be like a seperate program to use and broadcast (The sourcecode would only be <50 lines long). Btw oclua doesn't fire all those initialisation functions like on.activate
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: AnToX98 on August 25, 2013, 01:14:34 pm
I was wondering how do you compress your images in Lua ? Because 27 ko with all those textures :p
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on August 25, 2013, 05:11:55 pm
This Script Editor doesn't include any textures, the font and the menu is from the OS and everything else is generated with the graphic engine
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: AnToX98 on August 26, 2013, 03:08:26 am
Oh sorry I was talking about Minecraft 2D :P
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on August 26, 2013, 02:11:04 pm
I just started to work on version 2.0 and those are the features/changes I want to include:
- full console to see output of the print function
- User Skript runs on its own page to switch to the editor/console screen for debugging
- console runs on its own frame so that you can copy it and attach it to the running skript screen
- (as suggested by adriweb) an autocompletion popup
- (as suggested by AnToX98) a customizable "insert" function and customizable syntax colouring
- faster rendering (I'll have to do some research there, maybe if I'd use textures for letters or render them with gc:drawPolyLine(...))

Please tell me what you think of those features and feel free to make proposals if you have any suggestions for the new version!

PS: The development of this version 2.0 will be much slower! (school started again and I continued working on Minecraft 2D...)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: AnToX98 on August 26, 2013, 03:02:56 pm
This is nice update but it would be cool to enable selecting with shift (like on computers) instead of ctrl+click :p
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on August 27, 2013, 08:38:22 am
Yes, that would be cool, but unfortunately it is not possible to detect the shift or ctrl key :-\ ctrl+click is an exception because it triggeres the "grab" function
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: AnToX98 on August 30, 2013, 09:12:51 am
It would be cool to be able to custom the "insert" function in the menu, it would be very helpful :)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on August 30, 2013, 10:41:26 am
@AnToX98: Yeah, I had the same idea when I made that insert function, but I forgot it later, thank you very much for this suggestion, I'll add it to the list! :D
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: AnToX98 on September 03, 2013, 03:25:35 am
Two things :
- Is the physics engine running on this editor ?
- There's a bug when you "undo" just after inserting some stuff
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on September 03, 2013, 09:52:06 am
The physics engine should work on the apilevel2+ version and yes, there seems to be a bug at undoing an insertion, I'll fix that for v2.0 or maybe on an earlier version (possibly v1.0.1) thanks for the report!
Edit: I tested
Code: [Select]
require "color"
function on.paint(gc)
    gc:setColorRGB(color.red)
    gc:drawString("Red",10,30)
end
and it worked. That proves that loading libraries works!
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: AnToX98 on September 03, 2013, 10:20:53 am
It's strange because when I tested, it don't worked... I'll check again :p

EDIT : This code works on TINSS but don't works on your editor :S. Is there an error on the code or a problem with your editor ?

Code: [Select]
platform.apilevel = "2.0"
require "physics"
timer.start(0.01)

function on.resize()
    W = platform.window:width()
    H = platform.window:height()
    space = physics.Space()
    newBody = physics.Body(100, 0)
    newBody:setVel(physics.Vect(1000,1000))
    space:addBody(newBody)
end

function on.paint(gc)
   
    local width = W/10
    local pos = newBody:pos()
    local vel = newBody:vel()
    local velX = vel:x()
    local velY = vel:y()
    local posX = pos:x()
    local posY = pos:y()
 
    if posX > W then
        velX = -1 * math.abs(velX)
        posX = W
    elseif posX < 0 then
        velX = math.abs(velX)
        posX = 0
    end
    if posY > H then
        velY = -1 * math.abs(velY)
        posY = H
    elseif posY < 0 then
        velY = math.abs(velY)
        posY = 0
    end

    newBody:setPos( physics.Vect(posX, posY) )
    newBody:setVel( physics.Vect(velX, velY) )
    gc:setColorRGB(0, 0, 255)
    gc:fillArc(posX, posY, width, width, 0, 360)
end

function on.timer()
    space:step(0.01)
    platform.window:invalidate()
end
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on September 04, 2013, 09:48:25 am
That's very strange, I copied the code and it works perfectly when I run it in my Editor. Mybe it's because of the line platform.apilevel = "2.0", that doesn't have any effect in the Editor because it's not on the first line on the whole program and it can cause errors if you do it anyways. Are you sure that you are using the file "Jens' Script Editor apilevel2+"? What error does it output?
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: AnToX98 on September 05, 2013, 11:48:57 am
Yeah sorry I made a mistake, now it works perfectly :)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: ElementCoder on September 05, 2013, 02:43:48 pm
Thanks to this I'm able to do some coding on the daily bus ride to school and the manual page has proven to be immensely helpful :)
The word 'class' doesn't seem to be highlighted (pink) for me. I'm using the 3.1 version. I'm looking forward to the 2.0 version.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on September 05, 2013, 04:06:43 pm
@ElementCoder: That's the purpose I made it for, I'm glad that it's useful for you :) And yes, class() is not highlighted yet, I forgot that because it was not listed under the basic functions... thanks for the report, I'll fix that for the next update!
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: AnToX98 on September 06, 2013, 05:52:25 am
I think the "repeat" loop is not highlighted to.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on September 06, 2013, 08:18:53 am
Indeed, I dont know where to get a list of all keywords to mark... If you find more I forgot please report it! Here are the lists of the keywords I got now:
Spoiler For Purple:
"'",'"',"[[","]]","nil","true","false"
Spoiler For Blue:
"function","return","end","for","in","do","if","then","else","elseif","while","and","or","not","local","repeat","break"
Spoiler For Pink:
"assert","collectgarbage","error","_G","getfenv","getmetatable","ipairs","load","loadstring","next","pairs","pcall","print","rawequal","rawget","rawset","select","setfenv","setmetatable","tonumber","tostring","type","unpack","_VERSION","xpcall","require","class"
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: AnToX98 on September 26, 2013, 01:24:03 pm
Would be super interesting to custom the color synthaxing, or simply improve it (like, puting number input in green)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on September 26, 2013, 04:03:51 pm
Ah, good idea, I'll add that to the list. The most work will be developing a gui for that :P
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Roondak on September 28, 2013, 11:47:36 am
I've been using this script editor, it's really good.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on September 29, 2013, 08:12:53 am
Small Update: Version 1.0.1 is now attached to the first Post
It only contains some Bugfixes, missing syntax colorations and huge performance optimisations!
It now runs superfast on handheld device because of partially frame updates!
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on September 29, 2013, 08:23:18 am
Very nice :D

Not so much of a small update, then :)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: AnToX98 on October 01, 2013, 10:29:27 am
That's a very nice update (I tested it and it works fine) but there's some bugs :
- When you add a new line with enter, all the code dissapear
That's is an all versions bug, but it's very annoying :
- Running TI-images on code slow down very much the editor (If there's no way to correct this, maybe create a different editor page only for TI-images ?)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: LDStudios on October 01, 2013, 09:23:04 pm
I really like this program. The one issue is that long scripts cause the program to run slow, but there is not a whole lot that can be done about this. It is MUCH faster with the update though, Nice job!
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on October 02, 2013, 07:27:32 am
Thank you all for your nice feedback! :D

@AnToX98: Indeed, these are serious bugs which I have to fix soon, thanks for the report!
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on October 09, 2013, 01:42:23 pm
Another tiny Update: Version 1.0.2 is now attached to the first Post

Fixes:
- program won't crash now if you try to copy an empty line
- all lines will now be visible if you press enter on an indented line
- syntax colouring is now limited to 250 chars/line
- correct description of image:rotate in the Reference Guide

Very long lines of code will still vastly slow the editor down but not as much as before :P But I know what the problem is now and I'll try to solve it for v2.0!
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: AnToX98 on October 30, 2013, 06:04:54 am
Working on insert function ? Because we really need that, coding oncalc is not very confonrtable with the non-azerty keyboard :3
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: The_King on November 03, 2013, 02:02:53 pm
jens
this is great
i am a beginner @ lua
yet this helping a lot
but i have a request
can u make separate document for lua directory with greater explanation


 
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: LDStudios on November 03, 2013, 02:06:29 pm
:D Always nice to see another lua programmer
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on November 03, 2013, 04:54:30 pm
@hking1: Hi and welcome to omnimaga! Im glad to see that my program helps newcomer to get into nspire lua programming :) The included reference guide is the official scripting api guide (http://education.ti.com/nspire/scripting-api). I think once you understood the basics it's enough information to use those functions properly. To get into nspire lua programming, here (http://wiki.inspired-lua.org) is a very useful wiki. To understand the structure of a nspire program just download a random program at ticalc.org (http://www.ticalc.org/pub/nspire/lua) and look through the code (That's how I learned lua programming ;)) I hope this helps a bit; I'm not that good at writing guides (in english)...

@AnToX98: Well, I'm very busy with Minecraft 2D and school right now, I don't know when I'll be able to come back to work on the script editor. But I promise to work on the insert function first ;)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: The_King on November 06, 2013, 10:00:20 pm
i have a problem ??? ???
when you want to publish a program i can save the document as something else. but pressing the [EE] button just opens the code again.
hope someone will help
thanks in advance.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: ElementCoder on November 07, 2013, 12:17:31 am
To make a tns document for your program you need an external tool such as the student/teacher software or th 3rd party tool luna.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: AnToX98 on November 07, 2013, 11:43:31 am
A little thing you should correct also :
- When using the 2D editor, you can't escape with [EE]
- It would be possible to create shortcuts, like [ctrl] + [7] to go at the the end of the code ?
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on November 07, 2013, 12:39:30 pm
@hking1 & ElementCoder: I have already a document lying around where you can insert your code once and then it will execute it automatically when restarting it. It would be like a seperate self-made program. I will include it to v2.0

@AnToX98: Yep, as mentioned in the readme, you shouldn't use the 2D Editors yet, if you don't remove.them yourself before exiting your program. But I already have an idea for that... is the a way to remove or hide the 2D Editors in apilevel 1?
Unfortunately, there is neither an event for ctrl+number nor for the ctrl key and I also used every detectable button... but you can do menu => 5 => 2 to get to the end.
Aand sorry for my stupidity about the insert function :/ I didn't notice that I broke it completely; I'll fix that soon :)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Levak on November 07, 2013, 01:03:15 pm
is the a way to remove or hide the 2D Editors in apilevel 1?
No, and this is why it exists in apilevel 2. In apilevel 1, D2Editors were unusable.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: AnToX98 on November 07, 2013, 02:15:09 pm
@Ok thank you for fast-answering :)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: AnToX98 on March 09, 2014, 04:56:24 am

Hey Jen's, i'm back with the features would be cool to add in v2.0 :)
These might be difficult to add but they'll make the editor so much better !


- Add a separated window with Only Images ! Images slow the coding too much !
- Possibility to edit TI-Images like Ncreator and directly copy the code to the Images window
- Autocompleting ?
- More synthax colouring, like with numbers or names of functions.


PS : I would recommend the Sublime text Lua synthax and colours that are so pretty
Pierrotdu18 started changing the colours of your editor :


(http://replayism.com/images/fixe_lua2.png)(http://img4.hostingpics.net/pics/545498temp.jpg)

But with numbers and functions names, in Sublime text 2 :


(http://i.imgur.com/u7HJh0f.png)




- Auto-indenting when writing if then/for do/ function()
- When autocompleting/writing gc:setColorRBG : possibility to open a little popup and choose color


I don't know if I said everything but these are all ideas and it's up to you :)
If someone has more ideas post it right here for 2.0 :)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: LDStudios on March 09, 2014, 07:10:25 am
Having those colors would be awesome. I would also love the ability to search and replace :)
Anyways, this is pretty much my favorite lua program.  :D
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on March 09, 2014, 07:48:17 am
@AnToX98: Thank you very much for the suggestions, that looks very cool! Now I'm looking forward to work on the editor again :D But to make that all properly, I'll have to rewrite very much of the code because some parts are really bad and slow; also a screen manager would be important for all the dialogues for the new features! I also didn't know about some very useful functions of the string library, which would make everything better! And seperating editor, console and user script to individual windows removes the annoying __mG! That will be über cool! :D :D

PS: How do you name development versions between v1.0 and v2.0?
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: The_King on March 09, 2014, 07:10:47 pm


PS: How do you name development versions between v1.0 and v2.0?


v1.5 maybe ;)

also i like the background color for the the pics by antox98
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: AnToX98 on March 10, 2014, 07:04:25 am

Other thing that would be very helpful when we're coding oncalc.
In a coding software called Intellij IDEA, you can reduce functions/strings. There's also a lot of things like autocompletion (Nspire API by Adriweb), and details that make programming so much easier :)


(http://i.imgur.com/1MfvLgp.png)


(http://i.imgur.com/4Bxmj7F.png)


(http://i.imgur.com/ty3EUWo.png)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: LDStudios on March 10, 2014, 09:48:21 am
You could also add a quicker method of scrolling. In oclua, I enjoyed the ctrl+9 and ctrl+3 that are quick scrollers for notes pages. I know you have the bar on the side, but I hate using the mouse. I would love a shortcut for scrolling faster :)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on May 25, 2014, 10:58:26 am

Hello again!


Well, you may noticed that the reboot of this project didn't proceed as intended; When I looked in the code the only thing I saw was very much work, and everything I did ended up in problems an more work which quite deterred me.


But finally I pulled myself up and did a huge chunk of work on this project so that I finally finished the following features:
- seperate editor, console and user script application
- far more efficient syntax colouring: Image codes are no problem anymore!
- advanced protection: custom event distribution and defining event handling functions after initialization is now supported and protected
- fixed the "insert" function


I know, that doesn't look like much work, it was enough to keep me from making progress :P
Now that I "broke this barrier", I hopefully can continue to work on your suggested features :D


Here is what's planned for v2.0
- autocompletion
- customizable "insert" function
- customizable syntax colouring
- better unicode character support
- better saving and loading (the menu doesn't support dynamic changes on OS 3.0, which is why some people had problems with loading)
- unlimited code length (It's currently limited by the maximum length of saveable strings)
- more detailed error screen with informations(callStack and local variables) via the registerErrorHandler; therefor only for apilevel 2.0
- save use of the 2DEditor (only for apilevel 2.0)
- if possible: resetting environment for every new "build" via setfenv (I have to do some research here)


The current develpment version is still very unstable and buggy, but as soon as I think it's usable, I'll upload it :3
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on May 25, 2014, 12:06:43 pm
Nice :D
GLHF !

Also, you should wonder if you want to support old apilevel (since 3.6 is ndlessed, not a whole lot of people will be/stay on OS 3.1 forever...).

On some cases, it will be simpler to just use new apis rather than testing if it's available then use it, (in addition to having to code fallbacks (when possible) for older versions.)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: AnToX98 on May 25, 2014, 02:55:04 pm
Thank you jens you are awesome :)

Reducing functions would be very nice to as I mentioned it but I know it's hard to do it :)


Could you give anyways the new file ?


Another question : how about compatibility with the "Ressources" images on os 3.6 ? And customize the colours ?
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on May 25, 2014, 05:01:34 pm
Also, you should wonder if you want to support old apilevel (since 3.6 is ndlessed, not a whole lot of people will be/stay on OS 3.1 forever...).

On some cases, it will be simpler to just use new apis rather than testing if it's available then use it, (in addition to having to code fallbacks (when possible) for older versions.)
Yes, you are right! Covering all possible situations for an error is far more complicated that just register and errorHandler... but now I already covered the most anyways ^^
But outsourcing the loading menu to a seperate GUI to be able to load files on apilevel 1.0 would be much work... I think I'll add a poll to this topic for the question of compatibility!


Reducing functions would be very nice to as I mentioned it but I know it's hard to do it :)
Yes, very hard indeed... I currently have no idea how to realize that with the current "engine"... But it wouldn't be the first time if I found an unexpected solution in the middle of a boring history lesson ;)

Could you give anyways the new file ?
Um... lets say tomorrow (trust me, you wouldn't have much fun with the current mess of the front-end! ;))

Another question : how about compatibility with the "Ressources" images on os 3.6 ? And customize the colours ?
I still use the old 3.2 software (sorry), because I couldn't find much informations about 3.6; neither about the lua api, nor the 3.6 script editor. Does it still have an option to convert an image to the old format?
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: AnToX98 on May 26, 2014, 12:08:37 pm
The old image format still works as well.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on May 27, 2014, 11:28:52 am
Sorry, I had no time yesterday, but now here is the first v2.0 alpha release:

Improvements:
- Seperate Applications for editor, console and user script execution application (I have no idea how to call it :P )
- console:
  - logs the "print" outputs, errors and status logs of the editor (will be adjustable)
  - scroll with arrow keys
  - clear with ctrl+del
- user script executor  ::)
  - support and securety for advanced event handling
- editor
  - fixed the insert function
  - more efficient syntax colouring (still a bit buggy)



Note:
- This is a very early alpha release, there are many bugs and unfinished features, feel free to report all bugs you find!
- After hitting "run" in the menu, switch to page 1.2; there your script will get executed as soon as you switch
- To stop your program switch back to the editor and press the return-button ("the little arrow in the bottom right corner)
- You have to manually stop the running program before you can start a new version
- Starting and stopping your script will be much easier and clearer in future releases

- You can freely rearrange and resize the applications as wanted, but only the console application is ment to be copy&pasted
- If the console on the user script page gets in your way, just click on it's bar and delete it
- The whole code is muddled up, I'll tidy it up later

PS: I'm also searching for a better name; "Jens' Script Editor" is quite unhandy... Would "IDE" be a correct term to describe this program, so that I can call it "jIDE" or something like that?
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on May 27, 2014, 11:58:49 am
You can stick with TINCS 3.2, it will be better for at least easily support OS 3.2.
And the apilevel by default will be good enough.

Downloaded the version, will try soon :)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: AnToX98 on May 27, 2014, 12:06:34 pm
Why I can't open MENU :D ?
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on May 27, 2014, 12:16:24 pm
Why I can't open MENU :D ?
Probably because you focus the console application, that happened to me too a few times ;) Just click on the editor so that it's rim is black instead of grey
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: AnToX98 on May 27, 2014, 12:42:03 pm
No I'm 100% on the editor and I can't open menu :(


EDIT : I deleted "platform.apilevel = 1.0" and replaced create by on.construction and it works :D
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: mdr1 on May 27, 2014, 02:58:01 pm
It doesn't work on 3.1. :(
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on May 27, 2014, 04:59:32 pm
No I'm 100% on the editor and I can't open menu :(


EDIT : I deleted "platform.apilevel = 1.0" and replaced create by on.construction and it works :D
Hm.. I couldn't recreate the problem, probably because you have 3.6 and I have 3.2... Thanks for the report, I'll fix it!


It doesn't work on 3.1. :(
Yes, this prerelease works only on OS>=3.2! I didn't think anybody still uses OS 3.1. Is there a special reason that you still use it? Because I'm not sure if I should still support OS3.1
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Streetwalrus on May 27, 2014, 05:33:39 pm
I plan to stick with os 3.1 because 3.6 sucks. :P Ndless 3.6 still supports it.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: DJ Omnimaga on May 27, 2014, 05:37:25 pm
The only reason why I think OS 3.1 could be used is that it's smaller, so you have extra diskspace to stock games and programs. However, OS 3.6 has a much faster Lua language than previous OSes so it has more game possibilities, while still having Ndless support.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Streetwalrus on May 27, 2014, 05:39:16 pm
Nah, I heard too much crap about OS 3.6. This is definitely not going onto my calc. :P
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on May 27, 2014, 06:07:30 pm
Ok I understand that you don't upgrade to 3.6 (I haven't upgraded yet too) but whats the problem with 3.2?
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Streetwalrus on May 27, 2014, 06:11:07 pm
I do dual boot 3.2 already. So it not running on 3.1 is not an issue as long as 3.2 works. ;)
The "wrong" part about 3.2 is no ndless on it.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on May 27, 2014, 06:15:57 pm
Ok, thank you! Supporting 3.1 would be much more work (as I mentioned earlier). So I'll develop for OS3.2+ for now and maybe do a 3.1 version later :)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Streetwalrus on May 27, 2014, 06:18:11 pm
OK nice. :)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: DJ Omnimaga on May 28, 2014, 12:27:56 am
I wonder if all OS 3.6 lua programs are guaranteed to run on 3.2? That could be an alternative as well. I'm just worried that now that Ndless 3.6 is out, fewer and fewer people will keep OS 3.1 and 3.2 compatibility, especially in games.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on May 28, 2014, 02:12:45 am
If you're using 3.2's apilevel (thus not using the new image/resource system, yes, the script (code) will be compatible.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: mdr1 on May 29, 2014, 05:59:33 am
Yes, this prerelease works only on OS>=3.2! I didn't think anybody still uses OS 3.1. Is there a special reason that you still use it? Because I'm not sure if I should still support OS3.1
Well, I'm not alone to remain on OS 3.1 because since the 3.2, many many bugs and display issues appeared.
But too bad if it's too much work. ;)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on June 09, 2014, 04:50:31 pm

Hello!
After wasting a bit of time with fractals I finished the second v2.0 alpha release today :) I also tried to use the "callStack" and "locals" information of the registered error handler but unfortunately those are not available for code loaded with the loadstring function, so this feature will not be possible to implement.  Anyways, here's what's new:


New features:
- the whole color-set can be customized now (menu => Style => Customize) (no custom syntax coloring yet!)
- added menu to the console application: choose which logs you want to get displayed! (The small squares in the upper right corner are indicators: black=print; red=errors; blue=status)
- now use of platform.registerErrorHandler ==> no crash possible anymore (on apilevel>1.0)
- use of custom error handler is still possible
- safe use of 2DEditors: they get removed as soon as you stop the script


Improvements/Changes:
- various fixes
- slightly optimized and improved syntax colouring
- now all dialogues are centered
- switched back to rendering only ascii characters because of performance; they still work but in the editor they are representated by their UTF-8 code
- added dialogue for stopping the user script


I also noticed that I have fallbacks for all apilevel 2.0 features, so I can continue the support for OS3.1 for now :)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: LDStudios on June 09, 2014, 05:03:50 pm
So nice to see that you are working on this! I like the idea of custom styles, but the controls for it are a bit awkward right now. I'm even more excited about the use of errorhandler to prevent crashing. Great work and I look forward to the next release!
Also, could you add more to the standard libs in your API Reference Guide on calc? I had not being able to check the string and math libraries on calc.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: mdr1 on June 10, 2014, 11:42:42 am
3.1! Great! I found a bug: when I launch the script and I modify it by removing a character, the application makes an error:
991: attempt to index field '?' (a nil value)

LDStudios: Those libraries are in the guide in the editor.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on June 10, 2014, 01:07:20 pm
3.1! Great! I found a bug: when I launch the script and I modify it by removing a character, the application makes an error:
991: attempt to index field '?' (a nil value)
Oh, yes, thank you for the report! I forgot some handlers for the new dialogue... Just don't try to modify your code while the script is running for now  ::)


LDStudios: Those libraries are in the guide in the editor.
LDStudios ment the standard libraries explained here: http://www.lua.org/manual/5.0/manual.html#5.1 (http://www.lua.org/manual/5.0/manual.html#5.1). I now plan to make an addable library file that includes the extended guide data  :)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on June 27, 2014, 09:49:09 am

Hi, sorry for this late update, but I didn't have much time lately...
Anyways here's the 3. alpha release of v2.0!


New Features/Improvements:
- change fontsize with "shift" & "+" and "shift" & "-"
- global environment now resets for each new build
- ctrl+M selects the current line and moves the cursor to its end
- rudimentary "find" function (menu=>"View"=>"Find")
- 90% faster and more accurate syntax colouring algorithm  (image code is defenitely no problem anymore!  :) )
- EE key now inserts a "#"
- improved file name format (longer names and less bugs)
- button rebindings now also works for dialogue inputs


Bugfixes:
- fixed a crash after undoing (still many bugs to fix with undoing...)


I also started working on a gui engine for better dialogues and easier and faster development of the guis for customnizations and other advanced functions!  :)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: mdr1 on July 08, 2014, 01:02:31 pm
Hi! Great work!

The ctrl+M doesn't select anything on 3.1 and the menu is unopenable though.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 08, 2014, 04:56:56 pm

So, here is the 4. alpha release of v2.0!


New Features & Improvements:
- implemented gui engine ==> better dialogues
- fully functional "find" function
  - option to search only whole word
  - option to search from cursor or from script start
  - enable/disable case sensibility
- autocompletion: press the return(↵)-key to open the autocompletion menu (customizability planned)
- color of strings, comments, keywords and lua standardFunctions is now customizable (proper syntax marking options are planned)
- replaced the old "Load" menu by a new filemanager
  - function to rename files
  - saved files can now be seen by OS 3.1!
- polished look of user script page


Fixes:
- moved menu initialization into on.activate ==> menu shows up on all OS again (sorry, forgot to fix it earlier :P )
- removal of "carriage return" characters of pasted texts


PS: I wrote the gui engine from scratch and didn't do thaat much testing, so some features might be a bit buggy! Feel free to report all bugs you find!  ;)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on July 08, 2014, 06:14:14 pm
Very nice :D
(I summed it up on tiplanet (http://tiplanet.org/forum/viewtopic.php?p=167741#p167741), btw)

Also, it crashed (line 2327 : attempt to index field '?' a nil value) when I tried to copy a part of the code I selected.

Why don't you just enable the errorHandler, by the way, for "releases" ? :P
(I don't recommend enabling it while writing/debugging, though ^^)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: LDStudios on July 08, 2014, 09:06:38 pm
I missed a lot while on vacation, this is looking amazing!
I can't wait to try it, great work as always!

I have a few suggestions:
-Ability to enable a specific key to restart script while on the page that runs it (any key or no key) because its annoying to do ctrl+left, escape, menu, enter, enter every time you want to restart it.
-Custom Libraries, with Adriweb's Better Lua API as a built in library. Also the ability to add other libraries of your own.
-Menu Items that are toggle based should have a checkmark next to them when turned on (checkmark character is in the character lib.. somewhere) EDIT: for things like font, write the current font next to it.
-Still waiting for that Standard Lib API guide  ;)

EDIT:

Okay, so I tried it out, and I have a few more suggestions/bug reports:
-Use of cursor.set() for selecting items in a dialog box, and for buttons
-Ability to  click the X in the top right of the customize box
-Clicking outside of a dialog box is the equivalent of pressing escape
-The application that runs the script didn't work for me until I clicked on the page, after the first time it worked fine
-In the customization menu, draw a square with the current color of the item, next to the name of the item so you can tell what it is currently set to
-Ability to mark check boxes with cursor as well as buttons
-Customization of syntax separate from customization of other stuff
-Ability to save custom themes
-Ability to customize dialog box colors

Also, how did you use ctrl+M to select the line?

2nd EDIT: I just wrote a lot of stuff ^ I understand if you don't want to do any of it, or if its just too much. Just a few of my thoughts to improve. Can't wait for the next update!  :D
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Streetwalrus on July 09, 2014, 08:41:46 am
Nice new features ! ;)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 09, 2014, 03:47:27 pm
Very nice :D
(I summed it up on tiplanet (http://tiplanet.org/forum/viewtopic.php?p=167741#p167741), btw)
Nice! I like that updates still get translated to ti-planet for the french community!  :)


Also, it crashed (line 2327 : attempt to index field '?' a nil value) when I tried to copy a part of the code I selected.
Thanks for the report, but I was not able to recreate the bug and I have no idea what could have caused it... But I made that part a bit safer to prevent a crash

Why don't you just enable the errorHandler, by the way, for "releases" ? :P
(I don't recommend enabling it while writing/debugging, though ^^)
Yes, you're right, I'll  do that  ;)




@LDStudios: First, thanks for all the good suggestions and reports!
-Custom Libraries, with Adriweb's Better Lua API as a built in library. Also the ability to add other libraries of your own.
Sorry, but I don't like the idea of a special environment. I want to keep the compatibility of the script as it is to any emulator. But you could pack the library into a library file and load it in your script! Another option would be, that I'll implement the option of setting a custom standard "Header" which is inserted in every new file you create. (Sorry, my english is bad today  :P )

-Ability to  click the X in the top right of the customize box
-Ability to mark check boxes with cursor as well as buttons
This is both already possible; it's just nearly impossible to aim correctly with the "text" cursor. But, as you mentioned, I'll change to the default cursor for dialogues in future ;)


-The application that runs the script didn't work for me until I clicked on the page, after the first time it worked fine
That's probably because the console application was focused. That's not really a bug, because the execution of the script in the user script page is triggered by the "on.activate" event, which is only triggered if it's application is focused.

-Ability to save custom themes
Indeed, it works fine on the emulator but doesn't on the handheld. The problem seems to be that var.recall apparently doesn't work in the first call of on.activate. I hate that TI doesn't mention such things in their guide and have such differences between emulator and handheld...  :(  I'll try to find an other suitable event for initialization that fits all needs then...  :/


Also, how did you use ctrl+M to select the line?
ctrl+M triggers the on.createMathBox event on OS>3.1

I added all the other things you wrote to my todo-list  ;)

Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on July 09, 2014, 03:56:04 pm
-Ability to save custom themes
Indeed, it works fine on the emulator but doesn't on the handheld. The problem seems to be that var.recall apparently doesn't work in the first call of on.activate. I hate that TI doesn't mention such things in their guide and have such differences between emulator and handheld...  :(  I'll try to find an other suitable event for initialization that fits all needs then...  :/


TI does warn about this kind of stuff for other functions... but apparently they forgot this one ?
Anyway, on.resize makes a good init functions.


But all that's obsolete with 3.9 where you can call any Nspire API function without having to worry if it's going to work (it will, as they kind of fake a first initial lua script setup, then launch the user code, so that the API is indeed ready.) So, basically, you're able to make an init() function and call it right after and whenever you need it.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: LDStudios on July 09, 2014, 04:05:00 pm
-Custom Libraries, with Adriweb's Better Lua API as a built in library. Also the ability to add other libraries of your own.
Sorry, but I don't like the idea of a special environment. I want to keep the compatibility of the script as it is to any emulator. But you could pack the library into a library file and load it in your script! Another option would be, that I'll implement the option of setting a custom standard "Header" which is inserted in every new file you create. (Sorry, my english is bad today  :P )

That makes sense, but you should at least be able to minimize the header so that you don't have to scroll through it.


Anyways, I probably won't be downloading JSE updates for a while, my calculator is broken and its useless on Student Software. I might be able to get a new one at the start of the school year but I'm not sure yet.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: DJ Omnimaga on July 10, 2014, 12:04:38 am
Wow I just saw the new features being added and the interface screenshots and good job. I like how this looks more and more like some sort of professional computer IDE. O.O
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: CinusMinus on July 11, 2014, 11:07:51 am
The last update includes some ncie functionality. However I found some bugs:
- the autocomplete function will only find functions for gc if you have "gc" or "gc:". Any further character won't be seen as part of "gc:", so "gc:f" will result in autocomplete option "for" and "function"
- When I tried to execute a script rebinding functions of the event handler using "setmetatable(on)" I encountered the problem that your execution page did this too and overwrote my event handler

And some ideas:
- Include other files saved in the editor as kind of header. Not just a standard header but any file that can be loaded from inside the editor
- make the autocompleter recognize variables and user functions
- include the standard table library to the autocompleter (you could also search _G and its subtables for available functions and tables)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 11, 2014, 03:34:08 pm
That makes sense, but you should at least be able to minimize the header so that you don't have to scroll through it.
Yes, but work! I'll have to completely rewrite many functions to make it possible to collapse/expand parts of the code; that'll take some time. I'll first implement a faster method of scrolling (as you suggested months ago); I only have to find a event for that: I think I'm already using all available Buttons  :/


Anyways, I probably won't be downloading JSE updates for a while, my calculator is broken and its useless on Student Software. I might be able to get a new one at the start of the school year but I'm not sure yet.
That's bad news! I hope that won't keep you from developing!


- the autocomplete function will only find functions for gc if you have "gc" or "gc:". Any further character won't be seen as part of "gc:", so "gc:f" will result in autocomplete option "for" and "function"
- include the standard table library to the autocompleter (you could also search _G and its subtables for available functions and tables)
I think you don't have the newest version; I already fixed both ;)

- When I tried to execute a script rebinding functions of the event handler using "setmetatable(on)" I encountered the problem that your execution page did this too and overwrote my event handler
Yes, that part of the code had some mistakes; it was on my todo-list to rewrite it for a while... I'll fix it for the next alpha release!

- make the autocompleter recognize variables and user functions
That'll be work too because the editor deosn't understand anything of the written code yet, it only colors it correctly. But soon holidays begin and I'll have more time to work then!  :)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: LDStudios on July 11, 2014, 03:41:20 pm
That makes sense, but you should at least be able to minimize the header so that you don't have to scroll through it.
Yes, but work! I'll have to completely rewrite many functions to make it possible to collapse/expand parts of the code; that'll take some time. I'll first implement a faster method of scrolling (as you suggested months ago); I only have to find a event for that: I think I'm already using all available Buttons  :/

You don't need collapsible functions, just have a menu item that hides the header.

Anyways, I probably won't be downloading JSE updates for a while, my calculator is broken and its useless on Student Software. I might be able to get a new one at the start of the school year but I'm not sure yet.
That's bad news! I hope that won't keep you from developing!

Hopefully it won't, I may get a new one at the beginning of the new school year, and I still have student software.

Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: CinusMinus on July 11, 2014, 04:49:09 pm
- the autocomplete function will only find functions for gc if you have "gc" or "gc:". Any further character won't be seen as part of "gc:", so "gc:f" will result in autocomplete option "for" and "function"
- include the standard table library to the autocompleter (you could also search _G and its subtables for available functions and tables)
I think you don't have the newest version; I already fixed both ;)
Even in the newest version the table library is not included to autocomplete ;) The coroutine library is mising, too
But the stuff with gc works fine :)

- make the autocompleter recognize variables and user functions
That'll be work too because the editor deosn't understand anything of the written code yet, it only colors it correctly. But soon holidays begin and I'll have more time to work then!  :)


Maybe you could load the code, cycle through the loaded _G and extract the functions? But I'm not sure if that would work
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: mdr1 on July 20, 2014, 06:11:46 am
On JSE 2.0A3 3.1, the multi-lines commentaries don't work:
Code: [Select]
--[[
A commentary
on several lines.
]]

JSE 2.0A4 doesn't work on 3.1.

It would be great to enable thanks to ndless to create a real Lua application with this program, like this editor is one.

EDIT: Special characters like "é", "è" and "à" don't work.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: CinusMinus on July 20, 2014, 06:37:48 am
It would be great to enable thanks to ndless to create a real Lua application with this program, like this editor is one.
The problem is that such a feature requires ndless and many people don't have ndless installed.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on July 20, 2014, 06:47:39 am
Sure, but for those who have it installed, the features is available and for those who don't, it's just "hidden" (or does nothing).
Detecting if ndless is installed is just doing : "if ndless then ... end", I believe. (that's because Ndless adds a global table called 'ndless' to Lua)


But that's not the "hard" part. The actual ndless hook (lua extension rather) that makes a proper .tns from a script is doable, I assume, but it would take a bit of work...


(@mdr1 : comments*)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 20, 2014, 09:45:19 am
On JSE 2.0A3 3.1, the multi-lines commentaries don't work:
Code: [Select]
--[[
A commentary
on several lines.
]]
It works, but the editor doesn't mark it correctly.

JSE 2.0A4 doesn't work on 3.1.
What's the problem? Does it not open, does it crash or does the menu not work?

It would be great to enable thanks to ndless to create a real Lua application with this program, like this editor is one.
I don't have ndless installed and I don't want to install it. But it's even possible with lua: A file where you can paste your code in and from then on it directly executes it everytime you open the file. It would handle exactly like a normal program with the given code. The only difference would be, that the file has a small script included, which loads the code from the memory.

EDIT: Special characters like "é", "è" and "à" don't work.
Yes, I switched back from rendering unicode characters to only ascii characters because of performance issues. Although they look strange in the editor, lua still handles them correctly.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: CinusMinus on July 20, 2014, 05:18:48 pm
It would be great to enable thanks to ndless to create a real Lua application with this program, like this editor is one.
I don't have ndless installed and I don't want to install it. But it's even possible with lua: A file where you can paste your code in and from then on it directly executes it everytime you open the file. It would handle exactly like a normal program with the given code. The only difference would be, that the file has a small script included, which loads the code from the memory.
itched back from rendering unicode characters to only ascii characters because of performance issues. Although they look strange in the editor, lua still handles them correctly.
Which is basically not much different from oclua. It would only keep the code forever.

But that's not the "hard" part. The actual ndless hook (lua extension rather) that makes a proper .tns from a script is doable, I assume, but it would take a bit of work...
Porting luna should do the job. The problem is that all libraries required to build luna have to be ported to ndless, too.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on July 20, 2014, 06:34:07 pm
@CinusMinus : nah, no need to port Luna, the OS has all the functions needed to create/encrypt/compress the XML into a proper .tns ;)
But then, it's a matter of finding them all (might have been done already) and call them correctly.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: mdr1 on July 21, 2014, 10:40:50 am
It works, but the editor doesn't mark it correctly.
That's what I meant. :)

What's the problem? Does it not open, does it crash or does the menu not work?

It seems you added JSE 2.0A4 3.1 but neither does it works. When I try to open it, the OS says the device has to be updated to open it.

Why does the unicode involve such performance issues?
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 21, 2014, 12:05:50 pm
What's the problem? Does it not open, does it crash or does the menu not work?

It seems you added JSE 2.0A4 3.1 but neither does it works. When I try to open it, the OS says the device has to be updated to open it.
Indeed, I had a problem registering my platform.withGC fallback function on apilevel="1.0", so I just disabled it and forgot to reenable it later, sorry!
Download the OS 3.1 version again to get the fixed file!
Thanks for the report!

Why does the unicode involve such performance issues?
Splitting a string in its characters and mind UTF-8 encoded unicode characters is a bit difficult. The Nspire API offers a special string.usub function for that, but it's slower than the normal string.sub function. Now after much optimizing, this wouldn't have a big impact anymore; I could switch it back, but there is  another problem: Most functions of the string library doesn't have a unicode equivalent, so I have to use the normal ascii-only functions. Using unicode characters at rendering, but using ascii-functions for editing leads to confusion results: I had this setup for v1.0 and there you can see offset cursor positions other weird behaviours when using unicode characters.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on July 21, 2014, 01:03:29 pm
If you want/need a string.ulen function, here you go :
 
Code: [Select]
function string.ulen(s) return select(2, s:gsub('[^\128-\193]', '')) end
(from https://github.com/Pogs/lua-utf8-simple/blob/master/utf8_simple.lua )
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: mdr1 on July 22, 2014, 09:30:15 am
It would be really great to avoid the confusion so that special characters can come back.

The 'fixed' file when launched has the following error: "40: attempt to call global 'getTableAsStrings' (a nil value)".
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on July 22, 2014, 09:38:01 am
The 'fixed' file when launched has the following error: "40: attempt to call global 'getTableAsStrings' (a nil value)".


Ok, fixed. NOW it should work...  ::)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: mdr1 on July 22, 2014, 10:42:35 am
Bug report: It is possible to go to the next item on the auto-completion menu with the return key but the arrow keys throw an "attempt to call a boolean value".

EDIT: And [Shift] + [down key] at any time throws the same error.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on August 24, 2014, 07:22:39 am

After vacation, gamescom and eye surgery I finally have time to work again! So here's the 5th alpha release of v2.0!

New:
- settings menu
  - adjustable amount of spaces per indent
  - activatable unicode mode (replaces some string functions by their unicode representive)
  - activatable autoregistered menu (OS>3.1) on user script page which offers to:
    - stop and restart current script
    - pause and resume current script
    - show/hide ipad keyboard
- shift++/shift+- now lets you scroll pagewise through your script
- insert saved files (menu=>"File"=>"Insert") (to insert saved headers and other stuff) *lazy solution :P *

Improvements:
- rewrote some safety functions
  - You can do everything with the "on"-table now; the user script page wont crash, even on OS 3.1!
  - eventhandling with on's metatable is now possible with nearly no restrictions and crashes
  - still "on" is only for eventhandling. For table library functions, it acts like an empty table!
  - don't write on=yourTable, do setmetatable(on,{_index=yourTable}) instead!
- improved dialogues (default cursor, customizable color, click outside = escape key)
- the editor now registeres an error handler on OS>3.1 so that it shouldn't crash
- the editor now searches for saved files instead of remembering them => less lost files

Fixes:
- print function now handles nil values correctly
- recalling saved settings now works
- added table and coroutine libraries to autocompletion list
- fixed that some scriptnames (e.g. starting with letter "e") were not possible


Here's also my current todo-list:
Spoiler For todo:
fix undo bugs
more error details
better unicode mode (ufind function needed)
customizable "insert"/autocomplete function
customizable syntax highlighting
unlimited code length (It's currently limited by the maximum length of saveable strings (65528 chars))
advanced lua&api guide
empty tns/script loader (in search of better name :P )
autosave (on.save,on.destroy,run)

As always, please report any bugs you find! ;)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Vsod99 on August 26, 2014, 07:27:06 pm
Sweet! I'm currently in the process of learning more advanced lua and the ability to do this on the go is great, glad you're still working on this project.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on October 07, 2014, 12:59:10 pm

Hi!
Sorry for the late update, I didn't have much time lately; but finally here is the 1st beta release of JSE v2.0!


Improvemetns:
- Custom syntax coloration!
  - you can now add new word groups and lua patterns and set their display color
  - I added some example entries which you can of course modify and remove
- Scripts are now split into (max. 26) parts with maximum saveble length (65528 chars)
  ==> Scripts can now have up to 1.7 million characters!
  (this feature took very long, because many features like saving, loading, deleting, renaming and transferring have to be able to process parts now)
  - "Export via Clipboard"-dialogue added to easier export long scripts via the limited clipboard storage
- Fully functional unicode support
  - everything (syntax coloring, find function, etc.) now works correctly in unicode mode (it's just a bit slower)
  - Added dialogue, asking for unicode mode when entering a non-ascii-character
  - UTF-8-sequence-bytes in not-unicode-mode are now represented by "□"
- Autosave function ("File"=>"Settings"): Saves current code in some events
- Textboxes now have a movable cursor and support paste
- If the on-table gets overwritten during initialization, the programm throws an error
- Added "Tipps & Tricks"-dialogue which shows some useful keycombinations, newcomers might not know


Fixes:
- Fixed (hopefully) all undo & redo bugs
- Modules (like "physics") are now usable more than 1 time :P


Other changes & improvements:
- "Insert"-menu now only offers to insert statements (use the autocomplete menu for eveything else)
- You can now reset the console via menu=>Delete=>Delete all
- Increased undo history depth from 10 to 20 states
- Pressing a letter button on listboxes makes it select the first item starting with this letter
- Rearranged main menu a bit to make it more handy


Now that all major bugs are fixed and most main features of v2.0 are implemented, I declare the beta stage, so feel free to report all bugs and strange behaviours of JSE! I will of course continue to work on it until I have finished all things on my todo-list ;)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on October 07, 2014, 01:54:14 pm
Nice !

Updated on TI-Planet too.
(however I was too lazy to translate the changelog so I just spoiler'ed a copy/paste :P)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: DJ Omnimaga on October 07, 2014, 01:54:51 pm
Looks very neat! :D
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: pierrotdu18 on October 08, 2014, 01:28:45 pm
It looks awesome !  :D


But... How can I do if I want for example to color only the content of the brackets after a function declaration ?
Like in sublime text : "function foo(a, b)", to put "a, b" in orange  ;D


Thanks a lot !


EDIT : In fact you should add a pritority for each pattern, cause as Lua patterns are not Regex...
For example, "function [%a%d%.]+%([%a%d%, ]*%)" colors me all the line even if I also have the pattern "function [%a%d%.]+" colored in an other color...
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on October 08, 2014, 03:55:37 pm
Thanks for the feedback!


@pierrotdu18: Yes, I thought about this option too. In fact, there is already a rudimentary option like this implemented (add ",overwrite=true" to an entry in the variable in jse.patterns), but it overwrites other coloration in any case, even inside strings. I will improve the custom syntax feature in future releases and add stuff like stuff like priority and hierarchies!  ;)  Btw: I saw your new sublime version (http://tiplanet.org/forum/viewtopic.php?f=19&t=14024&p=170831#p170831) on ti-planet; nice job! :)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: pierrotdu18 on October 08, 2014, 05:02:07 pm
Thanks :)


Ok that's cool, thanks too :D
And... do you think it woud be possible to input Regex Code and to treat inside the program the conversion to Lua patterns ?... Maybe it is impossible I don't know :p


Anyway, great job !  :thumbsup:
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on October 26, 2014, 04:06:47 pm
Hello! We're getting close to the final release; here's the 2nd beta release of JSE v2.0 :D ! This time I also attached the current (unfinished) state of the advanced Lua and physics api guide ;)

New:
- Autocompletion Settings (menu=>"File"=>"Settings"=>"Autocompletion Settings"):
  - You can now add own entries to the autocompletion list
  - If not disabled, after running your script, all global variable names are added to the autocomplete menu (Thanks CinusMinus for the idea!)
- Custom pattern are now colored in the set order
  - patterns are movable in the hierarchy list with + and -
- Advanced Lua Guide Loader on page 1.4
- User Script page now can print the value of an entered global value after a runtime error and after stopping the script
- Double click on a alphanumeric word to select it
  - Triple click on a sequence of non-space-characters to select it
- New Dialogue added, which asks for the calculator layout and then shows all character shortcut buttons

Improvements:
- Setting the apilevel in a script had caused bugs; it's now protected
- Vastly improved unicode-mode speed
- Improved method to reset global environment (some strange behaviours may be fixed now)
- console app now also uses the custom color-set of the editor
- Monitored variables will now be unmoitored after stopping the script
- Disabled rendering code as background for some dialogues to improve performance (only on handheld)
- Rewritten character-centering algorithm => unicode characters are now correctly monospaced

Other changes:
- User Script Page auto-registered menu is now enbled by default
- User Script Page now warns you if your script is ready but it's not focused
- Various fixes and performance improvements

About the advanced Lua Guide:
- It includes basic functions and libraries, directly parsed from http://www.lua.org/manual/5.1/manual.html (http://www.lua.org/manual/5.1/manual.html)
- It also includes the Phsysics part of the TI-Nspire Lua Scripting API Reference Guide (work in progress!)
- The file can view its content by itself and its content can be viewed with the Advanced Lua Guide Loader on page 1.4 of JSE
- To install it, place it in the MyLib-folder (don't rename it) and then refresh libraries (doc=>6)


I didn't have much time to debug this time, so it may includes some bugs; so as always: please report bugs and other oddities ;)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: The_King on October 26, 2014, 04:08:32 pm
Finally some news Good luck jens :D
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on October 27, 2014, 01:02:02 pm
Congrats - reposted on tiplanet and a bit translated in French : https://tiplanet.org/forum/viewtopic.php?p=171634#p171634
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: LDStudios on October 27, 2014, 05:08:09 pm
This coming out really good! I like the standard advanced lua guide, but I don't like having to put it in myLib. It's kind of annoying to not have everything in one file in one place. Couldn't you just put it in the document, and if someone didn't want it they could delete the page? (I'm assuming you put it separate just to save  the 17Kb..)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on October 27, 2014, 05:15:58 pm
@Adriweb: Thank you for keeping the ti-planet article updated; I would do it myself if I could speak french  ;) . Oh and I noticed that you apparently mistakenly translated and pasted the post of the older beta 1 version...


@LDStudios: You're right, I thought it would be bigger; I'll include it in the main file next update. I have to leave it on a seperate page from the other guide page though, because I already used all available toolbox items on this page and I can't dynamically change the menu's content on OS 3.1
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Adriweb on October 27, 2014, 05:34:42 pm
@Adriweb: Thank you for keeping the ti-planet article updated; I would do it myself if I could speak french  ;) . Oh and I noticed that you apparently mistakenly translated and pasted the post of the older beta 1 version...
damn it that's why it looked familiar lol
Will fix soon, thanks.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on November 27, 2014, 02:39:13 pm
Ok, here it is: Version 2.0 is finished!
I really don't have much time lately due to last-schoolyear-before-a-levels-related-stuff, but I definitely wanted to finish it before the end of ticalcs nomination november, so maybe I rushed this final release a bit... Anyways, here's the changelog:

New:
- New tool to change indentation width of your code (especially useful when copy&pasting code from/to other editors)
- You can now enter commands during runtime by pressing enter on a console app (which imo is a really cool feature)
- The editor will restore its saved state (including code and cursorposition)

Improvements:
- Rearranged menu so that it's more clear
- The advanced lua/physics guide is now on page 1.4 of the main file (it is still not finished)

Fixes:
- Setmetatable function now returns the new table properly
- Full module support (previous fix didn't work)
- Initalization functions (like on.resize and on.activate) are called more accurately (metatable event handlers are now only called once) and are crash-protected on OS 3.1
- various bugfixes due to code revision

Code Cleanup:
- A new settings loading/storing module manages settings now
- More comments
- Revised some older parts of the code

The attached archive contains both JSE files for OS 3.1 and OS>3.1, controls pictures of both Nspire layouts and a readme.txt
PS: I will upload it to ticalc.org and update the first post of this topic with a full v2.0 changelog as soon as I have the time for it  ;)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: DJ Omnimaga on November 28, 2014, 06:27:36 pm
Good job on this :D
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: mdr1 on December 08, 2014, 12:18:04 pm
Thanks again for this editor!

Though, in JSE 2.0, there is no menu and clicking on the right key at the start menu (choose between a touchpad, clickpad or computer) throws the following error:

(http://img11.hostingpics.net/pics/260213capture.png)

About the autompletion menu, should it be possible to auto-activate it? And some keywords like "function" or "for" should come with a space.

EDIT: I achieved to show the menu: just go to the home screen and then return to the document.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on December 08, 2014, 01:46:54 pm
Ok, it's now finally on ticalc.org (http://www.ticalc.org/archives/files/fileinfo/462/46209.html), although it seems like I was too late for POTY  :/

@mdr1: Thanks for the reports (I don't have acces to OS 3.1, so I can't debug it)! I think I know how to fix the menu; if you have acces to the code via the student software you can fix it like this: Put "createMenu()" somewhere in the end of the code, to call it during initialization. I will also fix this in the next update.
The other problem with the start menu is more difficult to solve, because I don't have much information about it and right now I can't think of any possible cause... Does this error only occur on this dialogue? What about using [tab] or other arrow keys?

PS: I now have updated the first post with current screenshots, current version and stuff.  ;)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: LDStudios on December 08, 2014, 03:01:54 pm
Ok, it's now finally on ticalc.org (http://www.ticalc.org/archives/files/fileinfo/462/46209.html), although it seems like I was too late for POTY  :/

@mdr1: Thanks for the reports (I don't have acces to OS 3.1, so I can't debug it)! I think I know how to fix the menu; if you have acces to the code via the student software you can fix it like this: Put "createMenu()" somewhere in the end of the code, to call it during initialization. I will also fix this in the next update.
The other problem with the start menu is more difficult to solve, because I don't have much information about it and right now I can't think of any possible cause... Does this error only occur on this dialogue? What about using [tab] or other arrow keys?

PS: I now have updated the first post with current screenshots, current version and stuff.  ;)
Shame its so late, this would completely deserve a POTY (IMO). I would recommend removing the earlier version from ticalc so that people don't get confused and so that everyone downloads the newest version.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on December 08, 2014, 03:53:50 pm
@LDStudios: Yes, I sent an email to the ticalc staff on the 28th November, pointing out that I want to replace the old file and participate on POTY, but I still didn't get an answer... Seems like they were busy
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: DJ Omnimaga on December 15, 2014, 01:23:18 pm
Yeah a lot of programs were missed for this year's nomination november it seems. D: Hopefully POTY 2015?
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on February 11, 2015, 10:14:27 am
Hi again! I'm back to programming after a longer break for the A-level and stuff. So here's version 2.1 of JSE (New Version is attached to first post):

New:
- Status Bar
  - enable/disable in "General Settings" Menu
  - displays current name of the script and status of the editor

Improvements:
- Completed Physic API Guide (I had to shorten it a bit)
- Revised Console:
  - You can now copy lines from the console to the clipboard
  - Console now supports line-breaks
  - Console now always remembers the last 100 lines and monitoring-settings
  - Console now scrolls automatically through long lines
- Keywords like "function" or "for" come with a space after inserting from the acutocompletion menu

Fixes:
- Menu should now be available on OS 3.1
- Fixed some minor bugs

Other Changes:
- Console now doesn't log status logs by default


If everything works, this will probably the last update of JSE! Thanks for all of your support so far; without it I probably wouldn't have finished it, or at least not in this polished state!
I tried to make the best possible on-calc Lua Editor and now it fits my needs perfectly, and I hope it is and will be useful to other Lua programmers too!  :)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: pierrotdu18 on February 12, 2015, 12:42:16 pm
It seem really great !  ;D
Just one thing, I remember we talked about a system of priorities for the syntax highliting, would it be possible to add it or is it to long ? :)
Anyway, good job  :thumbsup:
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on February 12, 2015, 01:35:28 pm
It seem really great !  ;D
Just one thing, I remember we talked about a system of priorities for the syntax highliting, would it be possible to add it or is it to long ? :)
Anyway, good job  :thumbsup:
It's already implemented, just press/click on + or - on the "Patterns" list  ;)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: pierrotdu18 on February 13, 2015, 01:03:17 pm
Wahou !
I was wondering why there were some "+" and "-" and I have The Answer  :angel:
Great, great, great, you're perfect  *.*
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on June 24, 2015, 09:37:08 am
Hello again!
I said v2.1 was probably the last update, but it just had too many bugs I wanted to get fixed and I also wanted to implement the autorun feature, so here it is: version 2.2, the second final update :P

New:
- Autorun-option: Script now automatically runs when switching to the user script page (can be disabled in the settings menu)
- Revised autocompletion: Autocompletion now immediately inserts completions
- New double-size character handling for chinese characters (and unintentionally some other adjacent characters)
- New key combination: ctrl + ^ acts like the Pos1-Button; it sets the cursor to the left-most position
- You can now add custom highlighting-start/end flags by placing empty captures in your pattern:
  - E.g.: The pattern "%a()%d+()%a" on the line "foo42bar" will only highlight "42"
- Updated API Reference Guide's content to apilevel 2.4
- The "Change Indentaion"-tool can now also change the indentation of only the selected code
- Added a 'Help' button and corresponding message for the "Custom Highlightig" dialogue
- You can now use the [×] and [÷] buttons to scroll through the guides' articles

Fixed and improved other minor stuff:
- Reordered graphical functions in the autocompletion menu to fit the (subjective) average amount of usage
- "Find..."-Dialogue now keeps its settings
- Color-adjustments for grayscale displays
- Fixed a lot of interface problems on desktop mode
- on.create and on.construction are now only called on their associated apiLevel
- Editor now checks for and denies 0 character matching patterns (which would freeze the editor)
- Pressing "enter" on a console line while entering a line to execute adds that line to your input
- Editor now warns you if you select "Emulator" on the initial device query dialogue (special keys are then disabled which would be a problem when sent to a handheld afterwards)
- shift+'+' and shift+'-' switched scrolling direction to fit the clickpad layout properly
- Fixed a frame-update problem when using ctrl+x
- Made keywords appear slightly darker by default
- Fixed possible lock-ups when using the menu during a dialogue
- Numbers are not highlited in identifiers anymore (using the new pattern flag feature
- Execution Page script clean-up
- Fixed some errors in the guides due to parsing-errors and typos

The updated file is attached to the first post.
So this is it, I probably won't bother you anymore with any further updates, I had my fun with this project  ;)

PS: wtof1996 from cncalc.org is has currently started working on a chinese translation of JSE2.2, so if you're chinese maybe you should keep an eye on that.


EDIT: Reuploaded a slightly updated file: Fixed a timer-freeze problem after restarting a script on OS 3.2
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Weley on January 08, 2017, 04:47:38 pm
I just discovered this amazing editor! ;D But on on OS 3.1 pressing an arrow key on the editor page causes it to crash with error, "attempt to call a boolean value." I was able to fix it by deleting this part:
Code: [Select]
--disable specific arrow key events (to trigger the on.arrowKey(direction) event)
on.arrowUp=false
on.arrowDown=false
on.arrowRight=false
on.arrowLeft=false

So I've attached the version with that small fix.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on January 08, 2017, 08:17:19 pm
I just discovered this amazing editor! ;D But on on OS 3.1 pressing an arrow key on the editor page causes it to crash with error, "attempt to call a boolean value." I was able to fix it by deleting this part:
Code: [Select]
--disable specific arrow key events (to trigger the on.arrowKey(direction) event)
on.arrowUp=false
on.arrowDown=false
on.arrowRight=false
on.arrowLeft=false


Hey, thanks for pointing that out!
And that's great timing because I was about to release v2.2.1 this week, which also fixes some problems on the newer OS, so I'll also include a fix for that problem! Seems like the event caller was a bit dumb on OS 3.1  ;D  While your fix may work on OS3.1 (can't test it my self), it doesn't work on OS3.2+, but I found a different solution (make the event distributor (on's metatable) return nil when the event is one of the arrow key events)
But I'm wondering how nobody pointed this out yet; those lines have been there since v2.0A4!

Also: Thanks everyone for voting for POTY 2016! That's my 3rd win in a row, and I'm not even active anymore :w00t: Are there no Lua programmers anymore?! But I'm really glad that this project finally got the POTY, because I didn't make this editor just for fun (well at first I did), but as soon as I noticed that people are actually using it (some even bought a Nspire because of it), I really invested quite some work and time to polish it, so that it becomes a proper, polished on-calc editor as it is today. Sorry for leaving it in this now broken state for so long, I'll fix it soon!
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: mdr1 on January 08, 2017, 08:34:30 pm
But I'm wondering how nobody pointed this out yet; those lines have been there since v2.0A4!
Well, if you look deeper in the topic, you will find that I had already reported such bugs:

Bug report: It is possible to go to the next item on the auto-completion menu with the return key but the arrow keys throw an "attempt to call a boolean value".

EDIT: And [Shift] + [down key] at any time throws the same error.

Thanks again for this editor!

Though, in JSE 2.0, there is no menu and clicking on the right key at the start menu (choose between a touchpad, clickpad or computer) throws the following error:

(http://img11.hostingpics.net/pics/260213capture.png)

About the autompletion menu, should it be possible to auto-activate it? And some keywords like "function" or "for" should come with a space.

EDIT: I achieved to show the menu: just go to the home screen and then return to the document.

But I guess that most of Lua programmers use an OS > 3.1.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on January 12, 2017, 11:25:42 am
Version 2.2.1 is now attached to the first post!

As said, it fixes problems on newer OS versions and a problem with the arrow keys on OS3.1, so you won't miss anything if you don't update if everything still works for you.  ;)
It's built now with the recent version of the student software, which somehow saves ~10KB; I hope OS3.1 still accepts it. Please report if it doesn't, then I'll do it with the student software 3.2 again.




@mdr1: Yes, indeed! Seems like I wasn't able to figure what the problem was, since the error occured outside of my program and no line number was given. Sorry that I forgot about it, it should be fixed now!
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: 123outerme on January 23, 2017, 05:05:45 pm
Hi Jens_K! You've made a really great script editor! Everything that I needed to know was either in the readme, self-explanatory, or understood through trial-and-error. I just can't figure out one thing; How do you run a script? I get that you have to press MENU > Code > Run, but I switch to the Run page and can't figure out what I'm doing! It says Click to run, but I click the center button, and nothing happens. Sometimes it returns an error that won't solve (even when pressing Menu and trying to let the editor solve the error). I'm on a Clickpad running OS 3.6, if that makes any difference at all.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on January 23, 2017, 06:38:14 pm
Hi Jens_K! You've made a really great script editor! Everything that I needed to know was either in the readme, self-explanatory, or understood through trial-and-error. I just can't figure out one thing; How do you run a script? I get that you have to press MENU > Code > Run, but I switch to the Run page and can't figure out what I'm doing! It says Click to run, but I click the center button, and nothing happens. Sometimes it returns an error that won't solve (even when pressing Menu and trying to let the editor solve the error). I'm on a Clickpad running OS 3.6, if that makes any difference at all.

Hey, thanks for your feedback!
Seems like on the execution page (usually 1.2), you're focusing the console, but the script executor waits with execution until it has the focus itself. To change focus you can press ctrl + tab. The script executor should then have a black outline instead of a grey one.


I hope that helped. If it didn't, please send me your JSE file and some more infos about those errors! ;)

Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: 123outerme on January 23, 2017, 06:48:05 pm
Hi Jens_K! You've made a really great script editor! Everything that I needed to know was either in the readme, self-explanatory, or understood through trial-and-error. I just can't figure out one thing; How do you run a script? I get that you have to press MENU > Code > Run, but I switch to the Run page and can't figure out what I'm doing! It says Click to run, but I click the center button, and nothing happens. Sometimes it returns an error that won't solve (even when pressing Menu and trying to let the editor solve the error). I'm on a Clickpad running OS 3.6, if that makes any difference at all.

Hey, thanks for your feedback!
Seems like on the execution page (usually 1.2), you're focusing the console, but the script executor waits with execution until it has the focus itself. To change focus you can press ctrl + tab. The script executor should then have a black outline instead of a grey one.


I hope that helped. If it didn't, please send me your JSE file and some more infos about those errors! ;)


Thank you so much Jens! That worked. Like I said, I'm enjoying using the editor! It really has a UI like one of a computer IDE.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: 123outerme on January 24, 2017, 05:46:37 pm
Hi Jens, another issue I'm having: I'm trying to run a script with several parts. I can't seem to run this code, it always takes extremely long, presumably forever, to load page 1.2:
Code: [Select]
while true do
  function on.paint(gc)
    function textDisp(x,y,str)
      gc:drawString(str,x,y)
    end
  end
  platform.window.invalidate()
end
I've tested that whole code block without the while block, yet it doesn't work with the while. Is there a problem with my code? Or could it be the editor?
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jens_K on January 25, 2017, 10:14:58 am
Hi Jens, another issue I'm having: I'm trying to run a script with several parts. I can't seem to run this code, it always takes extremely long, presumably forever, to load page 1.2:
Code: [Select]
while true do
  function on.paint(gc)
    function textDisp(x,y,str)
      gc:drawString(str,x,y)
    end
  end
  platform.window.invalidate()
end
I've tested that whole code block without the while block, yet it doesn't work with the while. Is there a problem with my code? Or could it be the editor?
Nspire Lua programs have a different structure, they are event based; code outside of event handlers is usually only executed at the programs start and only for initialisation, which in your case takes an infinite amount of time due to your while loop, which is why your program doesn't respond.
You can see the available events in the Nspire API guide (on page 2.1).
To do what you wanted to do, you could use the timer to refresh the screen repeatingly:
Code: [Select]
x = 0
timer.start(0.01)
function on.timer()
  x = x + 1
  --update screen
  platform.window:invalidate()
end


function on.paint(gc)
  gc:drawString("hi", x % 300, 20)
end
But you don't have to update the screen repeatingly, whenever the Nspire forgets the screens content, it asks for an update by calling on.paint.
If you have further questions, you can ask here: https://www.omnimaga.org/lua-language/ (https://www.omnimaga.org/lua-language/) or send me a PM  ;)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: 123outerme on January 25, 2017, 02:41:43 pm
Hi Jens, another issue I'm having: I'm trying to run a script with several parts. I can't seem to run this code, it always takes extremely long, presumably forever, to load page 1.2:
Code: [Select]
while true do
  function on.paint(gc)
    function textDisp(x,y,str)
      gc:drawString(str,x,y)
    end
  end
  platform.window.invalidate()
end
I've tested that whole code block without the while block, yet it doesn't work with the while. Is there a problem with my code? Or could it be the editor?
Nspire Lua programs have a different structure, they are event based; code outside of event handlers is usually only executed at the programs start and only for initialisation, which in your case takes an infinite amount of time due to your while loop, which is why your program doesn't respond.
You can see the available events in the Nspire API guide (on page 2.1).
To do what you wanted to do, you could use the timer to refresh the screen repeatingly:
Code: [Select]
x = 0
timer.start(0.01)
function on.timer()
  x = x + 1
  --update screen
  platform.window:invalidate()
end


function on.paint(gc)
  gc:drawString("hi", x % 300, 20)
end
But you don't have to update the screen repeatingly, whenever the Nspire forgets the screens content, it asks for an update by calling on.paint.
If you have further questions, you can ask here: https://www.omnimaga.org/lua-language/ (https://www.omnimaga.org/lua-language/) or send me a PM  ;)
Oh, okay, I didn't know they were entirely event-based. Thanks so much for your help, and sorry for the false report. I don't think I'll need any more help, but if I do, I'll ask somewhere; not here. Again, thanks!
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Chirlian on February 20, 2017, 05:05:39 pm
Hi Jens,
now I am using your editor some time and I like to work with it very much. Now at this time I have to do with strings that fill the display (text game). Problem: no word wrap by the hard-/software. I found some code for this but like more the simple way: a lineal that shows me the cursor position. So here is my idea, if you like to add something to your editor: a position counter for lines and rows. It would be much easier to enter long strings with it and give a simple way to make word wrap w/o setting separators by hand. What do you think about this? Yes, I know that you closed the editor project. But maybe you like to take your code again in the hand...
cu
klaus
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: neuronix on May 11, 2019, 09:45:46 am
Sorry for this necropost, but a good feature would be to add a list of all user defined variables with var key  ;)
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: stevepetoskey on December 07, 2019, 02:26:55 pm
so It says use nSpaint to use images in the editor but I have no idea how to do that, or at least upload images using the editor in general. I assume that custom images in this editor is a thing, since this editor supports the image library.
Title: Re: Jens' Script Editor - An on-calc lua editor
Post by: Jonson26 on December 15, 2019, 09:35:36 pm
I kinda dabbled into this a while ago, so I think, yoou're supposed to use the clipboard.