Esempio n. 1
0
 /// <summary>
 /// 
 /// </summary>
 public static void AddHighlight(ScintillaControl sci, Int32 line, Int32 indicator, Int32 value)
 {
     Int32 start = sci.PositionFromLine(line);
     Int32 length = sci.LineLength(line);
     if (start < 0 || length < 1)
     {
         return;
     }
     // Remember previous EndStyled marker and restore it when we are done.
     Int32 es = sci.EndStyled;
     // Mask for style bits used for restore.
     Int32 mask = (1 << sci.StyleBits) - 1;
     Language lang = PluginBase.MainForm.SciConfig.GetLanguage(sci.ConfigurationLanguage);
     if (indicator == indicatorDebugCurrentLine)
     {
         sci.SetIndicFore(indicator, lang.editorstyle.DebugLineBack);
     }
     else if (indicator == indicatorDebugEnabledBreakpoint)
     {
         sci.SetIndicFore(indicator, lang.editorstyle.ErrorLineBack);
     }
     else if (indicator == indicatorDebugDisabledBreakpoint)
     {
         sci.SetIndicFore(indicator, lang.editorstyle.DisabledLineBack);
     }
     sci.SetIndicStyle(indicator, 7);
     sci.CurrentIndicator = indicator;
     sci.IndicatorValue = value;
     sci.IndicatorFillRange(start, length);
     sci.StartStyling(es, mask);
 }
Esempio n. 2
0
 /// <summary>
 /// Moves the cursor to the previous marker
 /// </summary>
 public static void PreviousMarker(ScintillaControl sci, Int32 marker, Int32 line)
 {
     Int32 prev = 0; Int32 count = 0;
     Int32 lineMask = sci.MarkerGet(line);
     if ((lineMask & GetMarkerMask(marker)) != 0)
     {
         prev = sci.MarkerPrevious(line - 1, GetMarkerMask(marker));
         if (prev != -1) sci.GotoLine(prev);
         else
         {
             count = sci.LineCount;
             prev = sci.MarkerPrevious(count, GetMarkerMask(marker));
             if (prev != -1) sci.GotoLine(prev);
         }
     }
     else
     {
         prev = sci.MarkerPrevious(line, GetMarkerMask(marker));
         if (prev != -1) sci.GotoLine(prev);
         else
         {
             count = sci.LineCount;
             prev = sci.MarkerPrevious(count, GetMarkerMask(marker));
             if (prev != -1) sci.GotoLine(prev);
         }
     }
 }
Esempio n. 3
0
        public void HandleEvent(object sender, NotifyEvent e, HandlingPriority priority)
        {
            try
            {
                switch (e.Type)
                {
                case EventType.FileSwitch:
                    sci = PluginBase.MainForm.CurrentDocument.SciControl;
                    break;

                case EventType.ApplySettings:
                    AddKeyEventHandler();
                    break;

                case EventType.Keys:
                    if (settingObj.HideMenu)
                    {
                        e.Handled = HandleKeyEvent(e as KeyEvent);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                ErrorManager.ShowError(ex);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Locates the parent tag of the tag provided
        /// </summary>
        public static XMLContextTag GetParentTag(ScintillaNet.ScintillaControl sci, XMLContextTag tag)
        {
            int pos = tag.Position + 1;

            if (pos <= 0)
            {
                pos = sci.CurrentPos;
            }
            XMLContextTag  parent;
            Stack <string> stack = new Stack <string>();

            do
            {
                parent = XMLComplete.GetXMLContextTag(sci, pos);
                pos    = parent.Position;
                if (parent.Name != null && parent.Tag != null)
                {
                    if (parent.Closing)
                    {
                        stack.Push(parent.Name);
                    }
                    else if (!parent.Closed && (stack.Count == 0 || stack.Pop() != parent.Name))
                    {
                        break;
                    }
                }
            }while (pos > 0);
            return(parent);
        }
Esempio n. 5
0
        static private string GetWordLeft(ScintillaNet.ScintillaControl Sci, ref int position)
        {
            string word    = "";
            string exclude = "(){};,+*/\\=:.%\"<>";
            char   c;

            while (position >= 0)
            {
                c = (char)Sci.CharAt(position);
                if (c <= ' ')
                {
                    break;
                }
                else if (exclude.IndexOf(c) >= 0)
                {
                    break;
                }
                else
                {
                    word = c + word;
                }
                position--;
            }
            return(word);
        }
        private static FoundDeclaration GetDeclarationAtLine(ScintillaNet.ScintillaControl Sci, int line)
        {
            FoundDeclaration result = new FoundDeclaration();
            FileModel        model  = ASContext.Context.CurrentModel;

            foreach (MemberModel member in model.Members)
            {
                if (member.LineFrom <= line && member.LineTo >= line)
                {
                    result.member = member;
                    return(result);
                }
            }

            foreach (ClassModel aClass in model.Classes)
            {
                if (aClass.LineFrom <= line && aClass.LineTo >= line)
                {
                    result.inClass = aClass;
                    foreach (MemberModel member in aClass.Members)
                    {
                        if (member.LineFrom <= line && member.LineTo >= line)
                        {
                            result.member = member;
                            return(result);
                        }
                    }
                    return(result);
                }
            }
            return(result);
        }
Esempio n. 7
0
 static public bool HandleGeneratorCompletion(ScintillaControl Sci, bool autoHide, string word)
 {
     ContextFeatures features = ASContext.Context.Features;
     if (features.overrideKey != null && word == features.overrideKey)
         return HandleOverrideCompletion(Sci, autoHide);
     return false;
 }
Esempio n. 8
0
 /// <summary>
 /// Adds or removes a marker
 /// </summary>
 public static void ToggleMarker(ScintillaControl sci, Int32 marker, Int32 line)
 {
     Int32 lineMask = sci.MarkerGet(line);
     if ((lineMask & GetMarkerMask(marker)) == 0) sci.MarkerAdd(line, marker);
     else sci.MarkerDelete(line, marker);
     UITools.Manager.MarkerChanged(sci, line);
 }
Esempio n. 9
0
 /// <summary>
 /// Moves the cursor to the next marker
 /// </summary>
 public static void NextMarker(ScintillaControl sci, Int32 marker, Int32 line)
 {
     Int32 next = 0;
     Int32 lineMask = sci.MarkerGet(line);
     if ((lineMask & GetMarkerMask(marker)) != 0)
     {
         next = sci.MarkerNext(line + 1, GetMarkerMask(marker));
         if (next != -1) sci.GotoLine(next);
         else
         {
             next = sci.MarkerNext(0, GetMarkerMask(marker));
             if (next != -1) sci.GotoLine(next);
         }
     }
     else
     {
         next = sci.MarkerNext(line, GetMarkerMask(marker));
         if (next != -1) sci.GotoLine(next);
         else
         {
             next = sci.MarkerNext(0, GetMarkerMask(marker));
             if (next != -1) sci.GotoLine(next);
         }
     }
 }
        /// <summary>
        /// 
        /// </summary>
        static public void SciControl_MarkerChanged(ScintillaControl sender, Int32 line)
        {
            if (line < 0) return;
			Boolean bCurrentLine = IsMarkerSet(sender, markerCurrentLine, line);
			Boolean bBpActive = IsMarkerSet(sender, markerBPEnabled, line);
			Boolean bBpDisabled = IsMarkerSet(sender, markerBPDisabled, line);
			if (bCurrentLine)
			{
				ScintillaHelper.RemoveHighlight(sender, line, indicatorDebugDisabledBreakpoint);
				ScintillaHelper.RemoveHighlight(sender, line, indicatorDebugEnabledBreakpoint);
				ScintillaHelper.AddHighlight(sender, line, indicatorDebugCurrentLine, 1);
			}
			else if (bBpActive)
			{
				ScintillaHelper.RemoveHighlight(sender, line, indicatorDebugCurrentLine);
				ScintillaHelper.RemoveHighlight(sender, line, indicatorDebugDisabledBreakpoint);
				ScintillaHelper.AddHighlight(sender, line, indicatorDebugEnabledBreakpoint, 1);
			}
			else if (bBpDisabled)
			{
				ScintillaHelper.RemoveHighlight(sender, line, indicatorDebugCurrentLine);
				ScintillaHelper.RemoveHighlight(sender, line, indicatorDebugEnabledBreakpoint);
				ScintillaHelper.AddHighlight(sender, line, indicatorDebugDisabledBreakpoint, 1);
			}
			else
			{
				ScintillaHelper.RemoveHighlight(sender, line, indicatorDebugCurrentLine);
				ScintillaHelper.RemoveHighlight(sender, line, indicatorDebugDisabledBreakpoint);
				ScintillaHelper.RemoveHighlight(sender, line, indicatorDebugEnabledBreakpoint);
			}
            PluginMain.breakPointManager.SetBreakPointInfo(sender.FileName, line, !(bBpActive || bBpDisabled), bBpActive);
        }
 static public void sci_Modified(ScintillaControl sender, int position, int modificationType, string text, int length, int linesAdded, int line, int foldLevelNow, int foldLevelPrev)
 {
     if (linesAdded != 0)
     {
         int modline = sender.LineFromPosition(position);
         PluginMain.breakPointManager.UpdateBreakPoint(sender.FileName, modline, linesAdded);
     }
 }
 /// <summary>
 /// 
 /// </summary>
 static public void SciControl_MarkerChanged(ScintillaControl sender, Int32 line)
 {
     if (line < 0) return;
     ITabbedDocument document = DocumentManager.FindDocument(sender);
     if (document == null || !document.IsEditable) return;
     ApplyHighlights(document.SplitSci1, line, true);
     ApplyHighlights(document.SplitSci2, line, false);
 }
Esempio n. 13
0
 // <summary>
 /// Removes the highlights from the correct sci control
 /// </summary>
 public static void RemoveHighlights(ScintillaControl sci)
 {
     Int32 es = sci.EndStyled;
     Int32 mask = (1 << sci.StyleBits);
     sci.StartStyling(0, mask);
     sci.SetStyling(sci.TextLength, 0);
     sci.StartStyling(es, mask - 1);
 }
 /// <summary>
 /// Selects a search match
 /// </summary>
 public static void SelectMatch(ScintillaControl sci, SearchMatch match)
 {
     Int32 start = sci.MBSafePosition(match.Index); // wchar to byte position
     Int32 end = start + sci.MBSafeTextLength(match.Value); // wchar to byte text length
     Int32 line = sci.LineFromPosition(start);
     sci.EnsureVisible(line);
     sci.SetSel(start, end);
 }
Esempio n. 15
0
        private static void TraceMethod(ScintillaControl sci, string name)
        {
            SkipMethod(sci);

            sci.NewLine();
            sci.InsertText(sci.CurrentPos, String.Format("trace(\"{0}()\");", name));
            sci.LineEnd();
        }
Esempio n. 16
0
        public CodePreview(ScintillaControl sci)
        {
            this.Sci = sci;
            this.Editor = new ScintillaControl();

            InitializeControls();
            SetupEditor();
        }
Esempio n. 17
0
        private static void TraceExpr(ScintillaControl sci, string expr)
        {
            if (IsMethoDecl(sci)) SkipMethod(sci);
            else sci.LineEnd();

            sci.NewLine();
            sci.InsertText(sci.CurrentPos, String.Format("trace(\"{0} = \" + {1});", expr, SafeExpr(expr)));
            sci.LineEnd();
        }
Esempio n. 18
0
        private static bool IsMethod(ScintillaControl sci, string name)
        {
            if (!Regex.IsMatch(name, "^[a-z0-9_]+$", RegexOptions.IgnoreCase))
                return false;

            string line = sci.GetLine(sci.CurrentLine);
            string pattern = "\\bfunction\\s+" + Regex.Escape(name) + "\\s*\\(";
            return Regex.IsMatch(line, pattern);
        }
Esempio n. 19
0
 private static void SkipMethod(ScintillaControl sci)
 {
     do
     {
         sci.LineDown();
         sci.LineEnd();
     }
     while (sci.CurrentLine < sci.LineCount && !IsMethodBodyStart(sci));
 }
Esempio n. 20
0
 public HaXeCompletion(ScintillaControl sci, ASExpr expr, bool autoHide, IHaxeCompletionHandler handler)
 {
     this.sci = sci;
     this.expr = expr;
     this.autoHide = autoHide;
     this.handler = handler;
     tips = new ArrayList();
     nbErrors = 0;
 }
Esempio n. 21
0
 public HaxeComplete(ScintillaControl sci, ASExpr expr, bool autoHide, IHaxeCompletionHandler completionHandler)
 {
     Sci = sci;
     Expr = expr;
     AutoHide = autoHide;
     handler = completionHandler;
     Status = HaxeCompleteStatus.NONE;
     FileName = PluginBase.MainForm.CurrentDocument.FileName;
 }
 /// <summary>
 /// Bookmarks a search match
 /// </summary>
 public static void BookmarkMatches(ScintillaControl sci, List<SearchMatch> matches)
 {
     for (Int32 i = 0; i < matches.Count; i++)
     {
         Int32 line = matches[i].Line - 1;
         sci.EnsureVisible(line);
         sci.MarkerAdd(line, 0);
     }
 }
        public void Execute()
        {
            Sci = PluginBase.MainForm.CurrentDocument.SciControl;

            IASContext context = ASContext.Context;
            Int32 pos = Sci.CurrentPos;

            ASGenerator.GenerateDelegateMethods(Sci, result.Member, selectedMembers, result.Type, result.InClass);
        }
Esempio n. 24
0
        public MiniMapPanel(ITabbedDocument document, ScintillaControl sci, Settings settings)
        {
            this.Document = document;
            this.ScintillaControl = sci;
            this.Settings = settings;

            InitializeControl();
            RefreshSettings();
            HookEvents();
        }
Esempio n. 25
0
 /// <summary>
 /// Update the manually syncable properties if needed.
 /// </summary>
 public static void UpdateSyncProps(ScintillaControl e1, ScintillaControl e2)
 {
     if (e2.SaveBOM != e1.SaveBOM) e2.SaveBOM = e1.SaveBOM;
     if (e2.Encoding != e1.Encoding) e2.Encoding = e1.Encoding;
     if (e2.FileName != e1.FileName) e2.FileName = e1.FileName;
     if (e2.SmartIndentType != e1.SmartIndentType) e2.SmartIndentType = e1.SmartIndentType;
     if (e2.UseHighlightGuides != e1.UseHighlightGuides) e2.UseHighlightGuides = e1.UseHighlightGuides;
     if (e2.ConfigurationLanguage != e1.ConfigurationLanguage) e2.ConfigurationLanguage = e1.ConfigurationLanguage;
     if (e2.IsHiliteSelected != e1.IsHiliteSelected) e2.IsHiliteSelected = e1.IsHiliteSelected;
     if (e2.IsBraceMatching != e1.IsBraceMatching) e2.IsBraceMatching = e1.IsBraceMatching;
 }
Esempio n. 26
0
		private void Manager_OnMouseHover(ScintillaControl sci, Int32 position)
		{
			DebuggerManager debugManager = PluginMain.debugManager;
			FlashInterface flashInterface = debugManager.FlashInterface;

			if (!PluginBase.MainForm.EditorMenu.Visible && flashInterface != null &&
				flashInterface.isDebuggerStarted && flashInterface.isDebuggerSuspended)
			{
				if (debugManager.CurrentLocation != null &&
					debugManager.CurrentLocation.File != null)
				{
					String localPath = debugManager.GetLocalPath(debugManager.CurrentLocation.File);

					if (localPath == null || localPath != PluginBase.MainForm.CurrentDocument.FileName)
					{
						return;
					}
				}
				else
				{
					return;
				}

				Point dataTipPoint = Control.MousePosition;
				Rectangle rect = new Rectangle(m_ToolTip.Location, m_ToolTip.Size);

				if (m_ToolTip.Visible && rect.Contains(dataTipPoint))
				{
					return;
				}

				position = sci.WordEndPosition(position, true);
				String leftword = GetWordAtPosition(sci, position);
				if (leftword != String.Empty)
				{
					try
					{
						ASTBuilder builder = new ASTBuilder(true);

						ValueExp exp = builder.parse(new System.IO.StringReader(leftword));
						ExpressionContext context = new ExpressionContext(flashInterface.Session);

						context.Depth = debugManager.CurrentFrame;

						Object obj = exp.evaluate(context);

						Show(dataTipPoint, (Variable)obj);
					}
					catch (Exception e)
					{
					}
				}
			}
		}
Esempio n. 27
0
        /// <summary>
        /// Checks if a given search match actually points to the given target source
        /// </summary
        /// <returns>True if the SearchMatch does point to the target source.</returns>
        static public bool DoesMatchPointToTarget(ScintillaNet.ScintillaControl Sci, SearchMatch match, ASResult target, DocumentHelper associatedDocumentHelper)
        {
            if (Sci == null || target == null)
            {
                return(false);
            }
            bool matchMember = target.InFile != null && target.Member != null;
            bool matchType   = target.Member == null && target.IsStatic && target.Type != null;

            if (!matchMember && !matchType)
            {
                return(false);
            }

            ASResult result = null;

            // get type at match position
            if (match.Index < Sci.Text.Length) // TODO: find out rare cases of incorrect index reported
            {
                result = DeclarationLookupResult(Sci, Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value));
                if (associatedDocumentHelper != null)
                {
                    // because the declaration lookup opens a document, we should register it with the document helper to be closed later
                    associatedDocumentHelper.RegisterLoadedDocument(PluginBase.MainForm.CurrentDocument);
                }
            }
            // check if the result matches the target
            if (result == null || (result.InFile == null && result.Type == null))
            {
                return(false);
            }
            if (matchMember)
            {
                if (result.Member == null)
                {
                    return(false);
                }
                return(result.InFile.BasePath == target.InFile.BasePath && result.InFile.FileName == target.InFile.FileName &&
                       result.Member.LineFrom == target.Member.LineFrom && result.Member.Name == target.Member.Name);
            }
            else // type
            {
                if (result.Type == null)
                {
                    return(false);
                }
                if (result.Type.QualifiedName == target.Type.QualifiedName)
                {
                    return(true);
                }
                return(false);
            }
        }
Esempio n. 28
0
        //public static void AddHighlights(ScintillaControl sci, int posText, string textToHigh, System.Drawing.Color color)
        //{
        //        //Int32 start = sci.MBSafePosition(posText);
        //        Int32 start = posText;
        //        Int32 end = start + sci.MBSafeTextLength(textToHigh);
        //        Int32 position = start;
        //        Int32 mask = 1 << sci.StyleBits;
        //        sci.SetIndicStyle(0, (Int32)IndicatorStyle.Plain);
        //        sci.SetIndicFore(0, DataConverter.ColorToInt32(color));
        //        sci.StartStyling(position, mask);
        //        sci.SetStyling(end - start, mask);
        //}
        public static void AddHighlights(ScintillaControl sci, Int32 posText, Int32 length, System.Drawing.Color color, IndicatorStyle indicator)
        {
            if (length == 0) return;

            Int32 mask = 1 << sci.StyleBits;

            sci.SetIndicStyle(0, (Int32)indicator);
            sci.SetIndicFore(0, DataConverter.ColorToInt32(color));

            sci.StartStyling(posText, mask);
            sci.SetStyling(length, mask);
        }
Esempio n. 29
0
 /// <summary>
 /// 切り替え初期化
 /// </summary>
 /// <param name="sci"></param>
 public void Init(ScintillaNet.ScintillaControl sci)
 {
     if (sci != null && sci.ConfigurationLanguage == "kag")
     {
         m_showComplete = true;
     }
     else
     {
         m_showComplete = false;
     }
     this.CurrentSci = sci;
 }
Esempio n. 30
0
        /// <summary>
        /// Checks if the given match actually is the declaration.
        /// </summary>
        public static bool IsMatchTheTarget(ScintillaNet.ScintillaControl Sci, SearchMatch match, ASResult target)
        {
            if (Sci == null || target == null || target.InFile == null || target.Member == null)
            {
                return(false);
            }
            String originalFile = Sci.FileName;
            // get type at match position
            ASResult declaration = DeclarationLookupResult(Sci, Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value));

            return((declaration.InFile != null && originalFile == declaration.InFile.FileName) && (Sci.CurrentPos == (Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value))));
        }
Esempio n. 31
0
 /// <summary>
 /// Detect syntax, ask from plugins if its correct and update
 /// </summary>
 public static void UpdateControlSyntax(ScintillaControl sci)
 {
     String language = SciConfig.GetLanguageFromFile(sci.FileName);
     TextEvent te = new TextEvent(EventType.SyntaxDetect, language);
     EventManager.DispatchEvent(SciConfig, te);
     if (te.Handled && te.Value != null) language = te.Value;
     if (sci.ConfigurationLanguage != language)
     {
         sci.ConfigurationLanguage = language;
     }
     ApplySciSettings(sci);
 }
Esempio n. 32
0
 /// <summary>
 /// Finds the document by the ScintillaControl
 /// </summary>
 public static ITabbedDocument FindDocument(ScintillaControl sci)
 {
     Int32 count = PluginBase.MainForm.Documents.Length;
     for (Int32 i = 0; i < count; i++)
     {
         ITabbedDocument current = PluginBase.MainForm.Documents[i];
         if (current.IsEditable && current.SciControl == sci)
         {
             return current;
         }
     }
     return null;
 }
Esempio n. 33
0
 /// <summary>
 /// Selects the text specified in the action point
 /// </summary>
 public static void ExecuteActionPoint(ActionPoint point, ScintillaControl sci)
 {
     if (point.EntryPosition != -1 && point.ExitPosition != -1)
     {
         Int32 start = sci.MBSafePosition(point.EntryPosition);
         Int32 end = sci.MBSafePosition(point.ExitPosition);
         sci.SetSel(start, end);
     }
     else if (point.EntryPosition != -1 && point.ExitPosition == -1)
     {
         Int32 start = sci.MBSafePosition(point.EntryPosition);
         sci.SetSel(start, start);
     }
 }
Esempio n. 34
0
		public TabbedDocument(MainForm mainForm, ScintillaControl sciControl)
		{
			string file = sciControl.Tag.ToString();
			if (!file.StartsWith("Untitled"))
			{
				this.fileInfo = new FileInfo(file);
			}
			this.mainForm = mainForm;
			this.BackColor = Color.White;
			this.Text = Path.GetFileName(file);
			this.DockPanel = this.mainForm.DockPanel;
			this.DockableAreas = DockAreas.Document;
			this.Controls.Add(sciControl);
			this.Show();
		}
Esempio n. 35
0
        /// <summary>
        /// focus a needed scientilla control and position the carret
        /// </summary>
        /// <param name="sci">a scientilla control to focus</param>
        /// <param name="position">position of the carret in the text</param>
        /// <param name="length"></param>
        public void GotoPosAndFocus(ScintillaNet.ScintillaControl sci, int position, int length)
        {
            // don't correct to multi-byte safe position (assumed correct)
            int line = sci.LineFromPosition(position);

            //sci.EnsureVisible(line);
            sci.ExpandAllFolds();

            sci.SetSel(position, position + length);
            // sci.EnsureVisible(line);

            int top    = sci.FirstVisibleLine;
            int middle = top + sci.LinesOnScreen / 2;

            sci.LineScroll(0, line - middle);
        }
        public ScintillaMiniMap(ScintillaControl sci, Settings settings)
        {
            InitializeMiniMap();

            _settings = settings;
            _sci = sci;

            // Visibilty no matching will force an update in RefreshSettings
            this.Visible = !_settings.IsVisible;

            HookEvents();
            UpdateText();
            RefreshSettings();

            _updateTimer.Start();
        }
Esempio n. 37
0
        private void OnMouseHover(ScintillaNet.ScintillaControl sci, int position)
        {
            if (!m_showComplete)
            {
                return;
            }

            //現在のカーソル位置にある
            string toolTip = KagToolTip.GetText(sci, position);

            if (string.IsNullOrEmpty(toolTip))
            {
                return;
            }

            UITools.Tip.ShowAtMouseLocation(toolTip);
        }
Esempio n. 38
0
 public void PositionControl(ScintillaControl sci)
 {
     // compute control location
     Point p = new Point(sci.PointXFromPosition(memberPos), sci.PointYFromPosition(memberPos));
     p = ((Form)PluginBase.MainForm).PointToClient(((Control)sci).PointToScreen(p));
     toolTip.Left = p.X + sci.Left;
     bool hasListUp = !CompletionList.Active || CompletionList.listUp;
     if (currentLine > sci.LineFromPosition(memberPos) || !hasListUp) toolTip.Top = p.Y - toolTip.Height + sci.Top;
     else toolTip.Top = p.Y + UITools.Manager.LineHeight(sci) + sci.Top;
     // Keep on control area
     if (toolTip.Right > ((Form)PluginBase.MainForm).ClientRectangle.Right)
     {
         toolTip.Left = ((Form)PluginBase.MainForm).ClientRectangle.Right - toolTip.Width;
     }
     toolTip.Show();
     toolTip.BringToFront();
 }
Esempio n. 39
0
 public void CallTipShow(ScintillaControl sci, int position, string text)
 {
     if (toolTip.Visible && position == memberPos && text == currentText)
         return;
     toolTip.Visible = false;
     currentText = text;
     Text = text;
     AutoSize();
     memberPos = position;
     startPos = memberPos + text.IndexOf('(');
     currentPos = sci.CurrentPos;
     currentLine = sci.LineFromPosition(currentPos);
     PositionControl(sci);
     // state
     isActive = true;
     faded = false;
     UITools.Manager.LockControl(sci);
 }
Esempio n. 40
0
        /// <summary>
        /// Checks if a given search match actually points to the given target source
        /// </summary
        /// <returns>True if the SearchMatch does point to the target source.</returns>
        static public bool DoesMatchPointToTarget(ScintillaNet.ScintillaControl Sci, SearchMatch match, ASResult target, DocumentHelper associatedDocumentHelper)
        {
            if (Sci == null || target == null || target.inFile == null || target.Member == null)
            {
                return(false);
            }
            // get type at match position
            ASResult result = DeclarationLookupResult(Sci, Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value));

            if (associatedDocumentHelper != null)
            {
                // because the declaration lookup opens a document, we should register it with the document helper to be closed later
                associatedDocumentHelper.RegisterLoadedDocument(PluginBase.MainForm.CurrentDocument);
            }
            // check if the result matches the target
            // TODO: this method of checking their equality seems pretty crude -- is there a better way?
            if (result == null || result.inFile == null || result.Member == null)
            {
                return(false);
            }
            Boolean doesMatch = result.inFile.BasePath == target.inFile.BasePath && result.inFile.FileName == target.inFile.FileName && result.Member.LineFrom == target.Member.LineFrom && result.Member.Name == target.Member.Name;

            return(doesMatch);
        }
Esempio n. 41
0
        /// <summary>
        /// Checks if a given search match actually points to the given target source
        /// </summary>
        /// <returns>True if the SearchMatch does point to the target source.</returns>
        public static ASResult DeclarationLookupResult(ScintillaNet.ScintillaControl Sci, int position)
        {
            if (!ASContext.Context.IsFileValid || (Sci == null))
            {
                return(null);
            }
            // get type at cursor position
            ASResult result = ASComplete.GetExpressionType(Sci, position);

            if (result.IsPackage)
            {
                return(result);
            }
            // open source and show declaration
            if (!result.IsNull())
            {
                if (result.Member != null && (result.Member.Flags & FlagType.AutomaticVar) > 0)
                {
                    return(null);
                }
                FileModel model = result.InFile ?? ((result.Member != null && result.Member.InFile != null) ? result.Member.InFile : null) ?? ((result.Type != null) ? result.Type.InFile : null);
                if (model == null || model.FileName == "")
                {
                    return(null);
                }
                ClassModel inClass = result.InClass ?? result.Type;
                // for Back command
                int lookupLine = Sci.LineFromPosition(Sci.CurrentPos);
                int lookupCol  = Sci.CurrentPos - Sci.PositionFromLine(lookupLine);
                ASContext.Panel.SetLastLookupPosition(ASContext.Context.CurrentFile, lookupLine, lookupCol);
                // open the file
                if (model != ASContext.Context.CurrentModel)
                {
                    // cached files declarations have no line numbers
                    if (model.CachedModel && model.Context != null)
                    {
                        ASFileParser.ParseFile(model);
                        if (inClass != null && !inClass.IsVoid())
                        {
                            inClass = model.GetClassByName(inClass.Name);
                            if (result.Member != null)
                            {
                                result.Member = inClass.Members.Search(result.Member.Name, 0, 0);
                            }
                        }
                        else
                        {
                            result.Member = model.Members.Search(result.Member.Name, 0, 0);
                        }
                    }
                    if (model.FileName.Length > 0 && File.Exists(model.FileName))
                    {
                        ASContext.MainForm.OpenEditableDocument(model.FileName, false);
                    }
                    else
                    {
                        ASComplete.OpenVirtualFile(model);
                        result.InFile = ASContext.Context.CurrentModel;
                        if (result.InFile == null)
                        {
                            return(null);
                        }
                        if (inClass != null)
                        {
                            inClass = result.InFile.GetClassByName(inClass.Name);
                            if (result.Member != null)
                            {
                                result.Member = inClass.Members.Search(result.Member.Name, 0, 0);
                            }
                        }
                        else if (result.Member != null)
                        {
                            result.Member = result.InFile.Members.Search(result.Member.Name, 0, 0);
                        }
                    }
                }
                if ((inClass == null || inClass.IsVoid()) && result.Member == null)
                {
                    return(null);
                }
                Sci = ASContext.CurSciControl;
                if (Sci == null)
                {
                    return(null);
                }
                int    line    = 0;
                string name    = null;
                bool   isClass = false;
                // member
                if (result.Member != null && result.Member.LineFrom > 0)
                {
                    line = result.Member.LineFrom;
                    name = result.Member.Name;
                }
                // class declaration
                else if (inClass.LineFrom > 0)
                {
                    line    = inClass.LineFrom;
                    name    = inClass.Name;
                    isClass = true;
                    // constructor
                    foreach (MemberModel member in inClass.Members)
                    {
                        if ((member.Flags & FlagType.Constructor) > 0)
                        {
                            line    = member.LineFrom;
                            name    = member.Name;
                            isClass = false;
                            break;
                        }
                    }
                }
                if (line > 0) // select
                {
                    if (isClass)
                    {
                        ASComplete.LocateMember("(class|interface)", name, line);
                    }
                    else
                    {
                        ASComplete.LocateMember("(function|var|const|get|set|property|[,(])", name, line);
                    }
                }
                return(result);
            }
            return(null);
        }