private void editControl1_UpdateContextToolTip(object sender, Syncfusion.Windows.Forms.Edit.UpdateTooltipEventArgs e) { if (e.Text == string.Empty) { Point pointVirtual = editControl1.PointToVirtualPosition(new Point(e.X, e.Y)); if (pointVirtual.Y > 0) { // Get the current line ILexemLine line = editControl1.GetLine(pointVirtual.Y); if (line != null) { // Get tokens from the current line ILexem lexem = line.FindLexemByColumn(pointVirtual.X); if (lexem != null) { IConfigLexem configLexem = lexem.Config as IConfigLexem; string formatName = configLexem.Format.Name; e.Text = "This is a " + formatName + " : " + lexem.Text; } } } } }
/// <summary> /// Gets context tooltip. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void editControl1_UpdateContextToolTip(object sender, Syncfusion.Windows.Forms.Edit.UpdateTooltipEventArgs e) { // If the text is already specified, than we should not change it. This is needed to display default tooltip for the collapsed region. if (e.Text != string.Empty) { return; } // Convert position of the mouse cursor to the position in text. Point virt = editControl1.PointToVirtualPosition(new Point(e.X, e.Y), true); // If there is no text in tat position, tan exit. if (virt.IsEmpty == true) { return; } ILexemLine line = editControl1.GetLine(virt.Y); if (line != null) { // Get lexem under cursor. ILexem lexem = line.FindLexemByColumn(virt.X); if (lexem != null) { // Set text of the tooltip. e.Text = GetLexemInfo(lexem) + "\n"; // Get stack of the lexem. ConfigStack stack = line.GetStackByColumn(virt.X); if (stack != null) { e.Text += "Stack before parsing lexem:\n"; while (stack.Count > 0) { IStackData stackItem = ( IStackData )stack.Pop(); if (stackItem.Lexem != null) { e.Text += "-- " + GetLexemInfo(stackItem.Lexem) + "\n"; } } e.Text += "\n"; } // Add description if present. if (m_MethodComments.Contains(lexem.Config.ID)) { e.Text += "Lexem contains description:\n"; e.Text += m_MethodComments[lexem.Config.ID]; } } } }
/// <summary> /// Looks for the first lexeme on the left with DropContextChoiceList set to true in config /// </summary> /// <returns></returns> private ILexem FindDropper() { ILexemLine line = editControl1.CurrentLineInstance; if (line == null) { return(null); } ILexem lexem = line.FindLexemByColumn(editControl1.CurrentColumn); if (lexem == null) { // If we are in the virtual space in the line. if (editControl1.CurrentColumn > 1) { lexem = line.FindLexemByColumn(line.LineLength); } if (lexem == null) { return(null); } } // If current lexem is dropper itself if (lexem.Config.DropContextChoiceList) { return(lexem); } int index = line.LineLexems.IndexOf(lexem); while (index > 0 && !lexem.Config.DropContextChoiceList) { lexem = line.LineLexems[--index] as ILexem; } if (index <= 0) { lexem = null; } return(lexem); }