Skip to content

Commit 097a685

Browse files
Add EditorCommands menu (#2058)
1 parent bcd5f11 commit 097a685

File tree

5 files changed

+47
-3
lines changed

5 files changed

+47
-3
lines changed

CodeEdit.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1784,7 +1784,7 @@
17841784
repositoryURL = "https://github.com/CodeEditApp/CodeEditSourceEditor";
17851785
requirement = {
17861786
kind = exactVersion;
1787-
version = 0.14.0;
1787+
version = 0.14.1;
17881788
};
17891789
};
17901790
/* End XCRemoteSwiftPackageReference section */

CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CodeEdit/Features/Editor/Models/EditorInstance.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,15 @@ class EditorInstance: Hashable {
8787
}
8888
return (endTextLine.index - startTextLine.index) + 1
8989
}
90+
91+
func moveLinesUp() {
92+
guard let controller = textViewController else { return }
93+
controller.moveLinesUp()
94+
}
95+
96+
func moveLinesDown() {
97+
guard let controller = textViewController else { return }
98+
controller.moveLinesDown()
99+
}
90100
}
91101
}

CodeEdit/Features/WindowCommands/CodeEditCommands.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ struct CodeEditCommands: Commands {
1818
FindCommands()
1919
NavigateCommands()
2020
if sourceControlIsEnabled { SourceControlCommands() }
21+
EditorCommands()
2122
ExtensionCommands()
2223
WindowCommands()
2324
HelpCommands()
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// EditorCommands.swift
3+
// CodeEdit
4+
//
5+
// Created by Bogdan Belogurov on 21/05/2025.
6+
//
7+
8+
import SwiftUI
9+
import CodeEditKit
10+
11+
struct EditorCommands: Commands {
12+
13+
@UpdatingWindowController var windowController: CodeEditWindowController?
14+
private var editor: Editor? {
15+
windowController?.workspace?.editorManager?.activeEditor
16+
}
17+
18+
var body: some Commands {
19+
CommandMenu("Editor") {
20+
Menu("Structure") {
21+
Button("Move line up") {
22+
editor?.selectedTab?.rangeTranslator?.moveLinesUp()
23+
}
24+
.keyboardShortcut("[", modifiers: [.command, .option])
25+
26+
Button("Move line down") {
27+
editor?.selectedTab?.rangeTranslator?.moveLinesDown()
28+
}
29+
.keyboardShortcut("]", modifiers: [.command, .option])
30+
}
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)