Skip to content

Commit

Permalink
Added methods to allow visible whitespace, and visible line endings t…
Browse files Browse the repository at this point in the history
…o be configured independently. (#20)

LGTM
  • Loading branch information
scottresnik authored and nedtwigg committed Nov 28, 2016
1 parent a38398e commit 144104d
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 deletions src/main/java/com/diffplug/gradle/oomph/ConventionStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,9 @@ public void niceText(String fontSize) {
props.put("org.eclipse.jface.textfont", "1|" + font + "|" + fontSize + "|0|WINDOWS|1|-12|0|0|0|400|0|0|0|0|3|2|1|49|" + font);
});
// visible whitespace
extension.workspaceProp(".metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs", props -> {
props.put("eclipse.preferences.version", "1");
props.put("showCarriageReturn", "false");
props.put("showLineFeed", "false");
props.put("showWhitespaceCharacters", "true");
});
showWhiteSpace(true);
showLineEndings(false);

// show line numbers
lineNumbers(true);
}
Expand All @@ -62,4 +59,34 @@ public void lineNumbers(boolean showLineNumbers) {
props.put("lineNumberRuler", Boolean.toString(showLineNumbers));
});
}

/** Determines whether or not to show white space not including line endings. */
public void showWhiteSpace(boolean showWhiteSpace) {
extension.workspaceProp(".metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs", props -> {
props.put("eclipse.preferences.version", "1");
props.put("showWhitespaceCharacters", Boolean.toString(showWhiteSpace));
});
}

/** Determines whether or not to show line ending characters (carriage return/line feeds). */
public void showLineEndings(boolean showLineEndings) {
showLineFeed(showLineEndings);
showCarriageReturn(showLineEndings);
}

/** Determines whether or not to show line feeds. */
public void showLineFeed(boolean showLineFeed) {
extension.workspaceProp(".metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs", props -> {
props.put("eclipse.preferences.version", "1");
props.put("showLineFeed", Boolean.toString(showLineFeed));
});
}

/** Determines whether or not to show carriage returns. */
public void showCarriageReturn(boolean showCarriageReturn) {
extension.workspaceProp(".metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs", props -> {
props.put("eclipse.preferences.version", "1");
props.put("showCarriageReturn", Boolean.toString(showCarriageReturn));
});
}
}

0 comments on commit 144104d

Please sign in to comment.