Re: [Ekit-info] tag info status bar
Brought to you by:
hexidec
|
From: Jochen S. <joc...@em...> - 2002-09-02 14:33:12
|
ho...@at... schrieb: >I am thinking of adding a status bar to the bottom of the Ekit >window, showing the tag (at least) associated with the cursor >position in the editor. In other words, at a glance, while in >WYSIWYG mode, the user could see that the text their cursor is on is >an h3 (for example) without having to toggle to HTML mode. > >Has anyone attempted this? I'd love to not reinvent the wheel >here ... > > there is a faq-entry at jguru.com (swing faq) which explains how to find out where a link points to the mouse clicked at. That's helpful in that matter, but it leaves out some tags for some reasons (h3 e.g.). You'd have to have an iterator run over all tags like Vector elementMap; ElementIterator iterator = new ElementIterator(htmldoc); while ((element=iterator.next())!=null) { if (!element.getName().equals("content")) { System.out.println("Element "+element.getName()+" goes from "+Integer.toString(element.getStartOffset()) +" to "+Integer.toString(element.getEndOffset())); elementMap.add(element); } } and then look for element[i].getStartOffset<=caretPos&&element[i].getEndOffset>=caretPos. I haven't tested this but i assume it is quite time-consuming. So either you do it only on command or you determine when to rebuild your elementmap very good (probably at every change of the document). good luck |