diff --git a/Text-Grab/Views/EditTextWindow.xaml.cs b/Text-Grab/Views/EditTextWindow.xaml.cs index d2831797..2c0b1f1a 100644 --- a/Text-Grab/Views/EditTextWindow.xaml.cs +++ b/Text-Grab/Views/EditTextWindow.xaml.cs @@ -1163,6 +1163,25 @@ private void MakeQrCodeExecuted(object sender, ExecutedRoutedEventArgs e) window.Show(); } + private void AddedLineAboveCommand(object sender, ExecutedRoutedEventArgs e) + { + int replaceCaret = PassedTextControl.CaretIndex + Environment.NewLine.Length; + int lineIndex = PassedTextControl.GetLineIndexFromCharacterIndex(PassedTextControl.CaretIndex); + int lineStart = PassedTextControl.GetCharacterIndexFromLineIndex(lineIndex); + PassedTextControl.Text = PassedTextControl.Text.Insert(lineStart, Environment.NewLine); + PassedTextControl.Select(replaceCaret, 0); + } + + private void DuplicateSelectedLine(object sender, ExecutedRoutedEventArgs e) + { + int replaceCaret = PassedTextControl.CaretIndex; + int selectionLength = PassedTextControl.SelectionLength; + SelectLine(); + string lineText = PassedTextControl.SelectedText; + PassedTextControl.SelectedText = lineText + Environment.NewLine + lineText; + PassedTextControl.Select(replaceCaret + (Environment.NewLine.Length + lineText.Length), selectionLength); + } + private void MarginsMenuItem_Checked(object sender, RoutedEventArgs e) { if (sender is not MenuItem marginsMenuItem) @@ -1807,6 +1826,14 @@ private void SetupRoutedCommands() RoutedCommand EscapeKeyed = new(); _ = EscapeKeyed.InputGestures.Add(new KeyGesture(Key.Escape)); _ = CommandBindings.Add(new CommandBinding(EscapeKeyed, KeyedEscape)); + + RoutedCommand AddedLineAbove = new(); + _ = AddedLineAbove.InputGestures.Add(new KeyGesture(Key.Enter, ModifierKeys.Control)); + _ = CommandBindings.Add(new CommandBinding(AddedLineAbove, AddedLineAboveCommand)); + + RoutedCommand duplicateLine = new(); + _ = duplicateLine.InputGestures.Add(new KeyGesture(Key.D, ModifierKeys.Control)); + _ = CommandBindings.Add(new CommandBinding(duplicateLine, DuplicateSelectedLine)); } private void SingleLineCmdCanExecute(object sender, CanExecuteRoutedEventArgs e)