Skip to content

Commit f367910

Browse files
committed
chore: move line:col status to right to accomedate plugin statusbar tab panels
1 parent cb99e88 commit f367910

File tree

4 files changed

+44
-19
lines changed

4 files changed

+44
-19
lines changed

src/editor/EditorStatusBar.js

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ define(function (require, exports, module) {
5858
encodingSelect, // this is a DropdownButton instance
5959
tasksSelect, // this is a DropdownButton instance
6060
$cursorInfo,
61+
$statusInfo,
6162
$fileInfo,
6263
$indentType,
6364
$indentAuto,
@@ -106,13 +107,17 @@ define(function (require, exports, module) {
106107
encodingSelect.$button.text(doc.file._encoding);
107108
}
108109

110+
function _getLineCountStr(editor) {
111+
const lines = editor.lineCount();
112+
return _formatCountable(lines, Strings.STATUSBAR_LINE_COUNT_SINGULAR, Strings.STATUSBAR_LINE_COUNT_PLURAL);
113+
}
114+
109115
/**
110116
* Update file information
111117
* @param {Editor} editor Current editor
112118
*/
113119
function _updateFileInfo(editor) {
114-
var lines = editor.lineCount();
115-
$fileInfo.text(_formatCountable(lines, Strings.STATUSBAR_LINE_COUNT_SINGULAR, Strings.STATUSBAR_LINE_COUNT_PLURAL));
120+
$fileInfo.text(_getLineCountStr(editor));
116121
}
117122

118123
/**
@@ -185,12 +190,15 @@ define(function (require, exports, module) {
185190
editor = editor || EditorManager.getActiveEditor();
186191

187192
// compute columns, account for tab size
188-
var cursor = editor.getCursorPos(true);
193+
const cursor = editor.getCursorPos(true);
189194

190-
var cursorStr = StringUtils.format(Strings.STATUSBAR_CURSOR_POSITION, cursor.line + 1, cursor.ch + 1);
195+
let cursorStr = StringUtils.format(Strings.STATUSBAR_CURSOR_POSITION, cursor.line + 1, cursor.ch + 1);
196+
let cursorStrShort = StringUtils.format(
197+
Strings.STATUSBAR_CURSOR_POSITION_SHORT, cursor.line + 1, cursor.ch + 1);
191198

192-
var sels = editor.getSelections(),
193-
selStr = "";
199+
let sels = editor.getSelections(),
200+
selStr = "",
201+
shortSelStr = "";
194202

195203
if (sels.length > 1) {
196204
//Send analytics data for multicursor use
@@ -200,20 +208,28 @@ define(function (require, exports, module) {
200208
"usage"
201209
);
202210
selStr = StringUtils.format(Strings.STATUSBAR_SELECTION_MULTIPLE, sels.length);
211+
shortSelStr = StringUtils.format(Strings.STATUSBAR_SELECTION_MULTIPLE_SHORT, sels.length);
203212
} else if (editor.hasSelection()) {
204-
var sel = sels[0];
213+
const sel = sels[0];
205214
if (sel.start.line !== sel.end.line) {
206-
var lines = sel.end.line - sel.start.line + 1;
215+
let lines = sel.end.line - sel.start.line + 1;
207216
if (sel.end.ch === 0) {
208217
lines--; // end line is exclusive if ch is 0, inclusive otherwise
209218
}
210-
selStr = _formatCountable(lines, Strings.STATUSBAR_SELECTION_LINE_SINGULAR, Strings.STATUSBAR_SELECTION_LINE_PLURAL);
219+
selStr = _formatCountable(lines, Strings.STATUSBAR_SELECTION_LINE_SINGULAR,
220+
Strings.STATUSBAR_SELECTION_LINE_PLURAL);
221+
shortSelStr = StringUtils.format(Strings.STATUSBAR_SELECTION_SHORT, lines);
211222
} else {
212-
var cols = editor.getColOffset(sel.end) - editor.getColOffset(sel.start); // end ch is exclusive always
213-
selStr = _formatCountable(cols, Strings.STATUSBAR_SELECTION_CH_SINGULAR, Strings.STATUSBAR_SELECTION_CH_PLURAL);
223+
// end ch is exclusive always
224+
const cols = editor.getColOffset(sel.end) - editor.getColOffset(sel.start);
225+
selStr = _formatCountable(cols, Strings.STATUSBAR_SELECTION_CH_SINGULAR,
226+
Strings.STATUSBAR_SELECTION_CH_PLURAL);
227+
shortSelStr = StringUtils.format(Strings.STATUSBAR_SELECTION_SHORT, cols);
214228
}
215229
}
216-
$cursorInfo.text(cursorStr + selStr);
230+
$cursorInfo.text(cursorStrShort + shortSelStr);
231+
$statusInfo.attr("title", cursorStr + selStr + " " + _getLineCountStr(editor)+ "\n" +
232+
Strings.STATUSBAR_CURSOR_GOTO);
217233
}
218234

219235
/**
@@ -392,13 +408,20 @@ define(function (require, exports, module) {
392408
function _init() {
393409

394410
$cursorInfo = $("#status-cursor");
411+
$statusInfo = $("#status-info");
395412
$fileInfo = $("#status-file");
396413
$indentType = $("#indent-type");
397414
$indentAuto = $("#indent-auto");
398415
$indentWidthLabel = $("#indent-width-label");
399416
$indentWidthInput = $("#indent-width-input");
400417
$statusOverwrite = $("#status-overwrite");
401418

419+
$statusInfo.click((event)=>{
420+
event.preventDefault();
421+
event.stopPropagation();
422+
CommandManager.execute(Commands.NAVIGATE_GOTO_LINE);
423+
});
424+
402425
languageSelect = new DropdownButton.DropdownButton("", [], function (item, index) {
403426
var document = EditorManager.getActiveEditor().document,
404427
defaultLang = LanguageManager.getLanguageForPath(document.file.fullPath, true);

src/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -854,10 +854,6 @@
854854
<!-- View Panes are programatically created here -->
855855
</div>
856856
<div id="status-bar" class="statusbar no-focus">
857-
<div id="status-info" class="info" >
858-
<div id="status-cursor"></div>
859-
<div id="status-file"></div>
860-
</div>
861857
<div id="status-indicators" class="indicators">
862858
<div id="status-indent">
863859
<div id="indent-type"></div>
@@ -868,6 +864,10 @@
868864
<div id="status-language"></div>
869865
<div id="status-encoding"></div>
870866
<div id="status-overwrite"></div>
867+
<div id="status-info" class="info" >
868+
<div id="status-cursor"></div>
869+
<div id="status-file"></div>
870+
</div>
871871
<div id="status-tasks" class="forced-hidden global-indicator">
872872
<div class="spinner spin"></div>
873873
</div>

src/nls/root/strings.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,15 @@ define({
389389
* StatusBar strings
390390
*/
391391
"STATUSBAR_CURSOR_POSITION": "Line {0}, Column {1}",
392+
"STATUSBAR_CURSOR_POSITION_SHORT": "{0} : {1}",
393+
"STATUSBAR_CURSOR_GOTO": "Click to Go To another :Line",
394+
"STATUSBAR_SELECTION_SHORT": " \u2014 Sel {0}",
392395
"STATUSBAR_SELECTION_CH_SINGULAR": " \u2014 Selected {0} column",
393396
"STATUSBAR_SELECTION_CH_PLURAL": " \u2014 Selected {0} columns",
394397
"STATUSBAR_SELECTION_LINE_SINGULAR": " \u2014 Selected {0} line",
395398
"STATUSBAR_SELECTION_LINE_PLURAL": " \u2014 Selected {0} lines",
396-
"STATUSBAR_SELECTION_MULTIPLE": " \u2014 {0} selections",
399+
"STATUSBAR_SELECTION_MULTIPLE": " \u2014 {0} Multi Cursor selections",
400+
"STATUSBAR_SELECTION_MULTIPLE_SHORT": " \u2014 Mul {0}",
397401
"STATUSBAR_INDENT_TOOLTIP_SPACES": "Click to switch indentation to spaces",
398402
"STATUSBAR_INDENT_TOOLTIP_TABS": "Click to switch indentation to tabs",
399403
"STATUSBAR_INDENT_SIZE_TOOLTIP_SPACES": "Click to change number of spaces used when indenting",

src/styles/brackets.less

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,6 @@ a, img {
303303

304304
#status-info {
305305
color: @bc-text;
306-
left: 10px;
307-
position: absolute;
308306
white-space: nowrap;
309307

310308
.dark & {

0 commit comments

Comments
 (0)