Script editor typing char by char
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Script editor typing char by char
Hello,
I would make amazing educational videos about livecode, but I need these feature:
a button that clicking on it it takes the text in the clipboard memory (CTRL+C) and then put it in the current script editor page char by char as I were typing it. (I made a lot o misspelling typing, so I can't do in real time during recording the videos )
Any ideas to do it?
I would make amazing educational videos about livecode, but I need these feature:
a button that clicking on it it takes the text in the clipboard memory (CTRL+C) and then put it in the current script editor page char by char as I were typing it. (I made a lot o misspelling typing, so I can't do in real time during recording the videos )
Any ideas to do it?
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Script editor typing char by char
Sure, give this a shot.
First, though, I wrote this in 6.5.2, to adjust for which ever IDE your using, open the message box and the script editor, move the mouse cursor over the script editor field, in the message box type
You can edit what is returned however you like, I just used the whole string that was returned.
In the button of the stack you make for this, put
Name it with 'rev' in front of whatever name you like, and then save the file with a revYourFileName.rev extension, and drop it into your plugins folder
*Edited for warning - BE CAREFUL!! This will copy the clipboard contents to whatever tab you have open, but it will empty that tab first. Before I hear about all the work you've lost using this, if you don't want to risk this kind of behavior, copy the contents to a variable, or remove the "put empty into field" parts before using.
You have been WARNED!!!
First, though, I wrote this in 6.5.2, to adjust for which ever IDE your using, open the message box and the script editor, move the mouse cursor over the script editor field, in the message box type
Code: Select all
"put the long name of the mouseControl"
In the button of the stack you make for this, put
Code: Select all
put empty into field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1" of stack "~/.runrev/livecodecommunity-6.5.2/Toolset/revscripteditor.rev" // put your returned long name here...
repeat for each character x in the clipboardData
put x into field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1" of stack "~/.runrev/livecodecommunity-6.5.2/Toolset/revscripteditor.rev" // put your returned long name here...
wait for .25 seconds
// if .25 seconds is too slow, lower it to .1 or even .05, or go to ticks...
end repeat
*Edited for warning - BE CAREFUL!! This will copy the clipboard contents to whatever tab you have open, but it will empty that tab first. Before I hear about all the work you've lost using this, if you don't want to risk this kind of behavior, copy the contents to a variable, or remove the "put empty into field" parts before using.
You have been WARNED!!!
-
- Livecode Staff Member
- Posts: 818
- Joined: Fri Feb 06, 2015 4:03 pm
Re: Script editor typing char by char
Hi Max,
You might also find the "type" command useful.
Best,
Panos
--
You might also find the "type" command useful.
Best,
Panos
--
Re: Script editor typing char by char
Hmm. A new toy to play with! Thank you Panos
@Max, I expect to see a link in this thread to these amazing videos my friend
@Max, I expect to see a link in this thread to these amazing videos my friend
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Script editor typing char by char
Mind you, if you use type without setting the typingRate
to something a bit higher than the default 100 the effect is not really marked.
- -
typingRat
to something a bit higher than the default 100 the effect is not really marked.
- -
typingRat
Re: Script editor typing char by char
Also, I wasn't able to get it to "type" into the script editor field (RATS!~). I think I'll stick with what I wrote
i also think I like this change to my above script. I set up a 2nd button (in case I didn't want to empty the field first) and put this change in the first line -
Funny enough, it skips exactly 1 line in the script editor, despite the two carriage returns. Now I am thinking about some how triggering the scroll on the script editor field, as it doesn't seem to scroll as the type is going in, so I need to figure out a way to advance it while the script is running. Get messages? I dunno, coffee hasn't hit yet
*Edit - this seems to work for scrolling the field (Thanks to Max's Wiki!)
Now I need to figure out how to insert a tabKey press into that field during the repeat loop through script so that the field auto-colors the script like it would when your typing directly into it
i also think I like this change to my above script. I set up a 2nd button (in case I didn't want to empty the field first) and put this change in the first line -
Code: Select all
on mouseUp
put cr & cr after field "Script" of group "Editor"
*Edit - this seems to work for scrolling the field (Thanks to Max's Wiki!)
Code: Select all
on mouseUp
put cr & cr after field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1"
repeat for each character x in the clipboardData
put x after field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1"
wait for .5 seconds with messages
set the vscroll of field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1" to (the effective textheight of field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1") * (the number of lines in field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1")
end repeat
end mouseUp
Re: Script editor typing char by char
Well ok then, I'm stuck
2 things I tried to implement but haven't figured out yet.
...How to send a tab key press to the field so that after each letter in the cb is placed, the code 'colorizes'. Any other ideas to colorize the code welcome as well.
...How to check if the last character is within a certain distance from the edge of the editor field so that a continuation character can be inserted before continuing. I tried a number of variations of the following, all failed.
I'm far more interested in solving the tab/colorizing the script thing than inserting the continuation mark, but as of now I'd take anything someone cares to throw out
Code: Select all
on mouseUp
/* this works as intended, if the field is empty, it places the cbData on the first line
if not empty, it inserts the 2 carriage returns... */
if field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1" is not empty then put cr & cr after field "Script" \
of group "Editor" of card "Main" of stack "revNewScriptEditor 1"
/* this works as intended... */
repeat for each character x in the clipboardData
wait for .02 seconds with messages
put x after field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1"
/* this works as intended, scrolling the field once text has reached the bottom of the script editor...*/
set the vscroll of field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1" \
to (the effective textheight of field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1") \
* (the number of lines in field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1")
end repeat
end mouseUp
...How to send a tab key press to the field so that after each letter in the cb is placed, the code 'colorizes'. Any other ideas to colorize the code welcome as well.
...How to check if the last character is within a certain distance from the edge of the editor field so that a continuation character can be inserted before continuing. I tried a number of variations of the following, all failed.
Code: Select all
if the formattedWidth of this line of field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1" > ((the width of field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1") - 10) then put " \" & cr after field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1"
Re: Script editor typing char by char
How can use type on the Livecode IDE script editor?LiveCode_Panos wrote: ↑Tue Aug 28, 2018 8:05 amHi Max,
You might also find the "type" command useful.
Best,
Panos
--
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Script editor typing char by char
I would like to know the answer to that as well, hopefully someone will pop in and spill the beansMaxV wrote: ↑Tue Aug 28, 2018 4:04 pmHow can use type on the Livecode IDE script editor?LiveCode_Panos wrote: ↑Tue Aug 28, 2018 8:05 amHi Max,
You might also find the "type" command useful.
Best,
Panos
Re: Script editor typing char by char
this seems working:
########CODE to copy and paste with your mouse#######
on MouseUp
repeat for each character x in the clipboardData
put x after field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1"
send "reapplyPreferences" to group "Editor" of card "Main" of stack "revNewScriptEditor 1"
wait for .1 seconds
end repeat
end MouseUp
########END OF CODE generated by this livecode app: http://tinyurl.com/j8xf3xq ########
########Code tested with livecode 9.0.0########
########CODE to copy and paste with your mouse#######
on MouseUp
repeat for each character x in the clipboardData
put x after field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1"
send "reapplyPreferences" to group "Editor" of card "Main" of stack "revNewScriptEditor 1"
wait for .1 seconds
end repeat
end MouseUp
########END OF CODE generated by this livecode app: http://tinyurl.com/j8xf3xq ########
########Code tested with livecode 9.0.0########
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Script editor typing char by char
Oh man, I feel like such a smoo
That worked perfectly Max!
What I have so far -
Code: Select all
on mouseUp
if field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1" is not empty then put cr after field "Script" \
of group "Editor" of card "Main" of stack "revNewScriptEditor 1"
repeat for each character x in the clipboardData
wait for .02 seconds with messages
put x after field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1"
set the vscroll of field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1" \
to (the effective textheight of field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1") \
* (the number of lines in field "Script" of group "Editor" of card "Main" of stack "revNewScriptEditor 1")
send "reapplyPreferences" to group "Editor" of card "Main" of stack "revNewScriptEditor 1"
/* need a way to apply the continuation character automatically when we reach the edge of the
script window... */
end repeat
end mouseUp
Re: Script editor typing char by char
By the way, in case you are wondering why I included the 'vscroll' section and the 'cr' if the field isn't empty, this is what happens without those -
Also, if you don't scroll the field, and you had a longer handler, whatever went past the bottom won't be seen.
*Edit - just in case anyone else might find this useful, I made it a plugin
Feel free to improve it (like having it be able to insert continuation characters automagically!) *Edit 2 - tested in Lc vers. 6.5 to 8.1.4 on Linux
If you were putting another segment of code after having moved the first lets say, it will run together. Also, if you don't scroll the field, and you had a longer handler, whatever went past the bottom won't be seen.
*Edit - just in case anyone else might find this useful, I made it a plugin
Feel free to improve it (like having it be able to insert continuation characters automagically!) *Edit 2 - tested in Lc vers. 6.5 to 8.1.4 on Linux
Re: Script editor typing char by char
Great work bogs. I'll use your script for the scroller in my next video.
Here my first video: https://youtu.be/K0fFwHPU7RY
Here my first video: https://youtu.be/K0fFwHPU7RY
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Script editor typing char by char
Breakout in 12 minutes? Great job Max (bookmarked the channel). Curious as to the "unpopular'' moniker though, is it a jokey thing?
Re: Script editor typing char by char
Try this game https://www.google.co.uk/imghp?q=atari+breakout
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w