@@ -11,6 +11,8 @@ import CodeEditSourceEditor
11
11
struct StatusBarCursorLocationLabel : View {
12
12
@Environment ( \. controlActiveState)
13
13
private var controlActive
14
+ @Environment ( \. modifierKeys)
15
+ private var modifierKeys
14
16
15
17
@EnvironmentObject private var model : UtilityAreaViewModel
16
18
@EnvironmentObject private var editorManager : EditorManager
@@ -38,11 +40,18 @@ struct StatusBarCursorLocationLabel: View {
38
40
return " "
39
41
}
40
42
43
+ // More than one selection, display the number of selections.
41
44
if cursorPositions. count > 1 {
42
45
return " \( cursorPositions. count) selected ranges "
43
46
}
44
47
48
+ // If the selection is more than just a cursor, return the length.
45
49
if cursorPositions [ 0 ] . range. length > 0 {
50
+ // When the option key is pressed display the character range.
51
+ if modifierKeys. contains ( . option) {
52
+ return " Char: \( cursorPositions [ 0 ] . range. location) Len: \( cursorPositions [ 0 ] . range. length) "
53
+ }
54
+
46
55
let lineCount = getLines ( cursorPositions [ 0 ] . range)
47
56
48
57
if lineCount > 1 {
@@ -52,6 +61,12 @@ struct StatusBarCursorLocationLabel: View {
52
61
return " \( cursorPositions [ 0 ] . range. length) characters "
53
62
}
54
63
64
+ // When the option key is pressed display the character offset.
65
+ if modifierKeys. contains ( . option) {
66
+ return " Char: \( cursorPositions [ 0 ] . range. location) Len: 0 "
67
+ }
68
+
69
+ // When there's a single cursor, display the line and column.
55
70
return " Line: \( cursorPositions [ 0 ] . line) Col: \( cursorPositions [ 0 ] . column) "
56
71
}
57
72
0 commit comments