Search code examples
jedit

How to make jedit file-dropdown to display absolute path (not filename followed by directory)?


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

Solution

  • 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();