summaryrefslogtreecommitdiffstats
path: root/gerrit-prettify
diff options
context:
space:
mode:
authorPravin Sethia <pravins@nvidia.com>2012-07-04 16:17:05 +0530
committerSasa Zivkov <sasa.zivkov@sap.com>2012-07-30 11:42:15 +0200
commit632653c2d0cb88ab5256b2d4077fcdc08df6728d (patch)
tree7fc3cbf269e8df1374064cd9ea5ac10f826a38d2 /gerrit-prettify
parente6ec46892f6585a11bf0db28f40cac109f3673ef (diff)
Option to display line endings
Displays Windows EOL/Cr-Lf on patch diff screen. This is optional and is controlled by a checkbox. A new column show_line_endings is added in account_diff_preferences. Display is similar to gitweb i.e. '\r' in dotted-line box Bug: issue 626 Change-Id: I6128575bd2f0869a3c59e3d2fd409d5ee431ecc5
Diffstat (limited to 'gerrit-prettify')
-rw-r--r--gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettifyConstants.java1
-rw-r--r--gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettifyConstants.properties3
-rw-r--r--gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettyFormatter.java17
-rw-r--r--gerrit-prettify/src/main/resources/com/google/gerrit/prettify/client/gerrit.css14
4 files changed, 31 insertions, 4 deletions
diff --git a/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettifyConstants.java b/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettifyConstants.java
index e14063a1d1..df603058bb 100644
--- a/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettifyConstants.java
+++ b/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettifyConstants.java
@@ -23,4 +23,5 @@ public interface PrettifyConstants extends Constants {
String wseTabAfterSpace();
String wseTrailingSpace();
String wseBareCR();
+ String leCR();
}
diff --git a/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettifyConstants.properties b/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettifyConstants.properties
index d440c65c55..97ab0cfc4b 100644
--- a/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettifyConstants.properties
+++ b/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettifyConstants.properties
@@ -1,3 +1,4 @@
wseTabAfterSpace=Whitespace error: Tab after space
wseTrailingSpace=Whitespace error: Trailing space at end of line
-wseBareCR=Whitespace error: CR without LF
+wseBareCR=CR without LF
+leCR=Carriage Return
diff --git a/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettyFormatter.java b/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettyFormatter.java
index c9a9ab8bd8..151149b52e 100644
--- a/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettyFormatter.java
+++ b/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettyFormatter.java
@@ -335,6 +335,10 @@ public abstract class PrettyFormatter implements SparseHtmlFile {
html = showTrailingWhitespace(html);
}
+ if (diffPrefs.isShowLineEndings()){
+ html = showLineEndings(html);
+ }
+
if (diffPrefs.isShowTabs()) {
String t = 1 < diffPrefs.getTabSize() ? "\t" : "";
html = html.replaceAll("\t", "<span class=\"vt\">\u00BB</span>" + t);
@@ -449,12 +453,11 @@ public abstract class PrettyFormatter implements SparseHtmlFile {
} else if (end) {
if (cr == src.length() - 1) {
- buf.append(src.substring(0, cr));
+ buf.append(src.substring(0, cr + 1));
return;
}
} else if (cr == src.length() - 2 && src.charAt(cr + 1) == '\n') {
- buf.append(src.substring(0, cr));
- buf.append('\n');
+ buf.append(src);
return;
}
@@ -499,6 +502,14 @@ public abstract class PrettyFormatter implements SparseHtmlFile {
return src;
}
+ private SafeHtml showLineEndings(SafeHtml src) {
+ final String r = "<span class=\"lecr\""
+ + " title=\"" + PrettifyConstants.C.leCR() + "\"" //
+ + ">\\\\r</span>";
+ src = src.replaceAll("\r", r);
+ return src;
+ }
+
private String expandTabs(String html) {
StringBuilder tmp = new StringBuilder();
int i = 0;
diff --git a/gerrit-prettify/src/main/resources/com/google/gerrit/prettify/client/gerrit.css b/gerrit-prettify/src/main/resources/com/google/gerrit/prettify/client/gerrit.css
index 3478e68763..23e7e4679e 100644
--- a/gerrit-prettify/src/main/resources/com/google/gerrit/prettify/client/gerrit.css
+++ b/gerrit-prettify/src/main/resources/com/google/gerrit/prettify/client/gerrit.css
@@ -14,6 +14,7 @@
*/
@external .wse;
+@external .lecr;
@external .vt;
@external .wdd;
@external .wdi;
@@ -35,6 +36,19 @@
cursor: pointer;
}
+.lecr {
+ border-bottom: #aaaaaa 1px dashed;
+ border-left: #aaaaaa 1px dashed;
+ padding-bottom: 0px;
+ margin: 0px 2px;
+ padding-left: 2px;
+ padding-right: 2px;
+ border-top: #aaaaaa 1px dashed;
+ border-right: #aaaaaa 1px dashed;
+ padding-top: 0px;
+ cursor: pointer;
+}
+
.vt,
.vt .str,
.vt .kwd,