VCS and editor plugin

Answered

Hi,

I am trying to show VCS changes as green for addition and red for deletion or another colour for changes to blocks or lines of code for a file in the editor. 

I already know the standard classes I need like Editor.java and ChangeList.java used in identifying file changes but what can I use in the editor to identify the line or block that got changed and display the colours I mentioned.

Thanks

Kenneth

0
6 comments

Could you show a mockup of what you're trying to achieve?

0
Avatar
Permanently deleted user

Sorry about the delay in the response.

https://www.jetbrains.com/idea/whatsnew/img/2016.1/idea-vcs-merge.png 

something like the above image with the color coding but in the editor window instead of a seperate window to show what changed in a commit for a file so a developer can navigate and identify changes quickly from file to file via ctrl click. 

 

Thanks

0

Do you want to add highlighting to the existing editor for a local file or to embed diff window into the editor window (as a separate tab)?

The difference is "I want to see <things that were changed in a past 2 weeks> while editing code" vs "I don't want to switch windows to check what was changed in <a commit #abcefg>".

0
Avatar
Permanently deleted user

The former. Its not a diff window but the aim is to add highlighting to all changes of a commit in a file.

0

 

You can highlight lines in Editor using RangeHighlighters:

TextAttributes attributes = new TextAttributes();
attributes.setBackgroundColor(<..>);
RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(startOffset, endOffset,
HighlighterLayer.SELECTION - 1, attributes, HighlighterTargetArea.LINES_IN_RANGE);
highlighter.setLineMarkerRenderer(<...>); // optional: draw "empty range" for deletions

Or using 

DiffDrawUtil.createHighlighter(), DiffDrawUtil.createInlineHighlighter()

If you need to calculate differences between two revisions of a file, you can use 

ComparisonManager.compareLines(), ComparisonManager.compareLinesInner()
0
Avatar
Permanently deleted user

Thanks Aleksey, I will try this.

0

Please sign in to leave a comment.