How to edit the active intellij editor background color ONLY

已回答

I know all about color code preferences. This is not in there, so I need to build a plugin for it. 

 

Basically, I would like to edit the color of the background of the currently active editor that is accepting INPUT. 

 

I've tried 

 

JComponent component = super.window.getSelectedEditor().getComponent();
component.setBackground(JBColor.YELLOW);

But this is not working. 

 

Alternatively, might be interesting to edit the color of the active line in the editor ACCEPTING INPUT only ... currently splitter groups will show the active line having the same color in all splitters, forcing you to see try to identify the CURSOR. 

 

So how can I edit these things? 

 

Thanks!

0

Having the Editor instance, you can call setBackgroundColor which is available in EditorEx interface.

 

0

I got it to work by using this.manager.getSelectedTextEditor and casting it. 

 

Frankly I don't know why I need to cast it. Why doesn't it give me the proper type to start with. 

 

this.editor = (EditorImpl) this.manager.getSelectedTextEditor();

 

I found this 

 

 

MessageBus bus = project.getMessageBus();

MessageBusConnection connection = bus.connect();

connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() {
@Override
public void fileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
System.out.println("11111111111111111111111111");
}

@Override
public void fileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
System.out.println("222222222222222222222222222");
}
});

 

Which will fire for events when an editor is opened, closed. 

But what is the one for editor active / inactive? That is being focused and loosing focus.

 

That way I avoid having to poll. 

 

Also, maybe it would be better to color only active LINE, rather than the entire editor. 

 

Also, why are my replies pending approval? Isn't this for a community to answer.

 

My latest posts has been delayed by days.

 

 

 

 

0

请先登录再写评论。