diff --git a/CodeEdit.xcodeproj/project.pbxproj b/CodeEdit.xcodeproj/project.pbxproj index 0511094f9..0c6b4b0c8 100644 --- a/CodeEdit.xcodeproj/project.pbxproj +++ b/CodeEdit.xcodeproj/project.pbxproj @@ -1784,7 +1784,7 @@ repositoryURL = "https://github.com/CodeEditApp/CodeEditSourceEditor"; requirement = { kind = exactVersion; - version = 0.14.0; + version = 0.14.1; }; }; /* End XCRemoteSwiftPackageReference section */ diff --git a/CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 49cc5d067..cb15291f4 100644 --- a/CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -42,8 +42,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/CodeEditApp/CodeEditSourceEditor", "state" : { - "revision" : "8a47aa4d3969a5e3bd372ce6c3d49ae3232883dd", - "version" : "0.14.0" + "revision" : "afc57523b05c209496a221655c2171c0624b51d3", + "version" : "0.14.1" } }, { diff --git a/CodeEdit/Features/Editor/Models/EditorInstance.swift b/CodeEdit/Features/Editor/Models/EditorInstance.swift index f8aeb8ebc..7ec13c53b 100644 --- a/CodeEdit/Features/Editor/Models/EditorInstance.swift +++ b/CodeEdit/Features/Editor/Models/EditorInstance.swift @@ -87,5 +87,15 @@ class EditorInstance: Hashable { } return (endTextLine.index - startTextLine.index) + 1 } + + func moveLinesUp() { + guard let controller = textViewController else { return } + controller.moveLinesUp() + } + + func moveLinesDown() { + guard let controller = textViewController else { return } + controller.moveLinesDown() + } } } diff --git a/CodeEdit/Features/WindowCommands/CodeEditCommands.swift b/CodeEdit/Features/WindowCommands/CodeEditCommands.swift index ef5714559..e2182de99 100644 --- a/CodeEdit/Features/WindowCommands/CodeEditCommands.swift +++ b/CodeEdit/Features/WindowCommands/CodeEditCommands.swift @@ -18,6 +18,7 @@ struct CodeEditCommands: Commands { FindCommands() NavigateCommands() if sourceControlIsEnabled { SourceControlCommands() } + EditorCommands() ExtensionCommands() WindowCommands() HelpCommands() diff --git a/CodeEdit/Features/WindowCommands/EditorCommands.swift b/CodeEdit/Features/WindowCommands/EditorCommands.swift new file mode 100644 index 000000000..607545200 --- /dev/null +++ b/CodeEdit/Features/WindowCommands/EditorCommands.swift @@ -0,0 +1,33 @@ +// +// EditorCommands.swift +// CodeEdit +// +// Created by Bogdan Belogurov on 21/05/2025. +// + +import SwiftUI +import CodeEditKit + +struct EditorCommands: Commands { + + @UpdatingWindowController var windowController: CodeEditWindowController? + private var editor: Editor? { + windowController?.workspace?.editorManager?.activeEditor + } + + var body: some Commands { + CommandMenu("Editor") { + Menu("Structure") { + Button("Move line up") { + editor?.selectedTab?.rangeTranslator?.moveLinesUp() + } + .keyboardShortcut("[", modifiers: [.command, .option]) + + Button("Move line down") { + editor?.selectedTab?.rangeTranslator?.moveLinesDown() + } + .keyboardShortcut("]", modifiers: [.command, .option]) + } + } + } +}