X11 paste in IDE

The thing is (unless you go the whole way and drop using IDE, which is looking more and more appealing) you need to understand all the preprocessing and file copying tricks in order to put you externally edited files where IDE wants them, not just #include them which, as I have just discovered, gets them ignored if the included file is not open in a "tab" in the IDE. :cold_sweat:

It's actually more trouble learning all the, not so clearly documented, tricks you need to work around.

That's why I said, it's not a case of "simply select".

Which, by the way, has some well-known and seriously screwy bugs that will result in mangling your perfectly sound sketch code into something that totally confuses the g++ compiler, and very likely you when you start trying to make sense of the resulting compiler error messages.

Yep, I met that one as well.

You've confirmed my impression that sketchland is more of a hinderance than a help and that I'm not missing some stunningly useful functionality.

Can you post an example Makefile , that would save me some head scratching.

thx.

I think an article somewhere on how do all of this straight off the bat would be a good idea at some point once I've mastered it a bit better.

Adding a section on Nick's work around for the heap allocation problem and we may be near to a workable development environment.

Here's an example makefile, to give you some idea:

ARDUINO_SHELL_DIR = \Arduino\arduino-0023
ARDUINO_DIR  = \Arduino\arduino-0023

PERL_EXE = \strawberry\perl\bin\perl
TARGET       = dht22_test3a
ARDUINO_LIBS = DHTxx2

BOARD_TAG    = pro5v328
ARDUINO_PORT = \\.\COM14

ARDUINO_MAKE = \Arduino\make\arduino-mk-0.8

include $(ARDUINO_MAKE)\Arduino-W32.mk

#
# Hopefully these will be self-explanatory but in case they're not:
#
#    ARDUINO_DIR  - Where the Arduino software has been unpacked
#
#    TARGET       - The basename used for the final files. Canonically
#                   this would match the .pde file, but it's not needed
#                   here: you could always set it to xx if you wanted!
#
#    ARDUINO_LIBS - A list of any libraries used by the sketch (we
#                   assume these are in
#                   $(ARDUINO_DIR)/libraries 
#
#    ARDUINO_PORT - The serial port where the Arduino can be found (only needed
#                   when uploading
#
#    BOARD_TAG    - The ard-parse-boards tag for the board e.g. uno or mega
#                   'make show_boards' shows a list
#
# You might also want to specify these, but normally they'll be read from the
# boards.txt file i.e. implied by BOARD_TAG
#
#    MCU,F_CPU    - The target processor description

Read that thread I pointed to, it has links to downloading Martin Oldfield's makefiles, which do all the "voodoo", but in make scripts instead of hard-coded Java in the IDE. He's done all the hard yards on this. The simple config file above is all the users (e.g., you and I) have left to do. Oh, and type "make" at the command prompt.

But before you dive into all that, I suggest first just trying out the "external editor" check-box option. Just to prove you really don't have to use the makefiles to use the IDE in external editor mode, you just press the build/upload button on the IDE and it does its usual build voodoo.

One step at a time -- flexibility is good.

BTW, one thing that's good about the makefiles is that is also demystifies the "voodoo" a bit. It's all pretty mundane what's going on, really.

Edit: Oh, in case you are wondering why I use backslashes rather than forward slashes in the example script, it is because I used this script for a Windows XP installation of the Arduino 0023 environment. Martin Oldfield's scripts are actually Unix/Linux oriented -- I did a little bit of "porting" of his scripts to cajole them to work under Windows with Msys.

But before you dive into all that, I suggest first just trying out the "external editor" check-box option. Just to prove you really don't have to use the makefiles to use the IDE in external editor mode, you just press the build/upload button on the IDE and it does its usual build voodoo.

Yes, I looked at external editor but to do that you need to know all the tricks the IDE is doing , like moving files somewhere else before compiling.

I recently got stuffed because I referenced a file in #include and put it in the sketch directory but it was not in a "tab". This did not even flag missing (missing by the time the sketch got silently copied elsewhere) but failed because a function in the (not) included file was not defined.

That means in order to work with an external editor I need to know the ins and outs of the build voodoo.

That seems a pointless effort to me.

Better spend the time setting up a Makefile so that I have a predictable , well-behaved development env.

Thanks for the posted file and the links that should save me some time.

:slight_smile:

ardnut:
Yes, I looked at external editor but to do that you need to know all the tricks the IDE is doing , like moving files somewhere else before compiling.

No, really, you don't. You just press the build button and it does it's "voodoo" just as if the sketch had been edited in the IDE editor. (The only difference is you have to remember to save the file to disk before pressing the compile button, unlike using the IDE editor!)

ardnut:
I recently got stuffed because I referenced a file in #include and put it in the sketch directory but it was not in a "tab". This did not even flag missing (missing by the time the sketch got silently copied elsewhere) but failed because a function in the (not) included file was not defined.

What was the extension of the file? I've read (but haven't yet verified) that in 1.0.1, only .h and .cpp files can now be included by a #include directive from within a sketch (who knows why... the Arduino team seem hell-bent on doing all they can to subvert the expected and otherwise well-defined behaviour of the venerable C preprocessor.)

ardnut:
That means in order to work with an external editor I need to know the ins and outs of the build voodoo.

No really, whatever the problem was, it was independent of using an external editor, or not.

ardnut:
That seems a pointless effort to me.

Better spend the time setting up a Makefile so that I have a predictable , well-behaved development env.

I agree that ultimately going with the makefiles is a better and saner way to go, but it is never pointless effort to try to understand what's really going on with your tools. As I said earlier, one of the advantanges of using the makefiles is that it demystifies the build process a great deal.

ardnut:
Thanks for the posted file and the links that should save me some time.

:slight_smile:

No probs, good luck!

What was the extension of the file? I've read (but haven't yet verified) that in 1.0.1, only .h and .cpp files can now be included by a #include directive from within a sketch (who knows why... the Arduino team seem hell-bent on doing all they can to subvert the expected and otherwise well-defined behaviour of the venerable C preprocessor.)

Well there you go. It was a .c file. How the hell is anyone supposed to follow that kind of behaviour?

This is getting so reminiscent of MS mentality I'm ready to puke.

Dumb down the user and make things "easy" to the point where actually doing what you need to get done gets 10 times more difficult.

If they think they can do this in a micro-controller hardware design environment .... words fail me.

I was initially quite impressed when I read they provided an open source IDE. Then I found out it was not really an IDE , then I found out it was more hindrance than anything else.

Hopefully I'll stop wasting so much time chasing oddball behaviours once set up with Make.

Just have to hope I can write a function prototype without my IDE nanny. :wink:

It is even possible to make X11 style (mouse only) copy and paste work to/from Java-swing based applications?

@ardnut

The behaviour of the Arduino IDE is documented in different places. Maybe if you were less condescending you would have found out easily.
You're not providing any costructive comment, you're just ranting.
The Arduino IDE is an actual IDE and it has allowed hundreds of thousands of people to get into microcontroller programming.
You're very welcome to make a much better product and impress us with your ability until then use a more appropriate tone when participating in the discussion.

ardnut:
Just have to hope I can write a function prototype without my IDE nanny. :wink:

The Arduino IDE has long supported .c and .cpp files in the sketch, for people who want to compile code without preprocessing.

Just create an empty .ino file, which of course must be named the same as your sketch. Then put all your actual code into .c, .cpp and .h files within that same directory. All .c and .cpp files which happen to be in the same directory are compiled normally (no special preprocessing) and linked into your application. You can just leave the .ino file empty, except perhaps any #include lines to tell the environment which libraries you want built into your application.

Of course, that probably won't make you feel better, like this complaining & negativity probably does.

On the original topic (the reason I ended up reading this unpleasant thread), I use Linux as my primary desktop and I would really like to fix Arduino's poor copy-n-paste integration.

There are at least 2 problems.

1: Some programs using Window/Mac style copy-paste can't understand whatever Arduino is putting into the clipboard. For example, to go from Arduino to Gnome Terminal, I first copy (ctrl-c) in Arduino, then paste into Libre Office, then copy in Libre Office and paste into Gnome Terminal.

2: X11 style (mouse only) copy and paste doesn't work at all. People who've only used Windows or Mac and never used Unix or Linux can't even imagine how incredibly quick and convenient this mouse-only feature is. Especially when I get an email or a link to a code fragment (usually to help someone debug it), I'd really like this quick method to get it into Arduino to give the code a try.

Sadly, I'm just not very knowledgeable on the finer points of desktop programming. I mostly do analog & digital circuitry and embedded programming, but I have a pretty good history of managing to fix things in the Java-based IDE.

On this issue, I really do need some help. I did some googling and turned up several pages, with limited and differing info. Here's one:

https://groups.google.com/forum/?fromgroups#!topic/ibm.software.java.linux/jFN32WdAT4A[1-25]

Please, if anyone is reading this and also wants it fixed, and knows enough about java/swing/x11/gnome/kde desktop programming (or knows someone who knows and can bribe them with beer or whatever....), I could really use some useful hints about where to find the necessary info. I don't have the time to read through mountains of desktop environment documentation! I've already found lots of conflicting info, all apparently correct but applicable to unique circumstances with specific programs and/or certain JREs. I need someone who knows how this stuff works, and the finer points of integrating java/swing with x11/gnome/kde to point the way to a solution that will work in Arduino's specific circumstances. I can do the actual coding and testing, but without someone who knows and understands what's really wrong (rather than just ranting), I simply can't even start on fixing this.

Please, if you have useful info about why this doesn't work, and info that's specific the Arduino's case (not just links to huge volumes of java documentation), please please please post it here! Or email me directly, paul at pjrc dot com.

Thanks for the work around, however discovering things don't work as expected, then finding out it's some obscure IDE trick, then setting out to find some work around in the forums or get some kind sole to provide one seems a total waste of time compared to using standard, well-tested methods.

Apart from making me feel better, "complaining" has confirmed that I'm not missing some amazing features of the IDE and has got me some concrete suggestions from others who have reached similar conclusions about the IDE that will save re-inventing the wheel.

Please, if you have useful info about why this doesn't work, and info that's specific the Arduino's case

I would have thought that the best place to start was what I've already pointed out above: X11 cut and paste does work in the error window but context menus don't. Vice versa in main IDE editor window.

Both are presumably in the same java environment so that should not take someone with your talents too long to track down what they got wrong.

I'm sorry you seem to have missed the constructive criticism and lessons here.

The fact is, for many developers with even a reasonable amount of previous programming experience, a real, full-strength programming editor + Martin Oldfield's makefiles is a "better product" -- no contest.

While I agree a civil tone is important to keeping any forum a better place to be, and I personally strive to maintain one even when I'm being critical of something, I think the take-home lesson here for the developers is that despite apparently delighting hundreds of thousands of complete novices, the IDE is not a friendly tool for an experienced programmer -- it is a buggy and frustrating hinderence, in fact.

Some of that frustration is on display in this thread. It won't go away until you improve the IDE to make it more suitable for people of this background. Fixing the long-standing and significant bugs in the "Arduino" preprocessor, or giving the user a means of simply bypassing it to allow them to write code in "real" C++, would be a straigtforward and significant step forward.

Now, perhaps it is the case that you've made the business decision that the more experienced Arduino developer is simply irrelevant when considering the development of your products. Fine. That's your call. But whether or not that's a call you've consciously and deliberately made, the way things stand at the moment many people will be actively seeking alternatives to having to work within your IDE to develop for the Arduino platform.

And inevitably you will be seeing some vented spleen in these forums as people find their way along similar paths of annoyance, frustration, and sometimes sheer exasperation.

I hope you see I've taken the time to write this to in fact provide you some potentially useful feedback. Take it or leave it, but in any case, you're welcome.

Well said,

I think the take-home lesson here for the developers is that despite apparently delighting hundreds of thousands of complete novices, the IDE is not a friendly tool for an experienced programmer -- it is a buggy and frustrating hinderence, in fact.

This just about sums up my frustration.

What was the extension of the file? I've read (but haven't yet verified) that in 1.0.1, only .h and .cpp files can now be included by a #include directive from within a sketch (who knows why... the Arduino team seem hell-bent on doing all they can to subvert the expected and otherwise well-defined behaviour of the venerable C preprocessor.)

If this was seen in my post http://arduino.cc/forum/index.php/topic,117890.msg888860.html#msg888860, I didn't try .c, .hpp, other c or c++ files. I had a custom file to include in, it is standard behaviour, but Arduino IDE shrugged it off.

It also has a severe bug in the inclusion system of sketch and library paths ( added into v 1.0.1 ), static paths like the core and avr locations are fine as they are not intercepted by the IDE. Which leads me to ponder... why move the files at all if there is no need.

ardnut:
one very useful feature on X11 based systems is PRIMARY buffer. As soon as any text is selected it is copied to the buffer, then clicking mouse button 3 (often scroll wheel click) then pastes the buffer.

This is about an order of magnitude faster the all the right-click context menu cut and paste method

Huh? 10 times faster than pressing Ctrl+V?

Surely not.

Personally I find all this X11 stuff confusing. Who the hell wants stuff copied to the buffer just because you select it?

Nick, it really is incredibly quick and convenient. 10X might be an exaggeration, but trust me, it truly is very fast, especially in combination with focus-follows-cursor window management. It doesn't work nearly as well with click-to-focus, which is the standard window management on Windows and Macintosh.

To be honest, the X11 approach is mostly useful for quickly copying data between programs. Conventional Windows & Mac style tends to also be useful for keeping something around for a while, but X11-style tends to be used for very immediate short-term copying, since the selection is so fragile. Clicking the wrong way destroys the previous selection. But when you just want to copy some text from a window, and especially when the destination is an empty text box or console-based application (both cases the precise cursor position doesn't matter), you just click & drag to select the desired text, the move the mouse imprecisely (very quickly) to the destination (it automatically gets focus if you're using focus follows cursor) and click the middle button. To someone who's only ever used Macintosh and Windows, that must sound really bizarre, but believe me, it's incredibly convenient.

There's absolutely no reason both can't work. Firefox, Libre/Open Office and lots of other major programs support both when running on X11. Arduino should too when running on X11. "When in Rome (do as the Romans do)." Don't worry, this isn't going to be somehow emulated on Mac or Windows. It's only about properly integrating with the environment in which Arduino is running. Good software should do that....

I personally use all 3 systems on a pretty regular basis. When I use Windows and Mac (and Arduino on Linux), I really miss the incredible speed & convenience of focus follows cursor window management and X11-style text copying. Arduino (perhaps due to Java?) also has some quirks where it doesn't obey focus-follows-cursor window management. Someday I'd like to fix these, but unfortunately my strengths are in low-level embedded programming and hardware, so I really need someone who truly understands these finer points of desktop and Java/swing development to at least point the way.

@pico
thanks for the civil feedback, I understand your point. We're working on a much more open development process encouraging more contributions.

Experienced developers have a simple way to solve some of their frustrations: git clone the arduino code, patch it, submit a pull request.
I will personally take charge of have any reasonable patch included in the IDE. We've also hired a developer to implement all the long standing issues the IDE has had.
Please understand that not all the patches that make experienced developers happy might end up in the IDE.

-----personal opinion, not an official Arduino position -------
I think that in the short term we can patch the IDE to make it more useable but the fundamental structure of the IDE is probably a bit old and makes it hard to add fancy features like step by step debugging and the rest. It's probably time we rebuild the ide based on a more solid basis but on the same principles of simplicity that make Arduino good as a beginner platform
---- end of personal opinion ------

m

Huh? 10 times faster than pressing Ctrl+V?

Surely not.

Yep, since it's a click instead of click + CRTL-V. No "let go of the mouse and find the keyboard" transition to make.

After you've selected the text, it's already copied, so there's no need for a CTRL-C, and the same mouse click that would change focus to the target window for the paste actually executes the paste.

So, for X-11:

click+drag, click

For Windows, et al:

click+drag, CTRL-C, click, CTRL-V

Note the mouse-to-keyboard (or vice versa) input device transitions in the X11 version (none) vs. the other version (minimum of 3), and the fact there are twice as many operations.

If you don't use focus-follows-mouse, there's an extra click in there for X11, but you don't even have to change buttons to do it.

-j

There's absolutely no reason both can't work.

That's the key point. And since only one of these two features works in each (no context menus in IDE code window but X11 works in error window) it must be possible. Someone is gobbling mouse events in the code window. Presumably this was designed on Windows and the defect was not noticed.

Nick:

Huh? 10 times faster than pressing Ctrl+V?

Before posting I wondered if it was overstating, though about it and decided it was not far off. I can effect a copy / paste from one window to another of withing a window in under 1/2 a second.

It seems all those who don't understand why those who miss it are moaning, are those who have not had the chance to experience how quick and easy it is. Once you've tasted it, you won't want to go back :wink:

That's encouraging. I started this thread to get this issue noticed and hopefully fixed. I'm pretty new with Arduino but have quickly become a bit disillusioned with the apparent lack of will to fix things in the official releases and with that QA in general.

The project seems mature enough that a lot of things should have been a long time back. The heap management is the most outstanding and unacceptable bug.

It really needs to be fixed.

ardnut:
I started this thread to get this issue noticed and hopefully fixed.

Most of the Arduino Team uses Macintosh. I'm probably the only one who will fix this, and I've tried to explain to you what I need.

Just to be absolutely clear, the observation that it works in one UI elememt but not another IS NOT ENOUGH. If you want me to fix this, you must dig deeper (or convince someone else to do so). I'm not a desktop environment or Java/swing UI expert, but if someone points the way with a good technical explanation of why it's not working and with links to relevant and specific documentation, I will work on this.

So, there you have it. You hoped someone would notice. I have. I'm a long-time contributor, and recently the Arduino Team gave me commit access. I do want to fix this.

But your hope that it will be fixed, merely because you've pointed out the problem, is unrealistic. This is a minor bug. Arduino doesn't employ programmers to fix minor issues (and lately there's been a lack of man-hours). Most of the programmers use Macs. If you really want this fixed, you're going to have to actually do more than just rant on a forum. Likewise with the issue tracker.

The ball's in your court! If you want this fixed, you're going to have to contribute. This problem isn't going to fix itself. It's extremely unlikely anyone will work on this with only the limited info you're provided so far. You don't need to fully develop a patch (I'll do that), but at the very least some in-depth research into what's different between those UI elements is required. If you're not willing to do that, and nobody else is, then this probably will never get fixed.