0

All is in the title.

If a have opened the three files:

  • /some/relatively/long/path/dir1/file_a
  • /some/relatively/long/path/dir1/file_b
  • /some/relatively/long/path/dir2/file_a

The file dropdown contains:

file_a (/some/relatively/long/path/dir1)
file_a (/some/relatively/long/path/dir2)
file_b (/some/relatively/long/path/dir1)

And that bother me because I have to look on the right to differentiate the two file_a, and on the left for the others. This happens a lot to me mostly because I code in python, and thus I often have several __init__.py files opened.

How do I get jedit to display

/some/relatively/long/path/dir1/file_a
/some/relatively/long/path/dir1/file_b
/some/relatively/long/path/dir2/file_a

config:

  • jedit 5.1.0
  • java 1.6.0_26
  • mac osx 10.6
Juh_
  • 14,628
  • 8
  • 59
  • 92

1 Answers1

2

Unfortunately this is not easily possible currently, I just had a look at the source and this is not configurable.

You can:

  • Submit a Feature Request to make this configurable (good idea in any case)
  • Create or let create a startup macro that
    • registers an EBComponent with the EditBus that listens for new EditPanes getting created
    • retrieve the BufferSwitcher from the EditPane
    • retrieve the ListCellRenderer from the BufferSwitcher
    • set a new ListCellRenderer to the BufferSwitcher that first calls the retrieved ListCellRenderer and then additionally sets the text to value.getPath()
  • Try the Buffer List plugin as to whether it maybe suits your needs

Now follows code that implements the work-part of option two, runnable as BeanShell code which does this manipulation for the current edit pane. The third line is not necessary when done in an EBComponent, this is just that the on-the-fly manipulation is shown immediately.

r = editPane.getBufferSwitcher().getRenderer();

editPane.getBufferSwitcher().setRenderer(
    new ListCellRenderer() { 
        public Component getListCellRendererComponent(list, value, index, isSelected, cellHasFocus) { 
            rc = r.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); 
            rc.setText(value.getPath()); 
            return rc; 
        } 
    });

editPane.repaint();
Juh_
  • 14,628
  • 8
  • 59
  • 92
Vampire
  • 35,631
  • 4
  • 76
  • 102
  • I tried your code, it works. But when called at startup, it fails with `undefined variable [...] editPane : at line: 1 [...]`. I seams `editPane` is not accessible at startup. Would you have an idea how to get access to it? – Juh_ Aug 27 '14 at 13:41
  • Then, there is one limitation to you code: it keep the file sorted by filename. When displaying abspath, it should be sorted by abspath. An idea how to do that? – Juh_ Aug 27 '14 at 13:46
  • You should read answers fully. I clearly stated that this code is only for on-the fly usage, not for the startup code. I described the whole process of how to make it work for all BufferSwitchers in all EditPanes from a startup macro. That code was only part of the deal as clearly stated in the paragraph before the code. ;-) At startup you can have no EditPane, as you are not in the context of an EditPane. And during runtime you can create and discard dozens of EditPanes by splitting, joining, openingn new windows, ... and all have an own BufferSwitcher that needs to be manipulated. – Vampire Aug 27 '14 at 14:33
  • 1
    About sorting, that is easy, just flip the switch in the settings: `Utilities -> Global Options... -> jEdit -> View -> Sort buffer sets by file name, instead of path name` – Vampire Aug 27 '14 at 14:34
  • Well, I just don't understand the technical parts (no idea what are `EBComponent`, `EditBus`, etc...). I just copied/pasted your code in a macro file, blindly. But in the end, a runtime-macro will be enough :-) – Juh_ Aug 27 '14 at 14:45