Skip to content

Commit 7f6369b

Browse files
committed
feat: editor lineheight adjust in theme settings
1 parent 3c00d6b commit 7f6369b

File tree

8 files changed

+63
-47
lines changed

8 files changed

+63
-47
lines changed

src/htmlContent/themes-settings.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,21 @@ <h1 class="dialog-title">{{Strings.THEMES_SETTINGS}}</h1>
4141
<input type="text" data-target="fontFamily" value="{{settings.fontFamily}}">
4242
</div>
4343
</div>
44+
45+
<div class="control-group">
46+
<label class="control-label">{{Strings.FONT_LINE_HEIGHT}}:</label>
47+
<div class="controls line-height-slider">
48+
<input
49+
type="range"
50+
min="1"
51+
max="3"
52+
step="0.1"
53+
value="{{settings.editorLineHeight}}"
54+
class="form-range fontLineHeightSlider"
55+
data-target="editorLineHeight">
56+
<span class="fontLineHeightValue">{{settings.editorLineHeight}}</span>
57+
</div>
58+
</div>
4459
</form>
4560
</div>
4661
<div class="modal-footer">

src/nls/root/strings.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ define({
688688
"USE_THEME_SCROLLBARS": "Use Theme Scrollbars",
689689
"FONT_SIZE": "Font Size",
690690
"FONT_FAMILY": "Font Family",
691+
"FONT_LINE_HEIGHT": "Line Height",
691692
"THEMES_SETTINGS": "Themes Settings",
692693
"THEMES_ERROR": "Themes Error",
693694
"THEMES_ERROR_CANNOT_APPLY": "Could not apply theme due to an error.",
@@ -1054,6 +1055,7 @@ define({
10541055
"DESCRIPTION_NUMBER_QUICK_VIEW": "true to show Quick View on hover over numbers in editor",
10551056
"DESCRIPTION_THEME": "Select a {APP_NAME} theme",
10561057
"DESCRIPTION_USE_THEME_SCROLLBARS": "true to allow custom scroll bars",
1058+
"DESCRIPTION_EDITOR_LINE_HEIGHT": "Adjust the vertical spacing between lines of code in the editor. Choose a value between 1 and 3, default is 1.5",
10571059
"DESCRIPTION_LINTING_COLLAPSED": "true to collapse linting panel",
10581060
"DESCRIPTION_FONT_FAMILY": "Change font family",
10591061
"DESCRIPTION_DESKTOP_ZOOM_SCALE": "Choose a zoom scale factor ranging from 0.1 (for a more compact view) to 2 (for a larger, more magnified view). Available in desktop apps only",

src/styles/brackets.less

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3130,6 +3130,19 @@ label input {
31303130
display: none;
31313131
}
31323132

3133+
.theme-settings {
3134+
.line-height-slider {
3135+
padding-top: 5px;
3136+
}
3137+
.fontLineHeightSlider {
3138+
width: 220px;
3139+
}
3140+
.fontLineHeightValue {
3141+
margin-left: 3px;
3142+
padding-top: 5px;
3143+
}
3144+
}
3145+
31333146
.theme-settings td {
31343147
padding: 2px;
31353148
}
@@ -3507,4 +3520,5 @@ label input {
35073520
.toggle input:checked ~ .labels::before {
35083521
opacity: 1;
35093522
}
3510-
}
3523+
}
3524+

src/styles/brackets_core_ui_variables.css

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/styles/brackets_core_ui_variables.less

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,17 @@
4141
*/
4242

4343

44-
@import (less) "./brackets_core_ui_variables.css";
45-
46-
// DEPRECATION WARNING: This file is here for legacy reasons and will be removed as we migrate entirely to css variables
47-
// this is necessary for extension them-ability.
48-
// Please use brackets_core_ui_variables.css for defining new style variables
44+
:root {
45+
--bc-toast-danger-bg-color: #FF5C33;
46+
--bc-toast-error-bg-color: #f74687;
47+
--bc-toast-success-bg-color: #82b839;
48+
--bc-toast-warning-bg-color: #FFAA00;
49+
--bc-toast-info-bg-color: #60A3D9;
50+
}
51+
52+
// WARNING: Use the above css variables section!!! This file uses less variables for legacy reasons
53+
// and we will migrate to css variables above. This is necessary for extension them-ability.
54+
// Please use css variables above for defining new style variables
4955

5056
// General
5157
@bc-bg-highlight: #e0f0fa;

src/styles/brackets_theme_default.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
*/
132132
.code-font() {
133133
color: @foreground;
134-
line-height: 1.25;
134+
line-height: var(--editor-line-height);
135135

136136
.dark & {
137137
color: @dark-bc-text;

src/styles/brackets_variables.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
/* Brackets Variables */
2424
:root {
2525
--z-index-parameter-hints: 19;
26+
--editor-line-height: 1.5;
2627
}
2728

2829
/* All paddings, gutters, etc. should be multiples of this */

src/view/ThemeSettings.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ define(function (require, exports, module) {
5050
themeScrollbars: true,
5151
theme: SYSTEM_DEFAULT_THEME,
5252
lightTheme: "light-theme",
53-
darkTheme: "dark-theme"
53+
darkTheme: "dark-theme",
54+
editorLineHeight: 1.5
5455
};
5556

5657

@@ -133,6 +134,12 @@ define(function (require, exports, module) {
133134
var targetValue = $(this).val();
134135
newSettings["fontFamily"] = targetValue;
135136
})
137+
.on("input", ".fontLineHeightSlider", function () {
138+
const targetValue = $(this).val();
139+
$template.find(".fontLineHeightValue").text(targetValue);
140+
newSettings["editorLineHeight"] = targetValue;
141+
prefs.set("editorLineHeight", targetValue + "");
142+
})
136143
.on("change", "select", function () {
137144
var $target = $(":selected", this);
138145
var attr = $target.attr("data-target");
@@ -163,6 +170,7 @@ define(function (require, exports, module) {
163170
} else if (id === "cancel") {
164171
// Make sure we revert any changes to theme selection
165172
prefs.set("theme", currentSettings.theme);
173+
prefs.set("editorLineHeight", currentSettings.editorLineHeight);
166174
}
167175
});
168176
$template
@@ -197,6 +205,15 @@ define(function (require, exports, module) {
197205
prefs.definePreference("themeScrollbars", "boolean", DEFAULTS.themeScrollbars, {
198206
description: Strings.DESCRIPTION_USE_THEME_SCROLLBARS
199207
});
208+
prefs.definePreference("editorLineHeight", "number", DEFAULTS.editorLineHeight, {
209+
description: Strings.DESCRIPTION_EDITOR_LINE_HEIGHT
210+
});
211+
212+
prefs.on("change", "editorLineHeight", function () {
213+
const lineHeight = prefs.get("editorLineHeight") + "";
214+
const $phoenixMain = $('#Phoenix-Main');
215+
$phoenixMain[0].style.setProperty('--editor-line-height', lineHeight);
216+
});
200217

201218
exports.DEFAULTS = DEFAULTS;
202219
exports._setThemes = setThemes;

0 commit comments

Comments
 (0)