Closed GoogleCodeExporter closed 9 years ago
I've been thinking about an idea that's come up several times lately, of being
able
to add tutorial circuits to each sketch easily. My first idea was to make a
browser
tab in the IDE that could open the tutorials from the site, or any other URL,
then I
realized there's a really simple way: just make URLs in the head comments of the
sketch clickable, like the help pages are from the help menu. They open in a
regular
browser.
That way we can include the tutorial page for each sketch available from the
sketch
itself, we can cut down on the head comments so you get to the code sooner, and
we
can make it possible for anyone to include their tutorial with their sketch
with just
a URL in the head comments.
Original comment by tom.i...@gmail.com
on 25 Nov 2009 at 12:28
Good idea.
Original comment by dmel...@gmail.com
on 25 Nov 2009 at 4:31
Christian, can you take a look at this?
It's possible someone's already implemented something similar for the text
editing code that underlies the Arduino IDE (jedit, I think). Or maybe
Processing has done it? Either way, it would be a nice thing to send upstream
to them, too, if they're interested in it.
Original comment by dmel...@gmail.com
on 18 Aug 2011 at 7:08
work in progress here:
https://github.com/cmaglie/Arduino/commit/a6c8753a80d6ccf2b168bb8609fbeb0c20a7c3
cc
now, if you put the keyword "@schematics" on code comments, like this:
/**
* My Amazing Sketch For Arduino v1.0
*
* @schematics http://www.arduino.cc/
*/
you will see a little arrow appearing at the right of the URL. Right-click on
it -> "Open URL".
I know, this is not what requested, but its a WIP, and before i do the latest
steps i just wanted you to look the actual status.
To-do:
- Find a good reg-exp to match URLs (now everything after keyword "@schematics"
is treated as URL without other checks)
- Highlight URLS.
Original comment by c.mag...@bug.st
on 19 Aug 2011 at 6:13
Will check, but why not just look for http::// and everything to the right of
it? @schematics is inaccurate, the links contain more than schematics.
Original comment by tom.i...@gmail.com
on 19 Aug 2011 at 6:22
Tom, yes, i'm going to remove "@schematics", it was to do a rapid check if it
is working.
Original comment by c.mag...@bug.st
on 19 Aug 2011 at 6:42
It's working on my machine OK!
Original comment by t...@nyu.edu
on 19 Aug 2011 at 6:45
Tom, try with the latest update:
https://github.com/cmaglie/Arduino/commit/d60c42e5eddf0e5326f38c870eaa5c61b86f82
23
as you can see detecting a correct URL is not so simple :)
Right now, only ONE link per line is supported, hope we can live with this
limit for a while.
things that can be done before including it in production:
1) The full-URL can be made right-clickable.
2) The arrow can be removed
Original comment by c.mag...@bug.st
on 19 Aug 2011 at 8:38
So far, so good. Works on my machine!
Cristian, what are you using to do this? It's a common enough task that I bet
there is a solution for it, to save you time on the more complex versions.
There's a getURL example in the Java cookbook, and I thin jTextPane and
jEditorPane supports it too. jEditorPane may give us some other nice editor
features too, if we're not already using it. A few links I found that may help:
http://www.daniweb.com/software-development/java/threads/331500
http://stackoverflow.com/questions/1909534/java-replacing-text-url-with-clickabl
e-html-link
http://download.oracle.com/javase/1.5.0/docs/api/javax/swing/JEditorPane.html
Original comment by tom.i...@gmail.com
on 19 Aug 2011 at 9:12
Seems to work for me too!
Can we change it so you just click on the URL and it opens page? (Instead of
right-clicking and selecting "Open URL".) And then remove the arrow?
Also, is it possible to underline the URLs instead of making them italicized?
Original comment by dmel...@gmail.com
on 23 Aug 2011 at 3:05
Ok pushed fix for all, except for single click for two reasons:
1) What if user just want to change the URL? Most users click on the link to
move cursor on it, but instead the link will be opened.
2) I must understand how to do it :) (for right-click i just extended a
pre-existent menù).
what if instead use double-click? (leaving Open URL on the popup menù)
Original comment by c.mag...@bug.st
on 23 Aug 2011 at 5:34
Pushed a fix also for double-click on URL, here:
https://github.com/cmaglie/Arduino/commit/88794ec1d6b5374548f251815c8a4fa2d5adec
6f
If you want to use the single-click, you can move the following lines:
// Check for click on urls
String clickedURL = checkClickedURL(getLineText(line), offset);
if (clickedURL != null) {
Base.openURL(clickedURL);
return;
}
from doDoubleClick to doSingleClick method. The return statement stops the
"click event processing", so the cursor is not moved.
Original comment by c.mag...@bug.st
on 24 Aug 2011 at 8:50
The "how do you edit the URL" problem is usually handled in one of two ways:
* right click or double click to go to the URL
* Drag over URL or use arrow keys to move cursor into URL
Either one works for me.
t.
Original comment by tom.i...@gmail.com
on 24 Aug 2011 at 12:51
This is looking great! I committed the changes so far (including switching
from double-click to single-click):
https://github.com/arduino/Arduino/commits/new-extension
One last thing. How hard is it to change the mouse cursor while hovering over
the link? It would be good to show the little hand instead of an arrow to make
it clear that you can click the URLs.
Original comment by dmel...@gmail.com
on 24 Aug 2011 at 3:37
I know you would ask for that :) but... i fear that this change is much more
hard to do in an efficient way.
Actually the IDE check if a line of text contains an url when it is being drawn
and when you click with the mouse on the textarea.
To change the mouse shape, i must check "continuosly" (every time the mouse
moves) if the line under the pointer contains an url. I think that this
approach is inefficient and highly CPU-consuming.
A more elegant way to solve this problem is to use the approach suggested by
tom here: http://www.daniweb.com/software-development/java/threads/331500
this thread suggest to apply a text attribute directly when the text is
entered, and this attribute is cached directly by JTextEditor.
Unfortunately this require to patch directly the editor. I tried and given up
after looking at the code: it's too much complicated and has a lot of patches
and hacks.
Original comment by c.mag...@bug.st
on 24 Aug 2011 at 4:01
Can we try it and see what the performance is like?
You should be able to add a mouseMoved() handler to JEditTextArea.MouseHandler,
right? And have that check for a URL? If uses a lot of CPU power, we can get
rid of it, but it seems worth trying.
Original comment by dmel...@gmail.com
on 24 Aug 2011 at 6:14
CPU usage seems reasonable, here the fix:
https://github.com/cmaglie/Arduino/commit/15b28b415d795d42ec2bbd32bed3b32fc21652
8f
Original comment by c.mag...@bug.st
on 30 Aug 2011 at 9:25
Merged, thanks!
https://github.com/arduino/Arduino/commit/15b28b415d795d42ec2bbd32bed3b32fc21652
8f
https://github.com/arduino/Arduino/commit/eff37540dbfc54be61fbf69a845d06eed9ac71
85
Original comment by dmel...@gmail.com
on 31 Aug 2011 at 6:24
Original issue reported on code.google.com by
tom.i...@gmail.com
on 25 Nov 2009 at 12:27