public static QualifiedSelection GetSelection(this CodePane pane) { int startLine; int endLine; int startColumn; int endColumn; if (pane == null) { return(new QualifiedSelection()); } pane.GetSelection(out startLine, out startColumn, out endLine, out endColumn); if (endLine > startLine && endColumn == 1) { endLine--; endColumn = pane.CodeModule.get_Lines(endLine, 1).Length; } var selection = new Selection(startLine, startColumn, endLine, endColumn); var moduleName = new QualifiedModuleName(pane.CodeModule.Parent); return(new QualifiedSelection(moduleName, selection)); }
public static Selection?GetSelection(this CodePane pane) { if (pane == null) { return(null); } int startLine; int endLine; int startColumn; int endColumn; pane.GetSelection(out startLine, out startColumn, out endLine, out endColumn); if (endLine > startLine && endColumn == 1) { endLine--; endColumn = pane.CodeModule.Lines[endLine, 1].Length; } if (startLine == 0 || startColumn == 0 || endLine == 0 || endColumn == 0) { return(new Selection?()); } return(new Selection(startLine, startColumn, endLine, endColumn)); }
public Declaration FindSelectedDeclaration(CodePane activeCodePane, bool procedureLevelOnly = false) { var selection = activeCodePane.GetSelection(); if (selection.Equals(_lastSelection)) { return(_selectedDeclaration); } _lastSelection = selection; _selectedDeclaration = null; if (!selection.Equals(default(QualifiedSelection))) { var matches = AllDeclarations .Where(item => item.DeclarationType != DeclarationType.Project && item.DeclarationType != DeclarationType.ModuleOption && item.DeclarationType != DeclarationType.ClassModule && item.DeclarationType != DeclarationType.ProceduralModule && (IsSelectedDeclaration(selection, item) || item.References.Any(reference => IsSelectedReference(selection, reference)))) .ToList(); try { if (matches.Count == 1) { _selectedDeclaration = matches.Single(); } else { Declaration match = null; if (procedureLevelOnly) { match = matches.SingleOrDefault(item => item.DeclarationType.HasFlag(DeclarationType.Member)); } // ambiguous (?), or no match - make the module be the current selection match = match ?? AllUserDeclarations.SingleOrDefault(item => (item.DeclarationType == DeclarationType.ClassModule || item.DeclarationType == DeclarationType.ProceduralModule) && item.QualifiedName.QualifiedModuleName.Equals(selection.QualifiedName)); _selectedDeclaration = match; } } catch (InvalidOperationException exception) { Debug.WriteLine(exception); } } if (_selectedDeclaration != null) { Debug.WriteLine("Current selection ({0}) is '{1}' ({2})", selection, _selectedDeclaration.IdentifierName, _selectedDeclaration.DeclarationType); } return(_selectedDeclaration); }
private static Selection GetSelection(CodePane codePane) { int startLine; int startColumn; int endLine; int endColumn; codePane.GetSelection(out startLine, out startColumn, out endLine, out endColumn); return(new Selection(startLine, startColumn, endLine, endColumn)); }
/// <summary> A CodePane extension method that gets the current selection. </summary> /// <returns> The selection. </returns> public static Selection GetSelection(this CodePane code) { int startLine; int endLine; int startColumn; int endColumn; code.GetSelection(out startLine, out startColumn, out endLine, out endColumn); return(new Selection(startLine, startColumn, endLine, endColumn)); }
public void GetSelection(out int startLine, out int startColumn, out int endLine, out int endColumn) { _codePane.GetSelection(out startLine, out startColumn, out endLine, out endColumn); }
private static Selection GetSelection(CodePane codePane) { int startLine; int startColumn; int endLine; int endColumn; codePane.GetSelection(out startLine, out startColumn, out endLine, out endColumn); return new Selection(startLine, startColumn, endLine, endColumn); }
public Declaration FindSelectedDeclaration(CodePane activeCodePane) { var selection = activeCodePane.GetSelection(); if (selection.Equals(_lastSelection)) { return _selectedDeclaration; } _lastSelection = selection; _selectedDeclaration = null; if (!selection.Equals(default(QualifiedSelection))) { var matches = AllDeclarations .Where(item => item.DeclarationType != DeclarationType.Project && item.DeclarationType != DeclarationType.ModuleOption && item.DeclarationType != DeclarationType.Class && item.DeclarationType != DeclarationType.Module && (IsSelectedDeclaration(selection, item) || item.References.Any(reference => IsSelectedReference(selection, reference)))); try { var match = matches.SingleOrDefault() ?? AllUserDeclarations .SingleOrDefault(item => (item.DeclarationType == DeclarationType.Class || item.DeclarationType == DeclarationType.Module) && item.QualifiedName.QualifiedModuleName.Equals(selection.QualifiedName)); _selectedDeclaration = match; } catch (InvalidOperationException exception) { Debug.WriteLine(exception); } } if (_selectedDeclaration != null) { Debug.WriteLine("Current selection ({0}) is '{1}' ({2})", selection, _selectedDeclaration.IdentifierName, _selectedDeclaration.DeclarationType); } return _selectedDeclaration; }