summaryrefslogtreecommitdiffstats
path: root/gerrit-prettify
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2010-02-26 16:37:06 -0800
committerShawn O. Pearce <sop@google.com>2010-02-26 16:37:06 -0800
commit721754c312d06d37c6818f8348802bc6130e5e35 (patch)
tree4eeaf81b8acb01da26b49ba9e923602cb61ee4d2 /gerrit-prettify
parentc23529ddf9b68e07c2a0f44262043321b7defe5e (diff)
Allow user to modify patch display settings
Users can now set the size of tabs, the number of columns displayed, and also toggle the various flags associated with our pretty printer like syntax coloring or intraline difference. Change-Id: Ic86894b76fdc7f7d5e8a494227e2e8a22dd3b1b1 Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'gerrit-prettify')
-rw-r--r--gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettyFormatter.java13
-rw-r--r--gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettySettings.java11
2 files changed, 23 insertions, 1 deletions
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 43a1e0658d..109a48e81a 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
@@ -303,7 +303,18 @@ public abstract class PrettyFormatter implements SparseHtmlFile {
}
private String toHTML(SparseFileContent src) {
- SafeHtml html = colorLineEdits(src);
+ SafeHtml html;
+
+ if (settings.isIntralineDifference()) {
+ html = colorLineEdits(src);
+ } else {
+ SafeHtmlBuilder b = new SafeHtmlBuilder();
+ for (int index = src.first(); index < src.size(); index = src.next(index)) {
+ b.append(src.get(index));
+ b.append('\n');
+ }
+ html = b;
+ }
if (settings.isShowWhiteSpaceErrors()) {
// We need to do whitespace errors before showing tabs, because
diff --git a/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettySettings.java b/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettySettings.java
index 657021c16d..7928668e68 100644
--- a/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettySettings.java
+++ b/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettySettings.java
@@ -22,6 +22,7 @@ public class PrettySettings {
protected int tabSize;
protected boolean showTabs;
protected boolean syntaxHighlighting;
+ protected boolean intralineDifference;
public PrettySettings() {
showWhiteSpaceErrors = true;
@@ -29,6 +30,7 @@ public class PrettySettings {
tabSize = 2;
showTabs = true;
syntaxHighlighting = true;
+ intralineDifference = true;
}
public PrettySettings(PrettySettings pretty) {
@@ -38,6 +40,7 @@ public class PrettySettings {
tabSize = pretty.tabSize;
showTabs = pretty.showTabs;
syntaxHighlighting = pretty.syntaxHighlighting;
+ intralineDifference = pretty.intralineDifference;
}
public String getFilename() {
@@ -92,4 +95,12 @@ public class PrettySettings {
public void setSyntaxHighlighting(final boolean on) {
syntaxHighlighting = on;
}
+
+ public boolean isIntralineDifference() {
+ return intralineDifference;
+ }
+
+ public void setIntralineDifference(final boolean on) {
+ intralineDifference = on;
+ }
}