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

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

0 Members and 4 Guests are viewing this topic.

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Jens' Script Editor - An on-calc lua editor
« Reply #60 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.

Offline Legimet

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +29/-0
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #61 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?)

Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #62 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"
« Last Edit: July 24, 2013, 03:30:44 pm by Jens_K »
Sorry for nonsense.

Projects:



Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Jens' Script Editor - An on-calc lua editor
« Reply #63 on: July 24, 2013, 03:07:06 pm »
Ah, very nice update :)

Edit : also, what about apilevel 2 documention ? (without the physics stuff, though)
« Last Edit: July 24, 2013, 03:26:48 pm by adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #64 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
Sorry for nonsense.

Projects:



Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Jens' Script Editor - An on-calc lua editor
« Reply #65 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), 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 (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)" .
« Last Edit: July 24, 2013, 04:18:24 pm by adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #66 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:

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?
« Last Edit: July 24, 2013, 04:07:56 pm by Jens_K »
Sorry for nonsense.

Projects:



Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Jens' Script Editor - An on-calc lua editor
« Reply #67 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:

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 ?
« Last Edit: July 24, 2013, 04:21:56 pm by adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #68 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?
« Last Edit: July 24, 2013, 04:57:57 pm by Jens_K »
Sorry for nonsense.

Projects:



Offline mdr1

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 303
  • Rating: +21/-2
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #69 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?
« Last Edit: July 24, 2013, 05:02:35 pm by mdr1 »



Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Jens' Script Editor - An on-calc lua editor
« Reply #70 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.
« Last Edit: July 24, 2013, 05:20:00 pm by adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #71 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
- 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 ./:
« Last Edit: July 24, 2013, 05:39:24 pm by Jens_K »
Sorry for nonsense.

Projects:



Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Jens' Script Editor - An on-calc lua editor
« Reply #72 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)
« Last Edit: July 24, 2013, 06:09:59 pm by adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Jens_K

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 187
  • Rating: +52/-0
    • View Profile
Re: Jens' Script Editor - An on-calc lua editor
« Reply #73 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)
« Last Edit: July 24, 2013, 06:14:13 pm by Jens_K »
Sorry for nonsense.

Projects:



Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Jens' Script Editor - An on-calc lua editor
« Reply #74 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 ^^
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation