Merge "Add a diff preference for font size"
This commit is contained in:
@@ -1382,7 +1382,8 @@ link:#diff-preferences-info[DiffPreferencesInfo] entity.
|
||||
"show_tabs": true,
|
||||
"show_whitespace_errors": true,
|
||||
"syntax_highlighting": true,
|
||||
"tab_size": 8
|
||||
"tab_size": 8,
|
||||
"font_size": 12
|
||||
}
|
||||
----
|
||||
|
||||
@@ -1413,7 +1414,8 @@ link:#diff-preferences-input[DiffPreferencesInput] entity.
|
||||
"show_tabs": true,
|
||||
"show_whitespace_errors": true,
|
||||
"syntax_highlighting": true,
|
||||
"tab_size": 8
|
||||
"tab_size": 8,
|
||||
"font_size": 12
|
||||
}
|
||||
----
|
||||
|
||||
@@ -1437,7 +1439,8 @@ link:#diff-preferences-info[DiffPreferencesInfo] entity.
|
||||
"show_tabs": true,
|
||||
"show_whitespace_errors": true,
|
||||
"syntax_highlighting": true,
|
||||
"tab_size": 8
|
||||
"tab_size": 8,
|
||||
"font_size": 12
|
||||
}
|
||||
----
|
||||
|
||||
@@ -2209,6 +2212,8 @@ scrolling down more than half of a page.
|
||||
If true the line numbers are hidden.
|
||||
|`tab_size` ||
|
||||
Number of spaces that should be used to display one tab.
|
||||
|`font_size` ||
|
||||
Default font size in pixels for change to be displayed in the diff view.
|
||||
|'hide_empty_pane' |not set if `false`|
|
||||
Whether empty panes should be hidden. The left pane is empty when a
|
||||
file was added; the right pane is empty when a file was deleted.
|
||||
@@ -2269,6 +2274,8 @@ scrolling down more than half of a page.
|
||||
True if the line numbers should be hidden.
|
||||
|`tab_size` |optional|
|
||||
Number of spaces that should be used to display one tab.
|
||||
|`font_size` |optional|
|
||||
Default font size in pixels for change to be displayed in the diff view.
|
||||
|`line_wrapping` |optional|
|
||||
Whether to enable line wrapping or not.
|
||||
|===========================================
|
||||
|
||||
@@ -78,6 +78,7 @@ public class DiffPreferencesIT extends AbstractDaemonTest {
|
||||
// change all default values
|
||||
i.context *= -1;
|
||||
i.tabSize *= -1;
|
||||
i.fontSize *= -1;
|
||||
i.lineLength *= -1;
|
||||
i.cursorBlinkRate = 500;
|
||||
i.theme = Theme.MIDNIGHT;
|
||||
@@ -121,9 +122,11 @@ public class DiffPreferencesIT extends AbstractDaemonTest {
|
||||
DiffPreferencesInfo d = DiffPreferencesInfo.defaults();
|
||||
int newLineLength = d.lineLength + 10;
|
||||
int newTabSize = d.tabSize * 2;
|
||||
int newFontSize = d.fontSize - 2;
|
||||
DiffPreferencesInfo update = new DiffPreferencesInfo();
|
||||
update.lineLength = newLineLength;
|
||||
update.tabSize = newTabSize;
|
||||
update.fontSize = newFontSize;
|
||||
gApi.config().server().setDefaultDiffPreferences(update);
|
||||
|
||||
DiffPreferencesInfo o = gApi.accounts()
|
||||
@@ -133,8 +136,9 @@ public class DiffPreferencesIT extends AbstractDaemonTest {
|
||||
// assert configured defaults
|
||||
assertThat(o.lineLength).isEqualTo(newLineLength);
|
||||
assertThat(o.tabSize).isEqualTo(newTabSize);
|
||||
assertThat(o.fontSize).isEqualTo(newFontSize);
|
||||
|
||||
// assert hard-coded defaults
|
||||
assertPrefs(o, d, "lineLength", "tabSize");
|
||||
assertPrefs(o, d, "lineLength", "tabSize", "fontSize");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,9 @@ public class DiffPreferencesInfo {
|
||||
/** Default tab size. */
|
||||
public static final int DEFAULT_TAB_SIZE = 8;
|
||||
|
||||
/** Default font size. */
|
||||
public static final int DEFAULT_FONT_SIZE = 12;
|
||||
|
||||
/** Default line length. */
|
||||
public static final int DEFAULT_LINE_LENGTH = 100;
|
||||
|
||||
@@ -41,6 +44,7 @@ public class DiffPreferencesInfo {
|
||||
|
||||
public Integer context;
|
||||
public Integer tabSize;
|
||||
public Integer fontSize;
|
||||
public Integer lineLength;
|
||||
public Integer cursorBlinkRate;
|
||||
public Boolean expandAllComments;
|
||||
@@ -68,6 +72,7 @@ public class DiffPreferencesInfo {
|
||||
DiffPreferencesInfo i = new DiffPreferencesInfo();
|
||||
i.context = DEFAULT_CONTEXT;
|
||||
i.tabSize = DEFAULT_TAB_SIZE;
|
||||
i.fontSize = DEFAULT_FONT_SIZE;
|
||||
i.lineLength = DEFAULT_LINE_LENGTH;
|
||||
i.cursorBlinkRate = 0;
|
||||
i.ignoreWhitespace = Whitespace.IGNORE_NONE;
|
||||
|
||||
@@ -100,6 +100,13 @@ limitations under the License.
|
||||
allowed-pattern="[0-9]"
|
||||
bind-value="{{_newPrefs.tab_size}}">
|
||||
</div>
|
||||
<div class="pref">
|
||||
<label for="fontSizeInput">Font Size</label>
|
||||
<input is="iron-input" type="number" id="fontSizeInput"
|
||||
prevent-invalid-input
|
||||
allowed-pattern="[0-9]"
|
||||
bind-value="{{_newPrefs.font_size}}">
|
||||
</div>
|
||||
<div class="pref">
|
||||
<label for="showTabsInput">Show tabs</label>
|
||||
<input is="iron-input" type="checkbox" id="showTabsInput"
|
||||
|
||||
@@ -41,6 +41,7 @@ limitations under the License.
|
||||
test('model changes', function() {
|
||||
element.prefs = {
|
||||
context: 10,
|
||||
font_size: 12,
|
||||
line_length: 100,
|
||||
show_tabs: true,
|
||||
tab_size: 8,
|
||||
@@ -51,11 +52,13 @@ limitations under the License.
|
||||
element.$.contextSelect.value = '50';
|
||||
element.fire('change', {}, {node: element.$.contextSelect});
|
||||
element.$.columnsInput.bindValue = 80;
|
||||
element.$.fontSizeInput.bindValue = 10;
|
||||
element.$.tabSizeInput.bindValue = 4;
|
||||
MockInteractions.tap(element.$.showTabsInput);
|
||||
MockInteractions.tap(element.$.syntaxHighlightInput);
|
||||
|
||||
assert.equal(element._newPrefs.context, 50);
|
||||
assert.equal(element._newPrefs.font_size, 10);
|
||||
assert.equal(element._newPrefs.line_length, 80);
|
||||
assert.equal(element._newPrefs.tab_size, 4);
|
||||
assert.isFalse(element._newPrefs.show_tabs);
|
||||
|
||||
@@ -113,6 +113,11 @@ limitations under the License.
|
||||
max-width: var(--content-width, 80ch);
|
||||
min-width: var(--content-width, 80ch);
|
||||
}
|
||||
.content,
|
||||
.lineNum {
|
||||
/* Set font size based the user's diff preference. */
|
||||
font-size: var(--font-size, 12px);
|
||||
}
|
||||
.content.add .intraline,
|
||||
.content.add.darkHighlight {
|
||||
background-color: var(--dark-add-highlight-color);
|
||||
|
||||
@@ -359,6 +359,7 @@
|
||||
_prefsChanged: function(prefs) {
|
||||
if (!prefs) { return; }
|
||||
this.customStyle['--content-width'] = prefs.line_length + 'ch';
|
||||
this.customStyle['--font-size'] = prefs.font_size + 'px';
|
||||
this.updateStyles();
|
||||
|
||||
if (this._diff && this._comments) {
|
||||
|
||||
@@ -231,6 +231,17 @@ limitations under the License.
|
||||
bind-value="{{_diffPrefs.tab_size}}">
|
||||
</span>
|
||||
</section>
|
||||
<section>
|
||||
<span class="title">Font Size</span>
|
||||
<span class="value">
|
||||
<input
|
||||
is="iron-input"
|
||||
type="number"
|
||||
prevent-invalid-input
|
||||
allowed-pattern="[0-9]"
|
||||
bind-value="{{_diffPrefs.font_size}}">
|
||||
</span>
|
||||
</section>
|
||||
<section>
|
||||
<span class="title">Show Tabs</span>
|
||||
<span class="value">
|
||||
|
||||
@@ -92,6 +92,7 @@ limitations under the License.
|
||||
diffPreferences = {
|
||||
context: 10,
|
||||
tab_size: 8,
|
||||
font_size: 12,
|
||||
line_length: 100,
|
||||
cursor_blink_rate: 0,
|
||||
intraline_difference: true,
|
||||
@@ -192,6 +193,8 @@ limitations under the License.
|
||||
.firstElementChild.bindValue, diffPreferences.line_length);
|
||||
assert.equal(valueOf('Tab Width', 'diffPreferences')
|
||||
.firstElementChild.bindValue, diffPreferences.tab_size);
|
||||
assert.equal(valueOf('Font Size', 'diffPreferences')
|
||||
.firstElementChild.bindValue, diffPreferences.font_size);
|
||||
assert.equal(valueOf('Show Tabs', 'diffPreferences')
|
||||
.firstElementChild.checked, diffPreferences.show_tabs);
|
||||
|
||||
|
||||
@@ -191,6 +191,7 @@
|
||||
auto_hide_diff_table_header: true,
|
||||
context: 10,
|
||||
cursor_blink_rate: 0,
|
||||
font_size: 12,
|
||||
ignore_whitespace: 'IGNORE_NONE',
|
||||
intraline_difference: true,
|
||||
line_length: 100,
|
||||
|
||||
Reference in New Issue
Block a user