copying and pasting code effectively

Introduce yourself, create test postings or talk nonsense
User avatar
jayseye
Posts: 233
Joined: 24. Jul 2011, 17:22
Location: Brownsmead, Oregon (Center of the Universe)

Re: copying and pasting code effectively

Post by jayseye » 22. Nov 2012, 07:46

Yes, in nano, "Meta i" (Alt+i) toggles auto-indent, which is on by default. The example code pasted fine after disabling that option.

As to spaces versus tabs, I have jEdit configured to convert all tabs to spaces. The reverse is also an option, and the third possibility is to leave spaces and tabs as typed.

Geany likely has similar options, and I assume that vi(m) can be configured six ways to Tuesday, now that you know what to look for ;->

User avatar
mimosa
Salix Warrior
Posts: 3141
Joined: 25. May 2010, 17:02
Contact:

Re: copying and pasting code effectively

Post by mimosa » 22. Nov 2012, 23:09

One solution for the original problem, in Geany, is to Edit preferences like so:

Indentation

Tick "Detect width from file" and "Detect type from file".

I had trouble with both caret browsing in Firefox, and that Nano option ... but never mind. :)

jEdit itself may be a good solution, too.

I'll open a new topic about the trouble I'm having with Java and menus. However, before I do ... you mentioned environment variables. Could that be the housekeeping that is needed, and that I haven't done, or wasn't done automatically on installing openjdk?

Were you able to run the example code?

User avatar
jayseye
Posts: 233
Joined: 24. Jul 2011, 17:22
Location: Brownsmead, Oregon (Center of the Universe)

Re: copying and pasting code effectively

Post by jayseye » 22. Nov 2012, 23:44

Thanks for the follow-up, mimosa. The install script likely adds the required environment variables and PATH. It might be though, that you need to restart shells (Terminal sessions) before they get applied; or you might need to exit and restart your X session; or as a last resort, rebooting should definitely solve that issue. However:

Just to be sure, I should mention that there's a documented conflict between any JRE and any JDK. If you've somehow managed to install both, then it might be best to uninstall them both, in reverse order, then install just the JDK.

One other possibility is that there might be compatibility problems with the latest OpenJDK. To check that, you could uninstall OpenJDK, and use the Oracle JDK, at least just for testing. First, of course, you'd still need to resolve any existing conflict between JRE and and JDK, per my previous paragraph.

I've really tried to love Java since 1995 but, the fact is, it's always caused minor allergies. :wink: As Oracle declines in stewardship, I've been moving to Python, and jEdit is the only tie to Java that I have left. So if you'd like me to test the example code, would you please provide enough detail to pique my curiosity? :cool:

User avatar
mimosa
Salix Warrior
Posts: 3141
Joined: 25. May 2010, 17:02
Contact:

Re: copying and pasting code effectively

Post by mimosa » 23. Nov 2012, 00:14

Thanks jayseye. It sounds as though the environment variables shouldn't be a problem, since rebooting hasn't helped.

I'm testing Wenlin for Linux (wenlinux), Chinese language learning software incorporating a dictionary and flashcards:

http://www.wenlin.com

I had the same trouble with it as subsequently with jEdit, and that code sample was suggested by Tom at Wenlin as a way of working out where the trouble lay. The fact that jEdit misbehaves similarly already suggests it is a general java problem, not specific to the Wenlin code. That was what that sample was also meant to test: whether the MenuListener is working properly in Salix.

I'm curious now as to whether the problem is with java (or java as found in Salix) or something specific to my own setup. The latter seems likely, since you don't have the trouble with jEdit.

Experience suggests that there will be some mojo that all serious java hackers either have or do that I don't, because I only installed it on account of wenlin. If on the other hand I can identify an actual problem (or recommendation for some configuration that should really be done automatically on installing openjdk), that will benefit the distro.

I'm pretty sure I already tried Oracle JDK, and no dice. Also, if openjdk works for you, it should work here. As for JRE/JDK, installing one removes the other.

User avatar
jayseye
Posts: 233
Joined: 24. Jul 2011, 17:22
Location: Brownsmead, Oregon (Center of the Universe)

Re: copying and pasting code effectively

Post by jayseye » 23. Nov 2012, 01:25

I've runs lots of Java apps under Salix 13.37, both Fluxbox and XFCE, on several PCs. So IMO the issue is with your setup. I'm certainly willing to help troubleshoot your problem, though it may make more sense to focus on diagnostics on your system, rather than on mine. Except, of course, for A/B comparisons.

On this laptop, I'm running the stock Oracle JRE (rather than OpenJDK), which reports:

# java -version
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) Server VM (build 20.0-b11, mixed mode)

To clarify about OpenJDK, so far I run that on FreeBSD rather than on Salix. I definitely plan to test OpenJDK here for security reasons, though it may be a few months before that bubbles to to top of my priorities.

For troubleshooting, I'd start with three basic questions:

1. Are you running a Brazilian localization, or the EN_US configuration?

2. Why are you using the JDK, rather than JRE?

3. Can you test Wenlin on a Salix LiveCD, using default boot options?

If you provide details of how the example code fails on your current system, then it might be useful for me to test running that here for comparison.

User avatar
mimosa
Salix Warrior
Posts: 3141
Joined: 25. May 2010, 17:02
Contact:

Re: copying and pasting code effectively

Post by mimosa » 23. Nov 2012, 12:00

Morning jayseye. Thanks for the time you're taking over this.

My locale is EN-GB, but with a Brazilian keyboard and timezone.

jdk rather than jre, because though it may not be needed for either jEdit or the code sample, it is needed to buidl the Wenlin source, which is written in C with java on the outside.

I will test Wenlin in a clean system at the first opportunity - a good idea. However, it does the same in 13.37 and the RC, with openjdk 7 and 6 respectively.

The behaviour is exactly the same for Wenlin, jEdit, and the sample: clicking on menu items makes the drop-down list appear, but it disappears as soon as the button is released, making it impossible to select anything. Also, in tiling WMs, the application window doesn't take up the full space available and appears to be missing something to bottom and right.

I think that means Wenlin can be removed from the problem. If I can make jEdit work, Wenlin is going to work. The relevance of the sample is to narrow the problem down to the "MenuListener". That's just a plausible hypothesis.

If nobody else is seeing this (jEdit works, the sample works as expected) then it must be either something I've done or something I've omitted to do that the typical user of jdk as opposed to jre would have done - like having loads of perl libraries if you are a perl hacker. A sin by omission seems more likely than a sin by commission because I'm seeing the same in two different Salix versions. Testing with Live will clinch it.

I just realised I omitted to mention a very important fact as the topic of the thread moved from pasting to miscreant menus and windows. I am only seeing this in XMonad and Ratpoison. In xfce, everything works as expected. However, that's counterintuitive. What does the WM have to do with java? In particular, why should the "Menu Listener" not work in one but work in another? This is the same system, I should add, with XMonad and Xfce as choices at the login screen. Ratpoison is a separate (13.37) installation.

I'm sorry I lost sight of that detail :oops: The fact is, I rarely use xfce. I am doing so now, and that reminded me.

User avatar
jayseye
Posts: 233
Joined: 24. Jul 2011, 17:22
Location: Brownsmead, Oregon (Center of the Universe)

Re: copying and pasting code effectively

Post by jayseye » 23. Nov 2012, 13:02

You're welcome mimosa, and those are all good, informative answers. If I understand you correctly, that Java menus work perfectly for you under Salix XFCE, then it seems clear that the problem lies with XMonad and Ratpoison. Your quest for a "secret sauce," for configuring Java, is likely to come up empty. :sad:

WRT to your question, "What does the WM have to do with java?", I'd bet that the answer is, "Everything." :wink: The WM likely handles menus.

Have you checked upstream, at either of those WMs, to see whether this is a known bug / quirk with Java? If so there may be workarounds, perhaps something along the lines of a "menu delay" setting.

The MenuListener code sample will likely be your best diagnostic. While I love jEdit, it's got a limited user base, so jEdit would likely just add complexity to your troubleshooting. You could, of course, search http://jedit.org/ for problems with XMonad or Ratpoison; that's a long shot, though. Chances are much better to find issues with Java via the support resources for those two WMs.

User avatar
mimosa
Salix Warrior
Posts: 3141
Joined: 25. May 2010, 17:02
Contact:

Re: copying and pasting code effectively

Post by mimosa » 23. Nov 2012, 17:15

A bit of searching reveals that there are problems with java in both xmonad and ratpoison - not the same ones, but a cluster. I have yet to get close to a solution, but the following at least gives me a full-sized Wenlin window (and menus that work if you point an inch or two lower down than the desired item ;)):

https://wiki.archlinux.org/index.php/Xm ... plications

It doesn't seem to have helped jEdit, though.

It seems to be a toss-up whether these are to be considered bugs in java or the WMs concerned. Another way of looking at it is that Java just isn't that robust.

If I find a full solution, I will post. However, now I can run through Chinese character flashcards in my normal environment, so I'm a happy camper already.

Thanks again jayseye for your help :)

User avatar
jayseye
Posts: 233
Joined: 24. Jul 2011, 17:22
Location: Brownsmead, Oregon (Center of the Universe)

Re: copying and pasting code effectively

Post by jayseye » 23. Nov 2012, 23:28

Good to hear that you're at least limping along now, mimosa. :wink: While far from being a Java fanboy, in this case I'd say it's clear that those two (tiling) window managers could use improved Java support.

For comparison, twm is the X11 reference WM, available separately in the Salix / Slackware repos. It's about as bare-bones as possible, though IIRC jEdit runs fine there.

Still, to look forward toward the future, it might be worth searching for a Python-based alternative to Wenlin. Performance and compatibility may be superior to Java.

Regards,
Marc

Post Reply