Forum Controls
Spotlight Features

The Rich Engineering Heritage Behind Dependency Injection

Andrew McVeigh takes us on a tour of the rich heritage behind dependency injection, what it represents, and tells us why its here to stay.

Java, the OLPC, and community responsibility

The "One Laptop Per Child" project has a great device ready to ship, but there's no Java on there. Let's think about working together to put Java on OLPC!
Replies: 5 - Pages: 1  
  Click to reply to this thread Reply

Word Wrap in the Eclipse Editor

URL: Chris Aniszczyk Blogs on Eclipse Word Wrap

At 10:09 PM on Jun 18, 2006, R.J. Lorimer Javalobby Editors wrote:

I'm typically not one for meta-linking to other blogs to cover news items, but I think this one is important to get as much visibility as possible. One of the long standing bug entries that Eclipse has had regards word wrap support in the text editor (see Bug 35779). As simple as word wrap sounds (consider that even Windows Notepad has a word wrap feature), when you consider a structured text editor like the one in Eclipse, it becomes exponentially more difficult of a problem to solve. Primarily, the 'story' of what happens to a line (and all of the meta-data associated with it) when that line wraps, needs to be clearly figured out (for instance, should the line number support in Eclipse accept that one line number represents two lines leaving a hole, or should one line in the original file be represented by two line numbers). From Dani Megart (on the bug report):

Allowing word/soft wrap in the editor while typing is easy but not enough, a mapping between the model lines and the visual lines must be introduced to e.g. correctly show annotations. It also introduces various problems that need to be solved, e.g. 'Go to Line': tools like a debugger, compiler etc. will report the model line but a user it will look strange that a different line will be selected than the one entered into the 'Go to Line' dialog i.e. the dialog will probably have to support both, model and visual line numbers.

Having said that, I will add this one as an investigation item to the 3.2 plan.

As you probably have ascertained, it didn't make Eclipse 3.2.

To complicate matters, there are two common types of word wrap in the world - they have been dubbed in the bug entry 'soft' wrapping and 'hard' wrapping (ala jEdit). Soft wrapping is considered to be visual support in the editing program only. In this sense, I consider it much like the code-folding/projection support they introduced in 3.0 - it is a visual assistance tool, but doesn't affect the structure of the underlying data. The solution to implement word-wrap would probably use a similar approach (and maybe even the same model) as the code folding support.

The other type of word wrap (hard word wrap) actually modifies the underlying file to match the word wrap produced in the visual editor. This is the less common (and less popular) form of word wrap; it's primarily said to be useful for people working on a lot of readme files and so forth (as one commenter put it, 'files that would commonly be read in a terminal').

However, the world is not destined to be without word wrap in Eclipse forever. Chris Aniszczyk recently mentioned on his blog that an entry in the Eclipse Summer of Code project has released their first work towards word wrap in Eclipse editors . Ahti Kitsik, the student responsible for this project, had this to say on his blog :

First experimental version (0.0.1) of eclipse word/line wrapping is now released to test plugin release cycle, update-site structure and deliver almost working version of wordwrap!

The first version of word wrap is using eclipse SWT own wrap functionality that is disabled in eclipse SDK text/java editors. This plugin is basically just providing context menu option to turn this wrap on/off for active editor. It should be usable enough and I’ll encourage everyone to give it a try - it will make your life easier!

He then proceeds to give a stern warning that this plug-in doesn't go so far as to fix so many of the side-effects this will produce. This particular release is naturally experimental because so many of the Eclipse features (annotations, line numbers, 'go to line', and so forth) will almost always be disrupted by this feature.

While this first step is modest, it is an important one. After all, one of the pleas for help in the bug entry after it was announced that 3.2 would not include full word wrap support was for a context menu option that would just turn word wrap on (as this experimental plug-in has done). This is a desperate plea; we can't expect the Eclipse team to put a feature in that they know full well will break six others as soon as it is turned on (not to mention potentially have several unknown side-effects).

I went through the process of installing this plug-in in my workspace, and to the credit of Ahti Kitsik, it works like a charm. Here I am configuring the update site:

Here I am selecting the feature to install (I sound like I'm showing you my vacation pictures):

Next, I selected 'Virtual Word Wrap' in the context menu for the editor:

Finally, here is a screenshot from a log4j.properties file showing it working in full force:

As you can see, the line numbers are disrupted for the time being. Turning off this feature corrected the problem immediately, however.

In my mind this is a valuable first step from a very active community (and an already very positive outcome from the Eclipse Summer of Code , aka the Google Summer of Code doppleganger). For me, the primary time I want word wrap in the Eclipse text editor is when I'm working on a plain-text file or HTML file (such as one of these many articles I post every week). Typically when I'm editing Java code, I'm less concerned with wrapping (I'd rather just re-format the file and commit it back to subversion the way it's supposed to be formatted :)).

Anyway, while it's a 'use-at-your-own-risk' feature, this is one I personally think is worth the risk.

  Click to reply to this thread Reply
1. At 1:35 AM on Jun 19, 2006, Chris Aniszczyk DeveloperZone Top 100 wrote:

Re: Word Wrap in the Eclipse Editor

It's good to see the progress of students overtime. It's been fun mentoring. I'll be blogging about the ECF BitTorrent Provider progress soon :)
  Click to reply to this thread Reply
2. At 8:13 AM on Jun 19, 2006, Fred Grott DeveloperZone Top 100 wrote:

Re: Word Wrap in the Eclipse Editor

Good work Chris..
Fred Grott, ShareMe jabber:fg82183@conference.javalobby.org(shareme) Official contributor to EclipseZone.com and supporter of JavaLobby.org.
  Click to reply to this thread Reply
3. At 11:48 AM on Jun 19, 2006, Ahti Kitsik Javalobby Newcomers wrote:

Re: Word Wrap in the Eclipse Editor

Thank you for such kind words and taking time to create this well-formed post!

AhtiK / wordwrap developer
Ahti Kitsik AhtiK blog
  Click to reply to this thread Reply
4. At 5:52 PM on Jun 28, 2006, PRATHIMA VENKATESAN Javalobby Newcomers wrote:

Re: Word Wrap in the Eclipse Editor

Where is this plugin available?
  Click to reply to this thread Reply
5. At 6:23 AM on Jul 16, 2006, Ahti Kitsik Javalobby Newcomers wrote:

Re: Word Wrap in the Eclipse Editor

Hi Prathima! Please see http://ahtik.com/blog/eclipse-word-wrap/ for download instructions.
Ahti Kitsik AhtiK blog

thread.rss_message