Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11785


Ignore:
Timestamp:
01/16/15 10:43:48 (10 years ago)
Author:
jkarder
Message:

#2077:

  • added <Ctrl> + <G> keystroke to display a go to line dialog
  • minor code changes
Location:
branches/CodeEditor/HeuristicLab.CodeEditor/3.4
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/CodeEditor/HeuristicLab.CodeEditor/3.4/CodeEditor.cs

    r11743 r11785  
    209209      var moveLinesUpCommand = new Input.RoutedCommand();
    210210      moveLinesUpCommand.InputGestures.Add(new Input.KeyGesture(Input.Key.Up, Input.ModifierKeys.Alt));
    211       var moveLinesUpCommandBinding = new Input.CommandBinding(moveLinesUpCommand, (sender, args) => MoveLines(MovementDirection.Up));
     211      var moveLinesUpCommandBinding = new Input.CommandBinding(moveLinesUpCommand, (sender, args) => ExecuteMoveLinesCommand(MovementDirection.Up));
    212212      TextEditor.CommandBindings.Add(moveLinesUpCommandBinding);
    213213      #endregion
     
    216216      var moveLinesDownCommand = new Input.RoutedCommand();
    217217      moveLinesDownCommand.InputGestures.Add(new Input.KeyGesture(Input.Key.Down, Input.ModifierKeys.Alt));
    218       var moveLinesDownCommandBinding = new Input.CommandBinding(moveLinesDownCommand, (sender, args) => MoveLines(MovementDirection.Down));
     218      var moveLinesDownCommandBinding = new Input.CommandBinding(moveLinesDownCommand, (sender, args) => ExecuteMoveLinesCommand(MovementDirection.Down));
    219219      TextEditor.CommandBindings.Add(moveLinesDownCommandBinding);
     220      #endregion
     221
     222      #region GoToLineCommand
     223      var goToLineCommand = new Input.RoutedCommand();
     224      goToLineCommand.InputGestures.Add(new Input.KeyGesture(Input.Key.G, Input.ModifierKeys.Control));
     225      var goToLineCommandBinding = new Input.CommandBinding(goToLineCommand, (sender, args) => ExecuteGoToLineCommand());
     226      TextEditor.CommandBindings.Add(goToLineCommandBinding);
    220227      #endregion
    221228
     
    270277
    271278    private enum MovementDirection { Up, Down }
    272     private void MoveLines(MovementDirection movementDirection) {
     279    private void ExecuteMoveLinesCommand(MovementDirection movementDirection) {
    273280      var textArea = TextEditor.TextArea;
    274281      var selection = textArea.Selection;
     
    366373    }
    367374
     375    private void ExecuteGoToLineCommand() {
     376      using (var dlg = new GoToLineDialog(TextEditor)) {
     377        var result = dlg.ShowDialog(this);
     378        if (result == Forms.DialogResult.OK) {
     379          int lineNumber = dlg.Line;
     380          var line = Doc.GetLineByNumber(lineNumber);
     381          int offset = line.Offset;
     382          if (TextUtilities.GetLeadingWhitespace(Doc, line).Length > 0)
     383            offset = TextUtilities.GetNextCaretPosition(Doc, offset, LogicalDirection.Forward, CaretPositioningMode.WordStart);
     384          TextEditor.CaretOffset = offset;
     385        }
     386      }
     387    }
     388
    368389    #region Compiler Errors
    369390    public void ShowCompileErrors(CompilerErrorCollection compilerErrors) {
  • branches/CodeEditor/HeuristicLab.CodeEditor/3.4/HeuristicLab.CodeEditor-3.4.csproj

    r11722 r11785  
    125125    <Compile Include="CodeViewer.Designer.cs">
    126126      <DependentUpon>CodeViewer.cs</DependentUpon>
     127    </Compile>
     128    <Compile Include="GoToLineDialog.cs">
     129      <SubType>Form</SubType>
     130    </Compile>
     131    <Compile Include="GoToLineDialog.Designer.cs">
     132      <DependentUpon>GoToLineDialog.cs</DependentUpon>
    127133    </Compile>
    128134    <Compile Include="LanguageFeatures\CodeFolding\CodeFoldingResult.cs" />
Note: See TracChangeset for help on using the changeset viewer.